From ca54f8c37117b4326831e14f74d7d37a8a641694 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Mon, 29 Jul 2019 10:57:28 -0400 Subject: [PATCH 1/9] Work on CLI and I forget what else --- .../voxelsniper/RangeBlockHelper.java | 19 +- .../thevoxelbox/voxelsniper/VoxelSniper.java | 5 +- .../voxelsniper/brush/JaggedLineBrush.java | 21 +- .../voxelsniper/brush/RingBrush.java | 21 +- .../voxelsniper/brush/ScannerBrush.java | 62 +++-- .../com/boydti/fawe/bukkit/BukkitPlayer.java | 27 +-- .../com/boydti/fawe/bukkit/FaweBukkit.java | 33 ++- .../boydti/fawe/bukkit/beta/BukkitQueue.java | 1 + .../fawe/bukkit/regions/ASkyBlockHook.java | 18 +- .../fawe/bukkit/regions/FactionsFeature.java | 16 +- .../bukkit/regions/FactionsOneFeature.java | 15 +- .../bukkit/regions/FactionsUUIDFeature.java | 9 +- .../fawe/bukkit/regions/FreeBuildRegion.java | 14 +- .../regions/GriefPreventionFeature.java | 20 +- .../bukkit/regions/PreciousStonesFeature.java | 17 +- .../fawe/bukkit/regions/ResidenceFeature.java | 6 +- .../fawe/bukkit/regions/TownyFeature.java | 48 ++-- .../fawe/bukkit/regions/Worldguard.java | 34 ++- .../fawe/bukkit/regions/WorldguardFlag.java | 24 +- .../bukkit/BukkitBlockCommandSender.java | 168 +++++++++++++ .../worldedit/bukkit/BukkitCommandSender.java | 18 +- .../sk89q/worldedit/bukkit/BukkitPlayer.java | 11 +- .../sk89q/worldedit/bukkit/BukkitWorld.java | 5 + .../worldedit/bukkit/WorldEditPlugin.java | 2 + .../src/main/java/com/boydti/fawe/Fawe.java | 6 +- .../fawe/beta/IDelegateQueueExtent.java | 4 +- .../com/boydti/fawe/beta/IQueueExtent.java | 8 +- .../boydti/fawe/beta/filters/DistrFilter.java | 6 +- .../SingleThreadQueueExtent.java | 10 +- .../main/java/com/boydti/fawe/config/BBC.java | 226 +----------------- .../com/boydti/fawe/object/FawePlayer.java | 16 +- .../fawe/object/brush/CopyPastaBrush.java | 11 +- .../fawe/object/brush/FallingSphere.java | 2 - .../fawe/object/brush/InspectBrush.java | 5 +- .../boydti/fawe/object/brush/SplineBrush.java | 6 +- .../fawe/object/brush/SurfaceSpline.java | 4 +- .../cfi/HeightMapMCAGenerator.java | 131 +++++----- .../fawe/object/changeset/AnvilHistory.java | 5 +- .../fawe/object/changeset/CFIChangeSet.java | 2 +- .../object/changeset/DiskStorageHistory.java | 1 + .../fawe/object/changeset/FaweChangeSet.java | 14 +- .../object/changeset/FaweStreamChangeSet.java | 6 + .../changeset/MemoryOptimizedHistory.java | 3 +- .../clipboard/ResizableClipboardBuilder.java | 9 +- .../clipboard/remap/ClipboardRemapper.java | 11 +- .../fawe/object/collection/LongHashSet.java | 2 +- .../fawe/object/collection/MemBlockSet.java | 31 ++- .../object/collection/SummedAreaTable.java | 8 +- .../object/io/BufferedRandomAccessFile.java | 5 +- .../object/io/RandomFileOutputStream.java | 2 +- .../object/progress/ChatProgressTracker.java | 3 +- .../regions/selector/FuzzyRegionSelector.java | 9 +- .../fawe/object/schematic/PNGWriter.java | 32 ++- .../java/com/boydti/fawe/util/MainUtil.java | 6 +- .../java/com/boydti/fawe/util/MemUtil.java | 3 +- .../java/com/boydti/fawe/util/Permission.java | 8 +- .../java/com/boydti/fawe/util/StringMan.java | 29 +-- .../java/com/boydti/fawe/util/WEManager.java | 8 +- .../boydti/fawe/wrappers/PlayerWrapper.java | 14 +- .../java/com/sk89q/jnbt/NBTConstants.java | 7 +- .../main/java/com/sk89q/util/StringUtil.java | 2 +- .../com/sk89q/worldedit/LocalSession.java | 52 ++-- .../worldedit/MissingWorldException.java | 27 +++ .../java/com/sk89q/worldedit/WorldEdit.java | 24 +- .../worldedit/command/ChunkCommands.java | 26 +- .../worldedit/command/ClipboardCommands.java | 26 +- .../worldedit/command/GenerationCommands.java | 22 +- .../worldedit/command/HistoryCommands.java | 2 +- .../sk89q/worldedit/command/ListFilters.java | 3 +- .../worldedit/command/RegionCommands.java | 4 +- .../worldedit/command/SchematicCommands.java | 44 ++-- .../worldedit/command/SelectionCommands.java | 144 +++++------ .../worldedit/command/SnapshotCommands.java | 32 +-- .../command/SnapshotUtilCommands.java | 32 +-- .../worldedit/command/UtilityCommands.java | 8 +- .../worldedit/command/WorldEditCommands.java | 20 +- .../com/sk89q/worldedit/entity/Entity.java | 27 +-- .../com/sk89q/worldedit/entity/Player.java | 6 +- .../parser/mask/DefaultMaskParser.java | 2 +- .../parser/pattern/DefaultPatternParser.java | 2 +- .../platform/AbstractNonPlayerActor.java | 51 ++++ .../platform/AbstractPlayerActor.java | 162 ++++++++----- .../extension/platform/Locatable.java | 69 ++++++ .../platform/PlatformCommandManager.java | 5 - .../function/mask/BlockMaskBuilder.java | 2 +- .../function/mask/MaskIntersection.java | 17 +- .../worldedit/function/mask/MaskUnion.java | 8 +- .../worldedit/function/mask/RegionMask.java | 2 + .../worldedit/function/visitor/ScanChunk.java | 44 ++-- .../command/UserCommandCompleter.java | 72 ------ .../WorldEditExceptionConverter.java | 11 +- .../java/com/sk89q/worldedit/world/World.java | 3 +- 92 files changed, 1111 insertions(+), 1107 deletions(-) create mode 100644 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/MissingWorldException.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Locatable.java delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/UserCommandCompleter.java diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java index ad5bea3e0..4dd725463 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java @@ -26,8 +26,6 @@ package com.thevoxelbox.voxelsniper; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.boydti.fawe.bukkit.wrapper.AsyncWorld; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.world.registry.LegacyMapper; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -41,7 +39,6 @@ public class RangeBlockHelper { private Location playerLoc; private double rotX; private double rotY; - private double viewHeight; private double rotXSin; private double rotXCos; private double rotYSin; @@ -70,14 +67,14 @@ public class RangeBlockHelper { public RangeBlockHelper(Location location, int range, double step) { this.world = (AsyncWorld) location.getWorld(); - this.init(location, (double)range, step, 0.0D); + this.init(location, range, step, 0.0D); } public RangeBlockHelper(Player player, int range, double step) { if (player != null) { this.world = VoxelSniper.getInstance().getSniperManager().getSniperForPlayer(player).getWorld(); } - this.init(player.getLocation(), (double)range, step, 1.65D); + this.init(player.getLocation(), range, step, 1.65D); } public RangeBlockHelper(Player player, AsyncWorld world) { @@ -163,7 +160,6 @@ public class RangeBlockHelper { public final AsyncBlock getFaceBlock() { while(this.getNextBlock() != null && isAir(this.getCurBlock().getType())) { - ; } if(this.getCurBlock() != null) { @@ -205,7 +201,6 @@ public class RangeBlockHelper { this.fromOffworld(); while(this.getNextBlock() != null && isAir(this.getCurBlock().getType())) { - ; } return this.getCurBlock(); @@ -229,26 +224,26 @@ public class RangeBlockHelper { AsyncBlock block = world.getBlockAt(this.targetX, this.targetY, this.targetZ); Material type = block.getType(); - return !isAir(type) ? block : (this.length <= this.range && this.targetY <= 255 && this.targetY >= 0?this.getRange():this.world.getBlockAt(this.lastX, this.lastY, this.lastZ)); + return !isAir(type) ? block : + this.length <= this.range && this.targetY <= 255 && this.targetY >= 0?this.getRange():this.world.getBlockAt(this.lastX, this.lastY, this.lastZ); } private void init(Location location, double range, double step, double viewHeight) { this.playerLoc = location; - this.viewHeight = viewHeight; this.playerX = this.playerLoc.getX(); - this.playerY = this.playerLoc.getY() + this.viewHeight; + this.playerY = this.playerLoc.getY() + viewHeight; this.playerZ = this.playerLoc.getZ(); this.range = range; this.step = step; this.length = 0.0D; this.rotX = (this.playerLoc.getYaw() + 90.0F) % 360.0F; - this.rotY = this.playerLoc.getPitch() * -1.0F; + this.rotY = this.playerLoc.getPitch() * -1.0f; this.rotYCos = Math.cos(Math.toRadians(this.rotY)); this.rotYSin = Math.sin(Math.toRadians(this.rotY)); this.rotXCos = Math.cos(Math.toRadians(this.rotX)); this.rotXSin = Math.sin(Math.toRadians(this.rotX)); this.targetX = (int)Math.floor(this.playerLoc.getX()); - this.targetY = (int)Math.floor(this.playerLoc.getY() + this.viewHeight); + this.targetY = (int)Math.floor(this.playerLoc.getY() + viewHeight); this.targetZ = (int)Math.floor(this.playerLoc.getZ()); this.lastX = this.targetX; this.lastY = this.targetY; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java index 1af02afad..bbed59499 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java @@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.bukkit.BukkitCommand; import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.FawePlayer; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.thevoxelbox.voxelsniper.brush.*; import org.bukkit.Bukkit; import org.bukkit.command.Command; @@ -127,7 +128,7 @@ public class VoxelSniper extends JavaPlugin { setupCommand("/p", new FaweCommand("voxelsniper.sniper") { @Override public boolean execute(FawePlayer fp, String... args) { - Player player = (Player) fp.parent; + Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); return onCommand(player, new Command("p") { @Override public boolean execute(@NotNull CommandSender sender, String commandLabel, @NotNull String[] args) { @@ -140,7 +141,7 @@ public class VoxelSniper extends JavaPlugin { setupCommand("/d", new FaweCommand("voxelsniper.sniper") { @Override public boolean execute(FawePlayer fp, String... args) { - Player player = (Player) fp.parent; + Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); return onCommand(player, new Command("d") { @Override public boolean execute(@NotNull CommandSender sender, String commandLabel, @NotNull String[] args) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java index 19951eec8..231217225 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java @@ -18,9 +18,8 @@ public class JaggedLineBrush extends PerformBrush { private static final int RECURSION_DEFAULT = 3; private static final int RECURSION_MAX = 10; private static final int SPREAD_DEFAULT = 3; - private static int timesUsed = 0; private Random random = new Random(); - private Vector originCoords = null; + private Vector originCoords; private Vector targetCoords = new Vector(); private int recursion = RECURSION_DEFAULT; private int spread = SPREAD_DEFAULT; @@ -29,7 +28,7 @@ public class JaggedLineBrush extends PerformBrush { this.setName("Jagged Line"); } - private void jaggedP(final SnipeData v) { + private void jaggedP(SnipeData v) { final Vector originClone = this.originCoords.clone().add(JaggedLineBrush.HALF_BLOCK_OFFSET); final Vector targetClone = this.targetCoords.clone().add(JaggedLineBrush.HALF_BLOCK_OFFSET); @@ -51,7 +50,7 @@ public class JaggedLineBrush extends PerformBrush { } @Override - public final void arrow(final SnipeData v) { + public final void arrow(SnipeData v) { if (originCoords == null) { originCoords = new Vector(); } @@ -60,7 +59,7 @@ public class JaggedLineBrush extends PerformBrush { } @Override - public final void powder(final SnipeData v) { + public final void powder(SnipeData v) { if (originCoords == null) { v.sendMessage(ChatColor.RED + "Warning: You did not select a first coordinate with the arrow"); } else { @@ -71,15 +70,15 @@ public class JaggedLineBrush extends PerformBrush { } @Override - public final void info(final Message vm) { + public final void info(Message vm) { vm.brushName(this.getName()); vm.custom(ChatColor.GRAY + String.format("Recursion set to: %d", this.recursion)); vm.custom(ChatColor.GRAY + String.format("Spread set to: %d", this.spread)); } @Override - public final void parameters(final String[] par, final SnipeData v) { - for (final String parameter : par) { + public final void parameters(String[] par, SnipeData v) { + for (String parameter : par) { try { if (parameter.equalsIgnoreCase("info")) { v.sendMessage(ChatColor.GOLD + "Jagged Line Brush instructions: Right click first point with the arrow. Right click with powder to draw a jagged line to set the second point."); @@ -97,9 +96,9 @@ public class JaggedLineBrush extends PerformBrush { } return; - } else if (parameter.startsWith("s")) { - final int temp = Integer.parseInt(parameter.substring(1)); - this.spread = temp; + } + if (parameter.startsWith("s")) { + this.spread = Integer.parseInt(parameter.substring(1)); v.sendMessage(ChatColor.GREEN + "Spread set to: " + this.spread); } } catch (Exception exception) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java index 9208276d9..c0c5ff7b9 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java @@ -8,14 +8,14 @@ import org.bukkit.ChatColor; public class RingBrush extends PerformBrush { - private double trueCircle = 0; - private double innerSize = 0; + private double trueCircle; + private double innerSize; public RingBrush() { this.setName("Ring"); } - private void ring(final SnipeData v, AsyncBlock targetBlock) { + private void ring(SnipeData v, AsyncBlock targetBlock) { final int brushSize = v.getBrushSize(); final double outerSquared = Math.pow(brushSize + this.trueCircle, 2); final double innerSquared = Math.pow(this.innerSize, 2); @@ -24,7 +24,7 @@ public class RingBrush extends PerformBrush { final double xSquared = Math.pow(x, 2); for (int z = brushSize; z >= 0; z--) { final double ySquared = Math.pow(z, 2); - if ((xSquared + ySquared) <= outerSquared && (xSquared + ySquared) >= innerSquared) { + if (xSquared + ySquared <= outerSquared && xSquared + ySquared >= innerSquared) { current.perform(targetBlock.getRelative(x, 0, z)); current.perform(targetBlock.getRelative(x, 0, -z)); current.perform(targetBlock.getRelative(-x, 0, z)); @@ -37,24 +37,24 @@ public class RingBrush extends PerformBrush { } @Override - protected final void arrow(final SnipeData v) { + protected final void arrow(SnipeData v) { this.ring(v, this.getTargetBlock()); } @Override - protected final void powder(final SnipeData v) { + protected final void powder(SnipeData v) { this.ring(v, this.getLastBlock()); } @Override - public final void info(final Message vm) { + public final void info(Message vm) { vm.brushName(this.getName()); vm.size(); vm.custom(ChatColor.AQUA + "The inner radius is " + ChatColor.RED + this.innerSize); } @Override - public final void parameters(final String[] par, final SnipeData v) { + public final void parameters(String[] par, SnipeData v) { for (int i = 1; i < par.length; i++) { if (par[i].equalsIgnoreCase("info")) { v.sendMessage(ChatColor.GOLD + "Ring Brush Parameters:"); @@ -69,10 +69,9 @@ public class RingBrush extends PerformBrush { v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); } else if (par[i].startsWith("ir")) { try { - final double d = Double.parseDouble(par[i].replace("ir", "")); - this.innerSize = d; + this.innerSize = Double.parseDouble(par[i].replace("ir", "")); v.sendMessage(ChatColor.AQUA + "The inner radius has been set to " + ChatColor.RED + this.innerSize); - } catch (final Exception exception) { + } catch (Exception exception) { v.sendMessage(ChatColor.RED + "The parameters included are invalid."); } } else { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java index 2761adf64..4920a10d3 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java @@ -9,6 +9,7 @@ import org.bukkit.Material; import org.bukkit.block.BlockFace; public class ScannerBrush extends Brush { + private static final int DEPTH_MIN = 1; private static final int DEPTH_DEFAULT = 24; private static final int DEPTH_MAX = 64; @@ -20,7 +21,7 @@ public class ScannerBrush extends Brush { this.setName("Scanner"); } - private int clamp(final int value, final int min, final int max) { + private int clamp(int value, int min, int max) { if (value < min) { return min; } else { @@ -28,7 +29,7 @@ public class ScannerBrush extends Brush { } } - private void scan(final SnipeData v, final BlockFace bf) { + private void scan(SnipeData v, BlockFace bf) { if (bf == null) { return; } @@ -37,8 +38,10 @@ public class ScannerBrush extends Brush { case NORTH: // Scan south for (int i = 1; i < this.depth + 1; i++) { - if (this.clampY(this.getTargetBlock().getX() + i, this.getTargetBlock().getY(), this.getTargetBlock().getZ()).getType() == this.checkFor) { - v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); + if (this.clampY(this.getTargetBlock().getX() + i, this.getTargetBlock().getY(), + this.getTargetBlock().getZ()).getType() == this.checkFor) { + v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + + " blocks."); return; } } @@ -48,8 +51,10 @@ public class ScannerBrush extends Brush { case SOUTH: // Scan north for (int i = 1; i < this.depth + 1; i++) { - if (this.clampY(this.getTargetBlock().getX() - i, this.getTargetBlock().getY(), this.getTargetBlock().getZ()).getType() == this.checkFor) { - v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); + if (this.clampY(this.getTargetBlock().getX() - i, this.getTargetBlock().getY(), + this.getTargetBlock().getZ()).getType() == this.checkFor) { + v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + + " blocks."); return; } } @@ -59,8 +64,10 @@ public class ScannerBrush extends Brush { case EAST: // Scan west for (int i = 1; i < this.depth + 1; i++) { - if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ() + i).getType() == this.checkFor) { - v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); + if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), + this.getTargetBlock().getZ() + i).getType() == this.checkFor) { + v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + + " blocks."); return; } } @@ -70,8 +77,10 @@ public class ScannerBrush extends Brush { case WEST: // Scan east for (int i = 1; i < this.depth + 1; i++) { - if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ() - i).getType() == this.checkFor) { - v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); + if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), + this.getTargetBlock().getZ() - i).getType() == this.checkFor) { + v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + + " blocks."); return; } } @@ -81,11 +90,13 @@ public class ScannerBrush extends Brush { case UP: // Scan down for (int i = 1; i < this.depth + 1; i++) { - if ((this.getTargetBlock().getY() - i) <= 0) { + if (this.getTargetBlock().getY() - i <= 0) { break; } - if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() - i, this.getTargetBlock().getZ()).getType() == this.checkFor) { - v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); + if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() - i, + this.getTargetBlock().getZ()).getType() == this.checkFor) { + v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + + " blocks."); return; } } @@ -95,11 +106,13 @@ public class ScannerBrush extends Brush { case DOWN: // Scan up for (int i = 1; i < this.depth + 1; i++) { - if ((this.getTargetBlock().getY() + i) >= v.getWorld().getMaxHeight()) { + if (this.getTargetBlock().getY() + i >= v.getWorld().getMaxHeight()) { break; } - if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() + i, this.getTargetBlock().getZ()).getType() == this.checkFor) { - v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); + if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() + i, + this.getTargetBlock().getZ()).getType() == this.checkFor) { + v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + + " blocks."); return; } } @@ -113,38 +126,41 @@ public class ScannerBrush extends Brush { @SuppressWarnings("deprecation") @Override - protected final void arrow(final SnipeData v) { + protected final void arrow(SnipeData v) { this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId())); this.scan(v, this.getTargetBlock().getFace(this.getLastBlock())); } @SuppressWarnings("deprecation") @Override - protected final void powder(final SnipeData v) { + protected final void powder(SnipeData v) { this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId())); this.scan(v, this.getTargetBlock().getFace(this.getLastBlock())); } @Override - public final void info(final Message vm) { + public final void info(Message vm) { vm.brushName(this.getName()); vm.custom(ChatColor.GREEN + "Scanner depth set to " + this.depth); vm.custom(ChatColor.GREEN + "Scanner scans for " + this.checkFor + " (change with /v #)"); } @Override - public final void parameters(final String[] par, final SnipeData v) { + public final void parameters(String[] par, SnipeData v) { for (int i = 1; i < par.length; i++) { if (par[i].equalsIgnoreCase("info")) { v.sendMessage(ChatColor.GOLD + "Scanner brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b sc d# -- will set the search depth to #. Clamps to 1 - 64."); + v.sendMessage(ChatColor.AQUA + + "/b sc d# -- will set the search depth to #. Clamps to 1 - 64."); return; } if (par[i].startsWith("d")) { - this.depth = this.clamp(Integer.parseInt(par[i].substring(1)), DEPTH_MIN, DEPTH_MAX); + this.depth = this + .clamp(Integer.parseInt(par[i].substring(1)), DEPTH_MIN, DEPTH_MAX); v.sendMessage(ChatColor.AQUA + "Scanner depth set to " + this.depth); } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java index 7fe7f7a9e..2c811f70c 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java @@ -1,16 +1,13 @@ package com.boydti.fawe.bukkit; -import com.boydti.fawe.Fawe; -import com.boydti.fawe.config.BBC; import com.boydti.fawe.object.FawePlayer; import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; -import java.util.UUID; - public class BukkitPlayer extends FawePlayer { private static ConsoleCommandSender console; @@ -39,26 +36,6 @@ public class BukkitPlayer extends FawePlayer { return parent.isSneaking(); } - @Override - public void setPermission(final String perm, final boolean flag) { - /* - * Permissions are used to managing WorldEdit region restrictions - * - The `/wea` command will give/remove the required bypass permission - */ - if (Fawe.imp().getVault() == null || Fawe.imp().getVault().permission == null) { - this.parent.addAttachment(Fawe.imp().getPlugin()).setPermission(perm, flag); - } else if (flag) { - if (!Fawe.imp().getVault().permission.playerAdd(this.parent, perm)) { - this.parent.addAttachment(Fawe.imp().getPlugin()).setPermission(perm, flag); - } - } else { - if (!Fawe.imp().getVault().permission.playerRemove(this.parent, perm)) { - this.parent.addAttachment(Fawe.imp().getPlugin()).setPermission(perm, flag); - } - } - } - - @Override public void resetTitle() { parent.resetTitle(); @@ -77,7 +54,7 @@ public class BukkitPlayer extends FawePlayer { @Override public void sendMessage(final String message) { - this.parent.sendMessage(BBC.color(message)); + this.parent.sendMessage(message); } @Override public void printError(String msg) { 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 e37f7b888..061f04902 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 @@ -3,11 +3,9 @@ package com.boydti.fawe.bukkit; import com.boydti.fawe.Fawe; import com.boydti.fawe.IFawe; import com.boydti.fawe.beta.implementation.QueueHandler; -import com.boydti.fawe.bukkit.beta.BukkitQueue; import com.boydti.fawe.bukkit.beta.BukkitQueueHandler; import com.boydti.fawe.bukkit.listener.BrushListener; import com.boydti.fawe.bukkit.listener.BukkitImageListener; -import com.boydti.fawe.bukkit.listener.CFIPacketListener; import com.boydti.fawe.bukkit.listener.RenderListener; import com.boydti.fawe.bukkit.regions.*; import com.boydti.fawe.bukkit.util.BukkitReflectionUtils; @@ -21,7 +19,6 @@ import com.boydti.fawe.bukkit.v0.ChunkListener_8; import com.boydti.fawe.bukkit.v0.ChunkListener_9; import com.boydti.fawe.bukkit.v1_13.BukkitQueue_1_13; import com.boydti.fawe.bukkit.v1_14.BukkitQueue_1_14; -import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.FawePlayer; @@ -32,10 +29,10 @@ import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.image.ImageViewer; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.world.World; import org.bstats.bukkit.MetricsLite; import org.bukkit.Bukkit; -import org.bukkit.Chunk; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.entity.Player; @@ -43,11 +40,9 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; import java.io.File; import java.io.FileOutputStream; @@ -155,7 +150,7 @@ public class FaweBukkit implements IFawe, Listener { fos.write(jarData); } } - BukkitImageViewer viewer = new BukkitImageViewer((Player) fp.parent); + BukkitImageViewer viewer = new BukkitImageViewer(BukkitAdapter.adapt(fp.toWorldEditPlayer())); if (imageListener == null) { this.imageListener = new BukkitImageListener(plugin); } @@ -184,7 +179,7 @@ public class FaweBukkit implements IFawe, Listener { @Override public void debug(final String message) { ConsoleCommandSender console = Bukkit.getConsoleSender(); - console.sendMessage(BBC.color(message)); + console.sendMessage(message); } @Override @@ -398,19 +393,19 @@ public class FaweBukkit implements IFawe, Listener { final ArrayList managers = new ArrayList<>(); if (worldguardPlugin != null && worldguardPlugin.isEnabled()) { try { - managers.add(new Worldguard(worldguardPlugin, this)); - managers.add(new WorldguardFlag(worldguardPlugin, this)); + managers.add(new Worldguard(worldguardPlugin)); + managers.add(new WorldguardFlag(worldguardPlugin)); Fawe.debug("Plugin 'WorldGuard' found. Using it now."); - } catch (final Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny"); if (townyPlugin != null && townyPlugin.isEnabled()) { try { - managers.add(new TownyFeature(townyPlugin, this)); + managers.add(new TownyFeature(townyPlugin)); Fawe.debug("Plugin 'Towny' found. Using it now."); - } catch (final Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } @@ -419,7 +414,7 @@ public class FaweBukkit implements IFawe, Listener { try { managers.add(new FactionsFeature(factionsPlugin)); Fawe.debug("Plugin 'Factions' found. Using it now."); - } catch (final Throwable e) { + } catch (Throwable e) { try { managers.add(new FactionsUUIDFeature(factionsPlugin, this)); Fawe.debug("Plugin 'FactionsUUID' found. Using it now."); @@ -439,7 +434,7 @@ public class FaweBukkit implements IFawe, Listener { try { managers.add(new ResidenceFeature(residencePlugin, this)); Fawe.debug("Plugin 'Residence' found. Using it now."); - } catch (final Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } @@ -448,7 +443,7 @@ public class FaweBukkit implements IFawe, Listener { try { managers.add(new GriefPreventionFeature(griefpreventionPlugin)); Fawe.debug("Plugin 'GriefPrevention' found. Using it now."); - } catch (final Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } @@ -457,7 +452,7 @@ public class FaweBukkit implements IFawe, Listener { try { managers.add(new PreciousStonesFeature(preciousStonesPlugin, this)); Fawe.debug("Plugin 'PreciousStones' found. Using it now."); - } catch (final Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } @@ -468,7 +463,7 @@ public class FaweBukkit implements IFawe, Listener { try { managers.add(new ASkyBlockHook(aSkyBlock)); Fawe.debug("Plugin 'ASkyBlock' found. Using it now."); - } catch (final Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } @@ -476,7 +471,7 @@ public class FaweBukkit implements IFawe, Listener { try { managers.add(new FreeBuildRegion()); Fawe.debug("Plugin '' found. Using it now."); - } catch (final Throwable e) { + } catch (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 e23c09c0f..c0b0fb4ef 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 @@ -234,6 +234,7 @@ public class BukkitQueue extends SimpleCharQueueExtent { return playerChunk; } + @Override public boolean sendChunk(final int X, final int Z, final int mask) { PlayerChunk playerChunk = getPlayerChunk(X, Z); if (playerChunk == null) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java index 2c1a58fcd..664734cd9 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java @@ -3,10 +3,11 @@ package com.boydti.fawe.bukkit.regions; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.regions.FaweMask; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.wasteofplastic.askyblock.ASkyBlockAPI; import com.wasteofplastic.askyblock.Island; import org.bukkit.Location; -import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; @@ -24,22 +25,21 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener { @Override public FaweMask getMask(final FawePlayer fp, MaskType type) { - final Player player = fp.parent; + final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Location location = player.getLocation(); Island island = ASkyBlockAPI.getInstance().getIslandAt(location); if (island != null && isAllowed(player, island, type)) { - World world = location.getWorld(); - Location center = island.getCenter(); - Location pos1 = new Location(world, island.getMinProtectedX(), 0, island.getMinProtectedZ()); - Location pos2 = center.add(center.subtract(pos1)); - pos2.setY(255); + Location center1 = island.getCenter(); + MutableBlockVector3 center = MutableBlockVector3.at(center1.getX(), center1.getY(), center1.getZ()); + BlockVector3 pos1 = BlockVector3.at(island.getMinProtectedX(), 0, island.getMinProtectedZ()); + MutableBlockVector3 pos2 = center.add(center.subtract(pos1)).mutY(255); - return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { + return new FaweMask(pos1, pos2) { @Override public boolean isValid(FawePlayer player, MaskType type) { - return isAllowed((Player) player.parent, island, type); + return isAllowed(BukkitAdapter.adapt(player.toWorldEditPlayer()), island, type); } }; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java index 723a6a838..2b1fa2b62 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java @@ -7,6 +7,7 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.ps.PS; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.math.BlockVector3; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -21,7 +22,7 @@ public class FactionsFeature extends BukkitMaskManager implements Listener { @Override public FaweMask getMask(final FawePlayer fp, MaskType type) { - final Player player = fp.parent; + final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Location loc = player.getLocation(); final PS ps = PS.valueOf(loc); final Faction fac = BoardColl.get().getFactionAt(ps); @@ -30,16 +31,17 @@ public class FactionsFeature extends BukkitMaskManager implements Listener { MPlayer leader = fac.getLeader(); if (leader != null && fp.getUUID().equals(leader.getUuid())) { final Chunk chunk = loc.getChunk(); - final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); - final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); - return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); + final BlockVector3 pos1 = BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16); + final BlockVector3 pos2 = BlockVector3 + .at((chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); + return new FaweMask(pos1, pos2); } } else if (fac.getOnlinePlayers().contains(player)) { if (!fac.getComparisonName().equals("wilderness")) { final Chunk chunk = loc.getChunk(); - final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); - final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); - return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); + final BlockVector3 pos1 = BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16); + final BlockVector3 pos2 = BlockVector3.at((chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); + return new FaweMask(pos1, pos2); } } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java index e1ec86f25..656ebacf0 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java @@ -6,16 +6,15 @@ import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.util.Permission; import com.massivecraft.factions.FLocation; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.math.BlockVector3; +import java.lang.reflect.Method; +import java.util.List; import org.bukkit.Chunk; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; -import java.lang.reflect.Method; -import java.util.List; - public class FactionsOneFeature extends BukkitMaskManager implements Listener { private final Method methodGetFactionAt; @@ -28,7 +27,7 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener { @Override public FaweMask getMask(final FawePlayer fp, MaskType type) { - final Player player = fp.parent; + final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Chunk chunk = player.getLocation().getChunk(); final boolean perm = Permission .hasPermission(fp.toWorldEditPlayer(), "fawe.factions.wilderness"); @@ -75,9 +74,9 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener { } } - final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4); - final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4)); - return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); + final BlockVector3 pos1 = BlockVector3.at(locs.minX << 4, 1, locs.minZ << 4); + final BlockVector3 pos2 = BlockVector3.at(15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4)); + return new FaweMask(pos1, pos2); } return null; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java index c6f9e3bb2..cccb32804 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java @@ -9,6 +9,7 @@ import com.massivecraft.factions.Board; import com.massivecraft.factions.FLocation; import com.massivecraft.factions.Faction; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.math.BlockVector3; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; @@ -26,7 +27,7 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener { @Override public FaweMask getMask(final FawePlayer fp, MaskType type) { - final Player player = fp.parent; + final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Chunk chunk = player.getLocation().getChunk(); final boolean perm = Permission .hasPermission(fp.toWorldEditPlayer(), "fawe.factions.wilderness"); @@ -73,9 +74,9 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener { } } - final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4); - final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4)); - return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); + final BlockVector3 pos1 = BlockVector3.at(locs.minX << 4, 1, locs.minZ << 4); + final BlockVector3 pos2 = BlockVector3.at(15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4)); + return new FaweMask(pos1,pos2); } return null; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java index 6e9b47a9d..3a4c1268d 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java @@ -10,6 +10,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.block.BlockTypes; +import jdk.nashorn.internal.ir.Block; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -20,6 +21,7 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.plugin.RegisteredListener; import java.util.ArrayList; +import org.bukkit.util.BlockVector; public class FreeBuildRegion extends BukkitMaskManager { private final ArrayList listeners; @@ -52,20 +54,20 @@ public class FreeBuildRegion extends BukkitMaskManager { if (currRegList.isEmpty()) return null; RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[0]); - World bukkitWorld = player.parent.getWorld(); + World bukkitWorld = BukkitAdapter.adapt(player.toWorldEditPlayer().getWorld()); AsyncWorld asyncWorld = AsyncWorld.wrap(bukkitWorld); - Location pos1 = BukkitAdapter.adapt(bukkitWorld, BlockVector3.ZERO); - Location pos2 = BukkitAdapter.adapt(bukkitWorld, BlockVector3.ZERO); + BlockVector3 pos1 = BlockVector3.ZERO; + BlockVector3 pos2 = BlockVector3.ZERO; AsyncBlock block = new AsyncBlock(asyncWorld, new NullFaweQueue(asyncWorld.getWorldName(), BlockTypes.STONE.getDefaultState()), 0, 0, 0); - BlockBreakEvent event = new BlockBreakEvent(block, player.parent); + BlockBreakEvent event = new BlockBreakEvent(block, BukkitAdapter.adapt(player.toWorldEditPlayer())); - return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { + return new FaweMask(pos1, pos2) { @Override public boolean isValid(FawePlayer player, MaskType type) { - return bukkitWorld == ((FawePlayer)player).parent.getWorld() && type == MaskType.MEMBER; + return bukkitWorld == BukkitAdapter.adapt(player.toWorldEditPlayer().getWorld()) && type == MaskType.MEMBER; } @Override diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java index 6b987df14..15a22d1fe 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java @@ -5,10 +5,10 @@ import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.general.RegionFilter; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.math.BlockVector3; import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.GriefPrevention; import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.Listener; @@ -21,24 +21,24 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene } public boolean isAllowed(Player player, Claim claim, MaskType type) { - return claim != null && (claim.getOwnerName().equalsIgnoreCase(player.getName()) || claim.getOwnerName().equals(player.getUniqueId()) || (type == MaskType.MEMBER && (claim.allowBuild(player, Material.AIR) == null))); + return claim != null && (claim.getOwnerName().equalsIgnoreCase(player.getName()) || claim.getOwnerName().equals(player.getUniqueId()) || + type == MaskType.MEMBER && claim.allowBuild(player, Material.AIR) == null); } @Override public FaweMask getMask(final FawePlayer fp, MaskType type) { - final Player player = fp.parent; - final Location location = player.getLocation(); - final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, true, null); + final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); + final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(BukkitAdapter.adapt(fp.getLocation()), true, null); if (claim != null) { if (isAllowed(player, claim, type)) { claim.getGreaterBoundaryCorner().getBlockX(); - final Location pos1 = new Location(location.getWorld(), claim.getLesserBoundaryCorner().getBlockX(), 0, claim.getLesserBoundaryCorner().getBlockZ()); - final Location pos2 = new Location(location.getWorld(), claim.getGreaterBoundaryCorner().getBlockX(), 256, claim.getGreaterBoundaryCorner().getBlockZ()); - return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { + final BlockVector3 pos1 = BlockVector3.at(claim.getLesserBoundaryCorner().getBlockX(), 0, claim.getLesserBoundaryCorner().getBlockZ()); + final BlockVector3 pos2 = BlockVector3.at(claim.getGreaterBoundaryCorner().getBlockX(), 256, claim.getGreaterBoundaryCorner().getBlockZ()); + return new FaweMask(pos1, pos2) { @Override - public boolean isValid(FawePlayer player, MaskType type) { - return isAllowed((Player) player.parent, claim, type); + public boolean isValid(FawePlayer fp, MaskType type) { + return isAllowed(player, claim, type); } }; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java index d67f9a919..a94b4a7f2 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java @@ -3,6 +3,7 @@ package com.boydti.fawe.bukkit.regions; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.regions.FaweMask; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.math.BlockVector3; import java.util.List; @@ -15,23 +16,19 @@ import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; public class PreciousStonesFeature extends BukkitMaskManager implements Listener { - FaweBukkit plugin; - Plugin preciousstones; - public PreciousStonesFeature(final Plugin preciousstonesPlugin, final FaweBukkit p3) { + public PreciousStonesFeature(Plugin preciousstonesPlugin, FaweBukkit p3) { super(preciousstonesPlugin.getName()); - this.preciousstones = preciousstonesPlugin; - this.plugin = p3; } public boolean isAllowed(Player player, Field field, MaskType type, boolean allowMember) { - return field != null && (field.isOwner(player.getName()) || (type == MaskType.MEMBER && allowMember && field.getAllAllowed().contains(player.getName()))); + return field != null && (field.isOwner(player.getName()) || type == MaskType.MEMBER && allowMember && field.getAllAllowed().contains(player.getName())); } @Override - public FaweMask getMask(final FawePlayer fp, MaskType type) { - final Player player = fp.parent; + public FaweMask getMask(FawePlayer fp, MaskType type) { + final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Location location = player.getLocation(); final List fields = PreciousStones.API().getFieldsProtectingArea(FieldFlag.ALL, location); if (fields.isEmpty()) { @@ -39,14 +36,14 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener } String name = player.getName(); boolean member = fp.hasPermission("fawe.preciousstones.member"); - for (final Field myField : fields) { + for (Field myField : fields) { if (isAllowed(player, myField, type, member)) { BlockVector3 pos1 = BlockVector3.at(myField.getMinx(), myField.getMiny(), myField.getMinz()); BlockVector3 pos2 = BlockVector3.at(myField.getMaxx(), myField.getMaxy(), myField.getMaxz()); return new FaweMask(pos1, pos2) { @Override public boolean isValid(FawePlayer player, MaskType type) { - return isAllowed((Player) player.parent, myField, type, fp.hasPermission("fawe.preciousstones.member")); + return isAllowed((Player) BukkitAdapter.adapt(player.toWorldEditPlayer()), myField, type, fp.hasPermission("fawe.preciousstones.member")); } }; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java index 398be6d63..3217ab4e1 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java @@ -29,7 +29,7 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener { @Override public FaweMask getMask(final FawePlayer fp, final MaskType type) { - final Player player = fp.parent; + final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Location location = player.getLocation(); ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location); if (residence != null) { @@ -42,10 +42,10 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener { final Location pos1 = area.getLowLoc(); final Location pos2 = area.getHighLoc(); final ClaimedResidence finalResidence = residence; - return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { + return new FaweMask(BukkitAdapter.asBlockVector(pos1), BukkitAdapter.asBlockVector(pos2)) { @Override public boolean isValid(FawePlayer player, MaskType type) { - return isAllowed((Player) player.parent, finalResidence, type); + return isAllowed((Player) BukkitAdapter.adapt(player.toWorldEditPlayer()), finalResidence, type); } }; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java index 06a4476d1..f7cc9dc27 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java @@ -1,12 +1,17 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.regions.FaweMask; import com.palmergames.bukkit.towny.Towny; import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; -import com.palmergames.bukkit.towny.object.*; +import com.palmergames.bukkit.towny.object.PlayerCache; +import com.palmergames.bukkit.towny.object.Resident; +import com.palmergames.bukkit.towny.object.Town; +import com.palmergames.bukkit.towny.object.TownBlock; +import com.palmergames.bukkit.towny.object.TownyUniverse; +import com.palmergames.bukkit.towny.object.WorldCoord; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.math.BlockVector3; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -14,13 +19,12 @@ import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; public class TownyFeature extends BukkitMaskManager implements Listener { - FaweBukkit plugin; - Plugin towny; - public TownyFeature(final Plugin townyPlugin, final FaweBukkit p3) { + private Plugin towny; + + public TownyFeature(Plugin townyPlugin) { super(townyPlugin.getName()); this.towny = townyPlugin; - this.plugin = p3; } public boolean isAllowed(Player player, TownBlock block) { @@ -30,16 +34,19 @@ public class TownyFeature extends BukkitMaskManager implements Listener { Resident resident; try { resident = TownyUniverse.getDataSource().getResident(player.getName()); - try { - if (block.getResident().equals(resident)) { - return true; + try { + if (block.getResident().equals(resident)) { + return true; + } + } catch (NotRegisteredException ignore) { } - } catch (NotRegisteredException ignore) {} Town town = block.getTown(); if (town.isMayor(resident)) { return true; } - if (!town.hasResident(resident)) return false; + if (!town.hasResident(resident)) { + return false; + } if (player.hasPermission("fawe.towny.*")) { return true; } @@ -55,8 +62,8 @@ public class TownyFeature extends BukkitMaskManager implements Listener { } @Override - public FaweMask getMask(final FawePlayer fp) { - final Player player = fp.parent; + public FaweMask getMask(FawePlayer fp) { + final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Location location = player.getLocation(); try { final PlayerCache cache = ((Towny) this.towny).getCache(player); @@ -71,18 +78,23 @@ public class TownyFeature extends BukkitMaskManager implements Listener { boolean isMember = isAllowed(player, myplot); if (isMember) { final Chunk chunk = location.getChunk(); - final Location pos1 = new Location(location.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); - final Location pos2 = new Location(location.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); - return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { + final BlockVector3 pos1 = BlockVector3 + .at(chunk.getX() * 16, 0, chunk.getZ() * 16); + final BlockVector3 pos2 = BlockVector3.at( + chunk.getX() * 16 + 15, 156, chunk.getZ() * 16 + + 15); + return new FaweMask(pos1, pos2) { @Override public boolean isValid(FawePlayer player, MaskType type) { - return isAllowed((Player) player.parent, myplot); + return isAllowed(BukkitAdapter.adapt(player.toWorldEditPlayer()), + myplot); } }; } } } - } catch (final Exception e) {} + } catch (Exception ignored) { + } return null; } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java index 887c47a01..f9125bc0e 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java @@ -1,6 +1,5 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.filter.WorldGuardFilter; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RegionWrapper; @@ -30,7 +29,6 @@ import org.bukkit.plugin.Plugin; public class Worldguard extends BukkitMaskManager implements Listener { private WorldGuardPlugin worldguard; - FaweBukkit plugin; private WorldGuardPlugin getWorldGuard() { final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard"); @@ -43,13 +41,12 @@ public class Worldguard extends BukkitMaskManager implements Listener { return (WorldGuardPlugin) plugin; } - public Worldguard(final Plugin p2, final FaweBukkit p3) { + public Worldguard(Plugin p2) { super(p2.getName()); this.worldguard = this.getWorldGuard(); - this.plugin = p3; } - public ProtectedRegion getRegion(final LocalPlayer player, final Location location) { + public ProtectedRegion getRegion(LocalPlayer player, Location location) { RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); if (container == null) { System.out.println("Region capability is not enabled for WorldGuard."); @@ -65,7 +62,7 @@ public class Worldguard extends BukkitMaskManager implements Listener { return global; } final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(location.getX(), location.getY(), location.getZ())); - for (final ProtectedRegion region : regions) { + for (ProtectedRegion region : regions) { if (isAllowed(player, region)) { return region; } @@ -86,43 +83,42 @@ public class Worldguard extends BukkitMaskManager implements Listener { if (localplayer.hasPermission("fawe.worldguard.member")) { if (region.isMember(localplayer) || region.isMember(localplayer.getName())) { return true; - } else if (region.isMember("*")) { - return true; - } + } else + return region.isMember("*"); } return false; } @Override public FaweMask getMask(FawePlayer fp, MaskType type) { - final Player player = fp.parent; + final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final LocalPlayer localplayer = this.worldguard.wrapPlayer(player); final Location location = player.getLocation(); final ProtectedRegion myregion = this.getRegion(localplayer, location); if (myregion != null) { - final Location pos1; - final Location pos2; + final BlockVector3 pos1; + final BlockVector3 pos2; if (myregion.getId().equals("__global__")) { - pos1 = new Location(location.getWorld(), Integer.MIN_VALUE, 0, Integer.MIN_VALUE); - pos2 = new Location(location.getWorld(), Integer.MAX_VALUE, 255, Integer.MAX_VALUE); + pos1 = BlockVector3.at(Integer.MIN_VALUE, 0, Integer.MIN_VALUE); + pos2 = BlockVector3.at(Integer.MAX_VALUE, 255, Integer.MAX_VALUE); } else { if (myregion instanceof ProtectedCuboidRegion) { - pos1 = new Location(location.getWorld(), myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ()); - pos2 = new Location(location.getWorld(), myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ()); + pos1 = BlockVector3.at(myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ()); + pos2 = BlockVector3.at(myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ()); } else { return new FaweMask(adapt(myregion)) { @Override public boolean isValid(FawePlayer player, MaskType type) { - return isAllowed(worldguard.wrapPlayer((Player) player.parent), myregion); + return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player.toWorldEditPlayer())), myregion); } }; } } - return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { + return new FaweMask(pos1, pos2) { @Override public boolean isValid(FawePlayer player, MaskType type) { - return isAllowed(worldguard.wrapPlayer((Player) player.parent), myregion); + return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player.toWorldEditPlayer())), myregion); } }; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java index 4e5d5e7ed..7992f769f 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java @@ -1,10 +1,10 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.filter.WorldGuardFilter; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.general.RegionFilter; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldguard.LocalPlayer; @@ -12,29 +12,29 @@ import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.protection.flags.Flags; import com.sk89q.worldguard.protection.managers.RegionManager; -import com.sk89q.worldguard.protection.regions.*; +import com.sk89q.worldguard.protection.regions.ProtectedRegion; +import com.sk89q.worldguard.protection.regions.RegionContainer; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; -import java.util.Map; - public class WorldguardFlag extends BukkitMaskManager implements Listener { - private WorldGuardPlugin worldguard; - private FaweBukkit plugin; - public WorldguardFlag(Plugin p2, FaweBukkit p3) { + private WorldGuardPlugin worldguard; + + public WorldguardFlag(Plugin p2) { super("worldguardflag"); this.worldguard = (WorldGuardPlugin) p2; // this.getWorldGuard(); - this.plugin = p3; } @Override public FaweMask getMask(FawePlayer fp, MaskType type) { - final Player player = fp.parent; + final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final LocalPlayer localplayer = this.worldguard.wrapPlayer(player); - final RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); + final RegionContainer container = WorldGuard.getInstance().getPlatform() + .getRegionContainer(); final RegionManager manager = container.get(fp.getWorld()); return new FaweMask(new ManagerRegion(manager, localplayer)) { @@ -55,6 +55,7 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener { * ManagerRegion wraps a RegionManager and will provide results based upon the regions enclosed */ private static class ManagerRegion extends AbstractRegion { + private final RegionManager manager; private final LocalPlayer localplayer; @@ -105,7 +106,8 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener { @Override public boolean contains(BlockVector3 position) { // Make sure that all these flags are not denied. Denies override allows. WorldGuardExtraFlags can add Flags.WORLDEDIT - return manager.getApplicableRegions(position).testState(localplayer, Flags.BUILD, Flags.BLOCK_PLACE, Flags.BLOCK_BREAK); + return manager.getApplicableRegions(position) + .testState(localplayer, Flags.BUILD, Flags.BLOCK_PLACE, Flags.BLOCK_BREAK); } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java new file mode 100644 index 000000000..21053ba35 --- /dev/null +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java @@ -0,0 +1,168 @@ +/* + * 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.bukkit; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor; +import com.sk89q.worldedit.extension.platform.Locatable; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.session.SessionKey; +import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.auth.AuthorizationException; +import com.sk89q.worldedit.util.formatting.text.Component; +import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter; +import org.bukkit.Material; +import org.bukkit.command.BlockCommandSender; + +import java.util.UUID; + +import javax.annotation.Nullable; + +public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements Locatable { + + private final BlockCommandSender sender; + private final WorldEditPlugin plugin; + private final Location location; + private final UUID uuid; + + public BukkitBlockCommandSender(WorldEditPlugin plugin, BlockCommandSender sender) { + checkNotNull(plugin); + checkNotNull(sender); + + this.plugin = plugin; + this.sender = sender; + this.location = BukkitAdapter.adapt(sender.getBlock().getLocation()); + this.uuid = new UUID(location.toVector().toBlockPoint().hashCode(), location.getExtent().hashCode()); + } + + @Override + public String getName() { + return sender.getName(); + } + + @Override + public void printRaw(String msg) { + for (String part : msg.split("\n")) { + sender.sendMessage(part); + } + } + + @Override + public void print(String msg) { + for (String part : msg.split("\n")) { + sender.sendMessage("\u00A7d" + part); + } + } + + @Override + public void printDebug(String msg) { + for (String part : msg.split("\n")) { + sender.sendMessage("\u00A77" + part); + } + } + + @Override + public void printError(String msg) { + for (String part : msg.split("\n")) { + sender.sendMessage("\u00A7c" + part); + } + } + + @Override + public void print(Component component) { + TextAdapter.sendComponent(sender, component); + } + + @Override + public Location getLocation() { + return this.location; + } + + @Override + public boolean setLocation(Location location) { + return false; + } + + @Override + public Extent getExtent() { + return this.location.getExtent(); + } + + @Override + public UUID getUniqueId() { + return uuid; + } + + @Override + public String[] getGroups() { + return new String[0]; + } + + @Override + public void checkPermission(String permission) throws AuthorizationException { + if (!hasPermission(permission)) { + throw new AuthorizationException(); + } + } + + @Override + public boolean hasPermission(String permission) { + return sender.hasPermission(permission); + } + + @Override + public boolean togglePermission(String permission) { + return true; + } + + @Override + public void setPermission(String permission, boolean value) { + + } + + @Override + public SessionKey getSessionKey() { + return new SessionKey() { + @Nullable + @Override + public String getName() { + return sender.getName(); + } + + @Override + public boolean isActive() { + return sender.getBlock().getType() == Material.COMMAND_BLOCK + || sender.getBlock().getType() == Material.CHAIN_COMMAND_BLOCK + || sender.getBlock().getType() == Material.REPEATING_COMMAND_BLOCK; + } + + @Override + public boolean isPersistent() { + return false; + } + + @Override + public UUID getUniqueId() { + return uuid; + } + }; + } +} diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java index 36f7d248d..455fdc47f 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java @@ -22,21 +22,19 @@ package com.sk89q.worldedit.bukkit; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor; import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.auth.AuthorizationException; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter; +import java.io.File; +import java.util.UUID; +import javax.annotation.Nullable; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.io.File; -import java.util.UUID; - -import javax.annotation.Nullable; - -public class BukkitCommandSender implements Actor { +public class BukkitCommandSender extends AbstractNonPlayerActor { /** * One time generated ID. @@ -149,17 +147,17 @@ public class BukkitCommandSender implements Actor { @Nullable @Override public String getName() { - return null; + return sender.getName(); } @Override public boolean isActive() { - return false; + return true; } @Override public boolean isPersistent() { - return false; + return true; } @Override diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 3dee53bf9..cfcf9f44f 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -255,14 +255,13 @@ public class BukkitPlayer extends AbstractPlayerActor { } @Override - public void floatAt(int x, int y, int z, boolean alwaysGlass) { - if (alwaysGlass || !player.getAllowFlight()) { - super.floatAt(x, y, z, alwaysGlass); - return; + public boolean isAllowedToFly() { + return player.getAllowFlight(); } - setPosition(Vector3.at(x + 0.5, y, z + 0.5)); - player.setFlying(true); + @Override + public void setFlying(boolean flying) { + player.setFlying(flying); } @Override 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 b22974a4f..3c4888d41 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 @@ -45,6 +45,7 @@ import java.util.ArrayList; import java.util.EnumMap; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.annotation.Nullable; import org.bukkit.Effect; @@ -156,6 +157,10 @@ public class BukkitWorld extends AbstractWorld { return getWorld().getName(); } + @Override + public String getId() { + return getWorld().getName().replace(" ", "_").toLowerCase(Locale.ROOT); + } @Override public Path getStoragePath() { return getWorld().getWorldFolder().toPath(); 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 dcc606800..eb2b96707 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 @@ -527,6 +527,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter public Actor wrapCommandSender(CommandSender sender) { if (sender instanceof Player) { return wrapPlayer((Player) sender); + } else if (sender instanceof BlockCommandSender) { + return new BukkitBlockCommandSender(this, (BlockCommandSender) sender); } return new BukkitCommandSender(this, sender); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java index fe772decd..7b3795a59 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -133,7 +133,7 @@ public class Fawe { if (INSTANCE != null) { INSTANCE.IMP.debug(s); } else { - System.out.println(BBC.stripColor(BBC.color(s))); + System.out.println(s); } } @@ -145,10 +145,10 @@ public class Fawe { public static void debug(Object s) { Actor actor = Request.request().getActor(); if (actor != null && actor.isPlayer()) { - actor.print(BBC.color(BBC.PREFIX.original() + " " + s)); + actor.print((String)s); return; } - debugPlain(BBC.PREFIX.original() + " " + s); + debugPlain((String) s); } /** diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java index f05a1b2e5..ea890c85e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java @@ -16,8 +16,8 @@ public interface IDelegateQueueExtent extends IQueueExtent { } @Override - default IChunk getCachedChunk(final int X, final int Z) { - return getParent().getCachedChunk(X, Z); + default IChunk getCachedChunk(final int x, final int z) { + return getParent().getCachedChunk(x, z); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java index 66d7dcfda..1c24abddb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java @@ -42,15 +42,15 @@ public interface IQueueExtent extends Flushable, Trimable, Extent { * Get the {@link WorldChunkCache} * @return */ - IChunkGet getCachedGet(int X, int Z, Supplier supplier); + IChunkGet getCachedGet(int x, int z, Supplier supplier); /** * Get the IChunk at a position (and cache it if it's not already) - * @param X - * @param Z + * @param x + * @param z * @return IChunk */ - IChunk getCachedChunk(int X, int Z); + IChunk getCachedChunk(int x, int z); /** * Submit the chunk so that it's changes are applied to the world diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java index bde69e284..31d3eeb6c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java @@ -1,14 +1,12 @@ package com.boydti.fawe.beta.filters; import com.boydti.fawe.beta.FilterBlock; -import com.boydti.fawe.config.BBC; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.function.mask.ABlockMask; import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -95,13 +93,13 @@ public class DistrFilter extends ForkedFilter { } public void print(final Actor actor, final long size) { - for (final Countable c : getDistribution()) { + for (Countable c : getDistribution()) { final String name = c.getID().toString(); final String str = String.format("%-7s (%.3f%%) %s", String.valueOf(c.getAmount()), c.getAmount() / (double) size * 100, name); - actor.print(BBC.getPrefix() + str); + actor.print(str); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java index 814cd1146..d8cebe622 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java @@ -39,8 +39,8 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { } @Override - public IChunkGet getCachedGet(int X, int Z, Supplier supplier) { - return cache.get(MathMan.pairInt(X, Z), supplier); + public IChunkGet getCachedGet(int x, int z, Supplier supplier) { + return cache.get(MathMan.pairInt(x, z), supplier); } /** @@ -162,8 +162,8 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { } @Override - public final IChunk getCachedChunk(final int X, final int Z) { - final long pair = (((long) X) << 32) | (Z & 0xffffffffL); + public final IChunk getCachedChunk(final int x, final int z) { + final long pair = (((long) x) << 32) | (z & 0xffffffffL); if (pair == lastPair) { return lastChunk; } @@ -195,7 +195,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { submissions.add(future); } } - chunk = poolOrCreate(X, Z); + chunk = poolOrCreate(x, z); chunk = wrap(chunk); chunks.put(pair, chunk); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java b/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java index 374005175..a536d14aa 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java @@ -4,21 +4,13 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.configuration.MemorySection; import com.boydti.fawe.configuration.file.YamlConfiguration; import com.boydti.fawe.object.FawePlayer; -import com.boydti.fawe.object.RunnableVal3; -import com.boydti.fawe.util.StringMan; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; import com.sk89q.worldedit.extension.platform.Actor; import java.io.File; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.EnumSet; -import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Locale; -import java.util.Map; -import java.util.Objects; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; @@ -28,10 +20,9 @@ public enum BBC { * Things to note about this class: * Can use multiple arguments %s, %s1, %s2, %s3 etc */ - PREFIX("(FAWE)", "Info"), FILE_DELETED("%s0 has been deleted.", "Info"), SCHEMATIC_PASTING("&7The schematic is pasting. This cannot be undone.", "Info"), - LIGHTING_PROPOGATE_SELECTION("Lighting has been propogated in %s0 chunks. (Note: To remove light use //removelight)", "Info"), + LIGHTING_PROPAGATE_SELECTION("Lighting has been propogated in %s0 chunks. (Note: To remove light use //removelight)", "Info"), UPDATED_LIGHTING_SELECTION("Lighting has been updated in %s0 chunks. (It may take a second for the packets to send)", "Info"), SET_REGION("Selection set to your current allowed region", "Info"), WORLDEDIT_COMMAND_LIMIT("Please wait until your current action completes", "Info"), @@ -304,7 +295,7 @@ public enum BBC { SEL_CUBOID("Cuboid: left click for point 1, right click for point 2", "Selection"), SEL_CUBOID_EXTEND("Cuboid: left click for a starting point, right click to extend", "Selection"), SEL_2D_POLYGON("2D polygon selector: Left/right click to add a point.", "Selection"), - SEL_ELLIPSIOD("Ellipsoid selector: left click=center, right click to extend", "Selection"), + SAL_ELLIPSOID("Ellipsoid selector: left click=center, right click to extend", "Selection"), SEL_SPHERE("Sphere selector: left click=center, right click to set radius", "Selection"), SEL_CYLINDRICAL("Cylindrical selector: Left click=center, right click to extend.", "Selection"), SEL_MAX("%s0 points maximum.", "Selection"), @@ -365,16 +356,6 @@ public enum BBC { TIP_BIOME_PATTERN("Tip: The #biome[forest] pattern can be used in any command", "Tips"), TIP_BIOME_MASK("Tip: Restrict to a biome with the `$jungle` mask", "Tips"),; - - private static final HashMap replacements = new HashMap<>(); - static { - for (char letter : "1234567890abcdefklmnor".toCharArray()) { - replacements.put("&" + letter, "\u00a7" + letter); - } - replacements.put("\\\\n", "\n"); - replacements.put("\\n", "\n"); - replacements.put("&-", "\n"); - } /** * Translated */ @@ -460,7 +441,6 @@ public enum BBC { changed = true; yml.set(caption.category + "." + caption.name().toLowerCase(Locale.ROOT), caption.defaultMessage); } - caption.translatedMessage = StringMan.replaceFromMap(caption.translatedMessage, replacements); } if (changed) { yml.save(file); @@ -483,15 +463,6 @@ public enum BBC { return toString().length(); } - public static String color(String string) { - return StringMan.replaceFromMap(string, replacements); - } - - public static String stripColor(String string) { - - return StringMan.removeFromSet(string, replacements.values()); - } - public String s() { return this.translatedMessage; } @@ -519,17 +490,13 @@ public enum BBC { try { Method method = actor.getClass().getMethod("print", String.class); method.setAccessible(true); - method.invoke(actor, (PREFIX.isEmpty() ? "" : PREFIX.s() + " ") + this.format(args)); + method.invoke(actor, this.format(args)); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { e.printStackTrace(); } } } - public static String getPrefix() { - return PREFIX.isEmpty() ? "" : PREFIX.s() + " "; - } - public void send(FawePlayer player, Object... args) { if (isEmpty()) { return; @@ -537,7 +504,7 @@ public enum BBC { if (player == null) { Fawe.debug(this.format(args)); } else { - player.sendMessage((PREFIX.isEmpty() ? "" : PREFIX.s() + " ") + this.format(args)); + player.sendMessage(this.format(args)); } } public void send(Actor player, Object... args) { @@ -551,189 +518,4 @@ public enum BBC { } } - public static char getCode(String name) { - switch (name) { - case "BLACK": - return '0'; - case "DARK_BLUE": - return '1'; - case "DARK_GREEN": - return '2'; - case "DARK_AQUA": - return '3'; - case "DARK_RED": - return '4'; - case "DARK_PURPLE": - return '5'; - case "GOLD": - return '6'; - case "GRAY": - return '7'; - case "DARK_GRAY": - return '8'; - case "BLUE": - return '9'; - case "GREEN": - return 'a'; - case "AQUA": - return 'b'; - case "RED": - return 'c'; - case "LIGHT_PURPLE": - return 'd'; - case "YELLOW": - return 'e'; - case "WHITE": - return 'f'; - case "OBFUSCATED": - return 'k'; - case "BOLD": - return 'l'; - case "STRIKETHROUGH": - return 'm'; - case "UNDERLINE": - return 'n'; - case "ITALIC": - return 'o'; - default: - case "RESET": - return 'r'; - } - } - - public static String getColorName(char code) { - switch (code) { - case '0': - return "BLACK"; - case '1': - return "DARK_BLUE"; - case '2': - return "DARK_GREEN"; - case '3': - return "DARK_AQUA"; - case '4': - return "DARK_RED"; - case '5': - return "DARK_PURPLE"; - case '6': - return "GOLD"; - case '7': - return "GRAY"; - case '8': - return "DARK_GRAY"; - case '9': - return "BLUE"; - case 'a': - return "GREEN"; - case 'b': - return "AQUA"; - case 'c': - return "RED"; - case 'd': - return "LIGHT_PURPLE"; - case 'e': - return "YELLOW"; - case 'f': - return "WHITE"; - case 'k': - return "OBFUSCATED"; - case 'l': - return "BOLD"; - case 'm': - return "STRIKETHROUGH"; - case 'n': - return "UNDERLINE"; - case 'o': - return "ITALIC"; - case 'r': - return "RESET"; - default: - return "GRAY"; - } - } - - private static Object[] append(StringBuilder builder, Map obj, String color, Map properties) { - Object[] style = new Object[] { color, properties }; - for (Map.Entry entry : obj.entrySet()) { - switch (entry.getKey()) { - case "text": - String text = (String) entry.getValue(); - String newColor = (String) obj.get("color"); - String newBold = (String) obj.get("bold"); - int index = builder.length(); - if (!Objects.equals(color, newColor)) { - style[0] = newColor; - char code = BBC.getCode(newColor.toUpperCase(Locale.ROOT)); - builder.append('\u00A7').append(code); - } - for (Map.Entry entry2 : obj.entrySet()) { - if (StringMan.isEqualIgnoreCaseToAny(entry2.getKey(), "bold", "italic", "underlined", "strikethrough", "obfuscated")) { - boolean newValue = Boolean.parseBoolean((String) entry2.getValue()); - if (properties.put(entry2.getKey(), newValue) != newValue) { - if (newValue) { - char code = BBC.getCode(entry2.getKey().toUpperCase(Locale.ROOT)); - builder.append('\u00A7').append(code); - } else { - builder.insert(index, '\u00A7').append('r'); - if (Objects.equals(color, newColor) && newColor != null) { - builder.append('\u00A7').append(BBC.getCode(newColor.toUpperCase(Locale.ROOT))); - } - } - } - } - } - builder.append(text); - break; - case "extra": - List> list = (List>) entry.getValue(); - for (Map elem : list) { - elem.putIfAbsent("color", obj.get("color")); - for (Map.Entry entry2 : obj.entrySet()) { - if (StringMan.isEqualIgnoreCaseToAny(entry2.getKey(), "bold", "italic", "underlined", "strikethrough", "obfuscated")) { - elem.putIfAbsent(entry2.getKey(), entry2.getValue()); - } - } - style = append(builder, elem, (String) style[0], (Map) style[1]); - } - } - } - return style; - } - - public static String jsonToString(String text) { - Gson gson = new Gson(); - StringBuilder builder = new StringBuilder(); - Map obj = gson.fromJson(text, new TypeToken>() {}.getType()); - HashMap properties = new HashMap<>(); - properties.put("bold", false); - properties.put("italic", false); - properties.put("underlined", false); - properties.put("strikethrough", false); - properties.put("obfuscated", false); - append(builder, obj, null, properties); - return builder.toString(); - } - - /** - * @param m - * @param runPart Part, Color, NewLine - */ - public static void splitMessage(String m, RunnableVal3 runPart) { - m = color(m); - String color = "GRAY"; - boolean newline = false; - for (String line : m.split("\n")) { - boolean hasColor = line.charAt(0) == '\u00A7'; - String[] splitColor = line.split("\u00A7"); - for (String part : splitColor) { - if (hasColor) { - color = getColorName(part.charAt(0)); - part = part.substring(1); - } - runPart.run(part, color, newline); - hasColor = true; - } - newline = true; - } - } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java b/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java index d61ef443d..fbb94dac7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java @@ -145,7 +145,7 @@ public abstract class FawePlayer extends Metadatable { return cancelled; } - private void setConfirmTask(@NotNull Runnable task, InjectedValueAccess context, String command) { + private void setConfirmTask(@NotNull Runnable task, InjectedValueAccess context, @NotNull String command) { CommandEvent event = new CommandEvent(getPlayer(), command); Runnable newTask = () -> PlatformCommandManager.getInstance().handleCommandTask(() -> { task.run(); @@ -154,8 +154,8 @@ public abstract class FawePlayer extends Metadatable { setMeta("cmdConfirm", newTask); } - public void checkConfirmation(@NotNull Runnable task, String command, int times, int limit, InjectedValueAccess context) throws RegionOperationException { - if (command != null && !getMeta("cmdConfirmRunning", false)) { + public void checkConfirmation(@NotNull Runnable task, @NotNull String command, int times, int limit, InjectedValueAccess context) throws RegionOperationException { + if (!getMeta("cmdConfirmRunning", false)) { if (times > limit) { setConfirmTask(task, context, command); String volume = ""; @@ -181,8 +181,8 @@ public abstract class FawePlayer extends Metadatable { task.run(); } - public void checkConfirmationStack(@NotNull Runnable task, String command, Region region, int times, InjectedValueAccess context) throws RegionOperationException { - if (command != null && !getMeta("cmdConfirmRunning", false)) { + public void checkConfirmationStack(@NotNull Runnable task, @NotNull String command, Region region, int times, InjectedValueAccess context) throws RegionOperationException { + if (!getMeta("cmdConfirmRunning", false)) { if (region != null) { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); @@ -199,8 +199,8 @@ public abstract class FawePlayer extends Metadatable { task.run(); } - public void checkConfirmationRegion(@NotNull Runnable task, String command, Region region, InjectedValueAccess context) throws RegionOperationException { - if (command != null && !getMeta("cmdConfirmRunning", false)) { + public void checkConfirmationRegion(@NotNull Runnable task, @NotNull String command, Region region, InjectedValueAccess context) throws RegionOperationException { + if (!getMeta("cmdConfirmRunning", false)) { if (region != null) { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); @@ -576,7 +576,7 @@ public abstract class FawePlayer extends Metadatable { } /** - * Unregister this player (delets all metadata etc) + * Unregister this player (deletes all metadata etc) * - Usually called on logout */ public void unregister() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CopyPastaBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CopyPastaBrush.java index ba84ae19e..cc3f780c5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CopyPastaBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CopyPastaBrush.java @@ -9,7 +9,6 @@ import com.boydti.fawe.object.function.mask.AbstractDelegateMask; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -21,11 +20,10 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.transform.AffineTransform; -import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockTypes; - import java.util.concurrent.ThreadLocalRandom; public class CopyPastaBrush implements Brush, ResettableTool { @@ -62,7 +60,6 @@ public class CopyPastaBrush implements Brush, ResettableTool { mask = Masks.alwaysTrue(); } final ResizableClipboardBuilder builder = new ResizableClipboardBuilder(editSession.getWorld()); - final int size2 = (int) (size * size); final int minY = position.getBlockY(); mask = new AbstractDelegateMask(mask) { @Override @@ -93,13 +90,13 @@ public class CopyPastaBrush implements Brush, ResettableTool { } else { AffineTransform transform = null; if (randomRotate) { - if (transform == null) transform = new AffineTransform(); + transform = new AffineTransform(); int rotate = 90 * ThreadLocalRandom.current().nextInt(4); transform = transform.rotateY(rotate); } if (autoRotate) { if (transform == null) transform = new AffineTransform(); - Location loc = editSession.getPlayer().getPlayer().getLocation(); + Location loc = editSession.getPlayer().toWorldEditPlayer().getLocation(); float yaw = loc.getYaw(); float pitch = loc.getPitch(); transform = transform.rotateY((-yaw) % 360); @@ -108,8 +105,6 @@ public class CopyPastaBrush implements Brush, ResettableTool { if (transform != null && !transform.isIdentity()) { clipboard.setTransform(transform); } - Clipboard faweClip = clipboard.getClipboard(); - Region region = faweClip.getRegion(); Operation operation = clipboard .createPaste(editSession) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/FallingSphere.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/FallingSphere.java index e4506ca6d..08250d50c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/FallingSphere.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/FallingSphere.java @@ -15,8 +15,6 @@ public class FallingSphere implements Brush { int pz = position.getBlockZ(); int maxY = editSession.getMaxY(); - int lastY = py; - int radius = (int) Math.round(size); int radiusSqr = (int) Math.round(size * size); for (int z = -radius; z <= radius; z++) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java index ce7c8e4f4..245539c1c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java @@ -60,12 +60,11 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool { public boolean perform(final Player player, LocalSession session, boolean rightClick) { if (!session.isToolControlEnabled() || !player.hasPermission("worldedit.tool.inspect")) { - player.print(BBC.getPrefix() + BBC.NO_PERM.format("worldedit.tool.inspect")); + player.print(BBC.NO_PERM.format("worldedit.tool.inspect")); return false; } if (!Settings.IMP.HISTORY.USE_DATABASE) { - player.print(BBC.getPrefix() + BBC.SETTING_DISABLE - .format("history.use-database (Import with /frb #import )")); + player.print(BBC.SETTING_DISABLE.format("history.use-database (Import with /frb #import )")); return false; } BlockVector3 target = getTarget(player, rightClick).toBlockPoint(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java index 99ec8c3d8..e36f5e1e8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java @@ -95,13 +95,13 @@ public class SplineBrush implements Brush, ResettableTool { points.add(position); } this.positionSets.add(points); - player.print(BBC.getPrefix() + BBC.BRUSH_SPLINE_PRIMARY_2.s()); + player.print(BBC.BRUSH_SPLINE_PRIMARY_2.s()); if (!visualization) { return; } } if (positionSets.size() < 2) { - player.print(BBC.getPrefix() + BBC.BRUSH_SPLINE_SECONDARY_ERROR.s()); + player.print(BBC.BRUSH_SPLINE_SECONDARY_ERROR.s()); return; } List centroids = new ArrayList<>(); @@ -133,7 +133,7 @@ public class SplineBrush implements Brush, ResettableTool { } editSession.drawSpline(pattern, currentSpline, 0, 0, 0, 10, 0, true); } - player.print(BBC.getPrefix() + BBC.BRUSH_SPLINE_SECONDARY.s()); + player.print(BBC.BRUSH_SPLINE_SECONDARY.s()); if (visualization) { numSplines = originalSize; positionSets.remove(positionSets.size() - 1); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java index 8d30426bf..d6f3ab564 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java @@ -36,7 +36,7 @@ public class SurfaceSpline implements Brush { if (max == -1) return; // pos.mutY(max); path.add(BlockVector3.at(pos.getBlockX(), max, pos.getBlockZ())); - editSession.getPlayer().sendMessage(BBC.getPrefix() + BBC.BRUSH_SPLINE_PRIMARY_2.s()); + editSession.getPlayer().sendMessage(BBC.BRUSH_SPLINE_PRIMARY_2.s()); if (!vis) return; } LocalBlockVectorSet vset = new LocalBlockVectorSet(); @@ -90,6 +90,6 @@ public class SurfaceSpline implements Brush { editSession.setBlocks(newSet, pattern); if (!vis) path.clear(); } - editSession.getPlayer().sendMessage(BBC.getPrefix() + BBC.BRUSH_SPLINE_SECONDARY.s()); + editSession.getPlayer().sendMessage(BBC.BRUSH_SPLINE_SECONDARY.s()); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java index 691a3a72c..f5cde0b7f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java @@ -78,10 +78,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr protected final DifferentialArray main; protected DifferentialArray overlay; - protected final CFIPrimtives primtives = new CFIPrimtives(); - private CFIPrimtives oldPrimitives = new CFIPrimtives(); + protected final CFIPrimitives primitives = new CFIPrimitives(); + private CFIPrimitives oldPrimitives = new CFIPrimitives(); - public final class CFIPrimtives implements Cloneable { + public final class CFIPrimitives implements Cloneable { protected int waterHeight = 0; protected int floorThickness = 0; protected int worldThickness = 0; @@ -93,11 +93,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr @Override public boolean equals(Object obj) { - if (obj == null || !(obj instanceof CFIPrimtives)) { + if (obj == null || !(obj instanceof CFIPrimitives)) { return false; } try { - for (Field field : CFIPrimtives.class.getDeclaredFields()) { + for (Field field : CFIPrimitives.class.getDeclaredFields()) { if (field.get(this) != field.get(obj)) return false; } } catch (IllegalAccessException e) { @@ -125,8 +125,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr out.writeBoolean(overlay != null); if (overlay != null) overlay.flushChanges(out); try { - for (Field field : ReflectionUtils.sortFields(CFIPrimtives.class.getDeclaredFields())) { - Object now = field.get(primtives); + for (Field field : ReflectionUtils.sortFields(CFIPrimitives.class.getDeclaredFields())) { + Object now = field.get(primitives); Object old = field.get(oldPrimitives); boolean diff = old != now; out.writeBoolean(diff); @@ -135,7 +135,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr out.writePrimitive(now); } } - resetPrimtives(); + resetPrimitives(); } catch (Throwable neverHappens) { neverHappens.printStackTrace(); } @@ -148,11 +148,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr heights.isModified() || biomes.isModified() || (overlay != null && overlay.isModified()) || - !primtives.equals(oldPrimitives); + !primitives.equals(oldPrimitives); } - private void resetPrimtives() throws CloneNotSupportedException { - oldPrimitives = (CFIPrimtives) primtives.clone(); + private void resetPrimitives() throws CloneNotSupportedException { + oldPrimitives = (CFIPrimitives) primitives.clone(); } @Override @@ -163,13 +163,13 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr main.undoChanges(in); if (in.readBoolean()) overlay.undoChanges(in); try { - for (Field field : ReflectionUtils.sortFields(CFIPrimtives.class.getDeclaredFields())) { + for (Field field : ReflectionUtils.sortFields(CFIPrimitives.class.getDeclaredFields())) { if (in.readBoolean()) { - field.set(primtives, in.readPrimitive(field.getType())); // old + field.set(primitives, in.readPrimitive(field.getType())); // old in.readPrimitive(field.getType()); // new } } - resetPrimtives(); + resetPrimitives(); } catch (Throwable neverHappens) { neverHappens.printStackTrace(); } @@ -185,13 +185,13 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr if (in.readBoolean()) overlay.redoChanges(in); try { - for (Field field : ReflectionUtils.sortFields(CFIPrimtives.class.getDeclaredFields())) { + for (Field field : ReflectionUtils.sortFields(CFIPrimitives.class.getDeclaredFields())) { if (in.readBoolean()) { in.readPrimitive(field.getType()); // old - field.set(primtives, in.readPrimitive(field.getType())); // new + field.set(primitives, in.readPrimitive(field.getType())); // new } } - resetPrimtives(); + resetPrimitives(); } catch (Throwable neverHappens) { neverHappens.printStackTrace(); } @@ -332,7 +332,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr textureUtil = Fawe.get().getTextureUtil(); } try { - if (primtives.randomVariation) { + if (primitives.randomVariation) { return new RandomTextureUtil(textureUtil); } else if (textureUtil instanceof CachedTextureUtil) { return textureUtil; @@ -346,31 +346,31 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } public void setBedrockId(int bedrockId) { - this.primtives.bedrockId = bedrockId; + this.primitives.bedrockId = bedrockId; } public void setFloorThickness(int floorThickness) { - this.primtives.floorThickness = floorThickness; + this.primitives.floorThickness = floorThickness; } public void setWorldThickness(int height) { - this.primtives.worldThickness = height; + this.primitives.worldThickness = height; } public void setWaterHeight(int waterHeight) { - this.primtives.waterHeight = waterHeight; + this.primitives.waterHeight = waterHeight; } public void setWaterId(int waterId) { - this.primtives.waterId = waterId; + this.primitives.waterId = waterId; } public void setTextureRandomVariation(boolean randomVariation) { - this.primtives.randomVariation = randomVariation; + this.primitives.randomVariation = randomVariation; } public boolean getTextureRandomVariation() { - return this.primtives.randomVariation; + return this.primitives.randomVariation; } public void setTextureUtil(TextureUtil textureUtil) { @@ -428,16 +428,15 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } // Process table table.processSummedAreaTable(); - { // Copy from table - int localIndex = 0; - int zIndex = (minZ * getWidth()); - for (int z = minZ, localZ = 0; z <= maxZ; z++, localZ++, zIndex += getWidth()) { - int index = zIndex + minX; - for (int x = minX, localX = 0; x <= maxX; x++, localX++, index++, localIndex++) { - int y = heights[index] & 0xFF; - int newHeight = table.average(localX, localZ, localIndex); - setLayerHeight(index, newHeight); - } + // Copy from table + int localIndex = 0; + int zIndex = (minZ * getWidth()); + for (int z = minZ, localZ = 0; z <= maxZ; z++, localZ++, zIndex += getWidth()) { + int index = zIndex + minX; + for (int x = minX, localX = 0; x <= maxX; x++, localX++, index++, localIndex++) { + int y = heights[index] & 0xFF; + int newHeight = table.average(localX, localZ, localIndex); + setLayerHeight(index, newHeight); } } } @@ -909,8 +908,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } } } - if (y <= primtives.waterHeight) { - return primtives.waterId << 4; + if (y <= primitives.waterHeight) { + return primitives.waterId << 4; } return 0; } else if (y == height) { @@ -1020,11 +1019,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } public void setBiomePriority(int value) { - this.primtives.biomePriority = ((value * 65536) / 100) - 32768; + this.primitives.biomePriority = ((value * 65536) / 100) - 32768; } public int getBiomePriority() { - return ((primtives.biomePriority + 32768) * 100) / 65536; + return ((primitives.biomePriority + 32768) * 100) / 65536; } public void setBlockAndBiomeColor(BufferedImage img, Mask mask, BufferedImage imgMask, boolean whiteOnly) { @@ -1061,7 +1060,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr .current().nextInt(256) > height)) continue; } int color = img.getRGB(x, z); - if (textureUtil.getIsBlockCloserThanBiome(buffer, color, primtives.biomePriority)) { + if (textureUtil.getIsBlockCloserThanBiome(buffer, color, primitives.biomePriority)) { int combined = buffer[0]; mainArr[index] = combined; floorArr[index] = combined; @@ -1091,7 +1090,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr boolean yBiome = y > 0 && y < heightIndex; for (int x = 0; x < img.getWidth(); x++, index++) { int color = img.getRGB(x, y); - if (textureUtil.getIsBlockCloserThanBiome(buffer, color, primtives.biomePriority)) { + if (textureUtil.getIsBlockCloserThanBiome(buffer, color, primitives.biomePriority)) { int combined = buffer[0]; mainArr[index] = combined; floorArr[index] = combined; @@ -1131,7 +1130,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); if (mask.getWidth() != getWidth() || mask.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); - primtives.modifiedMain = true; + primitives.modifiedMain = true; TextureUtil textureUtil = getTextureUtil(); floor.record(() -> main.record(() -> { @@ -1160,7 +1159,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr public void setColor(BufferedImage img, Mask mask) { if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); - primtives.modifiedMain = true; + primitives.modifiedMain = true; TextureUtil textureUtil = getTextureUtil(); @@ -1193,7 +1192,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr public void setColor(BufferedImage img) { if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); - primtives.modifiedMain = true; + primitives.modifiedMain = true; TextureUtil textureUtil = getTextureUtil(); floor.record(() -> main.record(() -> { @@ -1296,7 +1295,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } else { if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); - primtives.modifiedMain = true; + primitives.modifiedMain = true; main.record(() -> { int[] mainArr = main.get(); @@ -1349,7 +1348,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } else { if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); - primtives.modifiedMain = true; + primitives.modifiedMain = true; main.record(() -> floor.record(() -> { int[] floorArr = floor.get(); @@ -1416,7 +1415,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr if (pattern instanceof BlockStateHolder) { setMain(mask, ((BlockStateHolder) pattern).getInternalId()); } else { - primtives.modifiedMain = true; + primitives.modifiedMain = true; int index = 0; for (int z = 0; z < getLength(); z++) { mutable.mutZ(z); @@ -1436,7 +1435,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr if (pattern instanceof BlockStateHolder) { setColumn(mask, ((BlockStateHolder) pattern).getInternalId()); } else { - primtives.modifiedMain = true; + primitives.modifiedMain = true; int index = 0; for (int z = 0; z < getLength(); z++) { mutable.mutZ(z); @@ -1597,12 +1596,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr for (int layer = 0; layer <= maxLayer; layer++) { chunk.hasSections[layer] = true; } - if (primtives.waterHeight != 0) { - int maxIndex = (primtives.waterHeight) << 8; - Arrays.fill(chunk.blocks, 0, maxIndex, primtives.waterId); + if (primitives.waterHeight != 0) { + int maxIndex = (primitives.waterHeight) << 8; + Arrays.fill(chunk.blocks, 0, maxIndex, primitives.waterId); } - if (primtives.modifiedMain) { // If the main block is modified, we can't short circuit this + if (primitives.modifiedMain) { // If the main block is modified, we can't short circuit this for (int z = csz; z <= cez; z++) { index = (z & 15) << 4; for (int x = csx; x <= cex; x++, index++) { @@ -1618,9 +1617,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr Arrays.fill(chunk.blocks, 0, maxIndex, BlockID.STONE); } - final boolean hasFloorThickness = primtives.floorThickness != 0 || primtives.worldThickness != 0; - if (primtives.worldThickness != 0) { - int endLayer = ((minY - primtives.worldThickness + 1) >> 4); + final boolean hasFloorThickness = primitives.floorThickness != 0 || primitives.worldThickness != 0; + if (primitives.worldThickness != 0) { + int endLayer = ((minY - primitives.worldThickness + 1) >> 4); for (int layer = 0; layer < endLayer; layer++) { chunk.hasSections[layer] = false; } @@ -1645,8 +1644,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int min = maxMainY; - if (primtives.floorThickness != 0) { - maxMainY = Math.max(0, maxMainY - (primtives.floorThickness - 1)); + if (primitives.floorThickness != 0) { + maxMainY = Math.max(0, maxMainY - (primitives.floorThickness - 1)); for (int y = maxMainY; y <= height; y++) { chunk.blocks[index + (y << 8)] = floorCombined; } @@ -1655,8 +1654,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr chunk.blocks[index + ((height) << 8)] = floorCombined; } - if (primtives.worldThickness != 0) { - minMainY = Math.max(minY, min - primtives.worldThickness + 1); + if (primitives.worldThickness != 0) { + minMainY = Math.max(minY, min - primitives.worldThickness + 1); for (int y = minY; y < minMainY; y++) { chunk.blocks[index + (y << 8)] = BlockID.AIR; } @@ -1676,8 +1675,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr chunk.blocks[overlayIndex] = overlayCombined; } - if (primtives.bedrockId != 0) { - chunk.blocks[index] = primtives.bedrockId; + if (primitives.bedrockId != 0) { + chunk.blocks[index] = primitives.bedrockId; } } } @@ -1775,7 +1774,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } private void setMain(Mask mask, int combined) { - primtives.modifiedMain = true; + primitives.modifiedMain = true; int index = 0; for (int z = 0; z < getLength(); z++) { mutable.mutZ(z); @@ -1791,7 +1790,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } private void setColumn(Mask mask, int combined) { - primtives.modifiedMain = true; + primitives.modifiedMain = true; int index = 0; for (int z = 0; z < getLength(); z++) { mutable.mutZ(z); @@ -1817,7 +1816,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } private void setMain(int value) { - primtives.modifiedMain = true; + primitives.modifiedMain = true; main.record(() -> Arrays.fill(main.get(), value)); } @@ -1848,7 +1847,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr private void setMain(BufferedImage img, int combined, boolean white) { if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); - primtives.modifiedMain = true; + primitives.modifiedMain = true; main.record(() -> { int index = 0; @@ -1885,7 +1884,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr private void setColumn(BufferedImage img, int combined, boolean white) { if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); - primtives.modifiedMain = true; + primitives.modifiedMain = true; main.record(() -> floor.record(() -> { int index = 0; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AnvilHistory.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AnvilHistory.java index 4474aafc7..190174f8f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AnvilHistory.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AnvilHistory.java @@ -2,7 +2,6 @@ package com.boydti.fawe.object.changeset; import com.boydti.fawe.Fawe; import com.boydti.fawe.config.Settings; -import com.boydti.fawe.jnbt.anvil.history.IAnvilHistory; import com.boydti.fawe.util.MainUtil; import com.google.common.base.Function; import com.google.common.collect.Iterators; @@ -20,7 +19,7 @@ import java.util.List; import java.util.UUID; import javax.annotation.Nullable; -public class AnvilHistory extends FaweChangeSet implements IAnvilHistory { +public class AnvilHistory extends FaweChangeSet { private final File folder; private int size; @@ -41,7 +40,7 @@ public class AnvilHistory extends FaweChangeSet implements IAnvilHistory { this.size = 0; } - @Override + //@Override public boolean addFileChange(File originalMCAFile) { try { Files.move(originalMCAFile.toPath(), Paths.get(folder.getPath(), originalMCAFile.getName()), StandardCopyOption.ATOMIC_MOVE); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java index 3e17f461c..c5d8f121c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java @@ -22,7 +22,7 @@ public class CFIChangeSet extends FaweChangeSet { super(hmmg); File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + uuid + File.separator + "CFI" + File.separator + hmmg.getWorldName()); int max = MainUtil.getMaxFileId(folder); - this.file = new File(folder, Integer.toString(max) + ".cfi"); + this.file = new File(folder, max + ".cfi"); File parent = this.file.getParentFile(); if (!parent.exists()) this.file.getParentFile().mkdirs(); if (!this.file.exists()) this.file.createNewFile(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java index 29bb363f4..4bb0c77bc 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java @@ -121,6 +121,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet { initFiles(folder); } + @Override public void delete() { // Fawe.debug("Deleting history: " + getWorld().getName() + "/" + uuid + "/" + index); deleteFiles(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweChangeSet.java index 3631eeafd..6b4b3995f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweChangeSet.java @@ -20,17 +20,11 @@ import com.sk89q.worldedit.history.change.EntityRemove; import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.util.task.LinkedFuture; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockID; - import java.util.Iterator; -import java.util.Map; -import java.util.Set; import java.util.UUID; -import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicInteger; @@ -57,7 +51,7 @@ public abstract class FaweChangeSet implements ChangeSet { public FaweChangeSet(String world) { this.worldName = world; - this.mainThread = (Fawe.get() == null) || Fawe.isMainThread(); + this.mainThread = Fawe.get() == null || Fawe.isMainThread(); this.layers = FaweCache.CHUNK_LAYERS; } @@ -65,7 +59,7 @@ public abstract class FaweChangeSet implements ChangeSet { this.world = world; this.worldName = world.getName(); this.mainThread = Fawe.isMainThread(); - this.layers = (this.world.getMaxY() + 1) >> 4; + this.layers = this.world.getMaxY() + 1 >> 4; } public String getWorldName() { @@ -177,6 +171,7 @@ public abstract class FaweChangeSet implements ChangeSet { addEntityRemove(tag); } + @Override public void add(Change change) { if (change.getClass() == BlockChange.class) { add((BlockChange) change); @@ -211,11 +206,13 @@ public abstract class FaweChangeSet implements ChangeSet { try { if (from.hasNbtData()) { CompoundTag nbt = from.getNbtData(); + assert nbt != null; MainUtil.setPosition(nbt, x, y, z); addTileRemove(nbt); } if (to.hasNbtData()) { CompoundTag nbt = to.getNbtData(); + assert nbt != null; MainUtil.setPosition(nbt, x, y, z); addTileCreate(nbt); } @@ -236,6 +233,7 @@ public abstract class FaweChangeSet implements ChangeSet { try { if (to.hasNbtData()) { CompoundTag nbt = to.getNbtData(); + assert nbt != null; MainUtil.setPosition(nbt, x, y, z); addTileCreate(nbt); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java index d40bb241e..ce19856b7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java @@ -312,6 +312,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet { return originZ; } + @Override public void add(int x, int y, int z, int combinedFrom, int combinedTo) { blockSize++; try { @@ -344,6 +345,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet { } } + @Override public void addTileCreate(CompoundTag tag) { if (tag == null) { return; @@ -357,6 +359,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet { } } + @Override public void addTileRemove(CompoundTag tag) { if (tag == null) { return; @@ -370,6 +373,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet { } } + @Override public void addEntityRemove(CompoundTag tag) { if (tag == null) { return; @@ -383,6 +387,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet { } } + @Override public void addEntityCreate(CompoundTag tag) { if (tag == null) { return; @@ -660,6 +665,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet { } } + @Override public Iterator getIterator(final boolean dir) { close(); try { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/MemoryOptimizedHistory.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/MemoryOptimizedHistory.java index d4d671a1f..b187ffc5f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/MemoryOptimizedHistory.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/MemoryOptimizedHistory.java @@ -155,8 +155,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet { if (biomes == null) { return null; } - FaweInputStream result = MainUtil.getCompressedIS(new FastByteArraysInputStream(biomes)); - return result; + return MainUtil.getCompressedIS(new FastByteArraysInputStream(biomes)); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ResizableClipboardBuilder.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ResizableClipboardBuilder.java index a7b74771f..ffa48eb06 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ResizableClipboardBuilder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ResizableClipboardBuilder.java @@ -11,7 +11,6 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockStateHolder; import java.util.Iterator; public class ResizableClipboardBuilder extends MemoryOptimizedHistory { @@ -63,13 +62,13 @@ public class ResizableClipboardBuilder extends MemoryOptimizedHistory { BlockVector3 pos2 = BlockVector3.at(maxX, maxY, maxZ); CuboidRegion region = new CuboidRegion(pos1, pos2); BlockArrayClipboard clipboard = new BlockArrayClipboard(region); - Iterator iter = getIterator(true); + Iterator iterator = getIterator(true); try { - while (iter.hasNext()) { - Change change = iter.next(); + while (iterator.hasNext()) { + Change change = iterator.next(); if (change instanceof MutableBlockChange) { MutableBlockChange blockChange = (MutableBlockChange) change; - BlockStateHolder block = BlockState.getFromInternalId(blockChange.combinedId); + BlockState block = BlockState.getFromInternalId(blockChange.combinedId); clipboard.setBlock(blockChange.x, blockChange.y, blockChange.z, block); } else if (change instanceof MutableTileChange) { MutableTileChange tileChange = (MutableTileChange) change; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/remap/ClipboardRemapper.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/remap/ClipboardRemapper.java index 328dd1106..df9d21db7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/remap/ClipboardRemapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/remap/ClipboardRemapper.java @@ -247,12 +247,11 @@ public class ClipboardRemapper { mapPEtoPC.put(new BaseBlock(198,-1), new BaseBlock(208,-1)); mapPEtoPC.put(new BaseBlock(207,-1), new BaseBlock(212,-1)); - { // beetroot - mapPEtoPC.put(new BaseBlock(244, 2), new BaseBlock(207, 1)); - mapPEtoPC.put(new BaseBlock(244, 4), new BaseBlock(207, 2)); - mapPEtoPC.put(new BaseBlock(244, 7), new BaseBlock(207, 3)); - for (int data = 3; data < 16; data++) mapPEtoPC.putIfAbsent(new BaseBlock(244, data), new BaseBlock(207, data)); - } + // beetroot + mapPEtoPC.put(new BaseBlock(244, 2), new BaseBlock(207, 1)); + mapPEtoPC.put(new BaseBlock(244, 4), new BaseBlock(207, 2)); + mapPEtoPC.put(new BaseBlock(244, 7), new BaseBlock(207, 3)); + for (int data = 3; data < 16; data++) mapPEtoPC.putIfAbsent(new BaseBlock(244, data), new BaseBlock(207, data)); for (int data = 0; data < 16; data++) { mapPEtoPC.put(new BaseBlock(218, data), new BaseBlock(219 + data, -1)); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LongHashSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LongHashSet.java index 4f1a6ff4d..2d9e37a1e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LongHashSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LongHashSet.java @@ -35,7 +35,7 @@ public class LongHashSet { } public static int lsw(long l) { - return (int) (l & 0xFFFFFFFF) + Integer.MIN_VALUE; + return (int) l + Integer.MIN_VALUE; } public boolean containsKey(int msw, int lsw) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java index e8800f057..ea5102ee6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java @@ -5,13 +5,11 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.math.MutableBlockVector3; -import org.jetbrains.annotations.NotNull; - import java.util.AbstractSet; import java.util.Arrays; -import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import org.jetbrains.annotations.NotNull; /** * Memory optimized BlockVector3 Set using a sparsely populated bitset and grouped by chunk section @@ -706,25 +704,26 @@ public final class MemBlockSet extends BlockSet { long total = 0; long lastBit = 0; int lastCount = 0; - for (int X = 0; X < rows.length; X++) { - IRow nullRowX = rows[X]; + for (int x = 0; x < rows.length; x++) { + IRow nullRowX = rows[x]; if (!(nullRowX instanceof RowX)) continue; RowX rowx = (RowX) nullRowX; - for (int Z = 0; Z < rowx.rows.length; Z++) { - IRow nullRowZ = rowx.rows[Z]; + for (int z = 0; z < rowx.rows.length; z++) { + IRow nullRowZ = rowx.rows[z]; if (!(nullRowZ instanceof RowZ)) continue; RowZ rowz = (RowZ) nullRowZ; - outer: - for (int Y = 0; Y < 16; Y++) { - IRow nullRowY = rowz.rows[Y]; - if (!(nullRowY instanceof RowY)) continue; + for (int y = 0; y < 16; y++) { + IRow nullRowY = rowz.rows[y]; + if (!(nullRowY instanceof RowY)) { + continue; + } RowY rowY = (RowY) nullRowY; for (long bit : rowY.bits) { - if (bit == 0) continue; - else if (bit == -1L) { + if (bit == 0) { + continue; + } else if (bit == -1L) { total += 64; - } - else if (bit == lastBit) { + } else if (bit == lastBit) { total += lastCount; } else { lastBit = bit; @@ -926,4 +925,4 @@ public final class MemBlockSet extends BlockSet { for (int i = len; i < newLen; i++) copy[i] = def; return copy; } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SummedAreaTable.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SummedAreaTable.java index 0e71b42b5..12f76dd8b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SummedAreaTable.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SummedAreaTable.java @@ -3,6 +3,7 @@ package com.boydti.fawe.object.collection; import com.boydti.fawe.util.MathMan; public class SummedAreaTable { + private final char[] source; private final long[] summed; private final int length; @@ -28,10 +29,9 @@ public class SummedAreaTable { public void processSummedAreaTable() { int rowSize = source.length / width; - int colSize = width; int index = 0; for (int i = 0; i < rowSize; i++) { - for (int j = 0; j < colSize; j++, index++) { + for (int j = 0; j < width; j++, index++) { long val = getVal(i, j, index, source[index]); summed[index] = val; } @@ -39,7 +39,9 @@ public class SummedAreaTable { } private long getSum(int index) { - if (index < 0) return 0; + if (index < 0) { + return 0; + } return summed[index]; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/io/BufferedRandomAccessFile.java b/worldedit-core/src/main/java/com/boydti/fawe/object/io/BufferedRandomAccessFile.java index 08b076b69..115f66bfd 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/io/BufferedRandomAccessFile.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/io/BufferedRandomAccessFile.java @@ -344,8 +344,7 @@ public class BufferedRandomAccessFile extends RandomAccessFile { if (this.curr_ == this.hi_) return -1; } - byte res = this.buff_[(int) (this.curr_ - this.lo_)]; - return res; + return this.buff_[(int) (this.curr_ - this.lo_)]; } public void writeCurrent(byte b) throws IOException { @@ -431,4 +430,4 @@ public class BufferedRandomAccessFile extends RandomAccessFile { this.curr_ += len; return len; } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/io/RandomFileOutputStream.java b/worldedit-core/src/main/java/com/boydti/fawe/object/io/RandomFileOutputStream.java index bee36115f..dfd6d4be3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/io/RandomFileOutputStream.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/io/RandomFileOutputStream.java @@ -23,7 +23,7 @@ public class RandomFileOutputStream extends OutputStream { protected boolean closeParent; // ***************************************************************************** -// INSTANCE CONSTRUCTION/INITIALIZATON/FINALIZATION, OPEN/CLOSE +// INSTANCE CONSTRUCTION/INITIALIZATION/FINALIZATION, OPEN/CLOSE // ***************************************************************************** public RandomFileOutputStream(String fnm) throws IOException { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/progress/ChatProgressTracker.java b/worldedit-core/src/main/java/com/boydti/fawe/object/progress/ChatProgressTracker.java index ae2fcf752..116f5fadf 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/progress/ChatProgressTracker.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/progress/ChatProgressTracker.java @@ -1,6 +1,5 @@ package com.boydti.fawe.object.progress; -import com.boydti.fawe.config.BBC; import com.boydti.fawe.object.FawePlayer; public class ChatProgressTracker extends DefaultProgressTracker { @@ -11,6 +10,6 @@ public class ChatProgressTracker extends DefaultProgressTracker { @Override public void sendTile(String title, String sub) { - getPlayer().sendMessage(BBC.getPrefix() + title + sub); + getPlayer().sendMessage(title + sub); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java index 006f0527d..c07421d0f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java @@ -20,6 +20,8 @@ import com.sk89q.worldedit.regions.selector.limit.SelectorLimits; import com.sk89q.worldedit.world.World; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import javax.annotation.Nullable; public class FuzzyRegionSelector extends AbstractDelegateExtent implements RegionSelector { @@ -147,11 +149,8 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio @Override public List getInformationLines() { - final List lines = new ArrayList<>(); - for (int i = 0; i < positions.size(); i++) { - lines.add("Position " + i + ": " + positions.get(i)); - } - return lines; + return IntStream.range(0, positions.size()) + .mapToObj(i -> "Position " + i + ": " + positions.get(i)).collect(Collectors.toList()); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java index 89ab0a3e4..76efe9b9c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java @@ -38,7 +38,6 @@ public class PNGWriter implements ClipboardWriter { double d = Math.min((double) imageSize / length, (double) imageSize / width) / 3; double d_2 = d / 2; double cx = (double) imageSize / 2; - double cy = (double) imageSize / 2; int[] poly1X = new int[4]; int[] poly1Y = new int[4]; @@ -106,50 +105,47 @@ public class PNGWriter implements ClipboardWriter { continue; } double cpy = cpy2 - dpxi[y - y0]; - poly1X[0] = (int) (cpx); - poly1Y[0] = (int) (cpy); + poly1X[0] = (int) cpx; + poly1Y[0] = (int) cpy; poly1X[1] = (int) (cpx - d); poly1Y[1] = (int) (cpy - d_2); - poly1X[2] = (int) (cpx); + poly1X[2] = (int) cpx; poly1Y[2] = (int) (cpy - d); poly1X[3] = (int) (cpx + d); poly1Y[3] = (int) (cpy - d_2); - poly2X[0] = (int) (cpx); - poly2Y[0] = (int) (cpy); + poly2X[0] = (int) cpx; + poly2Y[0] = (int) cpy; poly2X[1] = (int) (cpx + d); poly2Y[1] = (int) (cpy - d_2); poly2X[2] = (int) (cpx + d); poly2Y[2] = (int) (cpy + d_2 + dpxi[0]); - poly2X[3] = (int) (cpx); + poly2X[3] = (int) cpx; poly2Y[3] = (int) (cpy + dpxi[1]); - poly3X[0] = (int) (cpx); - poly3Y[0] = (int) (cpy); + poly3X[0] = (int) cpx; + poly3Y[0] = (int) cpy; poly3X[1] = (int) (cpx - d); poly3Y[1] = (int) (cpy - d_2); poly3X[2] = (int) (cpx - d); poly3Y[2] = (int) (cpy + d_2 + dpxi[0]); - poly3X[3] = (int) (cpx); + poly3X[3] = (int) cpx; poly3Y[3] = (int) (cpy + dpxi[1]); Color colorTop = new Color(tu.getColor(block.getBlockType())); - Color colorRight = colorTop; - Color colorLeft = colorTop; + g2.setColor(colorTop); if (fill) { - g2.setColor(colorTop); g2.fillPolygon(poly1X, poly1Y, 4); - g2.setColor(colorRight); + g2.setColor(colorTop); g2.fillPolygon(poly2X, poly2Y, 4); - g2.setColor(colorLeft); + g2.setColor(colorTop); g2.fillPolygon(poly3X, poly3Y, 4); } else { - g2.setColor(colorTop); g2.drawPolygon(poly1X, poly1Y, 4); - g2.setColor(colorRight); + g2.setColor(colorTop); g2.drawPolygon(poly2X, poly2Y, 4); - g2.setColor(colorLeft); + g2.setColor(colorTop); g2.drawPolygon(poly3X, poly3Y, 4); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java index ebf9786fe..4382a47fa 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java @@ -93,7 +93,6 @@ public class MainUtil { * e.g. sending messages */ public static void sendMessage(final FawePlayer player, String message) { - message = BBC.color(message); if (player == null) { Fawe.debug(message); } else { @@ -631,7 +630,6 @@ public class MainUtil { boolean reading = false; int index = 1; int numIndex = 1; - outer: for (int i = len; i >= 2; i--) { char c = fileName.charAt(i); if (!reading) { @@ -644,7 +642,9 @@ public class MainUtil { break; case '.': res[index--] = val; - if (index == -1) return res; + if (index == -1) { + return res; + } val = 0; numIndex = 1; break; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/MemUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/MemUtil.java index 4aa7f465b..285572885 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/MemUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/MemUtil.java @@ -28,8 +28,7 @@ public class MemUtil { } public static long getUsedBytes() { - long used = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); - return used; + return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); } public static long getFreeBytes() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/Permission.java b/worldedit-core/src/main/java/com/boydti/fawe/util/Permission.java index c99930820..8e0c0a0b2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/Permission.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/Permission.java @@ -1,6 +1,7 @@ package com.boydti.fawe.util; import com.sk89q.worldedit.util.auth.Subject; +import org.jetbrains.annotations.NotNull; public enum Permission { /* @@ -17,11 +18,8 @@ public enum Permission { } - public static boolean hasPermission(Subject player, String permission) { - if (player == null || player.hasPermission(ADMIN.permission)) { - return true; - } - if (player.hasPermission(permission)) { + public static boolean hasPermission(@NotNull Subject player, String permission) { + if (player.hasPermission(ADMIN.permission) || player.hasPermission(permission)) { return true; } final String[] nodes = permission.split("\\."); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/StringMan.java b/worldedit-core/src/main/java/com/boydti/fawe/util/StringMan.java index b49934f6a..1cf6e56ba 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/StringMan.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/StringMan.java @@ -6,33 +6,12 @@ import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.List; -import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import java.util.function.Function; +import java.util.stream.Collectors; import java.util.stream.IntStream; public class StringMan { - public static String replaceFromMap(String string, Map replacements) { - final StringBuilder sb = new StringBuilder(string); - int size = string.length(); - for (Entry entry : replacements.entrySet()) { - if (size == 0) { - break; - } - final String key = entry.getKey(); - final String value = entry.getValue(); - int start = sb.indexOf(key, 0); - while (start > -1) { - final int end = start + key.length(); - final int nextSearchStart = start + value.length(); - sb.replace(start, end, value); - size -= end - start; - start = sb.indexOf(key, nextSearchStart); - } - } - return sb.toString(); - } public static boolean containsAny(CharSequence sequence, String any) { return IntStream.range(0, sequence.length()) @@ -516,10 +495,6 @@ public class StringMan { } public static String repeat(String s, int n) { - final StringBuilder sb = new StringBuilder(); - for (int i = 0; i < n; i++) { - sb.append(s); - } - return sb.toString(); + return IntStream.range(0, n).mapToObj(i -> s).collect(Collectors.joining()); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java b/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java index 40b948fc2..7e4659a9c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java @@ -99,9 +99,9 @@ public class WEManager { synchronized (masks) { boolean removed = false; if (!masks.isEmpty()) { - Iterator iter = masks.iterator(); - while (iter.hasNext()) { - FaweMask mask = iter.next(); + Iterator iterator = masks.iterator(); + while (iterator.hasNext()) { + FaweMask mask = iterator.next(); if (mask.isValid(player, type)) { Region region = mask.getRegion(); if (region.contains(loc.toBlockPoint())) { @@ -112,7 +112,7 @@ public class WEManager { } } else { removed = true; - iter.remove(); + iterator.remove(); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java index 286b9e71f..98727d70a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java @@ -170,7 +170,7 @@ public class PlayerWrapper extends AbstractPlayerActor { } @Override - public void findFreePosition(final Location searchPos) { + public void findFreePosition(Location searchPos) { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Boolean value) { @@ -180,7 +180,7 @@ public class PlayerWrapper extends AbstractPlayerActor { } @Override - public void setOnGround(final Location searchPos) { + public void setOnGround(Location searchPos) { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Boolean value) { @@ -284,7 +284,7 @@ public class PlayerWrapper extends AbstractPlayerActor { } @Override - public void floatAt(final int x, final int y, final int z, final boolean alwaysGlass) { + public void floatAt(int x, int y, int z, boolean alwaysGlass) { RuntimeException caught = null; try { EditSession edit = new EditSessionBuilder(parent.getWorld()).player(FawePlayer.wrap(this)).build(); @@ -309,7 +309,7 @@ public class PlayerWrapper extends AbstractPlayerActor { } @Override - public Location getBlockTrace(final int range, final boolean useLastBlock) { + public Location getBlockTrace(int range, boolean useLastBlock) { return TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Location value) { @@ -320,7 +320,7 @@ public class PlayerWrapper extends AbstractPlayerActor { } @Override - public Location getBlockTraceFace(final int range, final boolean useLastBlock) { + public Location getBlockTraceFace(int range, boolean useLastBlock) { return TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Location value) { @@ -331,7 +331,7 @@ public class PlayerWrapper extends AbstractPlayerActor { } @Override - public Location getSolidBlockTrace(final int range) { + public Location getSolidBlockTrace(int range) { return TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Location value) { @@ -347,7 +347,7 @@ public class PlayerWrapper extends AbstractPlayerActor { } @Override - public boolean passThroughForwardWall(final int range) { + public boolean passThroughForwardWall(int range) { return TaskManager.IMP.sync(() -> { int searchDist = 0; TargetBlock hitBlox = new TargetBlock(PlayerWrapper.this, range, 0.2); diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java index 1cbff362d..2c8d284ce 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java @@ -20,13 +20,14 @@ package com.sk89q.jnbt; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; /** * A class which holds constant values. */ public final class NBTConstants { - public static final Charset CHARSET = Charset.forName("UTF-8"); + public static final Charset CHARSET = StandardCharsets.UTF_8; public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6, @@ -39,10 +40,10 @@ public final class NBTConstants { private NBTConstants() { } - + /** * Convert a type ID to its corresponding {@link Tag} class. - * + * * @param id type ID * @return tag class * @throws IllegalArgumentException thrown if the tag ID is not valid diff --git a/worldedit-core/src/main/java/com/sk89q/util/StringUtil.java b/worldedit-core/src/main/java/com/sk89q/util/StringUtil.java index dd4bf4b29..8f98d6093 100644 --- a/worldedit-core/src/main/java/com/sk89q/util/StringUtil.java +++ b/worldedit-core/src/main/java/com/sk89q/util/StringUtil.java @@ -135,7 +135,7 @@ public final class StringUtil { } StringBuilder buffer = new StringBuilder(Integer.toString(str[initialIndex])); for (int i = initialIndex + 1; i < str.length; ++i) { - buffer.append(delimiter).append(Integer.toString(str[i])); + buffer.append(delimiter).append(str[i]); } return buffer.toString(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index f351b686c..c89e9c502 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -56,6 +56,7 @@ import com.sk89q.worldedit.command.tool.SinglePickaxe; import com.sk89q.worldedit.command.tool.Tool; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.operation.ChangeSetExecutor; @@ -70,7 +71,6 @@ import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.regions.selector.RegionSelectorType; import com.sk89q.worldedit.session.ClipboardHolder; -import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.world.World; @@ -313,10 +313,6 @@ public class LocalSession implements TextureHolder { return (historyNegativeIndex == null ? historyNegativeIndex = 0 : historyNegativeIndex); } - public void setHistoryIndex(int value) { - historyNegativeIndex = history.size() - value - 1; - } - public boolean save() { saveHistoryNegativeIndex(uuid, currentWorld); if (defaultSelector == RegionSelectorType.CUBOID) { @@ -505,13 +501,14 @@ public class LocalSession implements TextureHolder { * Performs an undo. * * @param newBlockBag a new block bag - * @param player the player + * @param actor the actor * @return whether anything was undone */ - public EditSession undo(@Nullable BlockBag newBlockBag, Player player) { - checkNotNull(player); - FawePlayer fp = FawePlayer.wrap(player); - loadSessionHistoryFromDisk(player.getUniqueId(), fp.getWorldForEditing()); + public EditSession undo(@Nullable BlockBag newBlockBag, Actor actor) { + checkNotNull(actor); + //TODO This method needs to be modified to use actors instead of FAWEPlayer + FawePlayer fp = FawePlayer.wrap((Player)actor); + loadSessionHistoryFromDisk(actor.getUniqueId(), fp.getWorldForEditing()); if (getHistoryNegativeIndex() < history.size()) { FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex())); try (EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld()) @@ -521,7 +518,7 @@ public class LocalSession implements TextureHolder { .fastmode(false) .limitUnprocessed(fp) .player(fp) - .blockBag(getBlockBag(player)) + .blockBag(getBlockBag((Player)actor)) .build()) { newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.UNDO); setDirty(); @@ -542,13 +539,14 @@ public class LocalSession implements TextureHolder { * Performs a redo * * @param newBlockBag a new block bag - * @param player the player + * @param actor the actor * @return whether anything was redone */ - public EditSession redo(@Nullable BlockBag newBlockBag, Player player) { - checkNotNull(player); - FawePlayer fp = FawePlayer.wrap(player); - loadSessionHistoryFromDisk(player.getUniqueId(), fp.getWorldForEditing()); + public EditSession redo(@Nullable BlockBag newBlockBag, Actor actor) { + checkNotNull(actor); + //TODO This method needs to be modified to use actors instead of FAWEPlayer + FawePlayer fp = FawePlayer.wrap((Player)actor); + loadSessionHistoryFromDisk(actor.getUniqueId(), fp.getWorldForEditing()); if (getHistoryNegativeIndex() > 0) { setDirty(); historyNegativeIndex--; @@ -560,7 +558,7 @@ public class LocalSession implements TextureHolder { .fastmode(false) .limitUnprocessed(fp) .player(fp) - .blockBag(getBlockBag(player)) + .blockBag(getBlockBag((Player)actor)) .build()) { newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.REDO); return newEditSession; @@ -849,14 +847,18 @@ public class LocalSession implements TextureHolder { * Get the position use for commands that take a center point * (i.e. //forestgen, etc.). * - * @param player the player + * @param actor the actor * @return the position to use * @throws IncompleteRegionException thrown if a region is not fully selected */ - public BlockVector3 getPlacementPosition(Player player) throws IncompleteRegionException { - checkNotNull(player); + public BlockVector3 getPlacementPosition(Actor actor) throws IncompleteRegionException { + checkNotNull(actor); if (!placeAtPos1) { - return player.getBlockIn().toVector().toBlockPoint(); + if (actor instanceof Locatable) { + return ((Locatable) actor).getBlockLocation().toVector().toBlockPoint(); + } else { + throw new IncompleteRegionException(); + } } return selector.getPrimaryPosition(); @@ -1093,9 +1095,9 @@ public class LocalSession implements TextureHolder { /** * Tell the player the WorldEdit version. * - * @param player the player + * @param actor the actor */ - public void tellVersion(Actor player) { + public void tellVersion(Actor actor) { } public boolean shouldUseServerCUI() { @@ -1325,7 +1327,7 @@ public class LocalSession implements TextureHolder { /** * Construct a new edit session. * - * @param player the player + * @param player the actor * @return an edit session */ public EditSession createEditSession(Player player) { @@ -1334,12 +1336,12 @@ public class LocalSession implements TextureHolder { BlockBag blockBag = getBlockBag(player); World world = player.getWorld(); - boolean isPlayer = player.isPlayer(); EditSessionBuilder builder = new EditSessionBuilder(world); if (player.isPlayer()) builder.player(FawePlayer.wrap(player)); builder.blockBag(blockBag); builder.fastmode(fastMode); + // Create an edit session EditSession editSession = builder.build(); if (mask != null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/MissingWorldException.java b/worldedit-core/src/main/java/com/sk89q/worldedit/MissingWorldException.java new file mode 100644 index 000000000..fe6f6beaf --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/MissingWorldException.java @@ -0,0 +1,27 @@ +/* + * 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; + +/** + * Raised when a world is missing but is required. + */ +public class MissingWorldException extends WorldEditException { + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java index 485ed1623..64d759ac8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -109,7 +109,7 @@ public final class WorldEdit { private final PlatformManager platformManager = new PlatformManager(this); private final EditSessionFactory editSessionFactory = new EditSessionFactory.EditSessionFactoryImpl(eventBus); private final SessionManager sessions = new SessionManager(this); - private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20)); + private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20));; private final Supervisor supervisor = new SimpleSupervisor(); private final BlockFactory blockFactory = new BlockFactory(this); @@ -232,7 +232,7 @@ public final class WorldEdit { * traversal exploits by checking the root directory and the file directory. * On success, a {@code java.io.File} object will be returned. * - * @param player the player + * @param actor the actor * @param dir sub-directory to look in * @param filename filename (user-submitted) * @param defaultExt append an extension if missing one, null to not use @@ -240,8 +240,8 @@ public final class WorldEdit { * @return a file * @throws FilenameException thrown if the filename is invalid */ - public File getSafeSaveFile(Player player, File dir, String filename, String defaultExt, String... extensions) throws FilenameException { - return getSafeFile(player, dir, filename, defaultExt, extensions, true); + public File getSafeSaveFile(Actor actor, File dir, String filename, String defaultExt, String... extensions) throws FilenameException { + return getSafeFile(actor, dir, filename, defaultExt, extensions, true); } /** @@ -250,7 +250,7 @@ public final class WorldEdit { * traversal exploits by checking the root directory and the file directory. * On success, a {@code java.io.File} object will be returned. * - * @param player the player + * @param actor the actor * @param dir sub-directory to look in * @param filename filename (user-submitted) * @param defaultExt append an extension if missing one, null to not use @@ -258,14 +258,14 @@ public final class WorldEdit { * @return a file * @throws FilenameException thrown if the filename is invalid */ - public File getSafeOpenFile(Player player, File dir, String filename, String defaultExt, String... extensions) throws FilenameException { - return getSafeFile(player, dir, filename, defaultExt, extensions, false); + public File getSafeOpenFile(Actor actor, File dir, String filename, String defaultExt, String... extensions) throws FilenameException { + return getSafeFile(actor, dir, filename, defaultExt, extensions, false); } /** * Get a safe path to a file. * - * @param player the player + * @param actor the actor * @param dir sub-directory to look in * @param filename filename (user-submitted) * @param defaultExt append an extension if missing one, null to not use @@ -274,16 +274,16 @@ public final class WorldEdit { * @return a file * @throws FilenameException thrown if the filename is invalid */ - private File getSafeFile(@Nullable Player player, File dir, String filename, String defaultExt, String[] extensions, boolean isSave) throws FilenameException { + private File getSafeFile(@Nullable Actor actor, File dir, String filename, String defaultExt, String[] extensions, boolean isSave) throws FilenameException { if (extensions != null && (extensions.length == 1 && extensions[0] == null)) extensions = null; File f; - if (filename.equals("#") && player != null) { + if (filename.equals("#") && actor != null) { if (isSave) { - f = player.openFileSaveDialog(extensions); + f = actor.openFileSaveDialog(extensions); } else { - f = player.openFileOpenDialog(extensions); + f = actor.openFileOpenDialog(extensions); } if (f == null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java index 36d288eb4..fc2fb9927 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java @@ -31,6 +31,7 @@ import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.internal.anvil.ChunkDeleter; import com.sk89q.worldedit.internal.anvil.ChunkDeletionInfo; import com.sk89q.worldedit.math.BlockVector2; @@ -41,6 +42,7 @@ import com.sk89q.worldedit.util.formatting.component.PaginationBox; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; +import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.storage.LegacyChunkStore; import com.sk89q.worldedit.world.storage.McRegionChunkStore; import java.io.File; @@ -75,7 +77,7 @@ public class ChunkCommands { ) @CommandPermissions("worldedit.chunkinfo") public void chunkInfo(Player player) { - Location pos = player.getBlockIn(); + Location pos = player.getBlockLocation(); int chunkX = (int) Math.floor(pos.getBlockX() / 16.0); int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0); @@ -90,13 +92,13 @@ public class ChunkCommands { desc = "List chunks that your selection includes" ) @CommandPermissions("worldedit.listchunks") - public void listChunks(Player player, LocalSession session, + public void listChunks(Actor actor, World world, LocalSession session, @ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException { - Set chunks = session.getSelection(player.getWorld()).getChunks(); + Set chunks = session.getSelection(world).getChunks(); PaginationBox paginationBox = PaginationBox.fromStrings("Selected Chunks", "/listchunks -p %page%", chunks.stream().map(BlockVector2::toString).collect(Collectors.toList())); - player.print(paginationBox.create(page)); + actor.print(paginationBox.create(page)); } @Command( @@ -105,10 +107,10 @@ public class ChunkCommands { ) @CommandPermissions("worldedit.delchunks") @Logging(REGION) - public void deleteChunks(Player player, LocalSession session, + public void deleteChunks(Actor actor, World world, LocalSession session, @ArgFlag(name = 'o', desc = "Only delete chunks older than the specified time.", def = "") ZonedDateTime beforeTime) throws WorldEditException { - Path worldDir = player.getWorld().getStoragePath(); + Path worldDir = world.getStoragePath(); if (worldDir == null) { throw new StopExecutionException(TextComponent.of("Couldn't find world folder for this world.")); } @@ -131,10 +133,10 @@ public class ChunkCommands { ChunkDeletionInfo.ChunkBatch newBatch = new ChunkDeletionInfo.ChunkBatch(); newBatch.worldPath = worldDir.toAbsolutePath().normalize().toString(); newBatch.backup = true; - final Region selection = session.getSelection(player.getWorld()); + final Region selection = session.getSelection(world); if (selection instanceof CuboidRegion) { - newBatch.minChunk = BlockVector2.at(selection.getMinimumPoint().getBlockX() >> 4, selection.getMinimumPoint().getBlockZ() >> 4); - newBatch.maxChunk = BlockVector2.at(selection.getMaximumPoint().getBlockX() >> 4, selection.getMaximumPoint().getBlockZ() >> 4); + newBatch.minChunk = selection.getMinimumPoint().shr(4).toBlockVector2(); + newBatch.maxChunk = selection.getMaximumPoint().shr(4).toBlockVector2(); } else { // this has a possibility to OOM for very large selections still Set chunks = selection.getChunks(); @@ -156,13 +158,13 @@ public class ChunkCommands { throw new StopExecutionException(TextComponent.of("Failed to write chunk list: " + e.getMessage())); } - player.print(String.format("%d chunk(s) have been marked for deletion the next time the server starts.", + actor.print(String.format("%d chunk(s) have been marked for deletion the next time the server starts.", newBatch.getChunkCount())); if (currentInfo.batches.size() > 1) { - player.printDebug(String.format("%d chunks total marked for deletion. (May have overlaps).", + actor.printDebug(String.format("%d chunks total marked for deletion. (May have overlaps).", currentInfo.batches.stream().mapToInt(ChunkDeletionInfo.ChunkBatch::getChunkCount).sum())); } - player.print(TextComponent.of("You can mark more chunks for deletion, or to stop now, run: ", TextColor.LIGHT_PURPLE) + actor.print(TextComponent.of("You can mark more chunks for deletion, or to stop now, run: ", TextColor.LIGHT_PURPLE) .append(TextComponent.of("/stop", TextColor.AQUA) .clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/stop")))); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index 36f19c2c8..ea62cb9db 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -19,6 +19,10 @@ package com.sk89q.worldedit.command; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT; +import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; + import com.boydti.fawe.FaweAPI; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; @@ -35,10 +39,6 @@ import com.boydti.fawe.object.schematic.Schematic; import com.boydti.fawe.util.ImgurUtility; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MaskTraverser; - -import static com.google.common.base.Preconditions.checkNotNull; -import org.enginehub.piston.inject.InjectedValueAccess; - import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -47,8 +47,6 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.Logging; -import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT; -import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.extent.PasteEvent; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; @@ -74,12 +72,6 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.session.ClipboardHolder; -import org.enginehub.piston.annotation.Command; -import org.enginehub.piston.annotation.CommandContainer; -import org.enginehub.piston.annotation.param.Arg; -import org.enginehub.piston.annotation.param.ArgFlag; -import org.enginehub.piston.annotation.param.Switch; - import java.io.File; import java.io.IOException; import java.io.OutputStream; @@ -91,6 +83,12 @@ import java.util.HashSet; import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import org.enginehub.piston.annotation.Command; +import org.enginehub.piston.annotation.CommandContainer; +import org.enginehub.piston.annotation.param.Arg; +import org.enginehub.piston.annotation.param.ArgFlag; +import org.enginehub.piston.annotation.param.Switch; +import org.enginehub.piston.inject.InjectedValueAccess; /** @@ -159,7 +157,7 @@ public class ClipboardCommands { if (!player.hasPermission("fawe.tips")) { BBC.TIP_PASTE.or(BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(player); } - }, getArguments(context), region, context); + }, "/copy", region, context); } @Command( @@ -283,7 +281,7 @@ public class ClipboardCommands { if (!player.hasPermission("fawe.tips")) { BBC.TIP_LAZYCUT.send(player); } - }, getArguments(context), region, context); + }, "cut", region, context); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index 273a602f4..66001ebf0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL; import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT; import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION; +import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument; import com.boydti.fawe.Fawe; import com.boydti.fawe.config.BBC; @@ -105,7 +106,7 @@ public class GenerationCommands { CavesGen gen = new CavesGen(size, frequency, rarity, minY, maxY, systemFrequency, individualRarity, pocketChance, pocketMin, pocketMax); editSession.generate(region, gen); BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount()); - }, getArguments(context), region, context); + }, "/caves", region, context); } @@ -119,7 +120,7 @@ public class GenerationCommands { player.checkConfirmationRegion(() -> { editSession.addOres(region, mask); BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount()); - }, getArguments(context), region, context); + }, "/ores", region, context); } @Command( @@ -173,7 +174,7 @@ public class GenerationCommands { player.checkConfirmationRegion(() -> { editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY); BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount()); - }, getArguments(context), region, context); + }, "/ore", region, context); } @Command( @@ -195,7 +196,7 @@ public class GenerationCommands { fp.checkConfirmationRadius(() -> { int affected = editSession.makeHollowCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), thickness - 1); BBC.VISITOR_BLOCK.send(fp, affected); - }, getArguments(context), (int) max, context); + }, "/hcyl", (int) max, context); } @Command( @@ -218,7 +219,7 @@ public class GenerationCommands { fp.checkConfirmationRadius(() -> { int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), !hollow); BBC.VISITOR_BLOCK.send(fp, affected); - }, getArguments(context), (int) max, context); + }, "/cyl", (int) max, context); } @Command( @@ -260,7 +261,7 @@ public class GenerationCommands { int affected = editSession.makeSphere(finalPos, pattern, radii.getX(), radii.getY(), radii.getZ(), !hollow); player.findFreePosition(); BBC.VISITOR_BLOCK.send(fp, affected); - }, getArguments(context), (int) max, context); + }, "sphere", (int) max, context); } @Command( @@ -294,8 +295,9 @@ public class GenerationCommands { int size, @Arg(desc = "//TODO", def = "10") int apothem, - @Range(min = 0, max = 100) @Arg(desc = "//TODO ", def = "0.02") + @Arg(desc = "//TODO ", def = "0.02") double density) throws WorldEditException { + checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100"); int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), apothem, density); BBC.COMMAND_PUMPKIN.send(player, affected); return affected; @@ -335,7 +337,7 @@ public class GenerationCommands { int affected = editSession.makePyramid(pos, pattern, size, !hollow); player.findFreePosition(); BBC.VISITOR_BLOCK.send(fp, affected); - }, getArguments(context), size, context); + }, "/pyramid", size, player, editSession); } @Command( @@ -399,7 +401,7 @@ public class GenerationCommands { } catch (ExpressionException e) { player.printError(e.getMessage()); } - }, getArguments(context), region, context); + }, "/generate", region, context); } @Command( @@ -462,7 +464,7 @@ public class GenerationCommands { } catch (ExpressionException e) { fp.printError(e.getMessage()); } - }, getArguments(context), region, context); + }, "/generatebiome", region, context); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java index 2942671a9..c2dd01ca8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java @@ -256,7 +256,7 @@ public class HistoryCommands { if (undone == null) { BBC.COMMAND_UNDO_ERROR.send(player); } - }, getArguments(context), times, 50, context); + }, "undo", times, 50, context); } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ListFilters.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ListFilters.java index 9c6113657..aba5f43d3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ListFilters.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ListFilters.java @@ -10,11 +10,10 @@ import java.util.UUID; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import org.enginehub.piston.annotation.Command; -import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.exception.StopExecutionException; //TODO This class breaks compilation -@CommandContainer +//@CommandContainer public class ListFilters { public class Filter { public boolean listPrivate() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index ff8badd69..937c3ea81 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -135,7 +135,7 @@ public class RegionCommands { selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16)); } int count = FaweAPI.fixLighting(player.getWorld(), selection,null); - BBC.LIGHTING_PROPOGATE_SELECTION.send(fp, count); + BBC.LIGHTING_PROPAGATE_SELECTION.send(fp, count); } @Command( @@ -721,7 +721,7 @@ public class RegionCommands { Operations.completeLegacy(visitor); BBC.COMMAND_FLORA.send(player, ground.getAffected()); - }, getArguments(context), region, context); + }, "/flora", region, context); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 6cd085572..954ac76e3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -292,7 +292,7 @@ public class SchematicCommands { desc = "Save a schematic into your clipboard" ) @CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save", "worldedit.schematic.save.other"}) - public void save(Player player, LocalSession session, + public void save(Actor actor, LocalSession session, @Arg(desc = "File name.") String filename, @Arg(desc = "Format name.", def = "sponge") @@ -307,20 +307,20 @@ public class SchematicCommands { File dir = worldEdit.getWorkingDirectoryFile(config.saveDir); if (!global && Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS) { - dir = new File(dir, player.getUniqueId().toString()); + dir = new File(dir, actor.getUniqueId().toString()); } ClipboardFormat format = ClipboardFormats.findByAlias(formatName); if (format == null) { - player.printError("Unknown schematic format: " + formatName); + actor.printError("Unknown schematic format: " + formatName); return; } boolean other = false; if (filename.contains("../")) { other = true; - if (!player.hasPermission("worldedit.schematic.save.other")) { - BBC.NO_PERM.send(player, "worldedit.schematic.save.other"); + if (!actor.hasPermission("worldedit.schematic.save.other")) { + BBC.NO_PERM.send(actor, "worldedit.schematic.save.other"); return; } if (filename.startsWith("../")) { @@ -329,21 +329,21 @@ public class SchematicCommands { } } - File f = worldEdit.getSafeSaveFile(player, dir, filename, format.getPrimaryFileExtension()); + File f = worldEdit.getSafeSaveFile(actor, dir, filename, format.getPrimaryFileExtension()); boolean overwrite = f.exists(); if (overwrite) { - if (!player.hasPermission("worldedit.schematic.delete")) { + if (!actor.hasPermission("worldedit.schematic.delete")) { throw new StopExecutionException(TextComponent.of("That schematic already exists!")); } if (other) { - if (!player.hasPermission("worldedit.schematic.delete.other")) { + if (!actor.hasPermission("worldedit.schematic.delete.other")) { BBC.NO_PERM.send(player, "worldedit.schematic.delete.other"); return; } } if (!allowOverwrite) { - player.printError("That schematic already exists. Use the -f flag to overwrite it."); + actor.printError("That schematic already exists. Use the -f flag to overwrite it."); return; } } @@ -359,8 +359,8 @@ public class SchematicCommands { ClipboardHolder holder = session.getClipboard(); - SchematicSaveTask task = new SchematicSaveTask(player, f, format, holder, overwrite); - AsyncCommandBuilder.wrap(task, player) + SchematicSaveTask task = new SchematicSaveTask(actor, f, format, holder, overwrite); + AsyncCommandBuilder.wrap(task, actor) .registerWithSupervisor(worldEdit.getSupervisor(), "Saving schematic " + filename) .sendMessageAfterDelay("(Please wait... saving schematic.)") .onSuccess(filename + " saved" + (overwrite ? " (overwriting previous file)." : "."), null) @@ -635,12 +635,12 @@ public class SchematicCommands { } private static class SchematicLoadTask implements Callable { - private final Player player; + private final Actor actor; private final File file; private final ClipboardFormat format; - SchematicLoadTask(Player player, File file, ClipboardFormat format) { - this.player = player; + SchematicLoadTask(Actor actor, File file, ClipboardFormat format) { + this.actor = actor; this.file = file; this.format = format; } @@ -653,21 +653,21 @@ public class SchematicCommands { ClipboardReader reader = closer.register(format.getReader(bis)); Clipboard clipboard = reader.read(); - log.info(player.getName() + " loaded " + file.getCanonicalPath()); + log.info(actor.getName() + " loaded " + file.getCanonicalPath()); return new ClipboardHolder(clipboard); } } } private static class SchematicSaveTask implements Callable { - private final Player player; + private final Actor actor; private final File file; private final ClipboardFormat format; private final ClipboardHolder holder; private final boolean overwrite; - SchematicSaveTask(Player player, File file, ClipboardFormat format, ClipboardHolder holder, boolean overwrite) { - this.player = player; + SchematicSaveTask(Actor actor, File file, ClipboardFormat format, ClipboardHolder holder, boolean overwrite) { + this.actor = actor; this.file = file; this.format = format; this.holder = holder; @@ -700,14 +700,14 @@ public class SchematicCommands { } if (new PlayerSaveClipboardEvent(player, clipboard, uri, file.toURI()).call()) { if (writer instanceof MinecraftStructure) { - ((MinecraftStructure) writer).write(target, player.getName()); + ((MinecraftStructure) writer).write(target, actor.getName()); } else { writer.write(target); } - log.info(player.getName() + " saved " + file.getCanonicalPath()); - BBC.SCHEMATIC_SAVED.send(player, file.getName()); + log.info(actor.getName() + " saved " + file.getCanonicalPath()); + BBC.SCHEMATIC_SAVED.send(actor, file.getName()); } else { - BBC.WORLDEDIT_CANCEL_REASON_MANUAL.send(player); + BBC.WORLDEDIT_CANCEL_REASON_MANUAL.send(actor); } } return null; 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 591f61d76..5481447e6 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 @@ -40,6 +40,8 @@ import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.entity.Player; +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.extent.clipboard.Clipboard; @@ -61,6 +63,7 @@ import com.sk89q.worldedit.regions.selector.RegionSelectorType; import com.sk89q.worldedit.regions.selector.SphereRegionSelector; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.Countable; +import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.component.CommandListBox; import com.sk89q.worldedit.util.formatting.component.SubtleFormat; import com.sk89q.worldedit.util.formatting.component.TextComponentProducer; @@ -99,23 +102,26 @@ public class SelectionCommands { ) @Logging(POSITION) @CommandPermissions("worldedit.selection.pos") - public void pos1(Player player, LocalSession session, + public void pos1(Actor actor, World world, LocalSession session, @Arg(desc = "Coordinates to set position 1 to", def = "") BlockVector3 coordinates) throws WorldEditException { - BlockVector3 pos; + Location pos; if (coordinates != null) { - pos = coordinates; + pos = new Location(world, coordinates.toVector3()); + } else if (actor instanceof Locatable) { + pos = ((Locatable) actor).getBlockLocation(); } else { - pos = player.getBlockIn().toBlockPoint(); - } - pos = pos.clampY(0, player.getWorld().getMaximumPoint().getBlockY()); - if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) { - BBC.SELECTOR_ALREADY_SET.send(player); + actor.printError("You must provide coordinates as console."); return; } - session.getRegionSelector(player.getWorld()) - .explainPrimarySelection(player, session, pos); + if (!session.getRegionSelector(world).selectPrimary(pos.toBlockPoint(), ActorSelectorLimits.forActor(actor))) { + BBC.SELECTOR_ALREADY_SET.send(actor); + return; + } + + session.getRegionSelector(world) + .explainPrimarySelection(actor, session, pos.toBlockPoint()); } @Command( @@ -124,23 +130,25 @@ public class SelectionCommands { ) @Logging(POSITION) @CommandPermissions("worldedit.selection.pos") - public void pos2(Player player, LocalSession session, + public void pos2(Actor actor, World world, LocalSession session, @Arg(desc = "Coordinates to set position 2 to", def = "") BlockVector3 coordinates) throws WorldEditException { - BlockVector3 pos; + Location pos; if (coordinates != null) { - pos = coordinates; + pos = new Location(world, coordinates.toVector3()); + } else if (actor instanceof Locatable) { + pos = ((Locatable) actor).getBlockLocation(); } else { - pos = player.getBlockIn().toBlockPoint(); + actor.printError("You must provide coordinates as console."); + return; } - pos = pos.clampY(0, player.getWorld().getMaximumPoint().getBlockY()); - if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) { - BBC.SELECTOR_ALREADY_SET.send(player); + if (!session.getRegionSelector(world).selectSecondary(pos.toBlockPoint(), ActorSelectorLimits.forActor(actor))) { + BBC.SELECTOR_ALREADY_SET.send(actor); return; } - session.getRegionSelector(player.getWorld()) - .explainSecondarySelection(player, session, pos); + session.getRegionSelector(world) + .explainSecondarySelection(actor, session, pos.toBlockPoint()); } @Command( @@ -222,7 +230,7 @@ public class SelectionCommands { : ChunkStore.toChunk(coordinates.toBlockVector3()); } else { // use player loc - min2D = ChunkStore.toChunk(player.getBlockIn().toBlockPoint()); + min2D = ChunkStore.toChunk(player.getBlockLocation().toBlockPoint()); } min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16); @@ -296,7 +304,7 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.contract") - public void contract(Player player, LocalSession session, + public void contract(Actor actor, World world, LocalSession session, @Arg(desc = "Amount to contract the selection by") int amount, @Arg(desc = "Amount to contract the selection by in the other direction", def = "0") @@ -305,7 +313,7 @@ public class SelectionCommands { @MultiDirection List direction) throws WorldEditException { try { - Region region = session.getSelection(player.getWorld()); + Region region = session.getSelection(world); int oldSize = region.getArea(); if (reverseAmount == 0) { for (BlockVector3 dir : direction) { @@ -316,15 +324,15 @@ public class SelectionCommands { region.contract(dir.multiply(amount), dir.multiply(-reverseAmount)); } } - session.getRegionSelector(player.getWorld()).learnChanges(); + session.getRegionSelector(world).learnChanges(); int newSize = region.getArea(); - session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); + session.getRegionSelector(world).explainRegionAdjust(actor, session); - BBC.SELECTION_CONTRACT.send(player, (oldSize - newSize)); + BBC.SELECTION_CONTRACT.send(actor, (oldSize - newSize)); } catch (RegionOperationException e) { - player.printError(e.getMessage()); + actor.printError(e.getMessage()); } } @@ -334,26 +342,26 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.shift") - public void shift(Player player, LocalSession session, + public void shift(Actor actor, World world, LocalSession session, @Arg(desc = "Amount to shift the selection by") int amount, @Arg(desc = "Direction to contract", def = Direction.AIM) @MultiDirection List direction) throws WorldEditException { try { - Region region = session.getSelection(player.getWorld()); + Region region = session.getSelection(world); for (BlockVector3 dir : direction) { region.shift(dir.multiply(amount)); } - session.getRegionSelector(player.getWorld()).learnChanges(); + session.getRegionSelector(world).learnChanges(); - session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); + session.getRegionSelector(world).explainRegionAdjust(actor, session); - BBC.SELECTION_SHIFT.send(player); + BBC.SELECTION_SHIFT.send(actor); } catch (RegionOperationException e) { - player.printError(e.getMessage()); + actor.printError(e.getMessage()); } } @@ -363,18 +371,18 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.outset") - public void outset(Player player, LocalSession session, + public void outset(Actor actor, World world, LocalSession session, @Arg(desc = "Amount to expand the selection by in all directions") int amount, @Switch(name = 'h', desc = "Only expand horizontally") boolean onlyHorizontal, @Switch(name = 'v', desc = "Only expand vertically") boolean onlyVertical) throws WorldEditException { - Region region = session.getSelection(player.getWorld()); + Region region = session.getSelection(world); region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical)); - session.getRegionSelector(player.getWorld()).learnChanges(); - session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); - BBC.SELECTION_OUTSET.send(player); + session.getRegionSelector(world).learnChanges(); + session.getRegionSelector(world).explainRegionAdjust(actor, session); + BBC.SELECTION_OUTSET.send(actor); } @Command( @@ -383,18 +391,18 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.inset") - public void inset(Player player, LocalSession session, + public void inset(Actor actor, World world, LocalSession session, @Arg(desc = "Amount to contract the selection by in all directions") int amount, @Switch(name = 'h', desc = "Only contract horizontally") boolean onlyHorizontal, @Switch(name = 'v', desc = "Only contract vertically") boolean onlyVertical) throws WorldEditException { - Region region = session.getSelection(player.getWorld()); + Region region = session.getSelection(world); region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical)); - session.getRegionSelector(player.getWorld()).learnChanges(); - session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); - BBC.SELECTION_INSET.send(player); + session.getRegionSelector(world).learnChanges(); + session.getRegionSelector(world).explainRegionAdjust(actor, session); + actor.print("Region inset."); } private BlockVector3[] getChangesForEachDir(int amount, boolean onlyHorizontal, boolean onlyVertical) { @@ -544,17 +552,16 @@ public class SelectionCommands { aliases = { ";", "/desel", "/deselect" }, desc = "Choose a region selector" ) - public void select(Player player, LocalSession session, EditSession editSession, + public void select(Actor actor, World world, LocalSession session, EditSession editSession, @Arg(desc = "Selector to switch to", def = "") SelectorChoice selector, @Arg(desc = "Selector mask", def = "") Mask mask, @Switch(name = 'd', desc = "Set default selector") boolean setDefaultSelector) throws WorldEditException { - final World world = player.getWorld(); if (selector == null) { session.getRegionSelector(world).clear(); - session.dispatchCUISelection(player); - BBC.SELECTION_CLEARED.send(player); + session.dispatchCUISelection(actor); + BBC.SELECTION_CLEARED.send(actor); return; } @@ -564,55 +571,56 @@ public class SelectionCommands { switch (selector) { case CUBOID: newSelector = new CuboidRegionSelector(oldSelector); - player.print(BBC.SEL_CUBOID.s()); + actor.print(BBC.SEL_CUBOID.s()); break; case EXTEND: newSelector = new ExtendingCuboidRegionSelector(oldSelector); - player.print(BBC.SEL_CUBOID_EXTEND.s()); + actor.print(BBC.SEL_CUBOID_EXTEND.s()); break; case POLY: { newSelector = new Polygonal2DRegionSelector(oldSelector); - player.print(BBC.SEL_2D_POLYGON.s()); - Optional limit = ActorSelectorLimits.forActor(player).getPolygonVertexLimit(); - limit.ifPresent(integer -> player.print(BBC.SEL_MAX.format(integer))); + actor.print(BBC.SEL_2D_POLYGON.s()); + Optional limit = ActorSelectorLimits.forActor(actor).getPolygonVertexLimit(); + limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer))); break; } case ELLIPSOID: newSelector = new EllipsoidRegionSelector(oldSelector); - player.print(BBC.SEL_ELLIPSIOD.s()); + actor.print(BBC.SAL_ELLIPSOID.s()); break; case SPHERE: newSelector = new SphereRegionSelector(oldSelector); - player.print(BBC.SEL_SPHERE.s()); + actor.print(BBC.SEL_SPHERE.s()); break; case CYL: newSelector = new CylinderRegionSelector(oldSelector); - player.print(BBC.SEL_CYLINDRICAL.s()); + actor.print(BBC.SEL_CYLINDRICAL.s()); break; case CONVEX: case HULL: case POLYHEDRON: { newSelector = new ConvexPolyhedralRegionSelector(oldSelector); - player.print(BBC.SEL_CONVEX_POLYHEDRAL.s()); - Optional limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit(); - limit.ifPresent(integer -> player.print(BBC.SEL_MAX.format(integer))); + actor.print(BBC.SEL_CONVEX_POLYHEDRAL.s()); + Optional limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit(); + limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer))); break; } case POLYHEDRAL: - newSelector = new PolyhedralRegionSelector(player.getWorld()); - player.print(BBC.SEL_CONVEX_POLYHEDRAL.s()); - Optional limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit(); - limit.ifPresent(integer -> player.print(BBC.SEL_MAX.format(integer))); - player.print(BBC.SEL_LIST.s()); + newSelector = new PolyhedralRegionSelector(world); + actor.print(BBC.SEL_CONVEX_POLYHEDRAL.s()); + Optional limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit(); + limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer))); + actor.print(BBC.SEL_LIST.s()); break; case FUZZY: case MAGIC: if (mask == null) { mask = new IdMask(world); } - newSelector = new FuzzyRegionSelector(player, editSession, mask); - player.print(BBC.SEL_FUZZY.s()); - player.print(BBC.SEL_LIST.s()); + //TODO Make FuzzyRegionSelector accept actors + newSelector = new FuzzyRegionSelector((Player) actor, editSession, mask); + actor.print(BBC.SEL_FUZZY.s()); + actor.print(BBC.SEL_LIST.s()); break; case LIST: default: @@ -631,7 +639,7 @@ public class SelectionCommands { box.appendCommand("polyhedral", "Select a hollow polyhedral", "//sel polyhedral"); box.appendCommand("fuzzy[=]", "Select all connected blocks (magic wand)", "//sel fuzzy[=]"); - player.print(box.create(1)); + actor.print(box.create(1)); return; } @@ -646,14 +654,14 @@ public class SelectionCommands { if (found != null) { session.setDefaultRegionSelector(found); - BBC.SELECTOR_SET_DEFAULT.send(player, found.name()); + BBC.SELECTOR_SET_DEFAULT.send(actor, found.name()); } else { throw new RuntimeException("Something unexpected happened. Please report this."); } } session.setRegionSelector(world, newSelector); - session.dispatchCUISelection(player); + session.dispatchCUISelection(actor); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java index f8a012b46..a4ed9ed90 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java @@ -29,12 +29,14 @@ 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.extension.platform.Actor; import com.sk89q.worldedit.util.formatting.component.PaginationBox; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; +import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException; import com.sk89q.worldedit.world.snapshot.Snapshot; import com.sk89q.worldedit.world.storage.MissingWorldException; @@ -67,24 +69,24 @@ public class SnapshotCommands { desc = "List snapshots" ) @CommandPermissions("worldedit.snapshots.list") - public void list(Player player, + public void list(Actor actor, World world, @ArgFlag(name = 'p', desc = "Page of results to return", def = "1") int page) throws WorldEditException { LocalConfiguration config = we.getConfiguration(); if (config.snapshotRepo == null) { - BBC.SNAPSHOT_NOT_CONFIGURED.send(player); + BBC.SNAPSHOT_NOT_CONFIGURED.send(actor); return; } try { - List snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName()); + List snapshots = config.snapshotRepo.getSnapshots(true, world.getName()); if (!snapshots.isEmpty()) { - player.print(new SnapshotListBox(player.getWorld().getName(), snapshots).create(page)); + actor.print(new SnapshotListBox(world.getName(), snapshots).create(page)); } else { - BBC.SNAPSHOT_NOT_AVAILABLE.send(player); + BBC.SNAPSHOT_NOT_AVAILABLE.send(actor); // Okay, let's toss some debugging information! File dir = config.snapshotRepo.getDirectory(); @@ -99,7 +101,7 @@ public class SnapshotCommands { } } } catch (MissingWorldException ex) { - BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player); + BBC.SNAPSHOT_NOT_FOUND_WORLD.send(actor); } } @@ -108,37 +110,37 @@ public class SnapshotCommands { desc = "Choose a snapshot to use" ) @CommandPermissions("worldedit.snapshots.restore") - public void use(Player player, LocalSession session, - @Arg(desc = "Snapeshot to use") + public void use(Actor actor, World world, LocalSession session, + @Arg(desc = "Snapshot to use") String name) throws WorldEditException { LocalConfiguration config = we.getConfiguration(); if (config.snapshotRepo == null) { - BBC.SNAPSHOT_NOT_CONFIGURED.send(player); + BBC.SNAPSHOT_NOT_CONFIGURED.send(actor); return; } // Want the latest snapshot? if (name.equalsIgnoreCase("latest")) { try { - Snapshot snapshot = config.snapshotRepo.getDefaultSnapshot(player.getWorld().getName()); + Snapshot snapshot = config.snapshotRepo.getDefaultSnapshot(world.getName()); if (snapshot != null) { session.setSnapshot(null); - BBC.SNAPSHOT_NEWEST.send(player); + BBC.SNAPSHOT_NEWEST.send(actor); } else { - BBC.SNAPSHOT_NOT_FOUND.send(player); + BBC.SNAPSHOT_NOT_FOUND.send(actor); } } catch (MissingWorldException ex) { - BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player); + BBC.SNAPSHOT_NOT_FOUND_WORLD.send(actor); } } else { try { session.setSnapshot(config.snapshotRepo.getSnapshot(name)); - BBC.SNAPSHOT_SET.send(player, name); + BBC.SNAPSHOT_SET.send(actor, name); } catch (InvalidSnapshotException e) { - BBC.SNAPSHOT_NOT_AVAILABLE.send(player); + BBC.SNAPSHOT_NOT_AVAILABLE.send(actor); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java index aa6fda420..75b115a30 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java @@ -30,9 +30,10 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.Logging; -import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.DataException; +import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException; import com.sk89q.worldedit.world.snapshot.Snapshot; import com.sk89q.worldedit.world.snapshot.SnapshotRestore; @@ -60,25 +61,25 @@ public class SnapshotUtilCommands { ) @Logging(REGION) @CommandPermissions("worldedit.snapshots.restore") - public void restore(Player player, LocalSession session, EditSession editSession, + public void restore(Actor actor, World world, LocalSession session, EditSession editSession, @Arg(name = "snapshot", desc = "The snapshot to restore", def = "") String snapshotName) throws WorldEditException { LocalConfiguration config = we.getConfiguration(); if (config.snapshotRepo == null) { - BBC.SNAPSHOT_NOT_CONFIGURED.send(player); + BBC.SNAPSHOT_NOT_CONFIGURED.send(actor); return; } - Region region = session.getSelection(player.getWorld()); + Region region = session.getSelection(world); Snapshot snapshot; if (snapshotName != null) { try { snapshot = config.snapshotRepo.getSnapshot(snapshotName); } catch (InvalidSnapshotException e) { - BBC.SNAPSHOT_NOT_AVAILABLE.send(player); + BBC.SNAPSHOT_NOT_AVAILABLE.send(actor); return; } } else { @@ -88,10 +89,10 @@ public class SnapshotUtilCommands { // No snapshot set? if (snapshot == null) { try { - snapshot = config.snapshotRepo.getDefaultSnapshot(player.getWorld().getName()); + snapshot = config.snapshotRepo.getDefaultSnapshot(world.getName()); if (snapshot == null) { - BBC.SNAPSHOT_NOT_AVAILABLE.send(player); + BBC.SNAPSHOT_NOT_AVAILABLE.send(actor); // Okay, let's toss some debugging information! File dir = config.snapshotRepo.getDirectory(); @@ -108,7 +109,7 @@ public class SnapshotUtilCommands { return; } } catch (MissingWorldException ex) { - BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player); + BBC.SNAPSHOT_NOT_FOUND_WORLD.send(actor); return; } } @@ -116,7 +117,7 @@ public class SnapshotUtilCommands { // Load chunk store try (ChunkStore chunkStore = snapshot.getChunkStore()) { - BBC.SNAPSHOT_LOADED.send(player, snapshot.getName()); + BBC.SNAPSHOT_LOADED.send(actor, snapshot.getName()); // Restore snapshot SnapshotRestore restore = new SnapshotRestore(chunkStore, editSession, region); @@ -127,21 +128,20 @@ public class SnapshotUtilCommands { if (restore.hadTotalFailure()) { String error = restore.getLastErrorMessage(); if (!restore.getMissingChunks().isEmpty()) { - BBC.SNAPSHOT_ERROR_RESTORE.send(player); + BBC.SNAPSHOT_ERROR_RESTORE.send(actor); } else if (error != null) { - player.printError("Errors prevented any blocks from being restored."); - player.printError("Last error: " + error); + actor.printError("Errors prevented any blocks from being restored."); + actor.printError("Last error: " + error); } else { - BBC.SNAPSHOT_ERROR_RESTORE_CHUNKS.send(player); + BBC.SNAPSHOT_ERROR_RESTORE_CHUNKS.send(actor); } } else { - player.print(String.format("Restored; %d " - + "missing chunks and %d other errors.", + actor.print(String.format("Restored; %d missing chunks and %d other errors.", restore.getMissingChunks().size(), restore.getErrorChunks().size())); } } catch (DataException | IOException e) { - player.printError("Failed to load snapshot: " + e.getMessage()); + actor.printError("Failed to load snapshot: " + e.getMessage()); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java index 53dcfd15a..c5c046c18 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java @@ -785,10 +785,10 @@ public class UtilityCommands { actor.print(m.build()); } - public static int getFiles(File root, Actor actor, InjectedValueAccess args, int page, int perPage, String formatName, boolean playerFolder, Consumer forEachFile, ListFilters... filters) { - // TODO NOT IMPLEMENTED replace getFiles - return page; - } +// public static int getFiles(File root, Actor actor, InjectedValueAccess args, int page, int perPage, String formatName, boolean playerFolder, Consumer forEachFile, ListFilters... filters) { +// // TODO NOT IMPLEMENTED replace getFiles +// return page; +// } public static int getFiles(File dir, Actor actor, InjectedValueAccess args, @Range(min = 0) int page, int perPage, String formatName, boolean playerFolder, Consumer forEachFile) { Consumer rootFunction = forEachFile; 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 a700bf576..6b55e6457 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 @@ -36,6 +36,7 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; +import com.sk89q.worldedit.extension.platform.NoCapablePlatformException; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.PlatformManager; import java.io.IOException; @@ -98,8 +99,13 @@ public class WorldEditCommands { actor.printDebug("----------- Capabilities -----------"); for (Capability capability : Capability.values()) { - Platform platform = pm.queryCapability(capability); - actor.printDebug(String.format("%s: %s", capability.name(), platform != null ? platform.getPlatformName() : "NONE")); + try { + Platform platform = pm.queryCapability(capability); + actor.printDebug(String.format("%s: %s", capability.name(), + platform != null ? platform.getPlatformName() : "NONE")); + } catch (NoCapablePlatformException e) { + actor.printDebug(String.format("%s: %s", capability.name(), "NONE")); + } } actor.printDebug(""); actor.printDebug("Wiki: " + "https://github.com/boy0001/FastAsyncWorldedit/wiki"); @@ -120,7 +126,7 @@ public class WorldEditCommands { @Command( name = "report", aliases = { "debugpaste" }, - desc = "Writes a report of latest.log, config.yml, message.yml and your commands.yml to https://athion.net/ISPaster/paste" + desc = "Writes a report of latest.log, config.yml, message.yml https://athion.net/ISPaster/paste" ) @CommandQueued(false) @CommandPermissions({"worldedit.report", "worldedit.debugpaste"}) @@ -162,19 +168,19 @@ public class WorldEditCommands { name = "tz", desc = "Set your timezone for snapshots" ) - public void tz(Player player, LocalSession session, + public void tz(Actor actor, LocalSession session, @Arg(desc = "The timezone to set") String timezone) { try { ZoneId tz = ZoneId.of(timezone); session.setTimezone(tz); - BBC.TIMEZONE_SET.send(player, tz.getDisplayName( + BBC.TIMEZONE_SET.send(actor, tz.getDisplayName( TextStyle.FULL, Locale.ENGLISH )); BBC.TIMEZONE_DISPLAY - .send(player, dateFormat.format(ZonedDateTime.now(tz))); + .send(actor, dateFormat.format(ZonedDateTime.now(tz))); } catch (ZoneRulesException e) { - player.printError("Invalid timezone"); + actor.printError("Invalid timezone"); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Entity.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Entity.java index 23544ea30..b82be020d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Entity.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Entity.java @@ -19,11 +19,10 @@ package com.sk89q.worldedit.entity; +import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.util.Faceted; -import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.entity.EntityType; - import javax.annotation.Nullable; /** @@ -34,7 +33,7 @@ import javax.annotation.Nullable; * instance of an entity, but a {@link BaseEntity} can be created from * this entity by calling {@link #getState()}.

*/ -public interface Entity extends Faceted { +public interface Entity extends Faceted, Locatable { /** * Get a copy of the entity's state. @@ -48,33 +47,11 @@ public interface Entity extends Faceted { @Nullable BaseEntity getState(); - /** - * Get the location of this entity. - * - * @return the location of the entity - */ - Location getLocation(); - - /** - * Sets the location of this entity. - * - * @param location the new location of the entity - * @return if the teleport worked - */ - boolean setLocation(Location location); - default EntityType getType() { BaseEntity state = getState(); return state != null ? state.getType() : null; } - /** - * Get the extent that this entity is on. - * - * @return the extent - */ - Extent getExtent(); - /** * Remove this entity from it container. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java index 3673d8842..624bdbc6b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java @@ -191,8 +191,12 @@ public interface Player extends Entity, Actor { * Get the point of the block that is being stood in. * * @return point + * @deprecated Use Locatable#getBlockLocation */ - Location getBlockIn(); + @Deprecated + default Location getBlockIn() { + return getBlockLocation(); + } /** * Get the point of the block that is being stood upon. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java index b9d7990be..87eb1e579 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java @@ -198,7 +198,7 @@ public class DefaultMaskParser extends FaweParser { String suggestion = suggestions.get(i); if (suggestion.indexOf(' ') != 0) { String[] split = suggestion.split(" "); - suggestion = BBC.color("[" + StringMan.join(split, "][") + "]"); + suggestion = "[" + StringMan.join(split, "][") + "]"; suggestions.set(i, suggestion); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/DefaultPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/DefaultPatternParser.java index 738cbea35..7b027ebf9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/DefaultPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/DefaultPatternParser.java @@ -161,7 +161,7 @@ public class DefaultPatternParser extends FaweParser { String suggestion = suggestions.get(i); if (suggestion.indexOf(' ') != 0) { String[] split = suggestion.split(" "); - suggestion = BBC.color("[" + StringMan.join(split, "][") + "]"); + suggestion = "[" + StringMan.join(split, "][") + "]"; suggestions.set(i, suggestion); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java new file mode 100644 index 000000000..8262d0696 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java @@ -0,0 +1,51 @@ +/* + * 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.extension.platform; + +import com.sk89q.worldedit.internal.cui.CUIEvent; + +import java.io.File; + +public abstract class AbstractNonPlayerActor implements Actor { + + @Override + public boolean canDestroyBedrock() { + return true; + } + + @Override + public boolean isPlayer() { + return false; + } + + @Override + public File openFileOpenDialog(String[] extensions) { + return null; + } + + @Override + public File openFileSaveDialog(String[] extensions) { + return null; + } + + @Override + public void dispatchCUIEvent(CUIEvent event) { + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index f8b5971b9..cc8c89cb8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -19,7 +19,10 @@ package com.sk89q.worldedit.extension.platform; +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.NotABlockException; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extent.Extent; @@ -33,6 +36,7 @@ import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.TargetBlock; import com.sk89q.worldedit.util.auth.AuthorizationException; +import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -44,13 +48,13 @@ import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.registry.BlockMaterial; - import java.io.File; import javax.annotation.Nullable; /** - * An abstract implementation of both a {@link Actor} and a {@link Player} that is intended for - * implementations of WorldEdit to use to wrap players that make use of WorldEdit. + * An abstract implementation of both a {@link Actor} and a {@link Player} + * that is intended for implementations of WorldEdit to use to wrap + * players that make use of WorldEdit. */ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @@ -151,12 +155,12 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public void findFreePosition() { - findFreePosition(getBlockIn()); + findFreePosition(getBlockLocation()); } @Override public boolean ascendLevel() { - final Location pos = getBlockIn(); + final Location pos = getBlockLocation(); final int x = pos.getBlockX(); int y = Math.max(0, pos.getBlockY()); final int z = pos.getBlockZ(); @@ -214,7 +218,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public boolean descendLevel() { - final Location pos = getBlockIn(); + final Location pos = getBlockLocation(); final int x = pos.getBlockX(); int y = Math.max(0, pos.getBlockY()); final int z = pos.getBlockZ(); @@ -277,7 +281,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public boolean ascendToCeiling(int clearance, boolean alwaysGlass) { - Location pos = getBlockIn(); + Location pos = getBlockLocation(); int x = pos.getBlockX(); int initialY = Math.max(0, pos.getBlockY()); int y = Math.max(0, pos.getBlockY() + 2); @@ -294,6 +298,13 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial() .isMovementBlocker()) { int platformY = Math.max(initialY, y - 3 - clearance); + if (platformY < initialY) { // if ==, they already have the given clearance, if <, clearance is too large + printError("Not enough space above you!"); + return false; + } else if (platformY == initialY) { + printError("You're already at the ceiling."); + return false; + } floatAt(x, platformY + 1, z, alwaysGlass); return true; } @@ -311,7 +322,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public boolean ascendUpwards(int distance, boolean alwaysGlass) { - final Location pos = getBlockIn(); + final Location pos = getBlockLocation(); final int x = pos.getBlockX(); final int initialY = Math.max(0, pos.getBlockY()); int y = Math.max(0, pos.getBlockY() + 1); @@ -338,27 +349,41 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public void floatAt(int x, int y, int z, boolean alwaysGlass) { - try { + if (alwaysGlass || !isAllowedToFly()) { BlockVector3 spot = BlockVector3.at(x, y - 1, z); - if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial() - .isMovementBlocker()) { - getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState()); + final World world = getWorld(); + if (!world.getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) { + try (EditSession session = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 1, this)) { + session.setBlock(spot, BlockTypes.GLASS.getDefaultState()); + } catch (MaxChangedBlocksException ignored) { } - } catch (WorldEditException e) { - e.printStackTrace(); + } + } else { + setFlying(true); } setPosition(Vector3.at(x + 0.5, y, z + 0.5)); } - @Override - public Location getBlockIn() { - return getLocation().setPosition(getLocation().toVector().floor()); + /** + * Check whether the player is allowed to fly. + * + * @return true if allowed flight + */ + protected boolean isAllowedToFly() { + return false; + } + + /** + * Set whether the player is currently flying. + * + * @param flying true to fly + */ + protected void setFlying(boolean flying) { } @Override public Location getBlockOn() { - return getLocation() - .setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor()); + return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor()); } @Override @@ -407,15 +432,16 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public Direction getCardinalDirection(int yawOffset) { - if (getLocation().getPitch() > 67.5) { + final Location location = getLocation(); + if (location.getPitch() > 67.5) { return Direction.DOWN; } - if (getLocation().getPitch() < -67.5) { + if (location.getPitch() < -67.5) { return Direction.UP; } // From hey0's code - double rot = (getLocation().getYaw() + yawOffset) % 360; //let's use real yaw now + double rot = (location.getYaw() + yawOffset) % 360; //let's use real yaw now if (rot < 0) { rot += 360.0; } @@ -432,56 +458,66 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { } } + private boolean canPassThroughBlock(Location curBlock) { + BlockVector3 blockPos = curBlock.toVector().toBlockPoint(); + BlockState block = curBlock.getExtent().getBlock(blockPos); + return !block.getBlockType().getMaterial().isMovementBlocker(); + } + /** - * Get the player's view yaw. - * - * @return yaw + * Advances the block target block until the current block is a wall + * @return true if a wall is found */ - - @Override - public boolean passThroughForwardWall(int range) { - int searchDist = 0; - TargetBlock hitBlox = new TargetBlock(this, range, 0.2); - Extent world = getLocation().getExtent(); - Location block; - boolean firstBlock = true; - int freeToFind = 2; - boolean inFree = false; - - while ((block = hitBlox.getNextBlock()) != null) { - boolean free = !world.getBlock(block.toVector().toBlockPoint()).getBlockType() - .getMaterial().isMovementBlocker(); - - if (firstBlock) { - firstBlock = false; - - if (!free) { - --freeToFind; - continue; - } - } - - ++searchDist; - if (searchDist > 20) { - return false; - } - - if (inFree != free) { - if (free) { - --freeToFind; - } - } - - if (freeToFind == 0) { - setOnGround(block); + private boolean advanceToWall(TargetBlock hitBlox) { + Location curBlock; + while ((curBlock = hitBlox.getCurrentBlock()) != null) { + if (!canPassThroughBlock(curBlock)) { return true; } - inFree = free; + hitBlox.getNextBlock(); } return false; } + /** + * Advances the block target block until the current block is a free + * @return true if a free spot is found + */ + private boolean advanceToFree(TargetBlock hitBlox) { + Location curBlock; + while ((curBlock = hitBlox.getCurrentBlock()) != null) { + if (canPassThroughBlock(curBlock)) { + return true; + } + + hitBlox.getNextBlock(); + } + + return false; + } + + @Override + public boolean passThroughForwardWall(int range) { + TargetBlock hitBlox = new TargetBlock(this, range, 0.2); + + if (!advanceToWall(hitBlox)) { + return false; + } + + if (!advanceToFree(hitBlox)) { + return false; + } + + Location foundBlock = hitBlox.getCurrentBlock(); + if (foundBlock != null) { + setOnGround(foundBlock); + return true; + } + + + return false; + } @Override public void setPosition(Vector3 pos) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Locatable.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Locatable.java new file mode 100644 index 000000000..cc25ab5c7 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Locatable.java @@ -0,0 +1,69 @@ +/* + * 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.extension.platform; + +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.Vector3; +import com.sk89q.worldedit.util.Location; + +public interface Locatable { + + /** + * Get the location of this actor. + * + * @return the location of the actor + */ + Location getLocation(); + + /** + * Get the location of this actor in block coordinates. + * + * @return the block location of the actor + */ + default Location getBlockLocation() { + Location location = getLocation(); + return location.setPosition(location.toVector().floor()); + } + + /** + * Sets the location of this actor. + * + * @param location the new location of the actor + * @return if the teleport succeeded + */ + boolean setLocation(Location location); + + /** + * Sets the position of this actor. + * + * @param pos where to move them + */ + default void setPosition(Vector3 pos) { + setLocation(new Location(getExtent(), pos)); + } + + /** + * Get the extent that this actor is in. + * + * @return the extent + */ + Extent getExtent(); + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 270ddb3cd..6cdfaf54d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -411,11 +411,6 @@ public final class PlatformCommandManager { GenerationCommandsRegistration.builder(), new GenerationCommands(worldEdit) ); - this.registration.register( - new CFICommand(commandManager), - CFICommandsRegistration.builder(), - new CFICommands(worldEdit) - ); this.registration.register( commandManager, HistoryCommandsRegistration.builder(), diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java index 54ee24e23..3d77e7b6d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java @@ -232,7 +232,7 @@ public class BlockMaskBuilder { private void suggest(String input, String property, Collection finalTypes) throws InputParseException { throw new SuggestInputParseException(input + " does not have: " + property, input, () -> { Set keys = new HashSet<>(); - finalTypes.forEach(t -> t.getProperties().stream().forEach(p -> keys.add(p.getKey()))); + finalTypes.forEach(t -> t.getProperties().forEach(p -> keys.add(p.getKey()))); return keys.stream().map(PropertyKey::getId) .filter(p -> StringMan.blockStateMatches(property, p)) .sorted(StringMan.blockStateComparator(property)) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java index f71639485..8dea4f786 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java @@ -22,20 +22,20 @@ package com.sk89q.worldedit.function.mask; import static com.google.common.base.Preconditions.checkNotNull; import com.boydti.fawe.Fawe; -import com.google.common.base.Function; - import com.sk89q.worldedit.math.BlockVector3; - -import javax.annotation.Nullable; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; +import java.util.function.Function; +import javax.annotation.Nullable; /** @@ -100,7 +100,7 @@ public class MaskIntersection extends AbstractMask { } } - public Function, Mask> pairingFunction() { + public Function, Mask> pairingFunction() { return input -> input.getKey().tryCombine(input.getValue()); } @@ -120,12 +120,11 @@ public class MaskIntersection extends AbstractMask { } if (changed) { masks.clear(); - for (Mask mask : masksArray) masks.add(mask); + Collections.addAll(masks, masksArray); } // Optimize this boolean formArray = false; - for (int i = 0; i < masksArray.length; i++) { - Mask mask = masksArray[i]; + for (Mask mask : masksArray) { if (mask.getClass() == this.getClass()) { this.masks.remove(mask); this.masks.addAll(((MaskIntersection) mask).getMasks()); @@ -162,7 +161,7 @@ public class MaskIntersection extends AbstractMask { return changed ? this : null; } - private boolean combineMasks(Function, Mask> pairing, Set> failedCombines) { + private boolean combineMasks(Function, Mask> pairing, Set> failedCombines) { boolean hasOptimized = false; while (true) { Mask[] result = null; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java index 690f14361..6151a6c15 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java @@ -19,16 +19,14 @@ package com.sk89q.worldedit.function.mask; -import com.google.common.base.Function; import com.sk89q.worldedit.math.BlockVector3; - import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; - -import java.util.Map; +import java.util.Map.Entry; import java.util.Set; +import java.util.function.Function; import javax.annotation.Nullable; /** @@ -81,7 +79,7 @@ public class MaskUnion extends MaskIntersection { } @Override - public Function, Mask> pairingFunction() { + public Function, Mask> pairingFunction() { return input -> input.getKey().tryOr(input.getValue()); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java index 45a1343eb..ca1da29b5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java @@ -20,8 +20,10 @@ package com.sk89q.worldedit.function.mask; import static com.google.common.base.Preconditions.checkNotNull; + import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; +import javax.annotation.Nullable; /** * A mask that tests whether given positions are contained within a region. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/ScanChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/ScanChunk.java index 96ce3ca37..7e8b00667 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/ScanChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/ScanChunk.java @@ -1,17 +1,10 @@ package com.sk89q.worldedit.function.visitor; -import com.boydti.fawe.beta.IChunk; -import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.math.BlockVector3; -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.LongArraySet; -import it.unimi.dsi.fastutil.objects.ObjectIterator; - import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; @@ -24,12 +17,12 @@ public class ScanChunk { public static final BlockVector3[] DIAGONAL_DIRECTIONS; static { - DEFAULT_DIRECTIONS[0] = (BlockVector3.at(0, -1, 0)); - DEFAULT_DIRECTIONS[1] = (BlockVector3.at(0, 1, 0)); - DEFAULT_DIRECTIONS[2] = (BlockVector3.at(-1, 0, 0)); - DEFAULT_DIRECTIONS[3] = (BlockVector3.at(1, 0, 0)); - DEFAULT_DIRECTIONS[4] = (BlockVector3.at(0, 0, -1)); - DEFAULT_DIRECTIONS[5] = (BlockVector3.at(0, 0, 1)); + DEFAULT_DIRECTIONS[0] = BlockVector3.at(0, -1, 0); + DEFAULT_DIRECTIONS[1] = BlockVector3.at(0, 1, 0); + DEFAULT_DIRECTIONS[2] = BlockVector3.at(-1, 0, 0); + DEFAULT_DIRECTIONS[3] = BlockVector3.at(1, 0, 0); + DEFAULT_DIRECTIONS[4] = BlockVector3.at(0, 0, -1); + DEFAULT_DIRECTIONS[5] = BlockVector3.at(0, 0, 1); List list = new ArrayList<>(); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { @@ -43,13 +36,8 @@ public class ScanChunk { } } } - Collections.sort(list, new Comparator() { - @Override - public int compare(BlockVector3 o1, BlockVector3 o2) { - return (int) Math.signum(o1.lengthSq() - o2.lengthSq()); - } - }); - DIAGONAL_DIRECTIONS = list.toArray(new BlockVector3[list.size()]); + list.sort((o1, o2) -> (int) Math.signum(o1.lengthSq() - o2.lengthSq())); + DIAGONAL_DIRECTIONS = list.toArray(new BlockVector3[0]); } private final RegionFunction function; @@ -57,7 +45,7 @@ public class ScanChunk { private final Long2ObjectOpenHashMap visits; private final Long2ObjectOpenHashMap queues; - public ScanChunk(final RegionFunction function) { + public ScanChunk(RegionFunction function) { this.function = function; this.directions = DEFAULT_DIRECTIONS; @@ -65,8 +53,8 @@ public class ScanChunk { this.visits = new Long2ObjectOpenHashMap<>(); } - public static final long pairInt(int x, int y) { - return (((long) x) << 32) | (y & 0xffffffffL); + public static long pairInt(int x, int y) { + return (long) x << 32 | y & 0xffffffffL; } public boolean isVisited(int x, int y, int z) { @@ -180,7 +168,7 @@ public class ScanChunk { char triple = queue[index]; int x = index & 15; - int z = (index >> 4) & 15; + int z = index >> 4 & 15; int y = index >> 8; int absX = xx + x; @@ -249,7 +237,7 @@ public class ScanChunk { char triple = queue[index]; int x = index & 15; - int z = (index >> 4) & 15; + int z = index >> 4 & 15; int y = index >> 8; } queuePool.add(queue); @@ -327,11 +315,11 @@ public class ScanChunk { } public void set(long[] bits, int i) { - bits[i >> 6] |= (1L << (i & 0x3F)); + bits[i >> 6] |= 1L << (i & 0x3F); } - public boolean get(long[] bits, final int i) { - return (bits[i >> 6] & (1L << (i & 0x3F))) != 0; + public boolean get(long[] bits, int i) { + return (bits[i >> 6] & 1L << (i & 0x3F)) != 0; } public char getLocalIndex(int x, int y, int z) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/UserCommandCompleter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/UserCommandCompleter.java deleted file mode 100644 index a93363295..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/UserCommandCompleter.java +++ /dev/null @@ -1,72 +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.internal.command; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.sk89q.minecraft.util.commands.CommandException; -import com.sk89q.minecraft.util.commands.CommandLocals; -import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.extension.platform.Capability; -import com.sk89q.worldedit.extension.platform.MultiUserPlatform; -import com.sk89q.worldedit.extension.platform.Platform; -import com.sk89q.worldedit.extension.platform.PlatformManager; -import com.sk89q.worldedit.util.command.CommandCompleter; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * Provides the names of connected users as suggestions. - */ -public class UserCommandCompleter implements CommandCompleter { - - private final PlatformManager platformManager; - - /** - * Create a new instance. - * - * @param platformManager the platform manager - */ - public UserCommandCompleter(PlatformManager platformManager) { - checkNotNull(platformManager); - this.platformManager = platformManager; - } - - @Override - public List getSuggestions(String arguments, CommandLocals locals) throws CommandException { - Platform platform = platformManager.queryCapability(Capability.USER_COMMANDS); - if (platform instanceof MultiUserPlatform) { - List suggestions = new ArrayList<>(); - Collection users = ((MultiUserPlatform) platform).getConnectedUsers(); - for (Actor user : users) { - if (user.getName().toLowerCase().startsWith(arguments.toLowerCase().trim())) { - suggestions.add(user.getName()); - } - } - return suggestions; - } else { - return Collections.emptyList(); - } - } - -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/exception/WorldEditExceptionConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/exception/WorldEditExceptionConverter.java index 94d628128..f9b68cbb6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/exception/WorldEditExceptionConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/exception/WorldEditExceptionConverter.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.internal.command.exception; import static com.google.common.base.Preconditions.checkNotNull; + import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.DisallowedItemException; import com.sk89q.worldedit.EmptyClipboardException; @@ -40,11 +41,11 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException; import com.sk89q.worldedit.util.io.file.FilenameResolutionException; import com.sk89q.worldedit.util.io.file.InvalidFilenameException; -import org.enginehub.piston.exception.CommandException; -import org.enginehub.piston.exception.UsageException; - +import com.sk89q.worldedit.world.storage.MissingWorldException; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.enginehub.piston.exception.CommandException; +import org.enginehub.piston.exception.UsageException; /** * converts WorldEdit exceptions and converts them into {@link CommandException}s. @@ -80,6 +81,10 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper { throw newCommandException("Make a region selection first.", e); } + @ExceptionMatch + public void convert(MissingWorldException e) throws CommandException { + throw newCommandException("You need to provide a world (Try //world)", e); + } @ExceptionMatch public void convert(UnknownItemException e) throws CommandException { throw newCommandException("Block name '" + e.getID() + "' was not recognized.", e); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java index a6e061d01..055c8e294 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java @@ -32,6 +32,7 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.registry.Keyed; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.world.block.BlockState; @@ -45,7 +46,7 @@ import java.nio.file.Path; /** * Represents a world (dimension). */ -public interface World extends Extent { +public interface World extends Extent, Keyed { /** * Get the name of the world. From 12114ec987f529f1857d71b1d523b3cbbd905ae8 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Mon, 29 Jul 2019 11:19:38 -0400 Subject: [PATCH 2/9] Minor changes --- .../java/com/sk89q/worldedit/EditSession.java | 20 ++++++++++--------- .../function/pattern/BlockPattern.java | 4 ++-- .../worldedit/world/block/BaseBlock.java | 4 ++-- .../worldedit/world/block/BlockState.java | 6 +++--- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 485023787..251694c32 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -150,13 +150,9 @@ import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - /** * An {@link Extent} that handles history, {@link BlockBag}s, change limits, * block re-ordering, and much more. Most operations in WorldEdit use this class. @@ -170,6 +166,12 @@ public class EditSession extends AbstractDelegateExtent implements SimpleWorld, private static final Logger log = LoggerFactory.getLogger(EditSession.class); + //TODO + @Override + public String getId() { + return null; + } + /** * Used by {@link EditSession#setBlock(BlockVector3, BlockStateHolder, Stage)} to * determine which {@link Extent}s should be bypassed. @@ -1193,10 +1195,10 @@ public class EditSession extends AbstractDelegateExtent implements SimpleWorld, /** * Fills an area recursively in the X/Z directions. * - * @param origin the location to start from - * @param pattern the block to fill with - * @param radius the radius of the spherical area to fill - * @param depth the maximum depth, starting from the origin + * @param origin the location to start from + * @param pattern the block to fill with + * @param radius the radius of the spherical area to fill + * @param depth the maximum depth, starting from the origin * @param direction the direction to fill * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed @@ -2971,7 +2973,7 @@ public class EditSession extends AbstractDelegateExtent implements SimpleWorld, double scaledZ = (z - zero2D.getZ()) / unit2D.getZ(); try { - if (expression.evaluateTimeout(timeout, scaledX, scaledZ, timeout) <= 0) { + if (expression.evaluate(new double[]{scaledX, scaledZ}, timeout) <= 0) { return null; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java index 6ad68f5f9..118492bde 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java @@ -21,13 +21,14 @@ package com.sk89q.worldedit.function.pattern; import static com.google.common.base.Preconditions.checkNotNull; -import com.boydti.fawe.beta.FilterBlock; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; /** * A pattern that returns the same {@link BaseBlock} each time. + * + * @deprecated all BlockStateHolders can be used directly as a pattern */ @Deprecated public class BlockPattern extends AbstractPattern { @@ -39,7 +40,6 @@ public class BlockPattern extends AbstractPattern { * * @param block the block */ - @Deprecated public BlockPattern(BlockStateHolder block) { setBlock(block); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java index 80ed33065..f6ed36737 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java @@ -182,7 +182,7 @@ public class BaseBlock implements BlockStateHolder, TileEntityBlock { @Override public void setNbtData(@Nullable CompoundTag nbtData) { - throw new UnsupportedOperationException("Immutable"); + throw new UnsupportedOperationException("This class is immutable."); } /** @@ -239,7 +239,7 @@ public class BaseBlock implements BlockStateHolder, TileEntityBlock { } @Override - public final BaseBlock toBaseBlock() { + public BaseBlock toBaseBlock() { return this; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java index 07599940a..a0187ac4f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java @@ -301,6 +301,9 @@ public class BlockState implements BlockStateHolder, FawePattern { @Override public boolean equalsFuzzy(BlockStateHolder o) { + if (null == o) { + return false; + } if (this == o) { // Added a reference equality check for speediness return true; @@ -308,9 +311,6 @@ public class BlockState implements BlockStateHolder, FawePattern { if (o.getClass() == BlockState.class) { return o.getOrdinal() == this.getOrdinal(); } - if (null == o) { - return false; - } return o.equalsFuzzy(this); } From 198427dc3d928cfc25fafffd4af00753a8e6b7b5 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Mon, 29 Jul 2019 21:05:31 -0400 Subject: [PATCH 3/9] fix more compile errors --- .../boydti/fawe/beta/DelegateFilterBlock.java | 5 ++++ .../com/boydti/fawe/object/FawePlayer.java | 14 +++++------ .../java/com/sk89q/worldedit/EditSession.java | 24 +++++++++++++++++++ .../worldedit/command/ClipboardCommands.java | 3 ++- .../sk89q/worldedit/command/MaskCommands.java | 6 ++--- .../worldedit/command/RegionCommands.java | 4 ++-- .../worldedit/command/SchematicCommands.java | 2 +- .../worldedit/extension/platform/Actor.java | 2 +- .../com/sk89q/worldedit/extent/Extent.java | 5 ---- 9 files changed, 44 insertions(+), 21 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java index 01c34a309..4cb06ff5e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java @@ -650,6 +650,11 @@ public class DelegateFilterBlock extends FilterBlock { return parent.getBlock(position); } + @Override + public BlockType getBlockType(BlockVector3 position) { + return parent.getBlockType(position); + } + @Override public BaseBlock getFullBlock(BlockVector3 position) { return parent.getFullBlock(position); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java b/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java index fbb94dac7..66b4622f0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java @@ -265,18 +265,18 @@ public abstract class FawePlayer extends Metadatable { // Queue for async tasks private AtomicInteger runningCount = new AtomicInteger(); - private SimpleAsyncNotifyQueue asyncNotifyQueue = new SimpleAsyncNotifyQueue((t, e) -> { - while (e.getCause() != null) { - e = e.getCause(); + private SimpleAsyncNotifyQueue asyncNotifyQueue = new SimpleAsyncNotifyQueue((thread, throwable) -> { + while (throwable.getCause() != null) { + throwable = throwable.getCause(); } - if (e instanceof WorldEditException) { - sendMessage(e.getLocalizedMessage()); + if (throwable instanceof WorldEditException) { + sendMessage(throwable.getLocalizedMessage()); } else { - FaweException fe = FaweException.get(e); + FaweException fe = FaweException.get(throwable); if (fe != null) { sendMessage(fe.getMessage()); } else { - e.printStackTrace(); + throwable.printStackTrace(); } } }); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 251694c32..ad37cbe87 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -103,6 +103,7 @@ import com.sk89q.worldedit.internal.expression.runtime.ExpressionTimeoutExceptio import com.sk89q.worldedit.internal.expression.runtime.RValue; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.MathUtils; import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.Vector2; @@ -1403,6 +1404,29 @@ public class EditSession extends AbstractDelegateExtent implements SimpleWorld, return replaceBlocks(region, mask, pattern); } + /** + * Sets the blocks at the center of the given region to the given pattern. + * If the center sits between two blocks on a certain axis, then two blocks + * will be placed to mark the center. + * + * @param region the region to find the center of + * @param pattern the replacement pattern + * @return the number of blocks placed + * @throws MaxChangedBlocksException thrown if too many blocks are changed + */ + public int center(Region region, Pattern pattern) throws MaxChangedBlocksException { + checkNotNull(region); + checkNotNull(pattern); + + Vector3 center = region.getCenter(); + Region centerRegion = new CuboidRegion( + getWorld(), // Causes clamping of Y range + BlockVector3.at(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())), + BlockVector3.at(MathUtils.roundHalfUp(center.getX()), + center.getY(), MathUtils.roundHalfUp(center.getZ()))); + return setBlocks(centerRegion, pattern); + } + /** * Make the faces of the given region as if it was a {@link CuboidRegion}. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index ea62cb9db..4e24f8282 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -126,7 +126,8 @@ public class ClipboardCommands { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); - long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); + long volume = + ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1); FaweLimit limit = FawePlayer.wrap(player).getLimit(); if (volume >= limit.MAX_CHECKS) { throw FaweException.MAX_CHECKS; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java index b9bb4a190..149b8b1ef 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java @@ -88,8 +88,7 @@ public class MaskCommands { } @Command( - name = "false", - aliases = {"#false"}, + name = "#false", desc = "Always false" ) public Mask falseMask(Extent extent) { @@ -97,8 +96,7 @@ public class MaskCommands { } @Command( - name = "true", - aliases = {"#true"}, + name = "#true", desc = "Always true" ) public Mask trueMask(Extent extent) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 1073a665a..623bfc4d3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -547,7 +547,7 @@ public class RegionCommands { boolean skipEntities, @Switch(name = 'a', desc = "Ignore air blocks") boolean ignoreAirBlocks, - @Switch(name = 'm', desc = "Source mask") + @ArgFlag(name = "m", desc = "Source mask") Mask sourceMask, InjectedValueAccess context) throws WorldEditException { player.checkConfirmationStack(() -> { @@ -677,7 +677,7 @@ public class RegionCommands { int thickness, @Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air") Pattern pattern, - @Switch(name = 'm', desc = "Mask to hollow with") Mask mask, + @ArgFlag(name = "m", desc = "Mask to hollow with") Mask mask, InjectedValueAccess context) throws WorldEditException { checkCommandArgument(thickness >= 0, "Thickness must be >= 0"); Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 954ac76e3..3496c042c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -577,7 +577,7 @@ public class SchematicCommands { boolean oldFirst, @Switch(name = 'n', desc = "Sort by date, newest first") boolean newFirst, - @Switch(name = 'f', desc = "Restricts by format.") + @ArgFlag(name = 'f', desc = "Restricts by format.") String formatName, @Arg(name = "filter", desc = "Filter for schematics", def = "all") String filter) throws WorldEditException { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java index cdcba32a2..de8adb1e5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java @@ -83,7 +83,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject { */ void print(Component component); - /** + /**F * Returns true if the actor can destroy bedrock. * * @return true if bedrock can be broken by the actor diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index 03da1338c..955acb05c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -52,7 +52,6 @@ import com.sk89q.worldedit.registry.state.PropertyGroup; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; @@ -620,8 +619,4 @@ public interface Extent extends InputExtent, OutputExtent { return count; } - default World getWorld() { - return null; - } - } From cb03ed2fe8b433a767e3b253179492696a1dfdcc Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Tue, 30 Jul 2019 15:27:59 -0400 Subject: [PATCH 4/9] remove Fast2DIterator --- .../com/sk89q/worldedit/command/BiomeCommands.java | 5 ++--- .../worldedit/function/visitor/RegionVisitor.java | 4 ++++ .../sk89q/worldedit/math/convolution/HeightMap.java | 10 +++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java index 06a693df9..5bcf0e3e8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java @@ -22,7 +22,6 @@ package com.sk89q.worldedit.command; import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; import com.boydti.fawe.config.BBC; -import com.boydti.fawe.object.visitor.Fast2DIterator; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; @@ -141,14 +140,14 @@ public class BiomeCommands { Region region = session.getSelection(world); if (region instanceof FlatRegion) { - for (BlockVector2 pt : new Fast2DIterator(((FlatRegion) region).asFlatRegion(), editSession)) { + for (BlockVector2 pt : ((FlatRegion) region).asFlatRegion()) { biomes.add(world.getBiome(pt)); } } else { RegionVisitor visitor = new RegionVisitor(region, position -> { biomes.add(world.getBiome(position.toBlockVector2())); return true; - }, editSession); + }); Operations.completeBlindly(visitor); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java index 159601b79..8bcea5e28 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.function.visitor; import com.boydti.fawe.config.BBC; +import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.operation.Operation; @@ -58,6 +59,9 @@ public class RegionVisitor implements Operation { this.iterable = iterable; } + public RegionVisitor(Region region, RegionFunction regionFunction, EditSession editSession) { + } + /** * Get the number of affected objects. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java index 4aff22f49..be6917344 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.math.convolution; -import com.boydti.fawe.object.visitor.Fast2DIterator; - import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.EditSession; @@ -34,7 +32,6 @@ import com.sk89q.worldedit.registry.state.PropertyGroup; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; - import java.util.Iterator; import javax.annotation.Nullable; @@ -93,11 +90,10 @@ public class HeightMap { BlockVector3 min = region.getMinimumPoint(); int bx = min.getBlockX(); int bz = min.getBlockZ(); - Iterable flat = Regions.asFlatRegion(region).asFlatRegion(); - Iterator iter = new Fast2DIterator(flat, session).iterator(); + Iterator flat = Regions.asFlatRegion(region).asFlatRegion().iterator(); int layer = 0; - while (iter.hasNext()) { - BlockVector2 pos = iter.next(); + while (flat.hasNext()) { + BlockVector2 pos = flat.next(); int x = pos.getBlockX(); int z = pos.getBlockZ(); layer = session.getNearestSurfaceLayer(x, z, (layer + 7) >> 3, 0, maxY); From c4c90c99a8b552b996db0d89e950b3be516d3cba Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Tue, 30 Jul 2019 15:28:25 -0400 Subject: [PATCH 5/9] Fix Gradle Script --- build.gradle | 5 +++-- worldedit-bukkit/build.gradle | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index f0b7a714d..fc4de0d74 100644 --- a/build.gradle +++ b/build.gradle @@ -46,7 +46,7 @@ allprojects { def buildNumber = "" def date = "" ext { - git = Grgit.open(dir: '.git') + git = Grgit.open(dir: new File(rootDir.toString()+'/.git')) date = git.head().getDate().format("yy.MM.dd") revision = "-${git.head().abbreviatedId}" parents = git.head().parentIds; @@ -63,6 +63,7 @@ allprojects { version = String.format("%s.%s", rootVersion, buildNumber) } + description = rootProject.name subprojects { @@ -191,4 +192,4 @@ task aggregatedJavadocs(type: Javadoc, description: 'Generate javadocs from all includes += javadocTask.includes } } -} \ No newline at end of file +} diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle index 4004e00f1..d825d7e30 100644 --- a/worldedit-bukkit/build.gradle +++ b/worldedit-bukkit/build.gradle @@ -23,10 +23,10 @@ dependencies { compileOnly 'com.sk89q:dummypermscompat:1.10' testCompile 'org.mockito:mockito-core:1.9.0-rc1' implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.8.1'){transitive = false} - compileOnly 'com.destroystokyo.paper:paper-api:1.14.3-R0.1-SNAPSHOT' + compileOnly 'com.destroystokyo.paper:paper-api:1.14.4-R0.1-SNAPSHOT' implementation('io.papermc:paperlib:1.0.2'){transitive = false} compileOnly 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT' - compileOnly 'BuildTools:lastSuccessfulBuild:spigot-1.14.3@jar' + compileOnly 'BuildTools:lastSuccessfulBuild:spigot-1.14.4@jar' implementation('com.sk89q.worldguard:worldguard-core:7.0.0-20190215.210421-39'){transitive = false} implementation('com.sk89q.worldguard:worldguard-legacy:7.0.0-20190215.210421-39'){transitive = false} implementation('com.massivecraft:factions:2.8.0'){transitive = false} From 0449b5d8bab007678491cb63d8f0b6aa58dda48e Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Wed, 31 Jul 2019 19:00:05 -0400 Subject: [PATCH 6/9] Remove FAVS and update Gradle --- build.gradle | 2 +- favs/build.gradle | 27 - .../boydti/fawe/bukkit/favs/PatternUtil.java | 29 - .../com/thevoxelbox/voxelsniper/Brushes.java | 80 -- .../com/thevoxelbox/voxelsniper/Message.java | 140 ---- .../voxelsniper/PaintingWrapper.java | 78 -- .../voxelsniper/RangeBlockHelper.java | 256 ------ .../thevoxelbox/voxelsniper/SnipeAction.java | 5 - .../thevoxelbox/voxelsniper/SnipeData.java | 319 -------- .../com/thevoxelbox/voxelsniper/Sniper.java | 653 --------------- .../voxelsniper/SniperManager.java | 23 - .../com/thevoxelbox/voxelsniper/Undo.java | 71 -- .../thevoxelbox/voxelsniper/VoxelSniper.java | 246 ------ .../voxelsniper/VoxelSniperConfiguration.java | 39 - .../voxelsniper/VoxelSniperListener.java | 160 ---- .../voxelsniper/api/command/VoxelCommand.java | 81 -- .../voxelsniper/brush/BallBrush.java | 119 --- .../voxelsniper/brush/BiomeBrush.java | 101 --- .../voxelsniper/brush/BlendBallBrush.java | 125 --- .../voxelsniper/brush/BlendBrushBase.java | 58 -- .../voxelsniper/brush/BlendDiscBrush.java | 110 --- .../voxelsniper/brush/BlendVoxelBrush.java | 119 --- .../brush/BlendVoxelDiscBrush.java | 107 --- .../voxelsniper/brush/BlobBrush.java | 237 ------ .../voxelsniper/brush/BlockResetBrush.java | 85 -- .../brush/BlockResetSurfaceBrush.java | 127 --- .../thevoxelbox/voxelsniper/brush/Brush.java | 282 ------- .../voxelsniper/brush/CanyonBrush.java | 114 --- .../brush/CanyonSelectionBrush.java | 68 -- .../brush/CheckerVoxelDiscBrush.java | 75 -- .../voxelsniper/brush/CleanSnowBrush.java | 84 -- .../voxelsniper/brush/CloneStampBrush.java | 139 ---- .../voxelsniper/brush/CometBrush.java | 79 -- .../voxelsniper/brush/CopyPastaBrush.java | 177 ---- .../voxelsniper/brush/CylinderBrush.java | 110 --- .../voxelsniper/brush/DiscBrush.java | 83 -- .../voxelsniper/brush/DiscFaceBrush.java | 143 ---- .../voxelsniper/brush/DomeBrush.java | 98 --- .../voxelsniper/brush/DrainBrush.java | 125 --- .../voxelsniper/brush/EllipseBrush.java | 235 ------ .../voxelsniper/brush/EllipsoidBrush.java | 112 --- .../voxelsniper/brush/EntityBrush.java | 71 -- .../voxelsniper/brush/EntityRemovalBrush.java | 150 ---- .../voxelsniper/brush/EraserBrush.java | 70 -- .../voxelsniper/brush/ErodeBlendBrush.java | 52 -- .../voxelsniper/brush/ErodeBrush.java | 451 ----------- .../voxelsniper/brush/ExtrudeBrush.java | 177 ---- .../voxelsniper/brush/FillDownBrush.java | 119 --- .../voxelsniper/brush/FlatOceanBrush.java | 96 --- .../voxelsniper/brush/GenerateTreeBrush.java | 630 --------------- .../voxelsniper/brush/HeatRayBrush.java | 179 ---- .../thevoxelbox/voxelsniper/brush/IBrush.java | 47 -- .../voxelsniper/brush/JaggedLineBrush.java | 116 --- .../voxelsniper/brush/JockeyBrush.java | 204 ----- .../voxelsniper/brush/LightningBrush.java | 32 - .../voxelsniper/brush/LineBrush.java | 75 -- .../voxelsniper/brush/MoveBrush.java | 251 ------ .../voxelsniper/brush/OceanBrush.java | 148 ---- .../voxelsniper/brush/OverlayBrush.java | 211 ----- .../voxelsniper/brush/PaintingBrush.java | 47 -- .../voxelsniper/brush/PullBrush.java | 311 ------- .../voxelsniper/brush/PunishBrush.java | 320 -------- .../voxelsniper/brush/RandomErodeBrush.java | 357 -------- .../brush/RegenerateChunkBrush.java | 58 -- .../voxelsniper/brush/RingBrush.java | 87 -- .../voxelsniper/brush/Rot2DBrush.java | 171 ---- .../voxelsniper/brush/Rot2DvertBrush.java | 174 ---- .../voxelsniper/brush/Rot3DBrush.java | 231 ------ .../voxelsniper/brush/RulerBrush.java | 97 --- .../voxelsniper/brush/ScannerBrush.java | 172 ---- .../voxelsniper/brush/SetBrush.java | 85 -- .../brush/SetRedstoneFlipBrush.java | 117 --- .../brush/SetRedstoneRotateBrush.java | 86 -- .../voxelsniper/brush/ShellBallBrush.java | 129 --- .../voxelsniper/brush/ShellSetBrush.java | 111 --- .../voxelsniper/brush/ShellVoxelBrush.java | 128 --- .../voxelsniper/brush/SignOverwriteBrush.java | 374 --------- .../voxelsniper/brush/SnipeBrush.java | 35 - .../voxelsniper/brush/SnowConeBrush.java | 153 ---- .../brush/SpiralStaircaseBrush.java | 535 ------------ .../voxelsniper/brush/SplatterBallBrush.java | 217 ----- .../voxelsniper/brush/SplatterDiscBrush.java | 192 ----- .../brush/SplatterOverlayBrush.java | 341 -------- .../voxelsniper/brush/SplatterVoxelBrush.java | 207 ----- .../brush/SplatterVoxelDiscBrush.java | 190 ----- .../voxelsniper/brush/SplineBrush.java | 248 ------ .../voxelsniper/brush/StampBrush.java | 235 ------ .../voxelsniper/brush/StencilBrush.java | 362 --------- .../voxelsniper/brush/StencilListBrush.java | 763 ------------------ .../brush/ThreePointCircleBrush.java | 204 ----- .../voxelsniper/brush/TreeSnipeBrush.java | 100 --- .../voxelsniper/brush/TriangleBrush.java | 293 ------- .../voxelsniper/brush/UnderlayBrush.java | 147 ---- .../voxelsniper/brush/VoltMeterBrush.java | 55 -- .../voxelsniper/brush/VoxelBrush.java | 45 -- .../voxelsniper/brush/VoxelDiscBrush.java | 44 - .../voxelsniper/brush/VoxelDiscFaceBrush.java | 91 --- .../voxelsniper/brush/WallSider.java | 128 --- .../voxelsniper/brush/WarpBrush.java | 82 -- .../brush/perform/PatternPerformer.java | 43 - .../brush/perform/PerformBrush.java | 101 --- .../voxelsniper/brush/perform/Performer.java | 16 - .../voxelsniper/brush/perform/PerformerE.java | 146 ---- .../voxelsniper/brush/perform/pCombo.java | 40 - .../brush/perform/pComboCombo.java | 54 -- .../brush/perform/pComboComboNoPhys.java | 55 -- .../voxelsniper/brush/perform/pComboInk.java | 51 -- .../brush/perform/pComboInkNoPhys.java | 51 -- .../voxelsniper/brush/perform/pComboMat.java | 51 -- .../brush/perform/pComboMatNoPhys.java | 51 -- .../brush/perform/pComboNoPhys.java | 41 - .../brush/perform/pComboNoUndo.java | 42 - .../brush/perform/pExcludeCombo.java | 47 -- .../brush/perform/pExcludeInk.java | 44 - .../brush/perform/pExcludeMat.java | 44 - .../brush/perform/pIncludeCombo.java | 47 -- .../brush/perform/pIncludeInk.java | 44 - .../brush/perform/pIncludeMat.java | 44 - .../voxelsniper/brush/perform/pInk.java | 38 - .../voxelsniper/brush/perform/pInkCombo.java | 51 -- .../brush/perform/pInkComboNoPhys.java | 47 -- .../voxelsniper/brush/perform/pInkInk.java | 48 -- .../brush/perform/pInkInkNoPhys.java | 44 - .../voxelsniper/brush/perform/pInkMat.java | 48 -- .../brush/perform/pInkMatNoPhys.java | 44 - .../voxelsniper/brush/perform/pInkNoPhys.java | 34 - .../voxelsniper/brush/perform/pInkNoUndo.java | 39 - .../voxelsniper/brush/perform/pMatCombo.java | 51 -- .../brush/perform/pMatComboNophys.java | 51 -- .../voxelsniper/brush/perform/pMatInk.java | 48 -- .../brush/perform/pMatInkNoPhys.java | 48 -- .../voxelsniper/brush/perform/pMatMat.java | 48 -- .../brush/perform/pMatMatNoPhys.java | 48 -- .../voxelsniper/brush/perform/pMaterial.java | 40 - .../brush/perform/pMaterialNoPhys.java | 39 - .../voxelsniper/brush/perform/pNoUndo.java | 39 - .../voxelsniper/brush/perform/vPerformer.java | 39 - .../command/VoxelBrushCommand.java | 76 -- .../command/VoxelBrushToolCommand.java | 61 -- .../command/VoxelCenterCommand.java | 32 - .../command/VoxelChunkCommand.java | 18 - .../command/VoxelDefaultCommand.java | 24 - .../voxelsniper/command/VoxelGoToCommand.java | 29 - .../command/VoxelHeightCommand.java | 32 - .../voxelsniper/command/VoxelInkCommand.java | 51 -- .../command/VoxelInkReplaceCommand.java | 51 -- .../voxelsniper/command/VoxelListCommand.java | 57 -- .../command/VoxelPaintCommand.java | 36 - .../command/VoxelPerformerCommand.java | 47 -- .../command/VoxelReplaceCommand.java | 48 -- .../command/VoxelSniperCommand.java | 86 -- .../voxelsniper/command/VoxelUndoCommand.java | 32 - .../command/VoxelUndoUserCommand.java | 26 - .../command/VoxelVoxelCommand.java | 89 -- .../event/SniperBrushChangedEvent.java | 75 -- .../event/SniperBrushSizeChangedEvent.java | 45 -- .../event/SniperMaterialChangedEvent.java | 77 -- .../SniperReplaceMaterialChangedEvent.java | 22 - .../voxelsniper/jsap/HelpJSAP.java | 168 ---- .../jsap/NullableIntegerStringParser.java | 63 -- .../voxelsniper/util/BlockWrapper.java | 118 --- .../voxelsniper/util/UndoDelegate.java | 52 -- .../voxelsniper/util/VoxelList.java | 78 -- favs/src/main/resources/LICENSE | 53 -- favs/src/main/resources/config.yml | 4 - favs/src/main/resources/plugin.yml | 445 ---------- settings.gradle | 2 - 167 files changed, 1 insertion(+), 19974 deletions(-) delete mode 100644 favs/build.gradle delete mode 100644 favs/src/main/java/com/boydti/fawe/bukkit/favs/PatternUtil.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/Brushes.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/PaintingWrapper.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeAction.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeData.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/SniperManager.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/Undo.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperConfiguration.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/api/command/VoxelCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BallBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BiomeBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBallBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBrushBase.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendDiscBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelDiscBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlobBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetSurfaceBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Brush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonSelectionBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CheckerVoxelDiscBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CleanSnowBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CometBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CopyPastaBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CylinderBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscFaceBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DomeBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DrainBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipseBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipsoidBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityRemovalBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EraserBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBlendBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ExtrudeBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FillDownBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FlatOceanBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/GenerateTreeBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/HeatRayBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/IBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JockeyBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LightningBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LineBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/MoveBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OceanBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PaintingBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PullBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PunishBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RandomErodeBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RegenerateChunkBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DvertBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot3DBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RulerBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneFlipBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneRotateBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellBallBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellSetBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellVoxelBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SignOverwriteBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnipeBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SpiralStaircaseBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterBallBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterDiscBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelDiscBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplineBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StampBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilListBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ThreePointCircleBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TreeSnipeBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TriangleBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/UnderlayBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoltMeterBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscFaceBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WallSider.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WarpBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PatternPerformer.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformBrush.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/Performer.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformerE.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pCombo.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboCombo.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboComboNoPhys.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInk.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInkNoPhys.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMat.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMatNoPhys.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoPhys.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoUndo.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeCombo.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeInk.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeMat.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeCombo.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeInk.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeMat.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInk.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkCombo.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkComboNoPhys.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInk.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInkNoPhys.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMat.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMatNoPhys.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoPhys.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoUndo.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatCombo.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatComboNophys.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInk.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInkNoPhys.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMat.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMatNoPhys.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterial.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterialNoPhys.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pNoUndo.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/vPerformer.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushToolCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelCenterCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelChunkCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelDefaultCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelGoToCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelHeightCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkReplaceCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelListCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPaintCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPerformerCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelReplaceCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelSniperCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoUserCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelVoxelCommand.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushChangedEvent.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushSizeChangedEvent.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperMaterialChangedEvent.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperReplaceMaterialChangedEvent.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/HelpJSAP.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/NullableIntegerStringParser.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/util/BlockWrapper.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/util/UndoDelegate.java delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/util/VoxelList.java delete mode 100644 favs/src/main/resources/LICENSE delete mode 100644 favs/src/main/resources/config.yml delete mode 100644 favs/src/main/resources/plugin.yml diff --git a/build.gradle b/build.gradle index fc4de0d74..a5f7a101c 100644 --- a/build.gradle +++ b/build.gradle @@ -100,7 +100,7 @@ subprojects { } } -configure(['worldedit-core', 'worldedit-bukkit', 'favs'].collect { project("$it") }) { +configure(['worldedit-core', 'worldedit-bukkit'].collect { project("$it") }) { apply plugin: 'java' apply plugin: 'maven' // apply plugin: 'checkstyle' diff --git a/favs/build.gradle b/favs/build.gradle deleted file mode 100644 index 023a2a6a0..000000000 --- a/favs/build.gradle +++ /dev/null @@ -1,27 +0,0 @@ -apply plugin: 'eclipse' -apply plugin: 'maven' - -dependencies { - compile project(':worldedit-bukkit') - compile 'com.martiansoftware:jsap:2.1' -} - -processResources { - from('src/main/resources') { - include 'plugin.yml' - expand( - name: project.parent.name, - version: project.parent.version - ) - } -} - -shadowJar { - dependencies { - include(dependency('com.martiansoftware:jsap:2.1')) - } - archiveName = "FastAsyncVoxelSniper-${project.name}-${parent.version}.jar" - destinationDir = file '../target' -} - -build.dependsOn(shadowJar) \ No newline at end of file diff --git a/favs/src/main/java/com/boydti/fawe/bukkit/favs/PatternUtil.java b/favs/src/main/java/com/boydti/fawe/bukkit/favs/PatternUtil.java deleted file mode 100644 index c4c9c6172..000000000 --- a/favs/src/main/java/com/boydti/fawe/bukkit/favs/PatternUtil.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.boydti.fawe.bukkit.favs; - -import com.boydti.fawe.object.FawePlayer; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.extension.input.InputParseException; -import com.sk89q.worldedit.extension.input.ParserContext; -import com.sk89q.worldedit.function.pattern.Pattern; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -public class PatternUtil { - public static Pattern parsePattern(Player player, SnipeData snipeData, String arg) { - ParserContext context = new ParserContext(); - FawePlayer fp = FawePlayer.wrap(player); - context.setActor(fp.getPlayer()); - context.setWorld(fp.getWorld()); - context.setSession(fp.getSession()); - try { - Pattern pattern = WorldEdit.getInstance().getPatternFactory().parseFromInput(arg, context); - snipeData.setPattern(pattern, arg); - snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + arg); - return pattern; - } catch (InputParseException e) { - fp.sendMessage(e.getMessage()); - return null; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/Brushes.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/Brushes.java deleted file mode 100644 index e1d2fb7ae..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/Brushes.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.thevoxelbox.voxelsniper; - -import com.google.common.base.Preconditions; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; -import com.thevoxelbox.voxelsniper.brush.IBrush; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -/** - * Brush registration manager. - */ -public class Brushes { - private Multimap, String> brushes = HashMultimap.create(); - - /** - * Register a brush for VoxelSniper to be able to use. - * - * @param clazz Brush implementing IBrush interface. - * @param handles Handles under which the brush can be accessed ingame. - */ - public void registerSniperBrush(Class clazz, String... handles) { - Preconditions.checkNotNull(clazz, "Cannot register null as a class."); - for (String handle : handles) { - brushes.put(clazz, handle.toLowerCase()); - } - } - - /** - * Retrieve Brush class via handle Lookup. - * - * @param handle Case insensitive brush handle - * @return Brush class - */ - public Class getBrushForHandle(String handle) { - Preconditions.checkNotNull(handle, "Brushhandle can not be null."); - if (!brushes.containsValue(handle.toLowerCase())) { - return null; - } - - for (Map.Entry, String> entry : brushes.entries()) { - if (entry.getValue().equalsIgnoreCase(handle)) { - return entry.getKey(); - } - } - return null; - } - - /** - * @return Amount of IBrush classes registered with the system under Sniper visibility. - */ - public int registeredSniperBrushes() { - return brushes.keySet().size(); - } - - /** - * @return Amount of handles registered with the system under Sniper visibility. - */ - public int registeredSniperBrushHandles() { - return brushes.size(); - } - - /** - * @param clazz Brush class - * @return All Sniper registered handles for the brush. - */ - public Set getSniperBrushHandles(Class clazz) { - return new HashSet<>(brushes.get(clazz)); - } - - /** - * @return Immutable Multimap copy of all the registered brushes - */ - public Multimap, String> getRegisteredBrushesMultimap() { - return ImmutableMultimap.copyOf(brushes); - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java deleted file mode 100644 index 6fac69b6b..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.thevoxelbox.voxelsniper; - -import com.sk89q.worldedit.world.block.BlockTypes; -import org.bukkit.ChatColor; - -public class Message { - private static final int BRUSH_SIZE_WARNING_THRESHOLD = 20; - private final SnipeData snipeData; - - /** - * @param snipeData - */ - public Message(SnipeData snipeData) { - this.snipeData = snipeData; - } - - /** - * Send a brush message styled message to the player. - * - * @param brushMessage - */ - public void brushMessage(String brushMessage) { - snipeData.sendMessage(ChatColor.LIGHT_PURPLE + brushMessage); - } - - /** - * Display Brush Name. - * - * @param brushName - */ - public void brushName(String brushName) { - snipeData.sendMessage(ChatColor.AQUA + "Brush Type: " + ChatColor.LIGHT_PURPLE + brushName); - } - - /** - * Display Center Parameter. - */ - public void center() { - snipeData.sendMessage(ChatColor.DARK_BLUE + "Brush Center: " + ChatColor.DARK_RED + snipeData.getcCen()); - } - - /** - * Display custom message. - * - * @param message - */ - public void custom(String message) { - snipeData.sendMessage(message); - } - - /** - * Display data value. - */ - public void data() { - snipeData.sendMessage(ChatColor.BLUE + "Data Variable: " + ChatColor.DARK_RED + snipeData.getPropertyId()); - } - - /** - * Display voxel height. - */ - public void height() { - snipeData.sendMessage(ChatColor.DARK_AQUA + "Brush Height: " + ChatColor.DARK_RED + snipeData.getVoxelHeight()); - } - - /** - * Display performer. - * - * @param performerName - */ - public void performerName(String performerName) { - this.snipeData.sendMessage(ChatColor.DARK_PURPLE + "Performer: " + ChatColor.DARK_GREEN + performerName); - } - - /** - * Displaye replace material. - */ - @SuppressWarnings("deprecation") - public void replace() { - snipeData.sendMessage(ChatColor.AQUA + "Replace Material: " + BlockTypes.get(snipeData.getReplaceId())); - } - - /** - * Display replace data value. - */ - public void replaceData() { - snipeData.sendMessage(ChatColor.DARK_GRAY + "Replace Data Variable: " + ChatColor.DARK_RED + snipeData.getReplaceData()); - } - - /** - * Display brush size. - */ - public void size() { - snipeData.sendMessage(ChatColor.GREEN + "Brush Size: " + ChatColor.DARK_RED + snipeData.getBrushSize()); - if (snipeData.getBrushSize() >= BRUSH_SIZE_WARNING_THRESHOLD) { - snipeData.sendMessage(ChatColor.RED + "WARNING: Large brush size selected!"); - } - } - - /** - * Display toggle lightning message. - */ - public void toggleLightning() { - snipeData.sendMessage(ChatColor.GOLD + "Lightning mode has been toggled " + ChatColor.DARK_RED + ((snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).isLightningEnabled()) ? "on" : "off")); - } - - /** - * Display toggle printout message. - */ - public final void togglePrintout() { - snipeData.sendMessage(ChatColor.GOLD + "Brush info printout mode has been toggled " + ChatColor.DARK_RED + ((snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).isLightningEnabled()) ? "on" : "off")); - } - - /** - * Display toggle range message. - */ - public void toggleRange() { - snipeData.sendMessage(ChatColor.GOLD + "Distance Restriction toggled " + ChatColor.DARK_RED + ((snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).isRanged()) ? "on" : "off") + ChatColor.GOLD + ". Range is " + ChatColor.LIGHT_PURPLE + (double) snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).getRange()); - } - - /** - * Display voxel type. - */ - @SuppressWarnings("deprecation") - public void voxel() { - snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + BlockTypes.get(snipeData.getVoxelId())); - } - - /** - * Display voxel list. - */ - public void voxelList() { - if (snipeData.getVoxelList().isEmpty()) { - snipeData.sendMessage(ChatColor.DARK_GREEN + "No blocks selected!"); - } else { - String returnValueBuilder = ChatColor.DARK_GREEN + "Block Types Selected: " + ChatColor.AQUA - + snipeData.getVoxelList(); - snipeData.sendMessage(returnValueBuilder); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/PaintingWrapper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/PaintingWrapper.java deleted file mode 100644 index 94eb54c57..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/PaintingWrapper.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.thevoxelbox.voxelsniper; - -import org.bukkit.Art; -import org.bukkit.ChatColor; -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Painting; -import org.bukkit.entity.Player; - -/** - * Painting state change handler. - * - * @author Piotr - */ -public final class PaintingWrapper { - - private PaintingWrapper() { - } - - - /** - * The paint method used to scroll or set a painting to a specific type. - * - * @param p The player executing the method - * @param auto Scroll automatically? If false will use 'choice' to try and set the painting - * @param back Scroll in reverse? - * @param choice Chosen index to set the painting to - */ - @SuppressWarnings("deprecation") - public static void paint(final Player p, final boolean auto, final boolean back, final int choice) { - Location targetLocation = p.getTargetBlock(null, 4).getLocation(); - Chunk paintingChunk = p.getTargetBlock(null, 4).getLocation().getChunk(); - - Double bestDistanceMatch = 50D; - Painting bestMatch = null; - - for (Entity entity : paintingChunk.getEntities()) { - if (entity.getType() == EntityType.PAINTING) { - Double distance = targetLocation.distanceSquared(entity.getLocation()); - - if (distance <= 4 && distance < bestDistanceMatch) { - bestDistanceMatch = distance; - bestMatch = (Painting) entity; - } - } - } - - if (bestMatch != null) { - if (auto) { - try { - final int i = bestMatch.getArt().getId() + (back ? -1 : 1); - Art art = Art.getById(i); - - if (art == null) { - p.sendMessage(ChatColor.RED + "This is the final painting, try scrolling to the other direction."); - return; - } - - bestMatch.setArt(art); - p.sendMessage(ChatColor.GREEN + "Painting set to ID: " + (i)); - } catch (final Exception e) { - p.sendMessage(ChatColor.RED + "Oops. Something went wrong."); - } - } else { - try { - Art art = Art.getById(choice); - - bestMatch.setArt(art); - p.sendMessage(ChatColor.GREEN + "Painting set to ID: " + choice); - } catch (final Exception exception) { - p.sendMessage(ChatColor.RED + "Your input was invalid somewhere."); - } - } - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java deleted file mode 100644 index 4dd725463..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - This file is part of VoxelSniper, licensed under the MIT License (MIT). - - Copyright (c) The VoxelBox - Copyright (c) contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - */ -package com.thevoxelbox.voxelsniper; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.boydti.fawe.bukkit.wrapper.AsyncWorld; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -public class RangeBlockHelper { - private static final int MAXIMUM_WORLD_HEIGHT = 255; - private static final double DEFAULT_PLAYER_VIEW_HEIGHT = 1.65D; - private static final double DEFAULT_LOCATION_VIEW_HEIGHT = 0.0D; - private static final double DEFAULT_STEP = 0.2D; - private static final int DEFAULT_RANGE = 250; - private Location playerLoc; - private double rotX; - private double rotY; - private double rotXSin; - private double rotXCos; - private double rotYSin; - private double rotYCos; - private double length; - private double hLength; - private double step; - private double range; - private double playerX; - private double playerY; - private double playerZ; - private double xOffset; - private double yOffset; - private double zOffset; - private int lastX; - private int lastY; - private int lastZ; - private int targetX; - private int targetY; - private int targetZ; - private AsyncWorld world; - - public RangeBlockHelper(Location location) { - this.init(location, 250.0D, 0.2D, 0.0D); - } - - public RangeBlockHelper(Location location, int range, double step) { - this.world = (AsyncWorld) location.getWorld(); - this.init(location, range, step, 0.0D); - } - - public RangeBlockHelper(Player player, int range, double step) { - if (player != null) { - this.world = VoxelSniper.getInstance().getSniperManager().getSniperForPlayer(player).getWorld(); - } - this.init(player.getLocation(), range, step, 1.65D); - } - - public RangeBlockHelper(Player player, AsyncWorld world) { - if (player != null && (world == null || player.getWorld().getName().equals(world.getName()))) { - this.world = VoxelSniper.getInstance().getSniperManager().getSniperForPlayer(player).getWorld(); - } else { - this.world = world; - } - this.init(player.getLocation(), 250.0D, 0.2D, 1.65D); - } - - public RangeBlockHelper(Player player, AsyncWorld world, double range) { - if (player != null && (world == null || player.getWorld().getName().equals(world.getName()))) { - this.world = VoxelSniper.getInstance().getSniperManager().getSniperForPlayer(player).getWorld(); - } else { - this.world = world; - } - this.init(player.getLocation(), range, 0.2D, 1.65D); - this.fromOffworld(); - } - - public final void fromOffworld() { - if(this.targetY <= 255) { - if(this.targetY < 0) { - while(this.targetY < 0 && this.length <= this.range) { - this.lastX = this.targetX; - this.lastY = this.targetY; - this.lastZ = this.targetZ; - - while(true) { - this.length += this.step; - this.hLength = this.length * this.rotYCos; - this.yOffset = this.length * this.rotYSin; - this.xOffset = this.hLength * this.rotXCos; - this.zOffset = this.hLength * this.rotXSin; - this.targetX = (int)Math.floor(this.xOffset + this.playerX); - this.targetY = (int)Math.floor(this.yOffset + this.playerY); - this.targetZ = (int)Math.floor(this.zOffset + this.playerZ); - if(this.length > this.range || this.targetX != this.lastX || this.targetY != this.lastY || this.targetZ != this.lastZ) { - break; - } - } - } - } - } else { - while(this.targetY > 255 && this.length <= this.range) { - this.lastX = this.targetX; - this.lastY = this.targetY; - this.lastZ = this.targetZ; - - while(true) { - this.length += this.step; - this.hLength = this.length * this.rotYCos; - this.yOffset = this.length * this.rotYSin; - this.xOffset = this.hLength * this.rotXCos; - this.zOffset = this.hLength * this.rotXSin; - this.targetX = (int)Math.floor(this.xOffset + this.playerX); - this.targetY = (int)Math.floor(this.yOffset + this.playerY); - this.targetZ = (int)Math.floor(this.zOffset + this.playerZ); - if(this.length > this.range || this.targetX != this.lastX || this.targetY != this.lastY || this.targetZ != this.lastZ) { - break; - } - } - } - } - - } - - public final AsyncBlock getCurBlock() { - return this.length <= this.range && this.targetY <= 255 && this.targetY >= 0?this.world.getBlockAt(this.targetX, this.targetY, this.targetZ):null; - } - - private boolean isAir(Material m) { - switch (m) { - case AIR: - case CAVE_AIR: - case VOID_AIR: - return true; - default: - return false; - } - } - - public final AsyncBlock getFaceBlock() { - while(this.getNextBlock() != null && isAir(this.getCurBlock().getType())) { - } - - if(this.getCurBlock() != null) { - return this.getLastBlock(); - } else { - return null; - } - } - - public final AsyncBlock getLastBlock() { - return this.lastY <= 255 && this.lastY >= 0?this.world.getBlockAt(this.lastX, this.lastY, this.lastZ):null; - } - - public final AsyncBlock getNextBlock() { - this.lastX = this.targetX; - this.lastY = this.targetY; - this.lastZ = this.targetZ; - - do { - this.length += this.step; - this.hLength = this.length * this.rotYCos; - this.yOffset = this.length * this.rotYSin; - this.xOffset = this.hLength * this.rotXCos; - this.zOffset = this.hLength * this.rotXSin; - this.targetX = (int)Math.floor(this.xOffset + this.playerX); - this.targetY = (int)Math.floor(this.yOffset + this.playerY); - this.targetZ = (int)Math.floor(this.zOffset + this.playerZ); - } while(this.length <= this.range && this.targetX == this.lastX && this.targetY == this.lastY && this.targetZ == this.lastZ); - - return this.length <= this.range && this.targetY <= 255 && this.targetY >= 0?this.world.getBlockAt(this.targetX, this.targetY, this.targetZ):null; - } - - public final AsyncBlock getRangeBlock() { - this.fromOffworld(); - return this.length > this.range?null:this.getRange(); - } - - public final AsyncBlock getTargetBlock() { - this.fromOffworld(); - - while(this.getNextBlock() != null && isAir(this.getCurBlock().getType())) { - } - - return this.getCurBlock(); - } - - private AsyncBlock getRange() { - this.lastX = this.targetX; - this.lastY = this.targetY; - this.lastZ = this.targetZ; - - do { - this.length += this.step; - this.hLength = this.length * this.rotYCos; - this.yOffset = this.length * this.rotYSin; - this.xOffset = this.hLength * this.rotXCos; - this.zOffset = this.hLength * this.rotXSin; - this.targetX = (int)Math.floor(this.xOffset + this.playerX); - this.targetY = (int)Math.floor(this.yOffset + this.playerY); - this.targetZ = (int)Math.floor(this.zOffset + this.playerZ); - } while(this.length <= this.range && this.targetX == this.lastX && this.targetY == this.lastY && this.targetZ == this.lastZ); - - AsyncBlock block = world.getBlockAt(this.targetX, this.targetY, this.targetZ); - Material type = block.getType(); - return !isAir(type) ? block : - this.length <= this.range && this.targetY <= 255 && this.targetY >= 0?this.getRange():this.world.getBlockAt(this.lastX, this.lastY, this.lastZ); - } - - private void init(Location location, double range, double step, double viewHeight) { - this.playerLoc = location; - this.playerX = this.playerLoc.getX(); - this.playerY = this.playerLoc.getY() + viewHeight; - this.playerZ = this.playerLoc.getZ(); - this.range = range; - this.step = step; - this.length = 0.0D; - this.rotX = (this.playerLoc.getYaw() + 90.0F) % 360.0F; - this.rotY = this.playerLoc.getPitch() * -1.0f; - this.rotYCos = Math.cos(Math.toRadians(this.rotY)); - this.rotYSin = Math.sin(Math.toRadians(this.rotY)); - this.rotXCos = Math.cos(Math.toRadians(this.rotX)); - this.rotXSin = Math.sin(Math.toRadians(this.rotX)); - this.targetX = (int)Math.floor(this.playerLoc.getX()); - this.targetY = (int)Math.floor(this.playerLoc.getY() + viewHeight); - this.targetZ = (int)Math.floor(this.playerLoc.getZ()); - this.lastX = this.targetX; - this.lastY = this.targetY; - this.lastZ = this.targetZ; - } - - public static Class inject() { - return RangeBlockHelper.class; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeAction.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeAction.java deleted file mode 100644 index 1a11e4221..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeAction.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.thevoxelbox.voxelsniper; - -public enum SnipeAction { - ARROW, GUNPOWDER -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeData.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeData.java deleted file mode 100644 index ef4d2e9ba..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeData.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - This file is part of VoxelSniper, licensed under the MIT License (MIT). - - Copyright (c) The VoxelBox - Copyright (c) contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - */ -package com.thevoxelbox.voxelsniper; - -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.util.VoxelList; -import org.bukkit.ChatColor; -import org.bukkit.World; -import org.bukkit.entity.Player; - -public class SnipeData { - - public static final int DEFAULT_REPLACE_DATA_VALUE = 0; - public static final int DEFAULT_CYLINDER_CENTER = 0; - public static final int DEFAULT_VOXEL_HEIGHT = 1; - public static final int DEFAULT_BRUSH_SIZE = 3; - public static final int DEFAULT_DATA_VALUE = 0; - public static final int DEFAULT_REPLACE_ID = BlockTypes.AIR.getInternalId(); - public static final int DEFAULT_VOXEL_ID = BlockTypes.AIR.getInternalId(); - - private final Sniper owner; - private Message voxelMessage; - /** - * Brush size -- set blockPositionY /b #. - */ - private int brushSize = SnipeData.DEFAULT_BRUSH_SIZE; - /** - * Voxel Id -- set blockPositionY /v (#,name). - */ - private int voxelId = SnipeData.DEFAULT_VOXEL_ID; - /** - * Voxel Replace Id -- set blockPositionY /vr #. - */ - private int replaceId = SnipeData.DEFAULT_REPLACE_ID; - /** - * Voxel 'ink' -- set blockPositionY /vi #. - */ - private int data = SnipeData.DEFAULT_DATA_VALUE; - /** - * Voxel 'ink' Replace -- set blockPositionY /vir #. - */ - private int replaceData = SnipeData.DEFAULT_REPLACE_DATA_VALUE; - /** - * Voxel List of ID's -- set blockPositionY /vl # # # -#. - */ - private VoxelList voxelList = new VoxelList(); - /** - * Voxel 'heigth' -- set blockPositionY /vh #. - */ - private int voxelHeight = SnipeData.DEFAULT_VOXEL_HEIGHT; - /** - * Voxel centroid -- set Cylinder center /vc #. - */ - private int cCen = SnipeData.DEFAULT_CYLINDER_CENTER; - private int range = 0; - private boolean ranged = false; - private boolean lightning = false; - private Extent extent; - private Pattern pattern; - private String patternInfo; - - public SnipeData(final Sniper vs) { - this.owner = vs; - } - - /** - * Get the extent currently being used to set blocks - * @return - */ - public Extent getExtent() { - return extent; - } - - /** - * Set the extent currently being used to set blocks - * @param extent - */ - public void setExtent(Extent extent) { - this.extent = extent; - } - - public void setPattern(Pattern pattern, String info) { - if (pattern != null) { - if (info == null) info = ""; - } else { - info = null; - } - this.pattern = pattern; - this.patternInfo = info; - } - - public Pattern getPattern() { - return pattern; - } - - public String getPatternInfo() { - return patternInfo; - } - - /** - * @return the brushSize - */ - public final int getBrushSize() { - return this.brushSize; - } - - /** - * @return the cCen - */ - public final int getcCen() { - return this.cCen; - } - - /** - * @return the data - */ - public final int getPropertyId() { - return this.data; - } - - /** - * @return the replaceData - */ - public final int getReplaceData() { - return this.replaceData; - } - - /** - * @return the replaceId - */ - public final int getReplaceId() { - return this.replaceId; - } - - /** - * @return the voxelHeight - */ - public final int getVoxelHeight() { - return this.voxelHeight; - } - - /** - * @return the voxelId - */ - public final int getVoxelId() { - return this.voxelId; - } - - /** - * @return the voxelList - */ - public final VoxelList getVoxelList() { - return this.voxelList; - } - - /** - * @return the voxelMessage - */ - public final Message getVoxelMessage() { - return this.voxelMessage; - } - - /** - * @return World - */ - public final World getWorld() { - return this.owner.getWorld(); // Changed - } - - /** - * @return Sniper - */ - public final Sniper owner() { - return this.owner; - } - - /** - * Reset to default values. - */ - public final void reset() { - this.voxelId = SnipeData.DEFAULT_VOXEL_ID; - this.replaceId = SnipeData.DEFAULT_REPLACE_ID; - this.data = SnipeData.DEFAULT_DATA_VALUE; - this.brushSize = SnipeData.DEFAULT_BRUSH_SIZE; - this.voxelHeight = SnipeData.DEFAULT_VOXEL_HEIGHT; - this.cCen = SnipeData.DEFAULT_CYLINDER_CENTER; - this.replaceData = SnipeData.DEFAULT_REPLACE_DATA_VALUE; - this.voxelList = new VoxelList(); - } - - public final void sendMessage(final String message) { - this.owner.getPlayer().sendMessage(message); - } - - /** - * @param brushSize the brushSize to set - */ - public final void setBrushSize(final int brushSize) { - this.brushSize = brushSize; - } - - /** - * @param cCen the cCen to set - */ - public final void setcCen(final int cCen) { - this.cCen = cCen; - } - - /** - * @param data the data to set - */ - public final void setData(final int data) { - this.data = data; - } - - /** - * @param replaceData the replaceData to set - */ - public final void setReplaceData(final int replaceData) { - this.replaceData = replaceData; - } - - /** - * @param replaceId the replaceId to set - */ - public final void setReplaceId(final int replaceId) { - this.replaceId = replaceId; - } - - /** - * @param voxelHeight the voxelHeight to set - */ - public final void setVoxelHeight(final int voxelHeight) { - this.voxelHeight = voxelHeight; - } - - /** - * @param voxelId the voxelId to set - */ - public final void setVoxelId(final int voxelId) { - if (WorldEdit.getInstance().getConfiguration().checkDisallowedBlocks(BlockTypes.getFromStateId(voxelId).getDefaultState())) { - if (owner != null) { - Player plr = owner.getPlayer(); - if (plr != null) { - plr.sendMessage(ChatColor.RED + "You are not allowed to use '" + voxelId + "'"); - return; - } - } - } - this.voxelId = voxelId; - } - - /** - * @param voxelList the voxelList to set - */ - public final void setVoxelList(final VoxelList voxelList) { - this.voxelList = voxelList; - } - - /** - * @param voxelMessage the voxelMessage to set - */ - public final void setVoxelMessage(final Message voxelMessage) { - this.voxelMessage = voxelMessage; - } - - public int getRange() { - return range; - } - - public void setRange(int range) { - this.range = range; - } - - public boolean isRanged() { - return ranged; - } - - public void setRanged(boolean ranged) { - this.ranged = ranged; - } - - public boolean isLightningEnabled() { - return lightning; - } - - public void setLightningEnabled(boolean lightning) { - this.lightning = lightning; - } - - public static Class inject() { - return SnipeData.class; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java deleted file mode 100644 index 41fce3f5d..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java +++ /dev/null @@ -1,653 +0,0 @@ -/* - This file is part of VoxelSniper, licensed under the MIT License (MIT). - - Copyright (c) The VoxelBox - Copyright (c) contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - */ - -package com.thevoxelbox.voxelsniper; - -import com.boydti.fawe.Fawe; -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.boydti.fawe.bukkit.wrapper.AsyncWorld; -import com.boydti.fawe.config.BBC; -import com.boydti.fawe.config.Settings; -import com.boydti.fawe.logging.LoggingChangeSet; -import com.boydti.fawe.object.*; -import com.boydti.fawe.object.changeset.FaweChangeSet; -import com.boydti.fawe.object.extent.ResettableExtent; -import com.boydti.fawe.object.extent.SourceMaskExtent; -import com.boydti.fawe.object.queue.FaweQueueDelegateExtent; -import com.boydti.fawe.util.MaskTraverser; -import com.boydti.fawe.util.SetQueue; -import com.boydti.fawe.util.TaskManager; -import com.boydti.fawe.util.WEManager; -import com.google.common.base.Preconditions; -import com.google.common.collect.*; -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.extent.MaskingExtent; -import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.mask.Masks; -import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.session.request.Request; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.brush.IBrush; -import com.thevoxelbox.voxelsniper.brush.JockeyBrush; -import com.thevoxelbox.voxelsniper.brush.SnipeBrush; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import com.thevoxelbox.voxelsniper.brush.perform.Performer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.block.Action; -import org.bukkit.plugin.PluginManager; - -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -public class Sniper { - private final UUID player; - private boolean enabled = true; -// private LinkedList undoList = new LinkedList<>(); - private Map tools = new HashMap<>(); - - public Sniper(VoxelSniper plugin, Player player) { - Preconditions.checkNotNull(plugin); - Preconditions.checkNotNull(player); - this.player = player.getUniqueId(); - SniperTool sniperTool = new SniperTool(this); - sniperTool.assignAction(SnipeAction.ARROW, Material.ARROW); - sniperTool.assignAction(SnipeAction.GUNPOWDER, Material.GUNPOWDER); - tools.put(null, sniperTool); - } - - public String getCurrentToolId() { - return getToolId(getPlayer().getInventory().getItemInMainHand().getType()); - } - - public String getToolId(Material itemInHand) { - if (itemInHand == null) { - return null; - } - - for (Map.Entry entry : tools.entrySet()) { - if (entry.getValue().hasToolAssigned(itemInHand)) { - return entry.getKey(); - } - } - return null; - } - - // Added - private AsyncWorld permanentWorld; - - public void storeUndo(Undo undo) { - } - - // Added - public AsyncWorld getWorld() { - AsyncWorld world = permanentWorld; - if (world == null) { - Player bukkitPlayer = getPlayer(); - World bukkitWorld = bukkitPlayer.getWorld(); - world = AsyncWorld.wrap(bukkitWorld); - permanentWorld = world; - } - return world; - } - - public Player getPlayer() { - return Bukkit.getPlayer(player); - } - - /** - * Sniper execution call. - * - * @param action Action player performed - * @param itemInHand Item in hand of player - * @param clickedBlock Block that the player targeted/interacted with - * @param clickedFace Face of that targeted Block - * @return true if command visibly processed, false otherwise. - */ - public boolean snipe(final Action action, final Material itemInHand, final Block clickedBlock, final BlockFace clickedFace) { - switch (action) { - case LEFT_CLICK_AIR: - case LEFT_CLICK_BLOCK: - case RIGHT_CLICK_AIR: - case RIGHT_CLICK_BLOCK: - break; - default: - return false; - } - if (tools.isEmpty()) { - return false; - } - String toolId = getToolId(itemInHand); - SniperTool sniperTool = tools.get(toolId); - if (sniperTool == null) { - return false; - } - if (!sniperTool.hasToolAssigned(itemInHand)) { - return false; - } - if (sniperTool.getCurrentBrush() == null) { - getPlayer().sendMessage("No Brush selected."); - return false; - } - try { - Player player = getPlayer(); - final FawePlayer fp = FawePlayer.wrap(player); - TaskManager.IMP.taskNow(() -> { - if (!fp.runAction( - () -> snipeOnCurrentThread(fp, action, itemInHand, clickedBlock, clickedFace, sniperTool, toolId), false, true)) { - BBC.WORLDEDIT_COMMAND_LIMIT.send(fp); - } - }, Fawe.isMainThread()); - return true; - } catch (Throwable e) { - e.printStackTrace(); - } - return false; - } - - // Old method (plus world arg) - public synchronized boolean snipeOnCurrentThread(FawePlayer fp, final Action action, final Material itemInHand, Block clickedBlock, final BlockFace clickedFace, SniperTool sniperTool, String toolId) { - try { - Player bukkitPlayer = getPlayer(); - World bukkitWorld = bukkitPlayer.getWorld(); - - FaweQueue baseQueue = fp.getFaweQueue(false); - Region[] mask = WEManager.IMP.getMask(fp); - if (mask.length == 0) { - BBC.NO_REGION.send(fp); - return false; - } - MaskedFaweQueue maskQueue = new MaskedFaweQueue(baseQueue, mask); - com.sk89q.worldedit.world.World worldEditWorld = fp.getWorld(); - FaweChangeSet changeSet = FaweChangeSet.getDefaultChangeSet(worldEditWorld, fp.getUUID()); - if (Fawe.imp().getBlocksHubApi() != null) { - changeSet = LoggingChangeSet.wrap(fp, changeSet); - } - FaweQueue changeQueue; - if (Settings.IMP.HISTORY.COMBINE_STAGES) { - changeQueue = maskQueue; - changeSet.addChangeTask(baseQueue); - } else { - changeQueue = new ChangeSetFaweQueue(changeSet, maskQueue); - } - LocalSession session = fp.getSession(); - // Set mask etc - Mask destMask = session.getMask(); - if (!Masks.isNull(destMask)) { - new MaskTraverser(destMask).reset(changeQueue); - changeQueue = new FaweQueueDelegateExtent(changeQueue, new MaskingExtent(changeQueue, destMask)); - } - Mask sourceMask = session.getSourceMask(); - if (!Masks.isNull(sourceMask)) { - new MaskTraverser(sourceMask).reset(changeQueue); - changeQueue = new FaweQueueDelegateExtent(changeQueue, new SourceMaskExtent(changeQueue, sourceMask)); - } - ResettableExtent transform = session.getTransform(); - if (transform != null) { - transform.setExtent(changeQueue); - changeQueue = new FaweQueueDelegateExtent(changeQueue, transform); - } - - AsyncWorld world = getWorld(); - world.changeWorld(bukkitWorld, changeQueue); - - AsyncBlock asyncBlock = null; - if (clickedBlock != null) { - asyncBlock = world.getBlockAt(clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ()); - } - if (!getPlayer().hasPermission(sniperTool.getCurrentBrush().getPermissionNode())) { - getPlayer().sendMessage("You are not allowed to use this brush. You're missing the permission node '" + sniperTool.getCurrentBrush().getPermissionNode() + "'"); - return true; - } - - final SnipeData snipeData = sniperTool.getSnipeData(); - if (getPlayer().isSneaking()) { - AsyncBlock targetBlock; - SnipeAction snipeAction = sniperTool.getActionAssigned(itemInHand); - - switch (action) { - case LEFT_CLICK_BLOCK: - case LEFT_CLICK_AIR: - if (asyncBlock != null) { - targetBlock = asyncBlock; - } else { - RangeBlockHelper rangeBlockHelper = snipeData.isRanged() ? new RangeBlockHelper(getPlayer(), world, snipeData.getRange()) : new RangeBlockHelper(getPlayer(), world); - targetBlock = snipeData.isRanged() ? rangeBlockHelper.getRangeBlock() : rangeBlockHelper.getTargetBlock(); - } - - switch (snipeAction) { - case ARROW: - if (targetBlock != null) { - int originalVoxel = snipeData.getVoxelId(); - snipeData.setVoxelId(targetBlock.getTypeId()); -// SniperMaterialChangedEvent event = new SniperMaterialChangedEvent(this, toolId, BukkitAdapter.adapt(BlockState.get((originalVoxel << BlockTypes.BIT_OFFSET) + snipeData.getPropertyId())), BukkitAdapter.adapt(BlockState.get(snipeData.getVoxelId() + snipeData.getPropertyId()))); -// callEvent(event); - snipeData.getVoxelMessage().voxel(); - return true; - } else { - int originalVoxel = snipeData.getVoxelId(); - snipeData.setVoxelId(BlockTypes.AIR.getInternalId()); -// SniperMaterialChangedEvent event = new SniperMaterialChangedEvent(this, toolId, BukkitAdapter.adapt(BlockState.get((originalVoxel << BlockTypes.BIT_OFFSET) + snipeData.getPropertyId())), BukkitAdapter.adapt(BlockState.get(snipeData.getVoxelId() + snipeData.getPropertyId()))); -// callEvent(event); - snipeData.getVoxelMessage().voxel(); - return true; - } - case GUNPOWDER: - if (targetBlock != null) { - int originalData = snipeData.getPropertyId(); - snipeData.setData(targetBlock.getPropertyId()); -// SniperMaterialChangedEvent event = new SniperMaterialChangedEvent(this, toolId, BukkitAdapter.adapt(BlockState.get(snipeData.getVoxelId() + originalData)), BukkitAdapter.adapt(BlockState.get(snipeData.getVoxelId() + snipeData.getPropertyId()))); -// callEvent(event); - snipeData.getVoxelMessage().data(); - return true; - } else { - int originalData = snipeData.getPropertyId(); - snipeData.setData(0); -// SniperMaterialChangedEvent event = new SniperMaterialChangedEvent(this, toolId, BukkitAdapter.adapt(BlockState.get(snipeData.getVoxelId() + originalData)), BukkitAdapter.adapt(BlockState.get(snipeData.getVoxelId() + snipeData.getPropertyId()))); -// callEvent(event); - snipeData.getVoxelMessage().data(); - return true; - } - default: - break; - } - break; - case RIGHT_CLICK_AIR: - case RIGHT_CLICK_BLOCK: - if (asyncBlock != null) { - targetBlock = asyncBlock; - } else { - RangeBlockHelper rangeBlockHelper = snipeData.isRanged() ? new RangeBlockHelper(getPlayer(), world, snipeData.getRange()) : new RangeBlockHelper(getPlayer(), world); - targetBlock = snipeData.isRanged() ? rangeBlockHelper.getRangeBlock() : rangeBlockHelper.getTargetBlock(); - } - - switch (snipeAction) { - case ARROW: - if (targetBlock != null) { - int originalId = snipeData.getReplaceId(); - snipeData.setReplaceId(targetBlock.getTypeId()); -// SniperReplaceMaterialChangedEvent event = new SniperReplaceMaterialChangedEvent(this, toolId, BukkitAdapter.adapt(BlockState.get((originalId << BlockTypes.BIT_OFFSET) + snipeData.getReplaceData())), BukkitAdapter.adapt(BlockState.get((snipeData.getReplaceId() << BlockTypes.BIT_OFFSET) + snipeData.getReplaceData()))); -// callEvent(event); - snipeData.getVoxelMessage().replace(); - return true; - } else { - int originalId = snipeData.getReplaceId(); - snipeData.setReplaceId(BlockTypes.AIR.getInternalId()); -// SniperReplaceMaterialChangedEvent event = new SniperReplaceMaterialChangedEvent(this, toolId, BukkitAdapter.adapt(BlockState.get((originalId << BlockTypes.BIT_OFFSET) + snipeData.getReplaceData())), BukkitAdapter.adapt(BlockState.get((snipeData.getReplaceId() << BlockTypes.BIT_OFFSET) + snipeData.getReplaceData()))); -// callEvent(event); - snipeData.getVoxelMessage().replace(); - return true; - } - case GUNPOWDER: - if (targetBlock != null) { - int originalData = snipeData.getReplaceData(); - snipeData.setReplaceData(targetBlock.getPropertyId()); -// SniperReplaceMaterialChangedEvent event = new SniperReplaceMaterialChangedEvent(this, toolId, BukkitAdapter.adapt(BlockState.get((snipeData.getReplaceId() << BlockTypes.BIT_OFFSET) + originalData)), BukkitAdapter.adapt(BlockState.get((snipeData.getReplaceId() << BlockTypes.BIT_OFFSET) + snipeData.getReplaceData()))); -// callEvent(event); - snipeData.getVoxelMessage().replaceData(); - return true; - } else { - int originalData = snipeData.getReplaceData(); - snipeData.setReplaceData(0); -// SniperReplaceMaterialChangedEvent event = new SniperReplaceMaterialChangedEvent(this, toolId, BukkitAdapter.adapt(BlockState.get((snipeData.getReplaceId() << BlockTypes.BIT_OFFSET) + originalData)), BukkitAdapter.adapt(BlockState.get((snipeData.getReplaceId() << BlockTypes.BIT_OFFSET) + snipeData.getReplaceData()))); -// callEvent(event); - snipeData.getVoxelMessage().replaceData(); - return true; - } - default: - break; - } - break; - default: - return false; - } - } else { - final AsyncBlock targetBlock; - final AsyncBlock lastBlock; - final SnipeAction snipeAction = sniperTool.getActionAssigned(itemInHand); - - switch (action) { - case RIGHT_CLICK_AIR: - case RIGHT_CLICK_BLOCK: - break; - default: - return false; - } - - if (asyncBlock != null) { - targetBlock = asyncBlock; - lastBlock = asyncBlock.getRelative(clickedFace); - if (lastBlock == null || targetBlock == null) { - getPlayer().sendMessage(ChatColor.RED + "Snipe target block must be visible."); - return true; - } - } else { - RangeBlockHelper rangeBlockHelper = snipeData.isRanged() ? new RangeBlockHelper(getPlayer(), world, snipeData.getRange()) : new RangeBlockHelper(getPlayer(), world); - targetBlock = snipeData.isRanged() ? rangeBlockHelper.getRangeBlock() : rangeBlockHelper.getTargetBlock(); - lastBlock = rangeBlockHelper.getLastBlock(); - - if (targetBlock == null || lastBlock == null) { - getPlayer().sendMessage(ChatColor.RED + "Snipe target block must be visible."); - return true; - } - } - - final IBrush brush = sniperTool.getCurrentBrush(); - - try { - snipeData.setExtent(world); - Request.reset(); - Request.request().setExtent(world); - if (brush instanceof JockeyBrush) { - TaskManager.IMP.sync(new RunnableVal() { - @Override - public void run(Object value) { - brush.perform(snipeAction, snipeData, targetBlock, lastBlock); - } - }); - } else { - if (sniperTool.getCurrentBrush() instanceof PerformBrush) { - PerformBrush performerBrush = (PerformBrush) sniperTool.getCurrentBrush(); - performerBrush.initP(snipeData); - } - brush.perform(snipeAction, snipeData, targetBlock, lastBlock); - } - } finally { - snipeData.setExtent(null); - Request.reset(); - } - if (Fawe.isMainThread()) { - SetQueue.IMP.flush(changeQueue); - } else { - changeQueue.flush(); - } - if (Settings.IMP.HISTORY.COMBINE_STAGES) { - changeSet.closeAsync(); - } else { - changeSet.close(); - } - session.remember(changeSet.toEditSession(fp)); - return true; - } - return false; - } catch (Throwable e) { - e.printStackTrace(); - } - return false; - } - - private void callEvent(Event event) { - if (Fawe.isMainThread()) { - Bukkit.getPluginManager().callEvent(event); - } else { - if (event.isAsynchronous()) { - Bukkit.getPluginManager().callEvent(event); - } else { - try { - PluginManager plm = Bukkit.getPluginManager(); - Class clazz = plm.getClass(); - Method methodFireEvent = clazz.getDeclaredMethod("fireEvent", Event.class); - methodFireEvent.setAccessible(true); - methodFireEvent.invoke(plm, event); - } catch (Throwable ignore) {} - } - } - } - - public IBrush setBrush(String toolId, Class brush) { - if (!tools.containsKey(toolId)) { - return null; - } - - return tools.get(toolId).setCurrentBrush(brush); - } - - public IBrush getBrush(String toolId) { - if (!tools.containsKey(toolId)) { - return null; - } - - return tools.get(toolId).getCurrentBrush(); - } - - public IBrush previousBrush(String toolId) { - if (!tools.containsKey(toolId)) { - return null; - } - - return tools.get(toolId).previousBrush(); - } - - public boolean setTool(String toolId, SnipeAction action, Material itemInHand) { - for (Map.Entry entry : tools.entrySet()) { - if (entry.getKey() != toolId && entry.getValue().hasToolAssigned(itemInHand)) { - return false; - } - } - - if (!tools.containsKey(toolId)) { - SniperTool tool = new SniperTool(this); - tools.put(toolId, tool); - } - tools.get(toolId).assignAction(action, itemInHand); - return true; - } - - public void removeTool(String toolId, Material itemInHand) { - if (!tools.containsKey(toolId)) { - SniperTool tool = new SniperTool(this); - tools.put(toolId, tool); - } - tools.get(toolId).unassignAction(itemInHand); - } - - public void removeTool(String toolId) { - if (toolId == null) { - return; - } - tools.remove(toolId); - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public void undo() { - undo(1); - } - - public void undo(int amount) { - FawePlayer fp = FawePlayer.wrap(getPlayer()); - int count = 0; - for (int i = 0; i < amount; i++) { - EditSession es = fp.getSession().undo(null, fp.getPlayer()); - if (es == null) { - break; - } else { - es.flushQueue(); - } - count++; - } - if (count > 0) { - BBC.COMMAND_UNDO_SUCCESS.send(fp, count == 1 ? "" : " x" + count); - } else { - BBC.COMMAND_UNDO_ERROR.send(fp); - } - } - - public void reset(String toolId) { - SniperTool backup = tools.remove(toolId); - SniperTool newTool = new SniperTool(this); - - for (Map.Entry entry : backup.getActionTools().entrySet()) { - newTool.assignAction(entry.getKey(), entry.getValue()); - } - tools.put(toolId, newTool); - } - - public SnipeData getSnipeData(String toolId) { - return tools.containsKey(toolId) ? tools.get(toolId).getSnipeData() : null; - } - - public void displayInfo() { - String currentToolId = getCurrentToolId(); - SniperTool sniperTool = tools.get(currentToolId); - IBrush brush = sniperTool.getCurrentBrush(); - getPlayer().sendMessage("Current Tool: " + ((currentToolId != null) ? currentToolId : "Default Tool")); - if (brush == null) { - getPlayer().sendMessage("No brush selected."); - return; - } - brush.info(sniperTool.getMessageHelper()); - if (brush instanceof Performer) { - ((Performer) brush).showInfo(sniperTool.getMessageHelper()); - } - } - - public SniperTool getSniperTool(String toolId) { - return tools.get(toolId); - } - - public class SniperTool { - private BiMap actionTools = HashBiMap.create(); - private ClassToInstanceMap brushes = MutableClassToInstanceMap.create(); - private Class currentBrush; - private Class previousBrush; - private SnipeData snipeData; - private Message messageHelper; - - private SniperTool(Sniper owner) { - this(SnipeBrush.class, new SnipeData(owner)); - } - - private SniperTool(Class currentBrush, SnipeData snipeData) { - Preconditions.checkNotNull(currentBrush); - Preconditions.checkNotNull(snipeData); - this.snipeData = snipeData; - messageHelper = new Message(snipeData); - snipeData.setVoxelMessage(messageHelper); - - IBrush newBrushInstance = instantiateBrush(currentBrush); - if (snipeData.owner().getPlayer().hasPermission(newBrushInstance.getPermissionNode())) { - brushes.put(currentBrush, newBrushInstance); - this.currentBrush = currentBrush; - } - } - - public boolean hasToolAssigned(Material material) { - return actionTools.containsValue(material); - } - - public SnipeAction getActionAssigned(Material itemInHand) { - return actionTools.inverse().get(itemInHand); - } - - public Material getToolAssigned(SnipeAction action) { - return actionTools.get(action); - } - - public void assignAction(SnipeAction action, Material itemInHand) { - actionTools.forcePut(action, itemInHand); - } - - public void unassignAction(Material itemInHand) { - actionTools.inverse().remove(itemInHand); - } - - public BiMap getActionTools() { - return ImmutableBiMap.copyOf(actionTools); - } - - public SnipeData getSnipeData() { - return snipeData; - } - - public Message getMessageHelper() { - return messageHelper; - } - - public IBrush getCurrentBrush() { - if (currentBrush == null) { - return null; - } - return brushes.getInstance(currentBrush); - } - - public IBrush setCurrentBrush(Class brush) { - Preconditions.checkNotNull(brush, "Can't set brush to null."); - IBrush brushInstance = brushes.get(brush); - if (brushInstance == null) { - brushInstance = instantiateBrush(brush); - Preconditions.checkNotNull(brushInstance, "Could not instanciate brush class."); - if (snipeData.owner().getPlayer().hasPermission(brushInstance.getPermissionNode())) { - brushes.put(brush, brushInstance); - previousBrush = currentBrush; - currentBrush = brush; - return brushInstance; - } - } - - if (snipeData.owner().getPlayer().hasPermission(brushInstance.getPermissionNode())) { - previousBrush = currentBrush; - currentBrush = brush; - return brushInstance; - } - - return null; - } - - public IBrush previousBrush() { - if (previousBrush == null) { - return null; - } - return setCurrentBrush(previousBrush); - } - - private IBrush instantiateBrush(Class brush) { - try { - return brush.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - return null; - } - } - } - - public static Class inject() { - return Sniper.class; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/SniperManager.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/SniperManager.java deleted file mode 100644 index 2ba2a3b4c..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/SniperManager.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.thevoxelbox.voxelsniper; - -import com.google.common.collect.Maps; -import org.bukkit.entity.Player; - -import java.util.Map; -import java.util.UUID; - -public class SniperManager { - private Map sniperInstances = Maps.newHashMap(); - private VoxelSniper plugin; - - public SniperManager(VoxelSniper plugin) { - this.plugin = plugin; - } - - public Sniper getSniperForPlayer(Player player) { - if (sniperInstances.get(player.getUniqueId()) == null) { - sniperInstances.put(player.getUniqueId(), new Sniper(plugin, player)); - } - return sniperInstances.get(player.getUniqueId()); - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/Undo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/Undo.java deleted file mode 100644 index 7f6f7a2f4..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/Undo.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - This file is part of VoxelSniper, licensed under the MIT License (MIT). - - Copyright (c) The VoxelBox - Copyright (c) contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - */ -package com.thevoxelbox.voxelsniper; - -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.block.BlockState; - -/** - * Holds {@link BlockState}s that can be later on used to reset those block - * locations back to the recorded states. - */ -public class Undo { - - int size; - private World world; - - /** - * Default constructor of a Undo container. - */ - public Undo() {} - - /** - * Get the number of blocks in the collection. - * - * @return size of the Undo collection - */ - public int getSize() { - return size; - } - - /** - * Adds a Block to the collection. - * - * @param block Block to be added - */ - public void put(Block block) { - size++; - } - - - /** - * Set the blockstates of all recorded blocks back to the state when they - * were inserted. - */ - public void undo() { - - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java deleted file mode 100644 index bbed59499..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java +++ /dev/null @@ -1,246 +0,0 @@ -package com.thevoxelbox.voxelsniper; - -import com.boydti.fawe.Fawe; -import com.boydti.fawe.bukkit.BukkitCommand; -import com.boydti.fawe.object.FaweCommand; -import com.boydti.fawe.object.FawePlayer; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.thevoxelbox.voxelsniper.brush.*; -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginManager; -import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Bukkit extension point. - */ -public class VoxelSniper extends JavaPlugin { - private static VoxelSniper instance; - private final VoxelSniperListener voxelSniperListener = new VoxelSniperListener(this); - private SniperManager sniperManager = new SniperManager(this); - private VoxelSniperConfiguration voxelSniperConfiguration; - private Brushes brushManager = new Brushes(); - - /** - * @return {@link VoxelSniper} - */ - public static VoxelSniper getInstance() { - return VoxelSniper.instance; - } - - /** - * Returns {@link com.thevoxelbox.voxelsniper.Brushes} for current instance. - * - * @return Brush Manager for current instance. - */ - public Brushes getBrushManager() { - return brushManager; - } - - /** - * Returns object for accessing global VoxelSniper options. - * - * @return {@link VoxelSniperConfiguration} object for accessing global VoxelSniper options. - */ - public VoxelSniperConfiguration getVoxelSniperConfiguration() { - return voxelSniperConfiguration; - } - - /** - * Returns {@link com.thevoxelbox.voxelsniper.SniperManager} for current instance. - * - * @return SniperManager - */ - public SniperManager getSniperManager() { - return sniperManager; - } - - private static Map lookupNames; - static { - { // Disable BetterBrushes - FAVS includes the features and BetterBrushes is outdated - PluginManager manager = Bukkit.getPluginManager(); - try { - Field pluginsField = manager.getClass().getDeclaredField("plugins"); - Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames"); - pluginsField.setAccessible(true); - lookupNamesField.setAccessible(true); - List plugins = (List) pluginsField.get(manager); - lookupNames = (Map) lookupNamesField.get(manager); - pluginsField.set(manager, new ArrayList(plugins) { - @Override - public boolean add(Plugin plugin) { - if (plugin.getName().startsWith("BetterBrushes")) { - Fawe.debug("Disabling `" + plugin.getName() + "`. FastAsyncVoxelSniper includes all the features."); - } else { - return super.add(plugin); - } - return false; - } - }); - lookupNamesField.set(manager, lookupNames = new ConcurrentHashMap(lookupNames) { - @Override - public Plugin put(@NotNull String key, @NotNull Plugin plugin) { - if (plugin.getName().startsWith("BetterBrushes")) { - return null; - } - return super.put(key, plugin); - } - }); - } catch (Throwable ignore) {} - } - } - - @Override - public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, String commandLabel, @NotNull String[] args) { - if (sender instanceof Player) { - - return voxelSniperListener.onCommand((Player) sender, args, command.getName()); - } - - getLogger().info("Only players can execute VoxelSniper commands."); - return true; - } - - @Override - public void onEnable() { - VoxelSniper.instance = this; - - registerBrushes(); - getLogger().info("Registered " + brushManager.registeredSniperBrushes() + " Sniper Brushes with " + brushManager.registeredSniperBrushHandles() + " handles."); - - saveDefaultConfig(); - voxelSniperConfiguration = new VoxelSniperConfiguration(getConfig()); - - Bukkit.getPluginManager().registerEvents(this.voxelSniperListener, this); - getLogger().info("Registered Sniper Listener."); - - try { - setupCommand("/p", new FaweCommand("voxelsniper.sniper") { - @Override - public boolean execute(FawePlayer fp, String... args) { - Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); - return onCommand(player, new Command("p") { - @Override - public boolean execute(@NotNull CommandSender sender, String commandLabel, @NotNull String[] args) { - return false; - } - }, null, args); - - } - }); - setupCommand("/d", new FaweCommand("voxelsniper.sniper") { - @Override - public boolean execute(FawePlayer fp, String... args) { - Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); - return onCommand(player, new Command("d") { - @Override - public boolean execute(@NotNull CommandSender sender, String commandLabel, @NotNull String[] args) { - return false; - } - }, null, args); - - } - }); - } catch (Throwable ignore) { - } - } - - /** - * Registers all brushes. - */ - public void registerBrushes() { - brushManager.registerSniperBrush(BallBrush.class, "b", "ball"); - brushManager.registerSniperBrush(BiomeBrush.class, "bio", "biome"); - brushManager.registerSniperBrush(BlendBallBrush.class, "bb", "blendball"); - brushManager.registerSniperBrush(BlendDiscBrush.class, "bd", "blenddisc"); - brushManager.registerSniperBrush(BlendVoxelBrush.class, "bv", "blendvoxel"); - brushManager.registerSniperBrush(BlendVoxelDiscBrush.class, "bvd", "blendvoxeldisc"); - brushManager.registerSniperBrush(BlobBrush.class, "blob", "splatblob"); - brushManager.registerSniperBrush(BlockResetBrush.class, "brb", "blockresetbrush"); - brushManager.registerSniperBrush(BlockResetSurfaceBrush.class, "brbs", "blockresetbrushsurface"); - brushManager.registerSniperBrush(CanyonBrush.class, "ca", "canyon"); - brushManager.registerSniperBrush(CanyonSelectionBrush.class, "cas", "canyonselection"); - brushManager.registerSniperBrush(CheckerVoxelDiscBrush.class, "cvd", "checkervoxeldisc"); - brushManager.registerSniperBrush(CleanSnowBrush.class, "cls", "cleansnow"); - brushManager.registerSniperBrush(CloneStampBrush.class, "cs", "clonestamp"); - brushManager.registerSniperBrush(CometBrush.class, "com", "comet"); - brushManager.registerSniperBrush(CopyPastaBrush.class, "cp", "copypasta"); - brushManager.registerSniperBrush(CylinderBrush.class, "c", "cylinder"); - brushManager.registerSniperBrush(DiscBrush.class, "d", "disc"); - brushManager.registerSniperBrush(DiscFaceBrush.class, "df", "discface"); - brushManager.registerSniperBrush(DomeBrush.class, "dome", "domebrush"); - brushManager.registerSniperBrush(DrainBrush.class, "drain"); - brushManager.registerSniperBrush(EllipseBrush.class, "el", "ellipse"); - brushManager.registerSniperBrush(EllipsoidBrush.class, "elo", "ellipsoid"); - brushManager.registerSniperBrush(EntityBrush.class, "en", "entity"); - brushManager.registerSniperBrush(EntityRemovalBrush.class, "er", "entityremoval"); - brushManager.registerSniperBrush(EraserBrush.class, "erase", "eraser"); - brushManager.registerSniperBrush(ErodeBrush.class, "e", "erode"); - brushManager.registerSniperBrush(ErodeBlendBrush.class, "eb", "erodeblend", "erodeblendball"); - brushManager.registerSniperBrush(ExtrudeBrush.class, "ex", "extrude"); - brushManager.registerSniperBrush(FillDownBrush.class, "fd", "filldown"); - brushManager.registerSniperBrush(FlatOceanBrush.class, "fo", "flatocean"); - brushManager.registerSniperBrush(GenerateTreeBrush.class, "gt", "generatetree"); - brushManager.registerSniperBrush(HeatRayBrush.class, "hr", "heatray"); - brushManager.registerSniperBrush(JaggedLineBrush.class, "j", "jagged"); - brushManager.registerSniperBrush(JockeyBrush.class, "jockey"); - brushManager.registerSniperBrush(LightningBrush.class, "light", "lightning"); - brushManager.registerSniperBrush(LineBrush.class, "l", "line"); - brushManager.registerSniperBrush(MoveBrush.class, "mv", "move"); - brushManager.registerSniperBrush(OceanBrush.class, "o", "ocean"); - brushManager.registerSniperBrush(OverlayBrush.class, "over", "overlay"); - brushManager.registerSniperBrush(PaintingBrush.class, "paint", "painting"); - brushManager.registerSniperBrush(PullBrush.class, "pull"); - brushManager.registerSniperBrush(PunishBrush.class, "p", "punish"); - brushManager.registerSniperBrush(RandomErodeBrush.class, "re", "randomerode"); - brushManager.registerSniperBrush(RegenerateChunkBrush.class, "gc", "generatechunk"); - brushManager.registerSniperBrush(RingBrush.class, "ri", "ring"); - brushManager.registerSniperBrush(Rot2DBrush.class, "rot2", "rotation2d"); - brushManager.registerSniperBrush(Rot2DvertBrush.class, "rot2v", "rotation2dvertical"); - brushManager.registerSniperBrush(Rot3DBrush.class, "rot3", "rotation3d"); - brushManager.registerSniperBrush(RulerBrush.class, "r", "ruler"); - brushManager.registerSniperBrush(ScannerBrush.class, "sc", "scanner"); - brushManager.registerSniperBrush(SetBrush.class, "set"); - brushManager.registerSniperBrush(SetRedstoneFlipBrush.class, "setrf", "setredstoneflip"); - brushManager.registerSniperBrush(ShellBallBrush.class, "shb", "shellball"); - brushManager.registerSniperBrush(ShellSetBrush.class, "shs", "shellset"); - brushManager.registerSniperBrush(ShellVoxelBrush.class, "shv", "shellvoxel"); - brushManager.registerSniperBrush(SignOverwriteBrush.class, "sio", "signoverwriter"); - brushManager.registerSniperBrush(SnipeBrush.class, "s", "snipe"); - brushManager.registerSniperBrush(SnowConeBrush.class, "snow", "snowcone"); - brushManager.registerSniperBrush(SpiralStaircaseBrush.class, "sstair", "spiralstaircase"); - brushManager.registerSniperBrush(SplatterBallBrush.class, "sb", "splatball"); - brushManager.registerSniperBrush(SplatterDiscBrush.class, "sd", "splatdisc"); - brushManager.registerSniperBrush(SplatterOverlayBrush.class, "sover", "splatteroverlay"); - brushManager.registerSniperBrush(SplatterVoxelBrush.class, "sv", "splattervoxel"); - brushManager.registerSniperBrush(SplatterDiscBrush.class, "svd", "splatvoxeldisc"); - brushManager.registerSniperBrush(SplineBrush.class, "sp", "spline"); - brushManager.registerSniperBrush(StencilBrush.class, "st", "stencil"); - brushManager.registerSniperBrush(StencilListBrush.class, "sl", "stencillist"); - brushManager.registerSniperBrush(ThreePointCircleBrush.class, "tpc", "threepointcircle"); - brushManager.registerSniperBrush(TreeSnipeBrush.class, "t", "tree", "treesnipe"); - brushManager.registerSniperBrush(TriangleBrush.class, "tri", "triangle"); - brushManager.registerSniperBrush(UnderlayBrush.class, "under", "underlay"); - brushManager.registerSniperBrush(VoltMeterBrush.class, "volt", "voltmeter"); - brushManager.registerSniperBrush(VoxelBrush.class, "v", "voxel"); - brushManager.registerSniperBrush(VoxelDiscBrush.class, "vd", "voxeldisc"); - brushManager.registerSniperBrush(VoxelDiscFaceBrush.class, "vdf", "voxeldiscface"); - brushManager.registerSniperBrush(WarpBrush.class, "w", "warp"); - brushManager.registerSniperBrush(WallSider.class, "wallsider", "sider"); - } - - public void setupCommand(final String label, final FaweCommand cmd) { - this.getCommand(label).setExecutor(new BukkitCommand(cmd)); - } - -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperConfiguration.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperConfiguration.java deleted file mode 100644 index 1e1b58e63..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperConfiguration.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.thevoxelbox.voxelsniper; - -import org.bukkit.configuration.file.FileConfiguration; - -/** - * Configuration storage defining global configurations for VoxelSniper. - */ -public class VoxelSniperConfiguration { - public static final String CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE = "litesniper-max-brush-size"; - public static final String CONFIG_IDENTIFIER_MESSAGE_ON_LOGIN_ENABLED = "message-on-login-enabled"; - public static final int DEFAULT_LITESNIPER_MAX_BRUSH_SIZE = 30; - public static final boolean DEFAULT_MESSAGE_ON_LOGIN_ENABLED = true; - private FileConfiguration configuration; - - /** - * @param configuration Configuration that is going to be used. - */ - public VoxelSniperConfiguration(FileConfiguration configuration) { - this.configuration = configuration; - } - - /** - * Returns maximum size of brushes that LiteSnipers can use. - * - * @return maximum size - */ - public int getLiteSniperMaxBrushSize() { - return configuration.getInt(CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE, DEFAULT_LITESNIPER_MAX_BRUSH_SIZE); - } - - /** - * Returns if the login message is enabled. - * - * @return true if message on login is enabled, false otherwise. - */ - public boolean isMessageOnLoginEnabled() { - return configuration.getBoolean(CONFIG_IDENTIFIER_MESSAGE_ON_LOGIN_ENABLED, DEFAULT_MESSAGE_ON_LOGIN_ENABLED); - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java deleted file mode 100644 index da6e8eba5..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java +++ /dev/null @@ -1,160 +0,0 @@ -package com.thevoxelbox.voxelsniper; - -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.internal.command.exception.ExceptionConverter; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -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; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; - - -public class VoxelSniperListener implements Listener { - - private static final String SNIPER_PERMISSION = "voxelsniper.sniper"; - private final VoxelSniper plugin; - private Map commands = new HashMap<>(); - - /** - * @param plugin - */ - public VoxelSniperListener(final VoxelSniper plugin) { - this.plugin = plugin; - addCommand(new VoxelBrushCommand(plugin)); - addCommand(new VoxelBrushToolCommand(plugin)); - addCommand(new VoxelCenterCommand(plugin)); - addCommand(new VoxelChunkCommand(plugin)); - addCommand(new VoxelDefaultCommand(plugin)); - addCommand(new VoxelGoToCommand(plugin)); - addCommand(new VoxelHeightCommand(plugin)); - addCommand(new VoxelInkCommand(plugin)); - addCommand(new VoxelInkReplaceCommand(plugin)); - addCommand(new VoxelListCommand(plugin)); - addCommand(new VoxelPaintCommand(plugin)); - addCommand(new VoxelPerformerCommand(plugin)); - addCommand(new VoxelReplaceCommand(plugin)); - addCommand(new VoxelSniperCommand(plugin)); - addCommand(new VoxelUndoCommand(plugin)); - addCommand(new VoxelUndoUserCommand(plugin)); - addCommand(new VoxelVoxelCommand(plugin)); - } - - private void addCommand(final VoxelCommand command) { - this.commands.put(command.getIdentifier().toLowerCase(), command); - } - - /** - * @param player - * @param split - * @param command - * @return boolean Success. - */ - public boolean onCommand(final Player player, final String[] split, final String command) { - VoxelCommand found = this.commands.get(command.toLowerCase()); - if (found == null) { - return false; - } - - if (!hasPermission(found, player)) { - player.sendMessage(ChatColor.RED + "Insufficient Permissions."); - return true; - } - - FawePlayer fp = FawePlayer.wrap(player); - if (!fp.runAction(() -> { - ExceptionConverter exceptionConverter = PlatformCommandManager.getInstance().getExceptionConverter(); - try { - try { - found.onCommand(player, split); - return; - } catch (Throwable t) { - Throwable next = t; - exceptionConverter.convert(next); - while (next.getCause() != null) { - next = next.getCause(); - exceptionConverter.convert(next); - } - throw next; - } - } catch (CommandException e) { - String message = e.getMessage(); - if (message != null) { - fp.sendMessage(e.getMessage()); - return; - } - e.printStackTrace(); - } catch (Throwable e) { - e.printStackTrace(); - } - fp.sendMessage("An unknown FAWE error has occurred! Please see console."); - }, false, true)) { - BBC.WORLDEDIT_COMMAND_LIMIT.send(fp); - } - return true; - } - - private boolean hasPermission(final VoxelCommand command, final Player player) { - if (command == null || player == null) { - // Just a usual check for nulls - return false; - } else if (command.getPermission() == null || command.getPermission().isEmpty()) { - // This is for commands that do not require a permission node to be executed - return true; - } else { - // Should utilize Vault for permission checks if available - return player.hasPermission(command.getPermission()); - } - } - - @EventHandler(ignoreCancelled = false) - public final void onPlayerInteract(final PlayerInteractEvent event) { - Player player = event.getPlayer(); - - if (!player.hasPermission(SNIPER_PERMISSION)) { - return; - } - - try { - Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - if (sniper.isEnabled() && sniper.snipe(event.getAction(), event.getMaterial(), event.getClickedBlock(), event.getBlockFace())) { - event.setCancelled(true); - } - } catch (final Throwable throwable) { - throwable.printStackTrace(); - } - } - - @EventHandler - public final void onPlayerJoin(final PlayerJoinEvent event) { - Player player = event.getPlayer(); - Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - - if (player.hasPermission(SNIPER_PERMISSION) && plugin.getVoxelSniperConfiguration().isMessageOnLoginEnabled()) { - sniper.displayInfo(); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/api/command/VoxelCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/api/command/VoxelCommand.java deleted file mode 100644 index 3908d3e54..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/api/command/VoxelCommand.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.thevoxelbox.voxelsniper.api.command; - -import com.thevoxelbox.voxelsniper.VoxelSniper; -import org.bukkit.entity.Player; - -public abstract class VoxelCommand -{ - - private final String name; - private String description = ""; - private String permission = ""; - private String identifier = ""; - protected final VoxelSniper plugin; - - public VoxelCommand(String name, final VoxelSniper plugin) - { - this.name = name; - this.plugin = plugin; - } - - public abstract boolean onCommand(final Player player, final String[] args); - - public String getDescription() - { - return description; - } - - public String getPermission() - { - return this.permission; - } - - public String getName() - { - return this.name; - } - - public void setDescription(String description) - { - this.description = description; - } - - public void setPermission(String permission) - { - this.permission = permission; - } - - public String getIdentifier() - { - return this.identifier; - } - - public void setIdentifier(String identifier) - { - this.identifier = identifier; - } - - public boolean isIdentifier(String offered) - { - return this.identifier.isEmpty() || this.identifier.equalsIgnoreCase(offered); - } - - /** - * Padds an empty String to the front of the array. - * - * @param args Array to pad empty string in front of - * @return padded array - */ - protected String[] hackTheArray(String[] args) - { - String[] returnValue = new String[args.length + 1]; - returnValue[0] = ""; - for (int i = 0, argsLength = args.length; i < argsLength; i++) - { - String arg = args[i]; - returnValue[i + 1] = arg; - } - return returnValue; - } - -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BallBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BallBrush.java deleted file mode 100644 index ab0be7e1f..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BallBrush.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; - -/** - * A brush that creates a solid ball. - * - * @author Piotr - */ -public class BallBrush extends PerformBrush { - public static final double TRUE_CIRCLE_ON_VALUE = 0.5; - public static final int TRUE_CIRCLE_OFF_VALUE = 0; - private double trueCircle = 0; - -public BallBrush() { - this.setName("Ball"); - } - - private void ball(final SnipeData v, AsyncBlock targetBlock) { - final int brushSize = v.getBrushSize(); - final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); - - int blockPositionX = targetBlock.getX(); - int blockPositionY = targetBlock.getY(); - int blockPositionZ = targetBlock.getZ(); - this.current.perform(targetBlock); - - for (int z = 1; z <= brushSize; z++) { - final double zSquared = Math.pow(z, 2); - - this.current.perform(this.clampY(blockPositionX + z, blockPositionY, blockPositionZ)); - this.current.perform(this.clampY(blockPositionX - z, blockPositionY, blockPositionZ)); - this.current.perform(this.clampY(blockPositionX, blockPositionY + z, blockPositionZ)); - this.current.perform(this.clampY(blockPositionX, blockPositionY - z, blockPositionZ)); - this.current.perform(this.clampY(blockPositionX, blockPositionY, blockPositionZ + z)); - this.current.perform(this.clampY(blockPositionX, blockPositionY, blockPositionZ - z)); - - for (int x = 1; x <= brushSize; x++) { - final double xSquared = Math.pow(x, 2); - - if (zSquared + xSquared <= brushSizeSquared) { - this.current.perform(this.clampY(blockPositionX + z, blockPositionY, blockPositionZ + x)); - this.current.perform(this.clampY(blockPositionX + z, blockPositionY, blockPositionZ - x)); - this.current.perform(this.clampY(blockPositionX - z, blockPositionY, blockPositionZ + x)); - this.current.perform(this.clampY(blockPositionX - z, blockPositionY, blockPositionZ - x)); - this.current.perform(this.clampY(blockPositionX + z, blockPositionY + x, blockPositionZ)); - this.current.perform(this.clampY(blockPositionX + z, blockPositionY - x, blockPositionZ)); - this.current.perform(this.clampY(blockPositionX - z, blockPositionY + x, blockPositionZ)); - this.current.perform(this.clampY(blockPositionX - z, blockPositionY - x, blockPositionZ)); - this.current.perform(this.clampY(blockPositionX, blockPositionY + z, blockPositionZ + x)); - this.current.perform(this.clampY(blockPositionX, blockPositionY + z, blockPositionZ - x)); - this.current.perform(this.clampY(blockPositionX, blockPositionY - z, blockPositionZ + x)); - this.current.perform(this.clampY(blockPositionX, blockPositionY - z, blockPositionZ - x)); - } - - for (int y = 1; y <= brushSize; y++) { - if ((xSquared + Math.pow(y, 2) + zSquared) <= brushSizeSquared) { - this.current.perform(this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ + z)); - this.current.perform(this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ - z)); - this.current.perform(this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ + z)); - this.current.perform(this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ - z)); - this.current.perform(this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ + z)); - this.current.perform(this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ - z)); - this.current.perform(this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ + z)); - this.current.perform(this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ - z)); - } - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.ball(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.ball(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Ball Brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b b true -- will use a true sphere algorithm instead of the skinnier version with classic sniper nubs. /b b false will switch back. (false is default)"); - return; - } else if (parameter.startsWith("true")) { - this.trueCircle = TRUE_CIRCLE_ON_VALUE; - v.sendMessage(ChatColor.AQUA + "True circle mode ON."); - } else if (parameter.startsWith("false")) { - this.trueCircle = TRUE_CIRCLE_OFF_VALUE; - v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.ball"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BiomeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BiomeBrush.java deleted file mode 100644 index 4fe7eaedf..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BiomeBrush.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.ChatColor; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; - -public class BiomeBrush extends Brush { - - private Biome selectedBiome = Biome.PLAINS; - - public BiomeBrush() { - this.setName("Biome (/b biome [Biome Name])"); - } - - private void biome(final SnipeData v) { - final int brushSize = v.getBrushSize(); - final double brushSizeSquared = Math.pow(brushSize, 2); - - for (int x = -brushSize; x <= brushSize; x++) { - final double xSquared = Math.pow(x, 2); - - for (int z = -brushSize; z <= brushSize; z++) { - if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared) { - this.getWorld().setBiome(this.getTargetBlock().getX() + x, this.getTargetBlock().getZ() + z, this.selectedBiome); - } - } - } - - final Block block1 = this.getWorld().getBlockAt(this.getTargetBlock().getX() - brushSize, 0, this.getTargetBlock().getZ() - brushSize); - final Block block2 = this.getWorld().getBlockAt(this.getTargetBlock().getX() + brushSize, 0, this.getTargetBlock().getZ() + brushSize); - - final int lowChunkX = (block1.getX() <= block2.getX()) ? block1.getChunk().getX() : block2.getChunk().getX(); - final int lowChunkZ = (block1.getZ() <= block2.getZ()) ? block1.getChunk().getZ() : block2.getChunk().getZ(); - final int highChunkX = (block1.getX() >= block2.getX()) ? block1.getChunk().getX() : block2.getChunk().getX(); - final int highChunkZ = (block1.getZ() >= block2.getZ()) ? block1.getChunk().getZ() : block2.getChunk().getZ(); - - for (int x = lowChunkX; x <= highChunkX; x++) { - for (int z = lowChunkZ; z <= highChunkZ; z++) { - this.getWorld().refreshChunk(x, z); - } - } - } - - @Override - protected final void arrow(final SnipeData v) { - this.biome(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.biome(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - vm.custom(ChatColor.GOLD + "Currently selected biome type: " + ChatColor.DARK_GREEN + this.selectedBiome.name()); - } - - @Override - public final void parameters(final String[] args, final SnipeData v) { - if (args[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Biome Brush Parameters:"); - StringBuilder availableBiomes = new StringBuilder(); - - for (final Biome biome : Biome.values()) { - if (availableBiomes.length() == 0) { - availableBiomes = new StringBuilder(ChatColor.DARK_GREEN + biome.name()); - continue; - } - - availableBiomes.append(ChatColor.RED + ", " + ChatColor.DARK_GREEN) - .append(biome.name()); - - } - v.sendMessage(ChatColor.DARK_BLUE + "Available biomes: " + availableBiomes); - } else { - // allows biome names with spaces in their name - StringBuilder biomeName = new StringBuilder(args[1]); - for (int i = 2; i < args.length; i++) { - biomeName.append(" ").append(args[i]); - } - - for (final Biome biome : Biome.values()) { - if (biome.name().equalsIgnoreCase(biomeName.toString())) { - this.selectedBiome = biome; - break; - } - } - v.sendMessage(ChatColor.GOLD + "Currently selected biome type: " + ChatColor.DARK_GREEN + this.selectedBiome.name()); - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.biome"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBallBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBallBrush.java deleted file mode 100644 index 76f4a0bc6..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBallBrush.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; - -public class BlendBallBrush extends BlendBrushBase { - - public BlendBallBrush() { - this.setName("Blend Ball"); - } - - @SuppressWarnings("deprecation") - @Override - protected final void blend(final SnipeData v) { - final int brushSize = v.getBrushSize(); - final int brushSizeDoubled = 2 * brushSize; - // Array that holds the original materials plus a buffer - final int[][][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; - // Array that holds the blended materials - final int[][][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1]; - - // Log current materials into oldmats - for (int x = 0; x <= 2 * (brushSize + 1); x++) { - for (int y = 0; y <= 2 * (brushSize + 1); y++) { - for (int z = 0; z <= 2 * (brushSize + 1); z++) { - oldMaterials[x][y][z] = this.getBlockIdAt(this.getTargetBlock().getX() - brushSize - 1 + x, this.getTargetBlock().getY() - brushSize - 1 + y, this.getTargetBlock().getZ() - brushSize - 1 + z); - } - } - } - - // Log current materials into newmats - for (int x = 0; x <= brushSizeDoubled; x++) { - for (int y = 0; y <= brushSizeDoubled; y++) { - System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0, - brushSizeDoubled + 1); - } - } - - // Blend materials - for (int x = 0; x <= brushSizeDoubled; x++) { - for (int y = 0; y <= brushSizeDoubled; y++) { - for (int z = 0; z <= brushSizeDoubled; z++) { - final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block - int modeMatCount = 0; - int modeMatId = 0; - boolean tiecheck = true; - - for (int m = -1; m <= 1; m++) { - for (int n = -1; n <= 1; n++) { - for (int o = -1; o <= 1; o++) { - if (!(m == 0 && n == 0 && o == 0)) { - materialFrequency[oldMaterials[x + 1 + m][y + 1 + n][z + 1 + o]]++; - } - } - } - } - - // Find most common neighboring material. - for (BlockType type : BlockTypes.values) { - int i = type.getInternalId(); - if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) { - modeMatCount = materialFrequency[i]; - modeMatId = i; - } - } - // Make sure there'world not a tie for most common - for (int i = 0; i < modeMatId; i++) { - BlockType type = BlockTypes.get(i); - if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) { - tiecheck = false; - } - } - - // Record most common neighbor material for this block - if (tiecheck) { - newMaterials[x][y][z] = modeMatId; - } - } - } - } - - final Undo undo = new Undo(); - final double rSquared = Math.pow(brushSize + 1, 2); - - // Make the changes - for (int x = brushSizeDoubled; x >= 0; x--) { - final double xSquared = Math.pow(x - brushSize - 1, 2); - - for (int y = 0; y <= brushSizeDoubled; y++) { - final double ySquared = Math.pow(y - brushSize - 1, 2); - - for (int z = brushSizeDoubled; z >= 0; z--) { - if (xSquared + ySquared + Math.pow(z - brushSize - 1, 2) <= rSquared) { - if (!(this.excludeAir && BlockTypes.get(newMaterials[x][y][z]).getMaterial().isAir()) && !(this.excludeWater && (newMaterials[x][y][z] == BlockTypes.WATER.getInternalId()))) { - if (this.getBlockIdAt(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, this.getTargetBlock().getZ() - brushSize + z) != newMaterials[x][y][z]) { - undo.put(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, this.getTargetBlock().getZ() - brushSize + z)); - } - this.setBlockIdAt(this.getTargetBlock().getZ() - brushSize + z, this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, newMaterials[x][y][z]); - } - } - } - } - } - v.owner().storeUndo(undo); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Blend Ball Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b bb water -- toggle include or exclude (default: exclude) water"); - return; - } - - super.parameters(par, v); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.blendball"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBrushBase.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBrushBase.java deleted file mode 100644 index b0c0a0fa8..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBrushBase.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.ChatColor; - -public abstract class BlendBrushBase extends Brush { - protected boolean excludeAir = true; - protected boolean excludeWater = true; - - protected abstract void blend(final SnipeData v); - - @Override - protected final void arrow(final SnipeData v) { - this.excludeAir = false; - this.blend(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.excludeAir = true; - this.blend(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - vm.voxel(); - vm.custom(ChatColor.BLUE + "Water Mode: " + (this.excludeWater ? "exclude" : "include")); - } - - @Override - public void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; ++i) { - if (par[i].equalsIgnoreCase("water")) { - this.excludeWater = !this.excludeWater; - v.sendMessage(ChatColor.AQUA + "Water Mode: " + (this.excludeWater ? "exclude" : "include")); - } - } - } - - protected final boolean isExcludeAir() { - return excludeAir; - } - - protected final void setExcludeAir(boolean excludeAir) { - this.excludeAir = excludeAir; - } - - protected final boolean isExcludeWater() { - return excludeWater; - } - - protected final void setExcludeWater(boolean excludeWater) { - this.excludeWater = excludeWater; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendDiscBrush.java deleted file mode 100644 index 2c50ac304..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendDiscBrush.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; - -public class BlendDiscBrush extends BlendBrushBase { - - public BlendDiscBrush() { - this.setName("Blend Disc"); - } - - @SuppressWarnings("deprecation") - @Override - protected final void blend(final SnipeData v) { - final int brushSize = v.getBrushSize(); - final int brushSizeDoubled = 2 * brushSize; - final int[][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; // Array that holds the original materials plus a buffer - final int[][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Array that holds the blended materials - - // Log current materials into oldmats - for (int x = 0; x <= 2 * (brushSize + 1); x++) { - for (int z = 0; z <= 2 * (brushSize + 1); z++) { - oldMaterials[x][z] = this.getBlockIdAt(this.getTargetBlock().getX() - brushSize - 1 + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize - 1 + z); - } - } - - // Log current materials into newmats - for (int x = 0; x <= brushSizeDoubled; x++) { - System.arraycopy(oldMaterials[x + 1], 1, newMaterials[x], 0, brushSizeDoubled + 1); - } - - // Blend materials - for (int x = 0; x <= brushSizeDoubled; x++) { - for (int z = 0; z <= brushSizeDoubled; z++) { - final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block - int modeMatCount = 0; - int modeMatId = 0; - boolean tiecheck = true; - - for (int m = -1; m <= 1; m++) { - for (int n = -1; n <= 1; n++) { - if (!(m == 0 && n == 0)) { - materialFrequency[oldMaterials[x + 1 + m][z + 1 + n]]++; - } - } - } - - // Find most common neighboring material. - for (BlockType type : BlockTypes.values) { - int i = type.getInternalId(); - if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) { - modeMatCount = materialFrequency[i]; - modeMatId = i; - } - } - // Make sure there'world not a tie for most common - for (int i = 0; i < modeMatId; i++) { - BlockType type = BlockTypes.get(i); - if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) { - tiecheck = false; - } - } - - // Record most common neighbor material for this block - if (tiecheck) { - newMaterials[x][z] = modeMatId; - } - } - } - - final Undo undo = new Undo(); - final double rSquared = Math.pow(brushSize + 1, 2); - - // Make the changes - for (int x = brushSizeDoubled; x >= 0; x--) { - final double xSquared = Math.pow(x - brushSize - 1, 2); - - for (int z = brushSizeDoubled; z >= 0; z--) { - if (xSquared + Math.pow(z - brushSize - 1, 2) <= rSquared) { - if (!(this.excludeAir && BlockTypes.get(newMaterials[x][z]).getMaterial().isAir()) && !(this.excludeWater && (newMaterials[x][z] == BlockTypes.WATER.getInternalId()))) { - if (this.getBlockIdAt(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize + z) != newMaterials[x][z]) { - undo.put(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize + z)); - } - this.setBlockIdAt(this.getTargetBlock().getZ() - brushSize + z, this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), newMaterials[x][z]); - } - } - } - } - v.owner().storeUndo(undo); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Blend Disc Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b bd water -- toggle include or exclude (default) water"); - return; - } - - super.parameters(par, v); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.blenddisc"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelBrush.java deleted file mode 100644 index 89f5946bd..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelBrush.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; - -public class BlendVoxelBrush extends BlendBrushBase { - - public BlendVoxelBrush() { - this.setName("Blend Voxel"); - } - - @SuppressWarnings("deprecation") - @Override - protected final void blend(final SnipeData v) { - final int brushSize = v.getBrushSize(); - final int brushSizeDoubled = 2 * brushSize; - // Array that holds the original materials plus a buffer - final int[][][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; - // Array that holds the blended materials - final int[][][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1]; - - // Log current materials into oldmats - for (int x = 0; x <= 2 * (brushSize + 1); x++) { - for (int y = 0; y <= 2 * (brushSize + 1); y++) { - for (int z = 0; z <= 2 * (brushSize + 1); z++) { - oldMaterials[x][y][z] = this.getBlockIdAt(this.getTargetBlock().getX() - brushSize - 1 + x, this.getTargetBlock().getY() - brushSize - 1 + y, this.getTargetBlock().getZ() - brushSize - 1 + z); - } - } - } - - // Log current materials into newmats - for (int x = 0; x <= brushSizeDoubled; x++) { - for (int y = 0; y <= brushSizeDoubled; y++) { - System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0, - brushSizeDoubled + 1); - } - } - - // Blend materials - for (int x = 0; x <= brushSizeDoubled; x++) { - for (int y = 0; y <= brushSizeDoubled; y++) { - for (int z = 0; z <= brushSizeDoubled; z++) { - final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block - int modeMatCount = 0; - int modeMatId = 0; - boolean tiecheck = true; - - for (int m = -1; m <= 1; m++) { - for (int n = -1; n <= 1; n++) { - for (int o = -1; o <= 1; o++) { - if (!(m == 0 && n == 0 && o == 0)) { - materialFrequency[oldMaterials[x + 1 + m][y + 1 + n][z + 1 + o]]++; - } - } - } - } - - // Find most common neighboring material. - for (BlockType type : BlockTypes.values) { - int i = type.getInternalId(); - if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) { - modeMatCount = materialFrequency[i]; - modeMatId = i; - } - } - // Make sure there'world not a tie for most common - for (int i = 0; i < modeMatId; i++) { - BlockType type = BlockTypes.get(i); - if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) { - tiecheck = false; - } - } - - // Record most common neighbor material for this block - if (tiecheck) { - newMaterials[x][y][z] = modeMatId; - } - } - } - } - - final Undo undo = new Undo(); - - // Make the changes - for (int x = brushSizeDoubled; x >= 0; x--) { - for (int y = 0; y <= brushSizeDoubled; y++) { - for (int z = brushSizeDoubled; z >= 0; z--) { - if (!(this.excludeAir && BlockTypes.get(newMaterials[x][y][z]).getMaterial().isAir()) && !(this.excludeWater && (newMaterials[x][y][z] == BlockTypes.WATER.getInternalId()))) { - if (this.getBlockIdAt(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, this.getTargetBlock().getZ() - brushSize + z) != newMaterials[x][y][z]) { - undo.put(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, this.getTargetBlock().getZ() - brushSize + z)); - } - this.setBlockIdAt(this.getTargetBlock().getZ() - brushSize + z, this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, newMaterials[x][y][z]); - - } - } - } - } - v.owner().storeUndo(undo); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Blend Voxel Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b bv water -- toggle include or exclude (default) water"); - return; - } - - super.parameters(par, v); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.blendvoxel"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelDiscBrush.java deleted file mode 100644 index eb6d17de1..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelDiscBrush.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; - -public class BlendVoxelDiscBrush extends BlendBrushBase { - - public BlendVoxelDiscBrush() { - this.setName("Blend Voxel Disc"); - } - - @SuppressWarnings("deprecation") - @Override - protected final void blend(final SnipeData v) { - final int brushSize = v.getBrushSize(); - final int brushSizeDoubled = 2 * brushSize; - final int[][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; // Array that holds the original materials plus a buffer - final int[][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Array that holds the blended materials - - // Log current materials into oldmats - for (int x = 0; x <= 2 * (brushSize + 1); x++) { - for (int z = 0; z <= 2 * (brushSize + 1); z++) { - oldMaterials[x][z] = this.getBlockIdAt(this.getTargetBlock().getX() - brushSize - 1 + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize - 1 + z); - } - } - - // Log current materials into newmats - for (int x = 0; x <= brushSizeDoubled; x++) { - System.arraycopy(oldMaterials[x + 1], 1, newMaterials[x], 0, brushSizeDoubled + 1); - } - - // Blend materials - for (int x = 0; x <= brushSizeDoubled; x++) { - for (int z = 0; z <= brushSizeDoubled; z++) { - final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block - int modeMatCount = 0; - int modeMatId = 0; - boolean tiecheck = true; - - for (int m = -1; m <= 1; m++) { - for (int n = -1; n <= 1; n++) { - if (!(m == 0 && n == 0)) { - materialFrequency[oldMaterials[x + 1 + m][z + 1 + n]]++; - } - } - } - - // Find most common neighboring material. - for (BlockType type : BlockTypes.values) { - int i = type.getInternalId(); - if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) { - modeMatCount = materialFrequency[i]; - modeMatId = i; - } - } - // Make sure there'world not a tie for most common - for (int i = 0; i < modeMatId; i++) { - BlockType type = BlockTypes.get(i); - if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) { - tiecheck = false; - } - } - - // Record most common neighbor material for this block - if (tiecheck) { - newMaterials[x][z] = modeMatId; - } - } - } - - final Undo undo = new Undo(); - - // Make the changes - for (int x = brushSizeDoubled; x >= 0; x--) { - for (int z = brushSizeDoubled; z >= 0; z--) { - if (!(this.excludeAir && BlockTypes.get(newMaterials[x][z]).getMaterial().isAir()) && !(this.excludeWater && (newMaterials[x][z] == BlockTypes.WATER.getInternalId()))) { - if (this.getBlockIdAt(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize + z) != newMaterials[x][z]) { - undo.put(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize + z)); - } - this.setBlockIdAt(this.getTargetBlock().getZ() - brushSize + z, this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), newMaterials[x][z]); - - } - } - } - - v.owner().storeUndo(undo); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Blend Voxel Disc Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b bvd water -- toggle include or exclude (default) water"); - return; - } - - super.parameters(par, v); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.blendvoxeldisc"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlobBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlobBrush.java deleted file mode 100644 index 7b6a3675d..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlobBrush.java +++ /dev/null @@ -1,237 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; - -import java.util.Random; - -public class BlobBrush extends PerformBrush { - private static final int GROW_PERCENT_DEFAULT = 1000; - private static final int GROW_PERCENT_MIN = 1; - private static final int GROW_PERCENT_MAX = 9999; - - private Random randomGenerator = new Random(); - private int growPercent = GROW_PERCENT_DEFAULT; // chance block on recursion pass is made active - - public BlobBrush() { - this.setName("Blob"); - } - - private void checkValidGrowPercent(final SnipeData v) { - if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) { - this.growPercent = GROW_PERCENT_DEFAULT; - v.sendMessage(ChatColor.BLUE + "Growth percent set to: 10%"); - } - } - - private void digBlob(final SnipeData v) { - final int brushSize = v.getBrushSize(); - final int brushSizeDoubled = 2 * brushSize; - final int[][][] splat = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1]; - final int[][][] tempSplat = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1]; - - this.checkValidGrowPercent(v); - - // Seed the array - for (int x = brushSizeDoubled; x >= 0; x--) { - for (int y = brushSizeDoubled; y >= 0; y--) { - for (int z = brushSizeDoubled; z >= 0; z--) { - if ((x == 0 || y == 0 | z == 0 || x == brushSizeDoubled || y == brushSizeDoubled || z == brushSizeDoubled) && this.randomGenerator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) { - splat[x][y][z] = 0; - } else { - splat[x][y][z] = 1; - } - } - } - } - - // Grow the seed - for (int r = 0; r < brushSize; r++) { - for (int x = brushSizeDoubled; x >= 0; x--) { - for (int y = brushSizeDoubled; y >= 0; y--) { - for (int z = brushSizeDoubled; z >= 0; z--) { - tempSplat[x][y][z] = splat[x][y][z]; - double growCheck = 0; - if (splat[x][y][z] == 1) { - if (x != 0 && splat[x - 1][y][z] == 0) { - growCheck++; - } - if (y != 0 && splat[x][y - 1][z] == 0) { - growCheck++; - } - if (z != 0 && splat[x][y][z - 1] == 0) { - growCheck++; - } - if (x != 2 * brushSize && splat[x + 1][y][z] == 0) { - growCheck++; - } - if (y != 2 * brushSize && splat[x][y + 1][z] == 0) { - growCheck++; - } - if (z != 2 * brushSize && splat[x][y][z + 1] == 0) { - growCheck++; - } - } - - if (growCheck >= 1 && this.randomGenerator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) { - tempSplat[x][y][z] = 0; // prevent bleed into splat - } - } - } - } - - // shouldn't this just be splat = tempsplat;? -Gavjenks - // integrate tempsplat back into splat at end of iteration - for (int x = brushSizeDoubled; x >= 0; x--) { - for (int y = brushSizeDoubled; y >= 0; y--) { - System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, brushSizeDoubled + 1); - } - } - } - - final double rSquared = Math.pow(brushSize + 1, 2); - - // Make the changes - for (int x = brushSizeDoubled; x >= 0; x--) { - final double xSquared = Math.pow(x - brushSize - 1, 2); - - for (int y = brushSizeDoubled; y >= 0; y--) { - final double ySquared = Math.pow(y - brushSize - 1, 2); - - for (int z = brushSizeDoubled; z >= 0; z--) { - if (splat[x][y][z] == 1 && xSquared + ySquared + Math.pow(z - brushSize - 1, 2) <= rSquared) { - this.current.perform(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + z, this.getTargetBlock().getZ() - brushSize + y)); - } - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - private void growBlob(final SnipeData v) { - final int brushSize = v.getBrushSize(); - final int brushSizeDoubled = 2 * brushSize; - final int[][][] splat = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1]; - final int[][][] tempSplat = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1]; - - this.checkValidGrowPercent(v); - - // Seed the array - splat[brushSize][brushSize][brushSize] = 1; - - // Grow the seed - for (int r = 0; r < brushSize; r++) { - - for (int x = brushSizeDoubled; x >= 0; x--) { - for (int y = brushSizeDoubled; y >= 0; y--) { - for (int z = brushSizeDoubled; z >= 0; z--) { - tempSplat[x][y][z] = splat[x][y][z]; - int growCheck = 0; - if (splat[x][y][z] == 0) { - if (x != 0 && splat[x - 1][y][z] == 1) { - growCheck++; - } - if (y != 0 && splat[x][y - 1][z] == 1) { - growCheck++; - } - if (z != 0 && splat[x][y][z - 1] == 1) { - growCheck++; - } - if (x != 2 * brushSize && splat[x + 1][y][z] == 1) { - growCheck++; - } - if (y != 2 * brushSize && splat[x][y + 1][z] == 1) { - growCheck++; - } - if (z != 2 * brushSize && splat[x][y][z + 1] == 1) { - growCheck++; - } - } - - if (growCheck >= 1 && this.randomGenerator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) { - // prevent bleed into splat - tempSplat[x][y][z] = 1; - } - } - } - } - - // integrate tempsplat back into splat at end of iteration - for (int x = brushSizeDoubled; x >= 0; x--) { - for (int y = brushSizeDoubled; y >= 0; y--) { - System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, brushSizeDoubled + 1); - } - } - } - - final double rSquared = Math.pow(brushSize + 1, 2); - - // Make the changes - for (int x = brushSizeDoubled; x >= 0; x--) { - final double xSquared = Math.pow(x - brushSize - 1, 2); - - for (int y = brushSizeDoubled; y >= 0; y--) { - final double ySquared = Math.pow(y - brushSize - 1, 2); - - for (int z = brushSizeDoubled; z >= 0; z--) { - if (splat[x][y][z] == 1 && xSquared + ySquared + Math.pow(z - brushSize - 1, 2) <= rSquared) { - this.current.perform(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + z, this.getTargetBlock().getZ() - brushSize + y)); - } - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.growBlob(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.digBlob(v); - } - - @Override - public final void info(final Message vm) { - this.checkValidGrowPercent(null); - - vm.brushName(this.getName()); - vm.size(); - vm.custom(ChatColor.BLUE + "Growth percent set to: " + this.growPercent / 100 + "%"); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Blob brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b blob g[int] -- set a growth percentage (" + GROW_PERCENT_MIN + "-" + GROW_PERCENT_MAX + "). Default is " + GROW_PERCENT_DEFAULT); - return; - } - if (parameter.startsWith("g")) { - final int temp = Integer.parseInt(parameter.replace("g", "")); - if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + (float) temp / 100 + "%"); - this.growPercent = temp; - } else { - v.sendMessage(ChatColor.RED + "Growth percent must be an integer " + GROW_PERCENT_MIN + "-" + GROW_PERCENT_MAX + "!"); - } - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.blob"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetBrush.java deleted file mode 100644 index 538212094..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetBrush.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.world.block.BlockID; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.Material; -import org.bukkit.block.Block; - -import java.util.ArrayList; - -public class BlockResetBrush extends Brush { - private static final ArrayList DENIED_UPDATES = new ArrayList<>(); - - static { - BlockResetBrush.DENIED_UPDATES.add(Material.ACACIA_SIGN); - BlockResetBrush.DENIED_UPDATES.add(Material.SPRUCE_SIGN); - BlockResetBrush.DENIED_UPDATES.add(Material.ACACIA_WALL_SIGN); - BlockResetBrush.DENIED_UPDATES.add(Material.BIRCH_SIGN); - BlockResetBrush.DENIED_UPDATES.add(Material.SPRUCE_WALL_SIGN); - BlockResetBrush.DENIED_UPDATES.add(Material.BIRCH_WALL_SIGN); - BlockResetBrush.DENIED_UPDATES.add(Material.DARK_OAK_SIGN); - BlockResetBrush.DENIED_UPDATES.add(Material.DARK_OAK_WALL_SIGN); - BlockResetBrush.DENIED_UPDATES.add(Material.JUNGLE_SIGN); - BlockResetBrush.DENIED_UPDATES.add(Material.JUNGLE_WALL_SIGN); - BlockResetBrush.DENIED_UPDATES.add(Material.OAK_SIGN); - BlockResetBrush.DENIED_UPDATES.add(Material.OAK_WALL_SIGN); - BlockResetBrush.DENIED_UPDATES.add(Material.CHEST); - BlockResetBrush.DENIED_UPDATES.add(Material.FURNACE); - BlockResetBrush.DENIED_UPDATES.add(Material.REDSTONE_TORCH); - BlockResetBrush.DENIED_UPDATES.add(Material.REDSTONE_WALL_TORCH); - BlockResetBrush.DENIED_UPDATES.add(Material.REDSTONE_WIRE); - BlockResetBrush.DENIED_UPDATES.add(Material.OAK_DOOR); - BlockResetBrush.DENIED_UPDATES.add(Material.DARK_OAK_DOOR); - BlockResetBrush.DENIED_UPDATES.add(Material.BIRCH_DOOR); - BlockResetBrush.DENIED_UPDATES.add(Material.ACACIA_DOOR); - BlockResetBrush.DENIED_UPDATES.add(Material.SPRUCE_DOOR); - BlockResetBrush.DENIED_UPDATES.add(Material.JUNGLE_DOOR); - BlockResetBrush.DENIED_UPDATES.add(Material.IRON_DOOR); - BlockResetBrush.DENIED_UPDATES.add(Material.DARK_OAK_FENCE_GATE); - BlockResetBrush.DENIED_UPDATES.add(Material.ACACIA_FENCE_GATE); - BlockResetBrush.DENIED_UPDATES.add(Material.BIRCH_FENCE_GATE); - BlockResetBrush.DENIED_UPDATES.add(Material.SPRUCE_FENCE_GATE); - BlockResetBrush.DENIED_UPDATES.add(Material.JUNGLE_FENCE_GATE); - BlockResetBrush.DENIED_UPDATES.add(Material.OAK_FENCE_GATE); - } - - public BlockResetBrush() { - this.setName("Block Reset Brush"); - } - - private void applyBrush(final SnipeData v) { - for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) { - for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) { - for (int y = -v.getBrushSize(); y <= v.getBrushSize(); y++) { - final Block block = this.getWorld().getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z); - if (BlockResetBrush.DENIED_UPDATES.contains(block.getType())) { - continue; - } - - block.setBlockData(block.getType().createBlockData(), true); - } - } - } - } - - @Override - protected final void arrow(final SnipeData v) { - applyBrush(v); - } - - @Override - protected final void powder(final SnipeData v) { - applyBrush(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.blockreset"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetSurfaceBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetSurfaceBrush.java deleted file mode 100644 index c08e7e345..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetSurfaceBrush.java +++ /dev/null @@ -1,127 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.boydti.fawe.bukkit.wrapper.AsyncWorld; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.world.registry.BlockMaterial; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.Material; - -/** - * This brush only looks for solid blocks, and then changes those plus any air blocks touching them. If it works, this brush should be faster than the original - * blockPositionY an amount proportional to the volume of a snipe selection area / the number of blocks touching air in the selection. This is because every solid block - * surrounded blockPositionY others should take equally long to check and not change as it would take MC to change them and then check and find no lighting to update. For - * air blocks surrounded blockPositionY other air blocks, this brush saves about 80-100 checks blockPositionY not updating them or their lighting. And for air blocks touching solids, - * this brush is slower, because it replaces the air once per solid block it is touching. I assume on average this is about 2 blocks. So every air block - * touching a solid negates one air block floating in air. Thus, for selections that have more air blocks surrounded blockPositionY air than air blocks touching solids, - * this brush will be faster, which is almost always the case, especially for undeveloped terrain and for larger brush sizes (unlike the original brush, this - * should only slow down blockPositionY the square of the brush size, not the cube of the brush size). For typical terrain, blockPositionY my calculations, overall speed increase is - * about a factor of 5-6 for a size 20 brush. For a complicated city or ship, etc., this may be only a factor of about 2. In a hypothetical worst case scenario - * of a 3d checkerboard of stone and air every other block, this brush should only be about 1.5x slower than the original brush. Savings increase for larger - * brushes. - * - * @author GavJenks - */ -public class BlockResetSurfaceBrush extends Brush { - - public BlockResetSurfaceBrush() { - this.setName("Block Reset Brush Surface Only"); - } - - private void applyBrush(final SnipeData v) { - final AsyncWorld world = this.getWorld(); - - for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) { - for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) { - for (int y = -v.getBrushSize(); y <= v.getBrushSize(); y++) { - - AsyncBlock block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z); - - - Material type = block.getType(); - BlockMaterial mat = BukkitAdapter.adapt(type).getMaterial(); - if (!mat.isSolid() || !mat.isFullCube() || mat.hasContainer()) { - continue; - } - - boolean airFound = false; - - if (world.getBlockAt(this.getTargetBlock().getX() + x + 1, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z).isEmpty()) { - block = world.getBlockAt(this.getTargetBlock().getX() + x + 1, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z); - final int oldData = block.getPropertyId(); - resetBlock(block, oldData); - airFound = true; - } - - if (world.getBlockAt(this.getTargetBlock().getX() + x - 1, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z).isEmpty()) { - block = world.getBlockAt(this.getTargetBlock().getX() + x - 1, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z); - final int oldData = block.getPropertyId(); - resetBlock(block, oldData); - airFound = true; - } - - if (world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y + 1, this.getTargetBlock().getZ() + z).isEmpty()) { - block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y + 1, this.getTargetBlock().getZ() + z); - final int oldData = block.getPropertyId(); - resetBlock(block, oldData); - airFound = true; - } - - if (world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y - 1, this.getTargetBlock().getZ() + z).isEmpty()) { - block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y - 1, this.getTargetBlock().getZ() + z); - final int oldData = block.getPropertyId(); - resetBlock(block, oldData); - airFound = true; - } - - if (world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z + 1).isEmpty()) { - block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z + 1); - final int oldData = block.getPropertyId(); - resetBlock(block, oldData); - airFound = true; - } - - if (world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z - 1).isEmpty()) { - block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z - 1); - final int oldData = block.getPropertyId(); - resetBlock(block, oldData); - airFound = true; - } - - if (airFound) { - block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z); - final int oldData = block.getPropertyId(); - resetBlock(block, oldData); - } - } - } - } - } - - @SuppressWarnings("deprecation") - private void resetBlock(AsyncBlock block, final int oldData) { - block.setTypeIdAndPropertyId(block.getTypeId(), ((block.getPropertyId() + 1) & 0xf), true); - block.setTypeIdAndPropertyId(block.getTypeId(), oldData, true); - } - - @Override - protected final void arrow(final SnipeData v) { - applyBrush(v); - } - - @Override - protected final void powder(final SnipeData v) { - applyBrush(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.blockresetsurface"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Brush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Brush.java deleted file mode 100644 index abe48d61f..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Brush.java +++ /dev/null @@ -1,282 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.boydti.fawe.bukkit.wrapper.AsyncWorld; -import com.sk89q.worldedit.world.registry.LegacyMapper; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.RangeBlockHelper; -import com.thevoxelbox.voxelsniper.SnipeAction; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import com.thevoxelbox.voxelsniper.util.BlockWrapper; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; - -/** - * Abstract implementation of the {@link IBrush} interface. - */ -public abstract class Brush implements IBrush { - protected static final int CHUNK_SIZE = 16; - /** - * Targeted Block. - */ - private AsyncBlock targetBlock; - /** - * Last Block before targeted Block. - */ - private AsyncBlock lastBlock; - /** - * Brush name. - */ - private String name = "Undefined"; - - /** - * @param x X coordinate - * @param y Y coordinate - * @param z Z coordinate - * @return {@link Block} - */ - public final AsyncBlock clampY(final int x, final int y, final int z) { - int clampedY = y; - if (clampedY < 0) { - clampedY = 0; - } else if (clampedY > this.getWorld().getMaxHeight()) { - clampedY = this.getWorld().getMaxHeight(); - } - - return this.getWorld().getBlockAt(x, clampedY, z); - } - - private boolean preparePerform(final SnipeData v, final AsyncBlock clickedBlock, final BlockFace clickedFace) { - if (this.getTarget(v, clickedBlock, clickedFace)) { - if (this instanceof PerformBrush) { - ((PerformBrush) this).initP(v); - } - return true; - } - - return false; - } - - @Override - public boolean perform(SnipeAction action, SnipeData data, AsyncBlock targetBlock, AsyncBlock lastBlock) { - this.setTargetBlock(targetBlock); - this.setLastBlock(lastBlock); - switch (action) { - case ARROW: - this.arrow(data); - return true; - case GUNPOWDER: - this.powder(data); - return true; - default: - return false; - } - } - - /** - * The arrow action. Executed when a player RightClicks with an Arrow - * - * @param v Sniper caller - */ - protected void arrow(final SnipeData v) { - } - - /** - * The powder action. Executed when a player RightClicks with Gunpowder - * - * @param v Sniper caller - */ - protected void powder(final SnipeData v) { - } - - @Override - public abstract void info(Message vm); - - @Override - public void parameters(final String[] par, final SnipeData v) { - v.sendMessage(ChatColor.RED + "This brush does not accept additional parameters."); - } - - /** - * Overridable getTarget method. - * - * @param v Sniper caller - * @param clickedBlock Block that the player targeted/interacted with - * @param clickedFace Face of that targeted Block - * @return boolean - */ - protected final boolean getTarget(final SnipeData v, final AsyncBlock clickedBlock, final BlockFace clickedFace) { - if (clickedBlock != null) { - this.setTargetBlock(clickedBlock); - this.setLastBlock(clickedBlock.getRelative(clickedFace)); - if (this.getLastBlock() == null) { - v.sendMessage(ChatColor.RED + "Snipe target block must be visible."); - return false; - } - if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isLightningEnabled()) { - this.getWorld().strikeLightning(this.getTargetBlock().getLocation()); - } - return true; - } else { - RangeBlockHelper rangeBlockHelper; - if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isRanged()) { - rangeBlockHelper = new RangeBlockHelper(v.owner().getPlayer(), v.owner().getWorld(), v.owner().getSnipeData(v.owner().getCurrentToolId()).getRange()); - this.setTargetBlock(rangeBlockHelper.getRangeBlock()); - } else { - rangeBlockHelper = new RangeBlockHelper(v.owner().getPlayer(), v.owner().getWorld()); - this.setTargetBlock(rangeBlockHelper.getTargetBlock()); - } - if (this.getTargetBlock() != null) { - this.setLastBlock(rangeBlockHelper.getLastBlock()); - if (this.getLastBlock() == null) { - v.sendMessage(ChatColor.RED + "Snipe target block must be visible."); - return false; - } - if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isLightningEnabled()) { - this.getWorld().strikeLightning(this.getTargetBlock().getLocation()); - } - return true; - } else { - v.sendMessage(ChatColor.RED + "Snipe target block must be visible."); - return false; - } - } - } - - @Override - public final String getName() { - return this.name; - } - - @Override - public final void setName(final String name) { - this.name = name; - } - - @Override - public String getBrushCategory() { - return "General"; - } - - /** - * @return the targetBlock - */ - protected final AsyncBlock getTargetBlock() { - return this.targetBlock; - } - - /** - * @param targetBlock the targetBlock to set - */ - protected final void setTargetBlock(final AsyncBlock targetBlock) { - this.targetBlock = targetBlock; - } - - /** - * @return the world - */ - protected final AsyncWorld getWorld() { - return targetBlock.getWorld(); - } - - /** - * Looks up Type ID of Block at given coordinates in the world of the targeted Block. - * - * @param x X coordinate - * @param y Y coordinate - * @param z Z coordinate - * @return Type ID of Block at given coordinates in the world of the targeted Block. - */ - protected int getBlockIdAt(int x, int y, int z) { - return getWorld().getBlockAt(x, y, z).getTypeId(); - } - - protected Block getBlockAt(int x, int y, int z) { - return getWorld().getBlockAt(x, y, z); - } - - protected Material getBlockType(int x, int y, int z) { - return getWorld().getBlockAt(x, y, z).getType(); - } - - /** - * Looks up Block Data Value of Block at given coordinates in the world of the targeted Block. - * - * @param x X coordinate - * @param y Y coordinate - * @param z Z coordinate - * @return Block Data Value of Block at given coordinates in the world of the targeted Block. - */ - @SuppressWarnings("deprecation") - protected int getBlockDataAt(int x, int y, int z) { - return this.getWorld().getBlockAt(x, y, z).getPropertyId(); - } - - /** - * @return Block before target Block. - */ - protected final AsyncBlock getLastBlock() { - return this.lastBlock; - } - - /** - * @param lastBlock Last Block before target Block. - */ - protected final void setLastBlock(AsyncBlock lastBlock) { - this.lastBlock = lastBlock; - } - - /** - * Set block data with supplied data over BlockWrapper. - * - * @param blockWrapper Block data wrapper - */ - @Deprecated - protected final void setBlock(BlockWrapper blockWrapper) { - this.getWorld().getBlockAt(blockWrapper.getX(), blockWrapper.getY(), blockWrapper.getZ()).setTypeId(blockWrapper.getId()); - } - - /** - * Sets the Id of the block at the passed coordinate. - * - * @param z Z coordinate - * @param x X coordinate - * @param y Y coordinate - * @param id The id the block will be set to - */ - @SuppressWarnings("deprecation") - protected final void setBlockIdAt(int z, int x, int y, int id) { - this.getWorld().getBlockAt(x, y, z).setTypeId(id); - } - - /** - * Sets the id and data value of the block at the passed coordinate. - * - * @param x X coordinate - * @param y Y coordinate - * @param z Z coordinate - * @param id The id the block will be set to - * @param data The data value the block will be set to - */ - @SuppressWarnings("deprecation") - protected final void setBlockIdAndDataAt(int x, int y, int z, int id, int data) { - this.getWorld().getBlockAt(x, y, z).setTypeIdAndPropertyId(id, data, true); - } - - /** - * Sets the id and data value of the block at the passed coordinate. - * - * @param x X coordinate - * @param y Y coordinate - * @param z Z coordinate - * @param id The id the block will be set to - * @param data The data value the block will be set to - */ - @SuppressWarnings("deprecation") - protected final void setBlockLegacy(int x, int y, int z, int id, int data) { - this.getWorld().getBlockAt(x, y, z).setCombinedId(LegacyMapper.getInstance().getBlockFromLegacy(id, data).getInternalId()); - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonBrush.java deleted file mode 100644 index d075d7225..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonBrush.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.boydti.fawe.bukkit.wrapper.AsyncChunk; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.Chunk; -import org.bukkit.Material; -import org.bukkit.block.Block; - - -public class CanyonBrush extends Brush { - private static final int SHIFT_LEVEL_MIN = 10; - private static final int SHIFT_LEVEL_MAX = 60; - private int yLevel = 10; - - public CanyonBrush() { - this.setName("Canyon"); - } - - @SuppressWarnings("deprecation") - protected final void canyon(final AsyncChunk chunk, final Undo undo) { - for (int x = 0; x < CHUNK_SIZE; x++) { - for (int z = 0; z < CHUNK_SIZE; z++) { - int currentYLevel = this.yLevel; - - for (int y = 63; y < this.getWorld().getMaxHeight(); y++) { - final AsyncBlock block = chunk.getBlock(x, y, z); - final AsyncBlock currentYLevelBlock = chunk.getBlock(x, currentYLevel, z); - - undo.put(block); - undo.put(currentYLevelBlock); - - currentYLevelBlock.setTypeId(block.getTypeId()); - block.setType(Material.AIR); - - currentYLevel++; - } - - final AsyncBlock block = chunk.getBlock(x, 0, z); - undo.put(block); - block.setTypeId(BlockTypes.BEDROCK.getInternalId()); - - for (int y = 1; y < SHIFT_LEVEL_MIN; y++) { - final Block currentBlock = chunk.getBlock(x, y, z); - undo.put(currentBlock); - currentBlock.setType(Material.STONE); - } - } - } - } - - @Override - protected void arrow(final SnipeData v) { - final Undo undo = new Undo(); - - canyon(getTargetBlock().getChunk(), undo); - - v.owner().storeUndo(undo); - } - - @Override - protected void powder(final SnipeData v) { - final Undo undo = new Undo(); - - Chunk targetChunk = getTargetBlock().getChunk(); - for (int x = targetChunk.getX() - 1; x <= targetChunk.getX() + 1; x++) { - for (int z = targetChunk.getX() - 1; z <= targetChunk.getX() + 1; z++) { - canyon(getWorld().getChunkAt(x, z), undo); - } - } - - v.owner().storeUndo(undo); - } - - @Override - public void info(final Message vm) { - vm.brushName(this.getName()); - vm.custom(ChatColor.GREEN + "Shift Level set to " + this.yLevel); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GREEN + "y[number] to set the Level to which the land will be shifted down"); - } - if (par[1].startsWith("y")) { - int _i = Integer.parseInt(par[1].replace("y", "")); - if (_i < SHIFT_LEVEL_MIN) { - _i = SHIFT_LEVEL_MIN; - } else if (_i > SHIFT_LEVEL_MAX) { - _i = SHIFT_LEVEL_MAX; - } - this.yLevel = _i; - v.sendMessage(ChatColor.GREEN + "Shift Level set to " + this.yLevel); - } - } - - protected final int getYLevel() { - return yLevel; - } - - protected final void setYLevel(int yLevel) { - this.yLevel = yLevel; - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.canyon"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonSelectionBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonSelectionBrush.java deleted file mode 100644 index 7b2183fbe..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonSelectionBrush.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.Chunk; - - -public class CanyonSelectionBrush extends CanyonBrush { - private boolean first = true; - private int fx; - private int fz; - - public CanyonSelectionBrush() { - this.setName("Canyon Selection"); - } - - private void execute(final SnipeData v) { - final Chunk chunk = getTargetBlock().getChunk(); - - if (this.first) { - this.fx = chunk.getX(); - this.fz = chunk.getZ(); - - v.sendMessage(ChatColor.YELLOW + "First point selected!"); - this.first = !this.first; - } else { - v.sendMessage(ChatColor.YELLOW + "Second point selected!"); - selection(Math.min(fx, chunk.getX()), Math.min(fz, chunk.getZ()), Math.max(fx, chunk.getX()), Math.max(fz, chunk.getZ()), v); - - this.first = !this.first; - } - } - - private void selection(final int lowX, final int lowZ, final int highX, final int highZ, final SnipeData v) { - final Undo undo = new Undo(); - - for (int x = lowX; x <= highX; x++) { - for (int z = lowZ; z <= highZ; z++) { - canyon(getWorld().getChunkAt(x, z), undo); - } - } - - v.owner().storeUndo(undo); - } - - @Override - protected final void arrow(final SnipeData v) { - execute(v); - } - - @Override - protected final void powder(final SnipeData v) { - execute(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.custom(ChatColor.GREEN + "Shift Level set to " + this.getYLevel()); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.canyonselection"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CheckerVoxelDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CheckerVoxelDiscBrush.java deleted file mode 100644 index 50db6161d..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CheckerVoxelDiscBrush.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; - -public class CheckerVoxelDiscBrush extends PerformBrush { - private boolean useWorldCoordinates = true; - - /** - * Default constructor. - */ - public CheckerVoxelDiscBrush() { - this.setName("Checker Voxel Disc"); - } - - private void applyBrush(final SnipeData v, final Block target) { - for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) { - for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) { - final int sum = this.useWorldCoordinates ? target.getX() + x + target.getZ() + y : x + y; - if (sum % 2 != 0) { - this.current.perform(this.clampY(target.getX() + x, target.getY(), target.getZ() + y)); - } - } - } - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.applyBrush(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.applyBrush(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int x = 1; x < par.length; x++) { - final String parameter = par[x].toLowerCase(); - - if (parameter.equals("info")) { - v.sendMessage(ChatColor.GOLD + this.getName() + " Parameters:"); - v.sendMessage(ChatColor.AQUA + "true -- Enables using World Coordinates."); - v.sendMessage(ChatColor.AQUA + "false -- Disables using World Coordinates."); - return; - } - if (parameter.startsWith("true")) { - this.useWorldCoordinates = true; - v.sendMessage(ChatColor.AQUA + "Enabled using World Coordinates."); - } else if (parameter.startsWith("false")) { - this.useWorldCoordinates = false; - v.sendMessage(ChatColor.AQUA + "Disabled using World Coordinates."); - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - break; - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.checkervoxeldisc"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CleanSnowBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CleanSnowBrush.java deleted file mode 100644 index 69a012c4c..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CleanSnowBrush.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.Material; - -public class CleanSnowBrush extends Brush { - private double trueCircle = 0; - - public CleanSnowBrush() { - this.setName("Clean Snow"); - } - - private void cleanSnow(final SnipeData v) { - final int brushSize = v.getBrushSize(); - final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); - final Undo undo = new Undo(); - - for (int y = (brushSize + 1) * 2; y >= 0; y--) { - final double ySquared = Math.pow(y - brushSize, 2); - - for (int x = (brushSize + 1) * 2; x >= 0; x--) { - final double xSquared = Math.pow(x - brushSize, 2); - - for (int z = (brushSize + 1) * 2; z >= 0; z--) { - if ((xSquared + Math.pow(z - brushSize, 2) + ySquared) <= brushSizeSquared) { - if ((this.clampY(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, this.getTargetBlock().getZ() + y - brushSize).getType() == Material.SNOW) && ((this.clampY(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize - 1, this.getTargetBlock().getZ() + y - brushSize).getType() == Material.SNOW) || (this.clampY(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize - 1, this.getTargetBlock().getZ() + y - brushSize).isEmpty()))) { - undo.put(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + z, this.getTargetBlock().getZ() + y)); - this.setBlockIdAt(this.getTargetBlock().getZ() + y - brushSize, this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, BlockTypes.AIR.getInternalId()); - } - - } - } - } - } - - v.owner().storeUndo(undo); - } - - @Override - protected final void arrow(final SnipeData v) { - this.cleanSnow(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.cleanSnow(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Clean Snow Brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b cls true -- will use a true sphere algorithm instead of the skinnier version with classic sniper nubs. /b cls false will switch back. (false is default)"); - return; - } else if (parameter.startsWith("true")) { - this.trueCircle = 0.5; - v.sendMessage(ChatColor.AQUA + "True circle mode ON."); - } else if (parameter.startsWith("false")) { - this.trueCircle = 0; - v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.cleansnow"; - } -} 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 334b7a5ed..e69de29bb 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java @@ -1,139 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.ChatColor; - -/** - * The CloneStamp class is used to create a collection of blocks in a cylinder shape according to the selection the player has set. - * - * @author Voxel - */ -public class CloneStampBrush extends StampBrush { -public CloneStampBrush() { - this.setName("Clone"); - } - - /** - * 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 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 - */ - private void clone(final SnipeData v) { - final int brushSize = v.getBrushSize(); - this.clone.clear(); - this.fall.clear(); - this.drop.clear(); - this.solid.clear(); - this.sorted = false; - - int yStartingPoint = this.getTargetBlock().getY() + v.getcCen(); - int yEndPoint = this.getTargetBlock().getY() + v.getVoxelHeight() + v.getcCen(); - - if (yStartingPoint < 0) { - yStartingPoint = 0; - v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position."); - } else if (yStartingPoint > this.getWorld().getMaxHeight() - 1) { - yStartingPoint = this.getWorld().getMaxHeight() - 1; - v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position."); - } - - if (yEndPoint < 0) { - yEndPoint = 0; - v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position."); - } else if (yEndPoint > this.getWorld().getMaxHeight() - 1) { - yEndPoint = this.getWorld().getMaxHeight() - 1; - v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position."); - } - - final double bSquared = Math.pow(brushSize, 2); - - for (int z = yStartingPoint; z < yEndPoint; z++) { - this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX(), z, this.getTargetBlock().getZ()), 0, z - yStartingPoint, 0)); - for (int y = 1; y <= brushSize; y++) { - this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX(), z, this.getTargetBlock().getZ() + y), 0, z - yStartingPoint, y)); - this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX(), z, this.getTargetBlock().getZ() - y), 0, z - yStartingPoint, -y)); - this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() + y, z, this.getTargetBlock().getZ()), y, z - yStartingPoint, 0)); - this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() - y, z, this.getTargetBlock().getZ()), -y, z - yStartingPoint, 0)); - } - for (int x = 1; x <= brushSize; x++) { - final double xSquared = Math.pow(x, 2); - for (int y = 1; y <= brushSize; y++) { - if ((xSquared + Math.pow(y, 2)) <= bSquared) { - this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() + x, z, this.getTargetBlock().getZ() + y), x, z - yStartingPoint, y)); - this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() + x, z, this.getTargetBlock().getZ() - y), x, z - yStartingPoint, -y)); - this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() - x, z, this.getTargetBlock().getZ() + y), -x, z - yStartingPoint, y)); - this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() - x, z, this.getTargetBlock().getZ() - y), -x, z - yStartingPoint, -y)); - } - } - } - } - v.sendMessage(ChatColor.GREEN + String.valueOf(this.clone.size()) + ChatColor.AQUA + " blocks copied successfully."); - } - - @Override - protected final void powder(final SnipeData v) { - this.clone(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - vm.height(); - vm.center(); - switch (this.stamp) { - case DEFAULT: - vm.brushMessage("Default Stamp"); - break; - - case NO_AIR: - vm.brushMessage("No-Air Stamp"); - break; - - case FILL: - vm.brushMessage("Fill Stamp"); - break; - - default: - vm.custom(ChatColor.DARK_RED + "Error while stamping! Report"); - break; - } - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - final String parameter = par[1]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Clone / Stamp Cylinder brush parameters"); - v.sendMessage(ChatColor.GREEN + "cs f -- Activates Fill mode"); - v.sendMessage(ChatColor.GREEN + "cs a -- Activates No-Air mode"); - v.sendMessage(ChatColor.GREEN + "cs d -- Activates Default mode"); - } - if (parameter.equalsIgnoreCase("a")) { - this.setStamp(StampType.NO_AIR); - this.reSort(); - v.sendMessage(ChatColor.AQUA + "No-Air stamp brush"); - } else if (parameter.equalsIgnoreCase("f")) { - this.setStamp(StampType.FILL); - this.reSort(); - v.sendMessage(ChatColor.AQUA + "Fill stamp brush"); - } else if (parameter.equalsIgnoreCase("d")) { - this.setStamp(StampType.DEFAULT); - this.reSort(); - v.sendMessage(ChatColor.AQUA + "Default stamp brush"); - } else if (parameter.startsWith("c")) { - v.setcCen(Integer.parseInt(parameter.replace("c", ""))); - v.sendMessage(ChatColor.BLUE + "Center set to " + v.getcCen()); - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.clonestamp"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CometBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CometBrush.java deleted file mode 100644 index 4e1780fe8..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CometBrush.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.entity.LargeFireball; -import org.bukkit.entity.SmallFireball; -import org.bukkit.util.Vector; - -public class CometBrush extends Brush { - private boolean useBigBalls = false; - - public CometBrush() { - this.setName("Comet"); - } - - private void doFireball(final SnipeData v) { - final Vector targetCoords = new Vector(this.getTargetBlock().getX() + .5 * this.getTargetBlock().getX() / Math.abs(this.getTargetBlock().getX()), this.getTargetBlock().getY() + .5, this.getTargetBlock().getZ() + .5 * this.getTargetBlock().getZ() / Math.abs(this.getTargetBlock().getZ())); - final Location playerLocation = v.owner().getPlayer().getEyeLocation(); - final Vector slope = targetCoords.subtract(playerLocation.toVector()); - - if (useBigBalls) { - v.owner().getPlayer().launchProjectile(LargeFireball.class).setVelocity(slope.normalize()); - } else { - v.owner().getPlayer().launchProjectile(SmallFireball.class).setVelocity(slope.normalize()); - } - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 0; i < par.length; ++i) { - String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage("Parameters:"); - v.sendMessage("balls [big|small] -- Sets your ball size."); - } - if (parameter.equalsIgnoreCase("balls")) { - if (i + 1 >= par.length) { - v.sendMessage("The balls parameter expects a ball size after it."); - } - - String newBallSize = par[++i]; - if (newBallSize.equalsIgnoreCase("big")) { - useBigBalls = true; - v.sendMessage("Your balls are " + ChatColor.DARK_RED + ("BIG")); - } else if (newBallSize.equalsIgnoreCase("small")) { - useBigBalls = false; - v.sendMessage("Your balls are " + ChatColor.DARK_RED + ("small")); - } else { - v.sendMessage("Unknown ball size."); - } - } - } - } - - @Override - protected final void arrow(final SnipeData v) { - this.doFireball(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.doFireball(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.voxel(); - vm.custom("Your balls are " + ChatColor.DARK_RED + (useBigBalls ? "BIG" : "small")); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.comet"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CopyPastaBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CopyPastaBrush.java deleted file mode 100644 index 9b75d324e..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CopyPastaBrush.java +++ /dev/null @@ -1,177 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; - -public class CopyPastaBrush extends Brush { - private static final int BLOCK_LIMIT = 10000; - - private boolean pasteAir = true; // False = no air, true = air - private int points = 0; // - private int numBlocks = 0; - private int[] firstPoint = new int[3]; - private int[] secondPoint = new int[3]; - private int[] pastePoint = new int[3]; - private int[] minPoint = new int[3]; - private int[] offsetPoint = new int[3]; - private int[] blockArray; - private int[] arraySize = new int[3]; - private int pivot = 0; // ccw degrees - - public CopyPastaBrush() { - this.setName("CopyPasta"); - } - - private void doCopy(final SnipeData v) { - for (int i = 0; i < 3; i++) { - this.arraySize[i] = Math.abs(this.firstPoint[i] - this.secondPoint[i]) + 1; - this.minPoint[i] = Math.min(this.firstPoint[i], this.secondPoint[i]); - this.offsetPoint[i] = this.minPoint[i] - this.firstPoint[i]; // will always be negative or zero - } - - this.numBlocks = (this.arraySize[0]) * (this.arraySize[1]) * (this.arraySize[2]); - - if (this.numBlocks > 0 && this.numBlocks < CopyPastaBrush.BLOCK_LIMIT) { - this.blockArray = new int[this.numBlocks]; - - for (int i = 0; i < this.arraySize[0]; i++) { - for (int j = 0; j < this.arraySize[1]; j++) { - for (int k = 0; k < this.arraySize[2]; k++) { - final int currentPosition = i + this.arraySize[0] * j + this.arraySize[0] * this.arraySize[1] * k; - this.blockArray[currentPosition] = this.getWorld().getBlockAt(this.minPoint[0] + i, this.minPoint[1] + j, this.minPoint[2] + k).getCombinedId(); - } - } - } - - v.sendMessage(ChatColor.AQUA + "" + this.numBlocks + " blocks copied."); - } else { - v.sendMessage(ChatColor.RED + "Copy area too big: " + this.numBlocks + "(Limit: " + CopyPastaBrush.BLOCK_LIMIT + ")"); - } - } - - @SuppressWarnings("deprecation") - private void doPasta(final SnipeData v) { - final Undo undo = new Undo(); - - for (int i = 0; i < this.arraySize[0]; i++) { - for (int j = 0; j < this.arraySize[1]; j++) { - for (int k = 0; k < this.arraySize[2]; k++) { - final int currentPosition = i + this.arraySize[0] * j + this.arraySize[0] * this.arraySize[1] * k; - AsyncBlock block; - - switch (this.pivot) { - case 180: - block = this.clampY(this.pastePoint[0] - this.offsetPoint[0] - i, this.pastePoint[1] + this.offsetPoint[1] + j, this.pastePoint[2] - this.offsetPoint[2] - k); - break; - case 270: - block = this.clampY(this.pastePoint[0] + this.offsetPoint[2] + k, this.pastePoint[1] + this.offsetPoint[1] + j, this.pastePoint[2] - this.offsetPoint[0] - i); - break; - case 90: - block = this.clampY(this.pastePoint[0] - this.offsetPoint[2] - k, this.pastePoint[1] + this.offsetPoint[1] + j, this.pastePoint[2] + this.offsetPoint[0] + i); - break; - default: // assume no rotation - block = this.clampY(this.pastePoint[0] + this.offsetPoint[0] + i, this.pastePoint[1] + this.offsetPoint[1] + j, this.pastePoint[2] + this.offsetPoint[2] + k); - break; - } - - if (!(BlockTypes.getFromStateId(this.blockArray[currentPosition]).getMaterial().isAir() && !this.pasteAir)) { - - if (block.getCombinedId() != this.blockArray[currentPosition]) { - undo.put(block); - } - block.setCombinedId(this.blockArray[currentPosition]); - } - } - } - } - v.sendMessage(ChatColor.AQUA + "" + this.numBlocks + " blocks pasted."); - - v.owner().storeUndo(undo); - } - - @Override - protected final void arrow(final SnipeData v) { - switch (this.points) { - case 0: - this.firstPoint[0] = this.getTargetBlock().getX(); - this.firstPoint[1] = this.getTargetBlock().getY(); - this.firstPoint[2] = this.getTargetBlock().getZ(); - v.sendMessage(ChatColor.GRAY + "First point"); - this.points = 1; - break; - case 1: - this.secondPoint[0] = this.getTargetBlock().getX(); - this.secondPoint[1] = this.getTargetBlock().getY(); - this.secondPoint[2] = this.getTargetBlock().getZ(); - v.sendMessage(ChatColor.GRAY + "Second point"); - this.points = 2; - break; - default: - this.firstPoint = new int[3]; - this.secondPoint = new int[3]; - this.numBlocks = 0; - this.blockArray = new int[1]; - this.points = 0; - v.sendMessage(ChatColor.GRAY + "Points cleared."); - break; - } - } - - @Override - protected final void powder(final SnipeData v) { - if (this.points == 2) { - if (this.numBlocks == 0) { - this.doCopy(v); - } else if (this.numBlocks > 0 && this.numBlocks < CopyPastaBrush.BLOCK_LIMIT) { - this.pastePoint[0] = this.getTargetBlock().getX(); - this.pastePoint[1] = this.getTargetBlock().getY(); - this.pastePoint[2] = this.getTargetBlock().getZ(); - this.doPasta(v); - } else { - v.sendMessage(ChatColor.RED + "Error"); - } - } else { - v.sendMessage(ChatColor.RED + "You must select exactly two points."); - } - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.custom(ChatColor.GOLD + "Paste air: " + this.pasteAir); - vm.custom(ChatColor.GOLD + "Pivot angle: " + this.pivot); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - final String parameter = par[1]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "CopyPasta Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b cp air -- toggle include (default) or exclude air during paste"); - v.sendMessage(ChatColor.AQUA + "/b cp 0|90|180|270 -- toggle rotation (0 default)"); - return; - } - - if (parameter.equalsIgnoreCase("air")) { - this.pasteAir = !this.pasteAir; - - v.sendMessage(ChatColor.GOLD + "Paste air: " + this.pasteAir); - return; - } - - if (parameter.equalsIgnoreCase("90") || parameter.equalsIgnoreCase("180") || parameter.equalsIgnoreCase("270") || parameter.equalsIgnoreCase("0")) { - this.pivot = Integer.parseInt(parameter); - v.sendMessage(ChatColor.GOLD + "Pivot angle: " + this.pivot); - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.copypasta"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CylinderBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CylinderBrush.java deleted file mode 100644 index 7aedbaeaa..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CylinderBrush.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; - -public class CylinderBrush extends PerformBrush { - private double trueCircle = 0; - - public CylinderBrush() { - this.setName("Cylinder"); - } - - private void cylinder(final SnipeData v, Block targetBlock) { - final int brushSize = v.getBrushSize(); - int yStartingPoint = targetBlock.getY() + v.getcCen(); - int yEndPoint = targetBlock.getY() + v.getVoxelHeight() + v.getcCen(); - - if (yEndPoint < yStartingPoint) { - yEndPoint = yStartingPoint; - } - if (yStartingPoint < 0) { - yStartingPoint = 0; - v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position."); - } else if (yStartingPoint > this.getWorld().getMaxHeight() - 1) { - yStartingPoint = this.getWorld().getMaxHeight() - 1; - v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position."); - } - if (yEndPoint < 0) { - yEndPoint = 0; - v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position."); - } else if (yEndPoint > this.getWorld().getMaxHeight() - 1) { - yEndPoint = this.getWorld().getMaxHeight() - 1; - v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position."); - } - - final double bSquared = Math.pow(brushSize + this.trueCircle, 2); - - for (int y = yEndPoint; y >= yStartingPoint; y--) { - for (int x = brushSize; x >= 0; x--) { - final double xSquared = Math.pow(x, 2); - - for (int z = brushSize; z >= 0; z--) { - if ((xSquared + Math.pow(z, 2)) <= bSquared) { - this.current.perform(this.clampY(targetBlock.getX() + x, y, targetBlock.getZ() + z)); - this.current.perform(this.clampY(targetBlock.getX() + x, y, targetBlock.getZ() - z)); - this.current.perform(this.clampY(targetBlock.getX() - x, y, targetBlock.getZ() + z)); - this.current.perform(this.clampY(targetBlock.getX() - x, y, targetBlock.getZ() - z)); - } - } - } - } - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.cylinder(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.cylinder(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - vm.height(); - vm.center(); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Cylinder Brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b c h[number] -- set the cylinder v.voxelHeight. Default is 1."); - v.sendMessage(ChatColor.DARK_AQUA + "/b c true -- will use a true circle algorithm instead of the skinnier version with classic sniper nubs. /b b false will switch back. (false is default)"); - v.sendMessage(ChatColor.DARK_BLUE + "/b c c[number] -- set the origin of the cylinder compared to the target block. Positive numbers will move the cylinder upward, negative will move it downward."); - return; - } - if (parameter.startsWith("true")) { - this.trueCircle = 0.5; - v.sendMessage(ChatColor.AQUA + "True circle mode ON."); - } else if (parameter.startsWith("false")) { - this.trueCircle = 0; - v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); - } else if (parameter.startsWith("h")) { - v.setVoxelHeight((int) Double.parseDouble(parameter.replace("h", ""))); - v.sendMessage(ChatColor.AQUA + "Cylinder v.voxelHeight set to: " + v.getVoxelHeight()); - } else if (parameter.startsWith("c")) { - v.setcCen((int) Double.parseDouble(parameter.replace("c", ""))); - v.sendMessage(ChatColor.AQUA + "Cylinder origin set to: " + v.getcCen()); - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.cylinder"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscBrush.java deleted file mode 100644 index 907af9b75..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscBrush.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; -import org.bukkit.util.Vector; - -public class DiscBrush extends PerformBrush { - private double trueCircle = 0; - - /** - * Default Constructor. - */ - public DiscBrush() { - this.setName("Disc"); - } - - /** - * Disc executor. - * - * @param v Snipe Data - */ - private void disc(final SnipeData v, final Block targetBlock) { - final double radiusSquared = (v.getBrushSize() + this.trueCircle) * (v.getBrushSize() + this.trueCircle); - final Vector centerPoint = targetBlock.getLocation().toVector(); - final Vector currentPoint = centerPoint.clone(); - - for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) { - currentPoint.setX(centerPoint.getX() + x); - for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) { - currentPoint.setZ(centerPoint.getZ() + z); - if (centerPoint.distanceSquared(currentPoint) <= radiusSquared) { - this.current.perform(this.clampY(currentPoint.getBlockX(), currentPoint.getBlockY(), currentPoint.getBlockZ())); - } - } - } - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.disc(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.disc(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i].toLowerCase(); - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Disc Brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b d true|false" + " -- toggles useing the true circle algorithm instead of the skinnier version with classic sniper nubs. (false is default)"); - return; - } else if (parameter.startsWith("true")) { - this.trueCircle = 0.5; - v.sendMessage(ChatColor.AQUA + "True circle mode ON."); - } else if (parameter.startsWith("false")) { - this.trueCircle = 0; - v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.disc"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscFaceBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscFaceBrush.java deleted file mode 100644 index fd79fda34..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscFaceBrush.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; -import org.bukkit.block.BlockFace; - -public class DiscFaceBrush extends PerformBrush { - private double trueCircle = 0; - - public DiscFaceBrush() { - this.setName("Disc Face"); - } - - private void discUD(final SnipeData v, AsyncBlock targetBlock) { - final int brushSize = v.getBrushSize(); - final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); - - for (int x = brushSize; x >= 0; x--) { - final double xSquared = Math.pow(x, 2); - - for (int z = brushSize; z >= 0; z--) { - if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared) { - current.perform(targetBlock.getRelative(x, 0, z)); - current.perform(targetBlock.getRelative(x, 0, -z)); - current.perform(targetBlock.getRelative(-x, 0, z)); - current.perform(targetBlock.getRelative(-x, 0, -z)); - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - private void discNS(final SnipeData v, AsyncBlock targetBlock) { - final int brushSize = v.getBrushSize(); - final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); - - for (int x = brushSize; x >= 0; x--) { - final double xSquared = Math.pow(x, 2); - for (int y = brushSize; y >= 0; y--) { - if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared) { - current.perform(targetBlock.getRelative(x, y, 0)); - current.perform(targetBlock.getRelative(x, -y, 0)); - current.perform(targetBlock.getRelative(-x, y, 0)); - current.perform(targetBlock.getRelative(-x, -y, 0)); - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - private void discEW(final SnipeData v, AsyncBlock targetBlock) { - final int brushSize = v.getBrushSize(); - final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); - - for (int x = brushSize; x >= 0; x--) { - final double xSquared = Math.pow(x, 2); - for (int y = brushSize; y >= 0; y--) { - if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared) { - current.perform(targetBlock.getRelative(0, x, y)); - current.perform(targetBlock.getRelative(0, x, -y)); - current.perform(targetBlock.getRelative(0, -x, y)); - current.perform(targetBlock.getRelative(0, -x, -y)); - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - private void pre(final SnipeData v, AsyncBlock targetBlock) { - BlockFace blockFace = getTargetBlock().getFace(this.getLastBlock()); - if (blockFace == null) { - return; - } - switch (blockFace) { - case NORTH: - case SOUTH: - this.discNS(v, targetBlock); - break; - - case EAST: - case WEST: - this.discEW(v, targetBlock); - break; - - case UP: - case DOWN: - this.discUD(v, targetBlock); - break; - - default: - break; - } - } - - @Override - protected final void arrow(final SnipeData v) { - this.pre(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.pre(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Disc Face brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b df true -- will use a true circle algorithm instead of the skinnier version with classic sniper nubs. /b b false will switch back. (false is default)"); - return; - } - if (parameter.startsWith("true")) { - this.trueCircle = 0.5; - v.sendMessage(ChatColor.AQUA + "True circle mode ON."); - } else if (parameter.startsWith("false")) { - this.trueCircle = 0; - v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.discface"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DomeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DomeBrush.java deleted file mode 100644 index 8ab6d0480..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DomeBrush.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.block.Block; -import org.bukkit.util.NumberConversions; -import org.bukkit.util.Vector; - -import java.util.HashSet; -import java.util.Set; - -public class DomeBrush extends Brush { - - public DomeBrush() { - this.setName("Dome"); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - vm.voxel(); - vm.height(); - } - - /** - * @param v Snipe Data - * @param targetBlock the targetBlock to set - */ - @SuppressWarnings("deprecation") - private void generateDome(final SnipeData v, final Block targetBlock) { - - if (v.getVoxelHeight() == 0) { - v.sendMessage("VoxelHeight must not be 0."); - return; - } - - final int absoluteHeight = Math.abs(v.getVoxelHeight()); - final boolean negative = v.getVoxelHeight() < 0; - - final Set changeablePositions = new HashSet<>(); - - final Undo undo = new Undo(); - - final int brushSizeTimesVoxelHeight = v.getBrushSize() * absoluteHeight; - final double stepScale = ((v.getBrushSize() * v.getBrushSize()) + brushSizeTimesVoxelHeight + brushSizeTimesVoxelHeight) / 5; - - final double stepSize = 1 / stepScale; - - for (double u = 0; u <= Math.PI / 2; u += stepSize) { - final double y = absoluteHeight * Math.sin(u); - for (double stepV = -Math.PI; stepV <= -(Math.PI / 2); stepV += stepSize) { - final double x = v.getBrushSize() * Math.cos(u) * Math.cos(stepV); - final double z = v.getBrushSize() * Math.cos(u) * Math.sin(stepV); - - final double targetBlockX = targetBlock.getX() + 0.5; - final double targetBlockZ = targetBlock.getZ() + 0.5; - final int targetY = NumberConversions.floor(targetBlock.getY() + (negative ? -y : y)); - final int currentBlockXAdd = NumberConversions.floor(targetBlockX + x); - final int currentBlockZAdd = NumberConversions.floor(targetBlockZ + z); - final int currentBlockXSubtract = NumberConversions.floor(targetBlockX - x); - final int currentBlockZSubtract = NumberConversions.floor(targetBlockZ - z); - changeablePositions.add(new Vector(currentBlockXAdd, targetY, currentBlockZAdd)); - changeablePositions.add(new Vector(currentBlockXSubtract, targetY, currentBlockZAdd)); - changeablePositions.add(new Vector(currentBlockXAdd, targetY, currentBlockZSubtract)); - changeablePositions.add(new Vector(currentBlockXSubtract, targetY, currentBlockZSubtract)); - - } - } - - for (final Vector vector : changeablePositions) { - final AsyncBlock currentTargetBlock = (AsyncBlock) vector.toLocation(this.getTargetBlock().getWorld()).getBlock(); - if (currentTargetBlock.getTypeId() != v.getVoxelId() || currentTargetBlock.getPropertyId() != v.getPropertyId()) { - undo.put(currentTargetBlock); - currentTargetBlock.setTypeIdAndPropertyId(v.getVoxelId(), v.getPropertyId(), true); - } - } - - v.owner().storeUndo(undo); - } - - @Override - protected final void arrow(final SnipeData v) { - this.generateDome(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.generateDome(v, this.getLastBlock()); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.dome"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DrainBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DrainBrush.java deleted file mode 100644 index 80f0fcd2e..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DrainBrush.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; - -public class DrainBrush extends Brush { - private double trueCircle = 0; - private boolean disc = false; - - public DrainBrush() { - this.setName("Drain"); - } - - private void drain(final SnipeData v) { - final int brushSize = v.getBrushSize(); - final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); - final Undo undo = new Undo(); - - if (this.disc) { - for (int x = brushSize; x >= 0; x--) { - final double xSquared = Math.pow(x, 2); - - for (int y = brushSize; y >= 0; y--) { - if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared) { - if (this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y) == BlockTypes.LAVA.getInternalId()) { - undo.put(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y)); - this.setBlockIdAt(this.getTargetBlock().getZ() + y, this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), BlockTypes.AIR.getInternalId()); - } - - if (this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y) == BlockTypes.LAVA.getInternalId()) { - undo.put(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y)); - this.setBlockIdAt(this.getTargetBlock().getZ() - y, this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), BlockTypes.AIR.getInternalId()); - } - - if (this.getBlockIdAt(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y) == BlockTypes.LAVA.getInternalId()) { - undo.put(this.clampY(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y)); - this.setBlockIdAt(this.getTargetBlock().getZ() + y, this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), BlockTypes.AIR.getInternalId()); - } - - if (this.getBlockIdAt(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y) == BlockTypes.LAVA.getInternalId()) { - undo.put(this.clampY(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y)); - this.setBlockIdAt(this.getTargetBlock().getZ() - y, this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), BlockTypes.AIR.getInternalId()); - } - } - } - } - } else { - for (int y = (brushSize + 1) * 2; y >= 0; y--) { - final double ySquared = Math.pow(y - brushSize, 2); - - for (int x = (brushSize + 1) * 2; x >= 0; x--) { - final double xSquared = Math.pow(x - brushSize, 2); - - for (int z = (brushSize + 1) * 2; z >= 0; z--) { - if ((xSquared + Math.pow(z - brushSize, 2) + ySquared) <= brushSizeSquared) { - if (this.getBlockIdAt(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, this.getTargetBlock().getZ() + y - brushSize) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, this.getTargetBlock().getZ() + y - brushSize) == BlockTypes.LAVA.getInternalId()) { - undo.put(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + z, this.getTargetBlock().getZ() + y)); - this.setBlockIdAt(this.getTargetBlock().getZ() + y - brushSize, this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, BlockTypes.AIR.getInternalId()); - } - } - } - } - } - } - - v.owner().storeUndo(undo); - } - - @Override - protected final void arrow(final SnipeData v) { - this.drain(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.drain(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - - vm.custom(ChatColor.AQUA + ((this.trueCircle == 0.5) ? "True circle mode ON" : "True circle mode OFF")); - vm.custom(ChatColor.AQUA + ((this.disc) ? "Disc drain mode ON" : "Disc drain mode OFF")); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Drain Brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b drain true -- will use a true sphere algorithm instead of the skinnier version with classic sniper nubs. /b drain false will switch back. (false is default)"); - v.sendMessage(ChatColor.AQUA + "/b drain d -- toggles disc drain mode, as opposed to a ball drain mode"); - return; - } else if (parameter.startsWith("true")) { - this.trueCircle = 0.5; - v.sendMessage(ChatColor.AQUA + "True circle mode ON."); - } else if (parameter.startsWith("false")) { - this.trueCircle = 0; - v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); - } else if (parameter.equalsIgnoreCase("d")) { - if (this.disc) { - this.disc = false; - v.sendMessage(ChatColor.AQUA + "Disc drain mode OFF"); - } else { - this.disc = true; - v.sendMessage(ChatColor.AQUA + "Disc drain mode ON"); - } - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.drain"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipseBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipseBrush.java deleted file mode 100644 index 586e228a1..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipseBrush.java +++ /dev/null @@ -1,235 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; - -public class EllipseBrush extends PerformBrush { - private static final double TWO_PI = (2 * Math.PI); - private static final int SCL_MIN = 1; - private static final int SCL_MAX = 9999; - private static final int SCL_DEFAULT = 10; - private static final int STEPS_MIN = 1; - private static final int STEPS_MAX = 2000; - private static final int STEPS_DEFAULT = 200; - private int xscl; - private int yscl; - private int steps; - private double stepSize; - private boolean fill; - - public EllipseBrush() { - this.setName("Ellipse"); - } - - private void ellipse(final SnipeData v, AsyncBlock targetBlock) { - try { - for (double steps = 0; (steps <= TWO_PI); steps += stepSize) { - final int x = (int) Math.round(this.xscl * Math.cos(steps)); - final int y = (int) Math.round(this.yscl * Math.sin(steps)); - - switch (getTargetBlock().getFace(this.getLastBlock())) { - case NORTH: - case SOUTH: - current.perform(targetBlock.getRelative(0, x, y)); - break; - case EAST: - case WEST: - current.perform(targetBlock.getRelative(x, y, 0)); - break; - case UP: - case DOWN: - current.perform(targetBlock.getRelative(x, 0, y)); - default: - break; - } - - if (steps >= TWO_PI) { - break; - } - } - } catch (final Exception exception) { - v.sendMessage(ChatColor.RED + "Invalid target."); - } - - v.owner().storeUndo(this.current.getUndo()); - } - - private void ellipsefill(final SnipeData v, AsyncBlock targetBlock) { - int ix = this.xscl; - int iy = this.yscl; - - current.perform(targetBlock); - - try { - if (ix >= iy) { // Need this unless you want weird holes - for (iy = this.yscl; iy > 0; iy--) { - for (double steps = 0; (steps <= TWO_PI); steps += stepSize) { - final int x = (int) Math.round(ix * Math.cos(steps)); - final int y = (int) Math.round(iy * Math.sin(steps)); - - switch (getTargetBlock().getFace(this.getLastBlock())) { - case NORTH: - case SOUTH: - current.perform(targetBlock.getRelative(0, x, y)); - break; - case EAST: - case WEST: - current.perform(targetBlock.getRelative(x, y, 0)); - break; - case UP: - case DOWN: - current.perform(targetBlock.getRelative(x, 0, y)); - default: - break; - } - - if (steps >= TWO_PI) { - break; - } - } - ix--; - } - } else { - for (ix = this.xscl; ix > 0; ix--) { - for (double steps = 0; (steps <= TWO_PI); steps += stepSize) { - final int x = (int) Math.round(ix * Math.cos(steps)); - final int y = (int) Math.round(iy * Math.sin(steps)); - - switch (getTargetBlock().getFace(this.getLastBlock())) { - case NORTH: - case SOUTH: - current.perform(targetBlock.getRelative(0, x, y)); - break; - case EAST: - case WEST: - current.perform(targetBlock.getRelative(x, y, 0)); - break; - case UP: - case DOWN: - current.perform(targetBlock.getRelative(x, 0, y)); - default: - break; - } - - if (steps >= TWO_PI) { - break; - } - } - iy--; - } - } - } catch (final Exception exception) { - v.sendMessage(ChatColor.RED + "Invalid target."); - } - - v.owner().storeUndo(this.current.getUndo()); - } - - private void execute(final SnipeData v, AsyncBlock targetBlock) { - this.stepSize = (TWO_PI / this.steps); - - if (this.fill) { - this.ellipsefill(v, targetBlock); - } else { - this.ellipse(v, targetBlock); - } - } - - @Override - protected final void arrow(final SnipeData v) { - this.execute(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.execute(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - if (this.xscl < SCL_MIN || this.xscl > SCL_MAX) { - this.xscl = SCL_DEFAULT; - } - - if (this.yscl < SCL_MIN || this.yscl > SCL_MAX) { - this.yscl = SCL_DEFAULT; - } - - if (this.steps < STEPS_MIN || this.steps > STEPS_MAX) { - this.steps = STEPS_DEFAULT; - } - - vm.brushName(this.getName()); - vm.custom(ChatColor.AQUA + "X-size set to: " + ChatColor.DARK_AQUA + this.xscl); - vm.custom(ChatColor.AQUA + "Y-size set to: " + ChatColor.DARK_AQUA + this.yscl); - vm.custom(ChatColor.AQUA + "Render step number set to: " + ChatColor.DARK_AQUA + this.steps); - if (this.fill) { - vm.custom(ChatColor.AQUA + "Fill mode is enabled"); - } else { - vm.custom(ChatColor.AQUA + "Fill mode is disabled"); - } - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - try { - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Ellipse brush parameters"); - v.sendMessage(ChatColor.AQUA + "x[n]: Set X size modifier to n"); - v.sendMessage(ChatColor.AQUA + "y[n]: Set Y size modifier to n"); - v.sendMessage(ChatColor.AQUA + "t[n]: Set the amount of time steps"); - v.sendMessage(ChatColor.AQUA + "fill: Toggles fill mode"); - return; - } else if (parameter.startsWith("x")) { - int tempXScale = Integer.parseInt(par[i].replace("x", "")); - if (tempXScale < SCL_MIN || tempXScale > SCL_MAX) { - v.sendMessage(ChatColor.AQUA + "Invalid X scale (" + SCL_MIN + "-" + SCL_MAX + ")"); - continue; - } - this.xscl = tempXScale; - v.sendMessage(ChatColor.AQUA + "X-scale modifier set to: " + this.xscl); - } else if (parameter.startsWith("y")) { - int tempYScale = Integer.parseInt(par[i].replace("y", "")); - if (tempYScale < SCL_MIN || tempYScale > SCL_MAX) { - v.sendMessage(ChatColor.AQUA + "Invalid Y scale (" + SCL_MIN + "-" + SCL_MAX + ")"); - continue; - } - this.yscl = tempYScale; - v.sendMessage(ChatColor.AQUA + "Y-scale modifier set to: " + this.yscl); - } else if (parameter.startsWith("t")) { - int tempSteps = Integer.parseInt(par[i].replace("t", "")); - if (tempSteps < STEPS_MIN || tempSteps > STEPS_MAX) { - v.sendMessage(ChatColor.AQUA + "Invalid step number (" + STEPS_MIN + "-" + STEPS_MAX + ")"); - continue; - } - this.steps = tempSteps; - v.sendMessage(ChatColor.AQUA + "Render step number set to: " + this.steps); - } else if (parameter.equalsIgnoreCase("fill")) { - if (this.fill) { - this.fill = false; - v.sendMessage(ChatColor.AQUA + "Fill mode is disabled"); - } else { - this.fill = true; - v.sendMessage(ChatColor.AQUA + "Fill mode is enabled"); - } - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the \"info\" parameter to display parameter info."); - } - - } catch (final Exception exception) { - v.sendMessage(ChatColor.RED + "Incorrect parameter \"" + parameter + "\"; use the \"info\" parameter."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.ellipse"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipsoidBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipsoidBrush.java deleted file mode 100644 index 6202e4af5..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipsoidBrush.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; - -public class EllipsoidBrush extends PerformBrush { - private double xRad; - private double yRad; - private double zRad; - private boolean istrue; - - public EllipsoidBrush() { - this.setName("Ellipsoid"); - } - - private void execute(final SnipeData v, AsyncBlock targetBlock) { - this.current.perform(targetBlock); - double istrueoffset = istrue ? 0.5 : 0; - int blockPositionX = targetBlock.getX(); - int blockPositionY = targetBlock.getY(); - int blockPositionZ = targetBlock.getZ(); - - for (double x = 0; x <= xRad; x++) { - - final double xSquared = (x / (xRad + istrueoffset)) * (x / (xRad + istrueoffset)); - - for (double z = 0; z <= zRad; z++) { - - final double zSquared = (z / (zRad + istrueoffset)) * (z / (zRad + istrueoffset)); - - for (double y = 0; y <= yRad; y++) { - - final double ySquared = (y / (yRad + istrueoffset)) * (y / (yRad + istrueoffset)); - - if (xSquared + ySquared + zSquared <= 1) { - this.current.perform(this.clampY((int) (blockPositionX + x), (int) (blockPositionY + y), (int) (blockPositionZ + z))); - this.current.perform(this.clampY((int) (blockPositionX + x), (int) (blockPositionY + y), (int) (blockPositionZ - z))); - this.current.perform(this.clampY((int) (blockPositionX + x), (int) (blockPositionY - y), (int) (blockPositionZ + z))); - this.current.perform(this.clampY((int) (blockPositionX + x), (int) (blockPositionY - y), (int) (blockPositionZ - z))); - this.current.perform(this.clampY((int) (blockPositionX - x), (int) (blockPositionY + y), (int) (blockPositionZ + z))); - this.current.perform(this.clampY((int) (blockPositionX - x), (int) (blockPositionY + y), (int) (blockPositionZ - z))); - this.current.perform(this.clampY((int) (blockPositionX - x), (int) (blockPositionY - y), (int) (blockPositionZ + z))); - this.current.perform(this.clampY((int) (blockPositionX - x), (int) (blockPositionY - y), (int) (blockPositionZ - z))); - } - - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.execute(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.execute(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.custom(ChatColor.AQUA + "X-size set to: " + ChatColor.DARK_AQUA + this.xRad); - vm.custom(ChatColor.AQUA + "Y-size set to: " + ChatColor.DARK_AQUA + this.yRad); - vm.custom(ChatColor.AQUA + "Z-size set to: " + ChatColor.DARK_AQUA + this.zRad); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - this.istrue = false; - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - try { - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Ellipse brush parameters"); - v.sendMessage(ChatColor.AQUA + "x[n]: Set X radius to n"); - v.sendMessage(ChatColor.AQUA + "y[n]: Set Y radius to n"); - v.sendMessage(ChatColor.AQUA + "z[n]: Set Z radius to n"); - return; - } else if (parameter.startsWith("x")) { - this.xRad = Integer.parseInt(par[i].replace("x", "")); - v.sendMessage(ChatColor.AQUA + "X radius set to: " + this.xRad); - } else if (parameter.startsWith("y")) { - this.yRad = Integer.parseInt(par[i].replace("y", "")); - v.sendMessage(ChatColor.AQUA + "Y radius set to: " + this.yRad); - } else if (parameter.startsWith("z")) { - this.zRad = Integer.parseInt(par[i].replace("z", "")); - v.sendMessage(ChatColor.AQUA + "Z radius set to: " + this.zRad); - } else if (parameter.equalsIgnoreCase("true")) { - this.istrue = true; - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the \"info\" parameter to display parameter info."); - } - - } catch (final Exception exception) { - v.sendMessage(ChatColor.RED + "Incorrect parameter \"" + parameter + "\"; use the \"info\" parameter."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.ellipsoid"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityBrush.java deleted file mode 100644 index 70998fdae..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityBrush.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.ChatColor; -import org.bukkit.entity.EntityType; - - -public class EntityBrush extends Brush { - private EntityType entityType = EntityType.ZOMBIE; - - public EntityBrush() { - this.setName("Entity"); - } - - private void spawn(final SnipeData v) { - for (int x = 0; x < v.getBrushSize(); x++) { - try { - this.getWorld().spawn(this.getLastBlock().getLocation(), this.entityType.getEntityClass()); - } catch (final IllegalArgumentException exception) { - v.sendMessage(ChatColor.RED + "Cannot spawn entity!"); - } - } - } - - @Override - protected final void arrow(final SnipeData v) { - this.spawn(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.spawn(v); - } - - @SuppressWarnings("deprecation") - @Override - public final void info(final Message vm) { - vm.brushMessage(ChatColor.LIGHT_PURPLE + "Entity brush" + " (" + this.entityType.getName() + ")"); - vm.size(); - } - - @SuppressWarnings("deprecation") - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - String names = ""; - - v.sendMessage(ChatColor.BLUE + "The available entity types are as follows:"); - for (final EntityType currentEntity : EntityType.values()) { - - names += ChatColor.AQUA + " | " + ChatColor.DARK_GREEN + currentEntity.getName(); - } - names += ChatColor.AQUA + " |"; - v.sendMessage(names); - } else { - final EntityType currentEntity = EntityType.fromName(par[1]); - if (currentEntity != null) { - this.entityType = currentEntity; - v.sendMessage(ChatColor.GREEN + "Entity type set to " + this.entityType.getName()); - } else { - v.sendMessage(ChatColor.RED + "This is not a valid entity!"); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.entity"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityRemovalBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityRemovalBrush.java deleted file mode 100644 index 03273c709..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityRemovalBrush.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.ChatColor; -import org.bukkit.Chunk; -import org.bukkit.entity.Entity; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.regex.PatternSyntaxException; - -public class EntityRemovalBrush extends Brush { - private final List exemptions = new ArrayList<>(3); - - public EntityRemovalBrush() { - this.setName("Entity Removal"); - - exemptions.add("org.bukkit.entity.Player"); - exemptions.add("org.bukkit.entity.Hanging"); - exemptions.add("org.bukkit.entity.NPC"); - } - - private void radialRemoval(SnipeData v) { - final Chunk targetChunk = getTargetBlock().getChunk(); - int entityCount = 0; - int chunkCount = 0; - - try { - entityCount += removeEntities(targetChunk); - - int radius = Math.round(v.getBrushSize() / 16); - - for (int x = targetChunk.getX() - radius; x <= targetChunk.getX() + radius; x++) { - for (int z = targetChunk.getZ() - radius; z <= targetChunk.getZ() + radius; z++) { - entityCount += removeEntities(getWorld().getChunkAt(x, z)); - - chunkCount++; - } - } - } catch (final PatternSyntaxException pse) { - pse.printStackTrace(); - v.sendMessage(ChatColor.RED + "Error in RegEx: " + ChatColor.LIGHT_PURPLE + pse.getPattern()); - v.sendMessage(ChatColor.RED + String.format("%s (Index: %d)", pse.getDescription(), pse.getIndex())); - } - v.sendMessage(ChatColor.GREEN + "Removed " + ChatColor.RED + entityCount + ChatColor.GREEN + " entities out of " + ChatColor.BLUE + chunkCount + ChatColor.GREEN + (chunkCount == 1 ? " chunk." : " chunks.")); - } - - private int removeEntities(Chunk chunk) throws PatternSyntaxException { - int entityCount = 0; - - for (Entity entity : chunk.getEntities()) { - if (isClassInExemptionList(entity.getClass())) { - continue; - } - - entity.remove(); - entityCount++; - } - - return entityCount; - } - - private boolean isClassInExemptionList(Class entityClass) throws PatternSyntaxException { - // Create a list of superclasses and interfaces implemented by the current entity type - final List entityClassHierarchy = new ArrayList<>(); - - Class currentClass = entityClass; - while (currentClass != null && !currentClass.equals(Object.class)) { - entityClassHierarchy.add(currentClass.getCanonicalName()); - - for (final Class intrf : currentClass.getInterfaces()) { - entityClassHierarchy.add(intrf.getCanonicalName()); - } - - currentClass = currentClass.getSuperclass(); - } - - for (final String exemptionPattern : exemptions) { - for (final String typeName : entityClassHierarchy) { - if (typeName.matches(exemptionPattern)) { - return true; - } - - } - } - - return false; - } - - @Override - protected void arrow(SnipeData v) { - this.radialRemoval(v); - } - - @Override - protected void powder(SnipeData v) { - this.radialRemoval(v); - } - - @Override - public void info(Message vm) { - vm.brushName(getName()); - - final StringBuilder exemptionsList = new StringBuilder(ChatColor.GREEN + "Exemptions: " + ChatColor.LIGHT_PURPLE); - for (Iterator it = exemptions.iterator(); it.hasNext(); ) { - exemptionsList.append(it.next()); - if (it.hasNext()) { - exemptionsList.append(", "); - } - } - vm.custom(exemptionsList.toString()); - - vm.size(); - } - - @Override - public void parameters(final String[] par, final SnipeData v) { - for (final String currentParam : par) { - if (currentParam.startsWith("+") || currentParam.startsWith("-")) { - final boolean isAddOperation = currentParam.startsWith("+"); - - // +#/-# will suppress auto-prefixing - final String exemptionPattern = currentParam.startsWith("+#") || currentParam.startsWith("-#") ? - currentParam.substring(2) : - (currentParam.contains(".") ? currentParam.substring(1) : ".*." + currentParam.substring(1)); - - if (isAddOperation) { - exemptions.add(exemptionPattern); - v.sendMessage(String.format("Added %s to entity exemptions list.", exemptionPattern)); - } else { - exemptions.remove(exemptionPattern); - v.sendMessage(String.format("Removed %s from entity exemptions list.", exemptionPattern)); - } - } - - if (currentParam.equalsIgnoreCase("list-exemptions") || currentParam.equalsIgnoreCase("lex")) { - for (final String exemption : exemptions) { - v.sendMessage(ChatColor.LIGHT_PURPLE + exemption); - } - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.entityremoval"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EraserBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EraserBrush.java deleted file mode 100644 index 8d4c00c96..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EraserBrush.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; - -import java.util.EnumSet; -import java.util.Set; - - -public class EraserBrush extends Brush { - - private static final Set EXCLUSIVE_MATERIALS = EnumSet.of( - Material.AIR, Material.STONE, Material.GRASS, Material.DIRT, Material.SAND, Material.GRAVEL, Material.SANDSTONE); - private static final Set EXCLUSIVE_LIQUIDS = EnumSet.of( - Material.WATER, Material.WATER, Material.LAVA, Material.LAVA); - - public EraserBrush() { - this.setName("Eraser"); - } - - private void doErase(final SnipeData v, final boolean keepWater) { - final int brushSize = v.getBrushSize(); - final int brushSizeDoubled = 2 * brushSize; - World world = this.getTargetBlock().getWorld(); - final Undo undo = new Undo(); - - for (int x = brushSizeDoubled; x >= 0; x--) { - int currentX = this.getTargetBlock().getX() - brushSize + x; - for (int y = 0; y <= brushSizeDoubled; y++) { - int currentY = this.getTargetBlock().getY() - brushSize + y; - for (int z = brushSizeDoubled; z >= 0; z--) { - int currentZ = this.getTargetBlock().getZ() - brushSize + z; - Block currentBlock = world.getBlockAt(currentX, currentY, currentZ); - if (EXCLUSIVE_MATERIALS.contains(currentBlock.getType()) - || (keepWater && EXCLUSIVE_LIQUIDS.contains(currentBlock.getType()))) { - continue; - } - undo.put(currentBlock); - currentBlock.setType(Material.AIR); - } - } - } - v.owner().storeUndo(undo); - } - - @Override - protected final void arrow(final SnipeData v) { - this.doErase(v, false); - } - - @Override - protected final void powder(final SnipeData v) { - this.doErase(v, true); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.eraser"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBlendBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBlendBrush.java deleted file mode 100644 index 281db0b0d..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBlendBrush.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - -public class ErodeBlendBrush extends Brush { - - private BlendBallBrush blendBall; - private ErodeBrush erode; - - public ErodeBlendBrush() { - this.blendBall = new BlendBallBrush(); - this.erode = new ErodeBrush(); - this.setName("Erode BlendBall"); - } - - @Override - protected final void arrow(final SnipeData v) { - this.blendBall.excludeAir = false; - this.blendBall.setTargetBlock(this.getTargetBlock()); - this.blendBall.arrow(v); - this.erode.setTargetBlock(this.getTargetBlock()); - this.erode.arrow(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.blendBall.excludeAir = false; - this.blendBall.setTargetBlock(this.getTargetBlock()); - this.blendBall.arrow(v); - this.erode.setTargetBlock(this.getTargetBlock()); - this.erode.powder(v); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - this.blendBall.parameters(par, v); - this.erode.parameters(par, v); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.erodeblend"; - } - - @Override - public void info(Message vm) { - this.erode.info(vm); - this.blendBall.info(vm); - } - -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBrush.java deleted file mode 100644 index d2e37f7e8..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBrush.java +++ /dev/null @@ -1,451 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.boydti.fawe.bukkit.wrapper.AsyncWorld; -import com.google.common.base.Objects; -import com.martiansoftware.jsap.FlaggedOption; -import com.martiansoftware.jsap.JSAPException; -import com.martiansoftware.jsap.JSAPResult; -import com.martiansoftware.jsap.UnflaggedOption; -import com.martiansoftware.jsap.stringparsers.EnumeratedStringParser; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import com.thevoxelbox.voxelsniper.jsap.HelpJSAP; -import com.thevoxelbox.voxelsniper.jsap.NullableIntegerStringParser; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.util.ChatPaginator; -import org.bukkit.util.Vector; - -import java.util.*; - -public class ErodeBrush extends Brush { - private static final Vector[] FACES_TO_CHECK = {new Vector(0, 0, 1), new Vector(0, 0, -1), new Vector(0, 1, 0), new Vector(0, -1, 0), new Vector(1, 0, 0), new Vector(-1, 0, 0)}; - private final HelpJSAP parser = new HelpJSAP("/b e", "Brush for eroding landscape.", ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH); - private ErosionPreset currentPreset = new ErosionPreset(0, 1, 0, 1); - - public ErodeBrush() { - this.setName("Erode"); - - try { - this.parser.registerParameter(new UnflaggedOption("preset", EnumeratedStringParser.getParser(Preset.getValuesString(";"), false), null, false, false, "Preset options: " + Preset.getValuesString(", "))); - this.parser.registerParameter(new FlaggedOption("fill", NullableIntegerStringParser.getParser(), null, false, 'f', "fill", "Surrounding blocks required to fill the block.")); - this.parser.registerParameter(new FlaggedOption("erode", NullableIntegerStringParser.getParser(), null, false, 'e', "erode", "Surrounding air required to erode the block.")); - this.parser.registerParameter(new FlaggedOption("fillrecursion", NullableIntegerStringParser.getParser(), null, false, 'F', "fillrecursion", "Repeated fill iterations.")); - this.parser.registerParameter(new FlaggedOption("eroderecursion", NullableIntegerStringParser.getParser(), null, false, 'E', "eroderecursion", "Repeated erode iterations.")); - } catch (JSAPException ignored) { - } - } - - public static boolean sendHelpOrErrorMessageToPlayer(final JSAPResult result, final Player player, final HelpJSAP helpJSAP) { - final List output = helpJSAP.writeHelpOrErrorMessageIfRequired(result); - if (!output.isEmpty()) { - for (final String string : output) { - player.sendMessage(string); - } - return true; - } - return false; - } - - @Override - protected final void arrow(final SnipeData v) { - this.erosion(v, this.currentPreset); - } - - @SuppressWarnings("deprecation") - private void erosion(final SnipeData v, final ErosionPreset erosionPreset) { - - final BlockChangeTracker blockChangeTracker = new BlockChangeTracker(this.getTargetBlock().getWorld()); - - final Vector targetBlockVector = this.getTargetBlock().getLocation().toVector(); - - for (int i = 0; i < erosionPreset.getErosionRecursion(); ++i) { - erosionIteration(v, erosionPreset, blockChangeTracker, targetBlockVector); - } - - for (int i = 0; i < erosionPreset.getFillRecursion(); ++i) { - fillIteration(v, erosionPreset, blockChangeTracker, targetBlockVector); - } - - final Undo undo = new Undo(); - for (final BlockWrapper blockWrapper : blockChangeTracker.getAll()) { - undo.put(blockWrapper.getBlock()); - blockWrapper.getBlock().setTypeIdAndPropertyId(BukkitAdapter.adapt(blockWrapper.getMaterial()).getInternalId(), blockWrapper.getPropertyId(), true); - } - - v.owner().storeUndo(undo); - } - - private void fillIteration(final SnipeData v, final ErosionPreset erosionPreset, final BlockChangeTracker blockChangeTracker, final Vector targetBlockVector) { - final int currentIteration = blockChangeTracker.nextIteration(); - for (int x = this.getTargetBlock().getX() - v.getBrushSize(); x <= this.getTargetBlock().getX() + v.getBrushSize(); ++x) { - for (int z = this.getTargetBlock().getZ() - v.getBrushSize(); z <= this.getTargetBlock().getZ() + v.getBrushSize(); ++z) { - for (int y = this.getTargetBlock().getY() - v.getBrushSize(); y <= this.getTargetBlock().getY() + v.getBrushSize(); ++y) { - final Vector currentPosition = new Vector(x, y, z); - if (currentPosition.isInSphere(targetBlockVector, v.getBrushSize())) { - final BlockWrapper currentBlock = blockChangeTracker.get(currentPosition, currentIteration); - - if (!(currentBlock.isEmpty() || currentBlock.isLiquid())) { - continue; - } - - int count = 0; - - final Map blockCount = new HashMap<>(); - - for (final Vector vector : ErodeBrush.FACES_TO_CHECK) { - final Vector relativePosition = currentPosition.clone().add(vector); - final BlockWrapper relativeBlock = blockChangeTracker.get(relativePosition, currentIteration); - - if (!(relativeBlock.isEmpty() || relativeBlock.isLiquid())) { - count++; - final BlockWrapper typeBlock = new BlockWrapper(null, relativeBlock.getMaterial(), relativeBlock.getPropertyId()); - if (blockCount.containsKey(typeBlock)) { - blockCount.put(typeBlock, blockCount.get(typeBlock) + 1); - } else { - blockCount.put(typeBlock, 1); - } - } - } - - BlockWrapper currentMaterial = new BlockWrapper(null, Material.AIR, 0); - int amount = 0; - - for (final BlockWrapper wrapper : blockCount.keySet()) { - final Integer currentCount = blockCount.get(wrapper); - if (amount <= currentCount) { - currentMaterial = wrapper; - amount = currentCount; - } - } - - if (count >= erosionPreset.getFillFaces()) { - blockChangeTracker.put(currentPosition, new BlockWrapper(currentBlock.getBlock(), currentMaterial.getMaterial(), currentMaterial.getPropertyId()), currentIteration); - } - } - } - } - } - } - - private void erosionIteration(final SnipeData v, final ErosionPreset erosionPreset, final BlockChangeTracker blockChangeTracker, final Vector targetBlockVector) { - final int currentIteration = blockChangeTracker.nextIteration(); - for (int x = this.getTargetBlock().getX() - v.getBrushSize(); x <= this.getTargetBlock().getX() + v.getBrushSize(); ++x) { - for (int z = this.getTargetBlock().getZ() - v.getBrushSize(); z <= this.getTargetBlock().getZ() + v.getBrushSize(); ++z) { - for (int y = this.getTargetBlock().getY() - v.getBrushSize(); y <= this.getTargetBlock().getY() + v.getBrushSize(); ++y) { - final Vector currentPosition = new Vector(x, y, z); - if (currentPosition.isInSphere(targetBlockVector, v.getBrushSize())) { - final BlockWrapper currentBlock = blockChangeTracker.get(currentPosition, currentIteration); - - if (currentBlock.isEmpty() || currentBlock.isLiquid()) { - continue; - } - - int count = 0; - for (final Vector vector : ErodeBrush.FACES_TO_CHECK) { - final Vector relativePosition = currentPosition.clone().add(vector); - final BlockWrapper relativeBlock = blockChangeTracker.get(relativePosition, currentIteration); - - if (relativeBlock.isEmpty() || relativeBlock.isLiquid()) { - count++; - } - } - - if (count >= erosionPreset.getErosionFaces()) { - blockChangeTracker.put(currentPosition, new BlockWrapper(currentBlock.getBlock(), Material.AIR, 0), currentIteration); - } - } - } - } - } - } - - @Override - protected final void powder(final SnipeData v) { - this.erosion(v, this.currentPreset.getInverted()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - vm.custom(ChatColor.AQUA + "Erosion minimum exposed faces set to " + this.currentPreset.getErosionFaces()); - 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()); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - JSAPResult result = this.parser.parse(Arrays.copyOfRange(par, 1, par.length)); - - if (sendHelpOrErrorMessageToPlayer(result, v.owner().getPlayer(), this.parser)) { - return; - } - - if (result.getString("preset") != null) { - try { - this.currentPreset = Preset.valueOf(result.getString("preset").toUpperCase()).getPreset(); - v.getVoxelMessage().brushMessage("Brush preset set to " + result.getString("preset")); - return; - } catch (final IllegalArgumentException exception) { - v.getVoxelMessage().brushMessage("No such preset."); - return; - } - } - - ErosionPreset currentPresetBackup = this.currentPreset; - - if (result.getObject("fill") != null) { - this.currentPreset = new ErosionPreset(this.currentPreset.getErosionFaces(), this.currentPreset.getErosionRecursion(), result.getInt("fill"), this.currentPreset.getFillRecursion()); - } - - if (result.getObject("erode") != null) { - this.currentPreset = new ErosionPreset(result.getInt("erode"), this.currentPreset.getErosionRecursion(), this.currentPreset.getFillFaces(), this.currentPreset.getFillRecursion()); - } - - if (result.getObject("fillrecursion") != null) { - this.currentPreset = new ErosionPreset(this.currentPreset.getErosionFaces(), this.currentPreset.getErosionRecursion(), this.currentPreset.getFillFaces(), result.getInt("fillrecursion")); - } - - if (result.getObject("eroderecursion") != null) { - this.currentPreset = new ErosionPreset(this.currentPreset.getErosionFaces(), result.getInt("eroderecursion"), this.currentPreset.getFillFaces(), this.currentPreset.getFillRecursion()); - } - - if (!currentPreset.equals(currentPresetBackup)) { - if (currentPreset.getErosionFaces() != currentPresetBackup.getErosionFaces()) { - v.sendMessage(ChatColor.AQUA + "Erosion faces set to: " + ChatColor.WHITE + currentPreset.getErosionFaces()); - } - if (currentPreset.getFillFaces() != currentPresetBackup.getFillFaces()) { - v.sendMessage(ChatColor.AQUA + "Fill faces set to: " + ChatColor.WHITE + currentPreset.getFillFaces()); - } - if (currentPreset.getErosionRecursion() != currentPresetBackup.getErosionRecursion()) { - v.sendMessage(ChatColor.AQUA + "Erosion recursions set to: " + ChatColor.WHITE + currentPreset.getErosionRecursion()); - } - if (currentPreset.getFillRecursion() != currentPresetBackup.getFillRecursion()) { - v.sendMessage(ChatColor.AQUA + "Fill recursions set to: " + ChatColor.WHITE + currentPreset.getFillRecursion()); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.erode"; - } - - private enum Preset { - MELT(new ErosionPreset(2, 1, 5, 1)), - FILL(new ErosionPreset(5, 1, 2, 1)), - SMOOTH(new ErosionPreset(3, 1, 3, 1)), - LIFT(new ErosionPreset(6, 0, 1, 1)), - FLOATCLEAN(new ErosionPreset(6, 1, 6, 1)); - private ErosionPreset preset; - - Preset(final ErosionPreset preset) { - this.preset = preset; - } - - /** - * Generates a concat string of all options. - * - * @param separator Separator for delimiting entries. - */ - public static String getValuesString(String separator) { - StringBuilder valuesString = new StringBuilder(); - - boolean delimiterHelper = true; - for (final Preset preset : Preset.values()) { - if (delimiterHelper) { - delimiterHelper = false; - } else { - valuesString.append(separator); - } - valuesString.append(preset.name()); - } - return valuesString.toString(); - } - - public ErosionPreset getPreset() { - return this.preset; - } - - - } - - private static final class BlockChangeTracker { - private final Map> blockChanges; - private final Map flatChanges; - private final AsyncWorld world; - private int nextIterationId = 0; - - public BlockChangeTracker(final AsyncWorld world) { - this.blockChanges = new HashMap<>(); - this.flatChanges = new HashMap<>(); - this.world = world; - } - - public BlockWrapper get(final Vector position, final int iteration) { - BlockWrapper changedBlock; - - for (int i = iteration - 1; i >= 0; --i) { - if (this.blockChanges.containsKey(i) && this.blockChanges.get(i).containsKey(position)) { - changedBlock = this.blockChanges.get(i).get(position); - return changedBlock; - } - } - - changedBlock = new BlockWrapper((AsyncBlock) position.toLocation(this.world).getBlock()); - - return changedBlock; - } - - public Collection getAll() { - return this.flatChanges.values(); - } - - public int nextIteration() { - return this.nextIterationId++; - } - - public void put(final Vector position, final BlockWrapper changedBlock, final int iteration) { - if (!this.blockChanges.containsKey(iteration)) { - this.blockChanges.put(iteration, new HashMap<>()); - } - - this.blockChanges.get(iteration).put(position, changedBlock); - this.flatChanges.put(position, changedBlock); - } - } - - private static final class BlockWrapper { - - private final AsyncBlock block; - private final Material material; - private final int data; - - public BlockWrapper(final AsyncBlock block) { - this.block = block; - this.data = block.getPropertyId(); - this.material = block.getType(); - } - - public BlockWrapper(final AsyncBlock block, final Material material, final int data) { - this.block = block; - this.material = material; - this.data = data; - } - - /** - * @return the block - */ - public AsyncBlock getBlock() { - return this.block; - } - - /** - * @return the data - */ - public int getPropertyId() { - return this.data; - } - - /** - * @return the material - */ - public Material getMaterial() { - return this.material; - } - - /** - * @return if the block is Empty. - */ - public boolean isEmpty() { - switch (material) { - case AIR: - case CAVE_AIR: - case VOID_AIR: - return true; - default: - return false; - } - } - - /** - * @return if the block is a Liquid. - */ - public boolean isLiquid() { - switch (this.material) { - case WATER: - case LAVA: - return true; - default: - return false; - } - } - - } - - private static final class ErosionPreset { - private final int erosionFaces; - private final int erosionRecursion; - private final int fillFaces; - private final int fillRecursion; - - public ErosionPreset(final int erosionFaces, final int erosionRecursion, final int fillFaces, final int fillRecursion) { - this.erosionFaces = erosionFaces; - this.erosionRecursion = erosionRecursion; - this.fillFaces = fillFaces; - this.fillRecursion = fillRecursion; - } - - @Override - public int hashCode() { - return Objects.hashCode(erosionFaces, erosionRecursion, fillFaces, fillRecursion); - } - - @Override - public boolean equals(final Object obj) { - if (obj instanceof ErosionPreset) { - ErosionPreset other = (ErosionPreset) obj; - return Objects.equal(this.erosionFaces, other.erosionFaces) && Objects.equal(this.erosionRecursion, other.erosionRecursion) && Objects.equal(this.fillFaces, other.fillFaces) && Objects.equal(this.fillRecursion, other.fillRecursion); - } - return false; - } - - /** - * @return the erosionFaces - */ - public int getErosionFaces() { - return this.erosionFaces; - } - - /** - * @return the erosionRecursion - */ - public int getErosionRecursion() { - return this.erosionRecursion; - } - - /** - * @return the fillFaces - */ - public int getFillFaces() { - return this.fillFaces; - } - - /** - * @return the fillRecursion - */ - public int getFillRecursion() { - return this.fillRecursion; - } - - public ErosionPreset getInverted() { - return new ErosionPreset(this.fillFaces, this.fillRecursion, this.erosionFaces, this.erosionRecursion); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ExtrudeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ExtrudeBrush.java deleted file mode 100644 index 1d67d60a4..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ExtrudeBrush.java +++ /dev/null @@ -1,177 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; - -public class ExtrudeBrush extends Brush { - private double trueCircle; - - public ExtrudeBrush() { - this.setName("Extrude"); - } - - private void extrudeUpOrDown(final SnipeData v, boolean isUp) { - final int brushSize = v.getBrushSize(); - final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); - Undo undo = new Undo(); - - for (int x = -brushSize; x <= brushSize; x++) { - final double xSquared = Math.pow(x, 2); - for (int z = -brushSize; z <= brushSize; z++) { - if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared) { - final int direction = (isUp ? 1 : -1); - for (int y = 0; y < Math.abs(v.getVoxelHeight()); y++) { - final int tempY = y * direction; - undo = this.perform( - this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + tempY, this.getTargetBlock().getZ() + z), - this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + tempY + direction, this.getTargetBlock().getZ() + z), - v, undo); - } - } - } - } - - v.owner().storeUndo(undo); - } - - private void extrudeNorthOrSouth(final SnipeData v, boolean isSouth) { - final int brushSize = v.getBrushSize(); - final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); - Undo undo = new Undo(); - - for (int x = -brushSize; x <= brushSize; x++) { - final double xSquared = Math.pow(x, 2); - for (int y = -brushSize; y <= brushSize; y++) { - if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared) { - final int direction = (isSouth) ? 1 : -1; - for (int z = 0; z < Math.abs(v.getVoxelHeight()); z++) { - final int tempZ = z * direction; - undo = this.perform( - this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + tempZ), - this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + tempZ + direction), - v, undo); - } - - } - } - } - - v.owner().storeUndo(undo); - } - - private void extrudeEastOrWest(final SnipeData v, boolean isEast) { - final int brushSize = v.getBrushSize(); - final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); - Undo undo = new Undo(); - - for (int y = -brushSize; y <= brushSize; y++) { - final double ySquared = Math.pow(y, 2); - for (int z = -brushSize; z <= brushSize; z++) { - if ((ySquared + Math.pow(z, 2)) <= brushSizeSquared) { - final int direction = (isEast) ? 1 : -1; - for (int x = 0; x < Math.abs(v.getVoxelHeight()); x++) { - final int tempX = x * direction; - undo = this.perform( - this.clampY(this.getTargetBlock().getX() + tempX, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z), - this.clampY(this.getTargetBlock().getX() + tempX + direction, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z), - v, undo); - } - - } - } - } - v.owner().storeUndo(undo); - } - - @SuppressWarnings("deprecation") - private Undo perform(final Block b1, final Block b2, final SnipeData v, final Undo undo) { - if (v.getVoxelList().contains(b1.getBlockData())) { - undo.put(b2); - this.setBlockIdAt(b2.getZ(), b2.getX(), b2.getY(), this.getBlockIdAt(b1.getX(), b1.getY(), b1.getZ())); - this.clampY(b2.getX(), b2.getY(), b2.getZ()).setPropertyId(this.clampY(b1.getX(), b1.getY(), b1.getZ()).getPropertyId()); - } - - return undo; - } - - private void selectExtrudeMethod(final SnipeData v, final BlockFace blockFace, final boolean towardsUser) { - if (blockFace == null || v.getVoxelHeight() == 0) { - return; - } - boolean tempDirection = towardsUser; - switch (blockFace) { - case DOWN: - tempDirection = !towardsUser; - case UP: - extrudeUpOrDown(v, tempDirection); - break; - case NORTH: - tempDirection = !towardsUser; - case SOUTH: - extrudeNorthOrSouth(v, tempDirection); - break; - case WEST: - tempDirection = !towardsUser; - case EAST: - extrudeEastOrWest(v, tempDirection); - break; - default: - break; - } - } - - @Override - protected final void arrow(final SnipeData v) { - this.selectExtrudeMethod(v, this.getTargetBlock().getFace(this.getLastBlock()), false); - } - - @Override - protected final void powder(final SnipeData v) { - this.selectExtrudeMethod(v, this.getTargetBlock().getFace(this.getLastBlock()), true); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - vm.height(); - vm.voxelList(); - - vm.custom(ChatColor.AQUA + ((this.trueCircle == 0.5) ? "True circle mode ON" : "True circle mode OFF")); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - try { - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Extrude brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b ex true -- will use a true circle algorithm instead of the skinnier version with classic sniper nubs. /b ex false will switch back. (false is default)"); - return; - } else if (parameter.startsWith("true")) { - this.trueCircle = 0.5; - v.sendMessage(ChatColor.AQUA + "True circle mode ON."); - } else if (parameter.startsWith("false")) { - this.trueCircle = 0; - v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the \"info\" parameter to display parameter info."); - return; - } - } catch (final Exception exception) { - v.sendMessage(ChatColor.RED + "Incorrect parameter \"" + parameter + "\"; use the \"info\" parameter."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.extrude"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FillDownBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FillDownBrush.java deleted file mode 100644 index cd2315747..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FillDownBrush.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; - - -public class FillDownBrush extends PerformBrush { - private double trueCircle = 0; - private boolean fillLiquid = true; - private boolean fromExisting = false; - - public FillDownBrush() { - this.setName("Fill Down"); - } - - private void fillDown(final SnipeData v, final Block b) { - final int brushSize = v.getBrushSize(); - final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); - final Block targetBlock = this.getTargetBlock(); - for (int x = -brushSize; x <= brushSize; x++) { - final double currentXSquared = Math.pow(x, 2); - - for (int z = -brushSize; z <= brushSize; z++) { - if (currentXSquared + Math.pow(z, 2) <= brushSizeSquared) { - int y = 0; - boolean found = false; - if (this.fromExisting) { - for (y = -v.getVoxelHeight(); y < v.getVoxelHeight(); y++) { - final Block currentBlock = this.getWorld().getBlockAt( - targetBlock.getX() + x, - targetBlock.getY() + y, - targetBlock.getZ() + z); - if (!currentBlock.isEmpty()) { - found = true; - break; - } - } - if (!found) { - continue; - } - y--; - } - for (; y >= -targetBlock.getY(); --y) { - final AsyncBlock currentBlock = this.getWorld().getBlockAt( - targetBlock.getX() + x, - targetBlock.getY() + y, - targetBlock.getZ() + z); - if (currentBlock.isEmpty() || (fillLiquid && currentBlock.isLiquid())) { - this.current.perform(currentBlock); - } else { - break; - } - } - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.fillDown(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.fillDown(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - if (par[i].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Fill Down Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b fd true -- will use a true circle algorithm."); - v.sendMessage(ChatColor.AQUA + "/b fd false -- will switch back. (Default)"); - v.sendMessage(ChatColor.AQUA + "/b fd some -- Fills only into air."); - v.sendMessage(ChatColor.AQUA + "/b fd all -- Fills into liquids as well. (Default)"); - v.sendMessage(ChatColor.AQUA + "/b fd -e -- Fills into only existing blocks. (Toggle)"); - return; - } else if (par[i].equalsIgnoreCase("true")) { - this.trueCircle = 0.5; - v.sendMessage(ChatColor.AQUA + "True circle mode ON."); - } else if (par[i].equalsIgnoreCase("false")) { - this.trueCircle = 0; - v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); - } else if (par[i].equalsIgnoreCase("all")) { - this.fillLiquid = true; - v.sendMessage(ChatColor.AQUA + "Now filling liquids as well as air."); - } else if (par[i].equalsIgnoreCase("some")) { - this.fillLiquid = false; - v.setReplaceId(BlockTypes.AIR.getInternalId()); - v.sendMessage(ChatColor.AQUA + "Now only filling air."); - } else if (par[i].equalsIgnoreCase("-e")) { - this.fromExisting = !this.fromExisting; - v.sendMessage(ChatColor.AQUA + "Now filling down from " + ((this.fromExisting) ? "existing" : "all") + " blocks."); - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.filldown"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FlatOceanBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FlatOceanBrush.java deleted file mode 100644 index 2044ed672..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FlatOceanBrush.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncChunk; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.ChatColor; -import org.bukkit.Material; - -public class FlatOceanBrush extends Brush { - private static final int DEFAULT_WATER_LEVEL = 29; - private static final int DEFAULT_FLOOR_LEVEL = 8; - private int waterLevel = DEFAULT_WATER_LEVEL; - private int floorLevel = DEFAULT_FLOOR_LEVEL; - - public FlatOceanBrush() { - this.setName("FlatOcean"); - } - - private void flatOcean(final AsyncChunk chunk) { - for (int x = 0; x < CHUNK_SIZE; x++) { - for (int z = 0; z < CHUNK_SIZE; z++) { - for (int y = 0; y < chunk.getWorld().getMaxHeight(); y++) { - if (y <= this.floorLevel) { - chunk.getBlock(x, y, z).setType(Material.DIRT); - } else if (y <= this.waterLevel) { - chunk.getBlock(x, y, z).setType(Material.WATER); - } else { - chunk.getBlock(x, y, z).setType(Material.AIR); - } - } - } - } - } - - @Override - protected final void arrow(final SnipeData v) { - this.flatOcean(this.getWorld().getChunkAt(this.getTargetBlock())); - } - - @Override - protected final void powder(final SnipeData v) { - this.flatOcean(this.getWorld().getChunkAt(this.getTargetBlock())); - this.flatOcean(this.getWorld().getChunkAt(this.clampY(this.getTargetBlock().getX() + CHUNK_SIZE, 1, this.getTargetBlock().getZ()))); - this.flatOcean(this.getWorld().getChunkAt(this.clampY(this.getTargetBlock().getX() + CHUNK_SIZE, 1, this.getTargetBlock().getZ() + CHUNK_SIZE))); - this.flatOcean(this.getWorld().getChunkAt(this.clampY(this.getTargetBlock().getX(), 1, this.getTargetBlock().getZ() + CHUNK_SIZE))); - this.flatOcean(this.getWorld().getChunkAt(this.clampY(this.getTargetBlock().getX() - CHUNK_SIZE, 1, this.getTargetBlock().getZ() + CHUNK_SIZE))); - this.flatOcean(this.getWorld().getChunkAt(this.clampY(this.getTargetBlock().getX() - CHUNK_SIZE, 1, this.getTargetBlock().getZ()))); - this.flatOcean(this.getWorld().getChunkAt(this.clampY(this.getTargetBlock().getX() - CHUNK_SIZE, 1, this.getTargetBlock().getZ() - CHUNK_SIZE))); - this.flatOcean(this.getWorld().getChunkAt(this.clampY(this.getTargetBlock().getX(), 1, this.getTargetBlock().getZ() - CHUNK_SIZE))); - this.flatOcean(this.getWorld().getChunkAt(this.clampY(this.getTargetBlock().getX() + CHUNK_SIZE, 1, this.getTargetBlock().getZ() - CHUNK_SIZE))); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.custom(ChatColor.RED + "THIS BRUSH DOES NOT UNDO"); - vm.custom(ChatColor.GREEN + "Water level set to " + this.waterLevel); - vm.custom(ChatColor.GREEN + "Ocean floor level set to " + this.floorLevel); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GREEN + "yo[number] to set the Level to which the water will rise."); - v.sendMessage(ChatColor.GREEN + "yl[number] to set the Level to which the ocean floor will rise."); - } - if (parameter.startsWith("yo")) { - int newWaterLevel = Integer.parseInt(parameter.replace("yo", "")); - if (newWaterLevel < this.floorLevel) { - newWaterLevel = this.floorLevel + 1; - } - this.waterLevel = newWaterLevel; - v.sendMessage(ChatColor.GREEN + "Water Level set to " + this.waterLevel); - } else if (parameter.startsWith("yl")) { - int newFloorLevel = Integer.parseInt(parameter.replace("yl", "")); - if (newFloorLevel > this.waterLevel) { - newFloorLevel = this.waterLevel - 1; - if (newFloorLevel == 0) { - newFloorLevel = 1; - this.waterLevel = 2; - } - } - this.floorLevel = newFloorLevel; - v.sendMessage(ChatColor.GREEN + "Ocean floor Level set to " + this.floorLevel); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.flatocean"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/GenerateTreeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/GenerateTreeBrush.java deleted file mode 100644 index 3aed4ede9..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/GenerateTreeBrush.java +++ /dev/null @@ -1,630 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.block.Block; - -import java.util.ArrayList; -import java.util.Random; - -// Proposal: Use /v and /vr for leave and wood material // or two more parameters -- Monofraps - -public class GenerateTreeBrush extends Brush { - // Tree Variables. - private Random randGenerator = new Random(); - private ArrayList branchBlocks = new ArrayList<>(); - private Undo undo; - // If these default values are edited. Remember to change default values in the default preset. - private Material leafType = Material.OAK_LEAVES; - private Material woodType = Material.OAK_WOOD; - private boolean rootFloat = false; - private int startHeight = 0; - private int rootLength = 9; - private int maxRoots = 2; - private int minRoots = 1; - private int thickness = 1; - private int slopeChance = 40; - private int twistChance = 5; // This is a hidden value not available through Parameters. Otherwise messy. - private int heightMinimum = 14; - private int heightMaximum = 18; - private int branchLength = 8; - private int nodeMax = 4; - private int nodeMin = 3; - - private int blockPositionX; - private int blockPositionY; - private int blockPositionZ; - -public GenerateTreeBrush() { - this.setName("Generate Tree"); - } - - public boolean isLog(Material m) { - switch (m) { - case ACACIA_LOG: - case BIRCH_LOG: - case DARK_OAK_LOG: - case JUNGLE_LOG: - case OAK_LOG: - case SPRUCE_LOG: - return true; - default: - return false; - } - } - - public boolean isLeave(Material m) { - switch (m) { - case ACACIA_LEAVES: - case BIRCH_LEAVES: - case DARK_OAK_LEAVES: - case JUNGLE_LEAVES: - case OAK_LEAVES: - case SPRUCE_LEAVES: - return true; - default: - return false; - } - } - - // Branch Creation based on direction chosen from the parameters passed. - private void branchCreate(final int xDirection, final int zDirection) { - - // Sets branch origin. - final int originX = blockPositionX; - final int originY = blockPositionY; - final int originZ = blockPositionZ; - - // Sets direction preference. - final int xPreference = this.randGenerator.nextInt(60) + 20; - final int zPreference = this.randGenerator.nextInt(60) + 20; - - // Iterates according to branch length. - for (int r = 0; r < this.branchLength; r++) { - - // Alters direction according to preferences. - if (this.randGenerator.nextInt(100) < xPreference) { - blockPositionX = blockPositionX + 1 * xDirection; - } - if (this.randGenerator.nextInt(100) < zPreference) { - blockPositionZ = blockPositionZ + 1 * zDirection; - } - - // 50% chance to increase elevation every second block. - if (Math.abs(r % 2) == 1) { - blockPositionY = blockPositionY + this.randGenerator.nextInt(2); - } - - // Add block to undo function. - if (!isLog(this.getBlockType(blockPositionX, blockPositionY, blockPositionZ))) { - this.undo.put(this.clampY(blockPositionX, blockPositionY, blockPositionZ)); - } - - // Creates a branch block. - this.clampY(blockPositionX, blockPositionY, blockPositionZ).setType(this.woodType); - this.branchBlocks.add(this.clampY(blockPositionX, blockPositionY, blockPositionZ)); - } - - // Resets the origin - blockPositionX = originX; - blockPositionY = originY; - blockPositionZ = originZ; - } - - private void leafNodeCreate() { - // Generates the node size. - final int nodeRadius = this.randGenerator.nextInt(this.nodeMax - this.nodeMin + 1) + this.nodeMin; - final double bSquared = Math.pow(nodeRadius + 0.5, 2); - - // Lowers the current block in order to start at the bottom of the node. - blockPositionY = blockPositionY - 2; - - - for (int z = nodeRadius; z >= 0; z--) { - final double zSquared = Math.pow(z, 2); - - for (int x = nodeRadius; x >= 0; x--) { - final double xSquared = Math.pow(x, 2); - - for (int y = nodeRadius; y >= 0; y--) { - if ((xSquared + Math.pow(y, 2) + zSquared) <= bSquared) { - // Chance to skip creation of a block. - if (this.randGenerator.nextInt(100) >= 30) { - // If block is Air, create a leaf block. - if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ + z).isEmpty()) { - // Adds block to undo function. - if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY + y, blockPositionZ + z))) { - this.undo.put(this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ + z)); - } - // Creates block. - this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ + z).setType(this.leafType); - } - } - if (this.randGenerator.nextInt(100) >= 30) { - if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ - z).isEmpty()) { - if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY + y, blockPositionZ - z))) { - this.undo.put(this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ - z)); - } - this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ - z).setType(this.leafType); - } - } - if (this.randGenerator.nextInt(100) >= 30) { - if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY + y, blockPositionZ + z).isEmpty()) { - if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY + y, blockPositionZ + z))) { - this.undo.put(this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ + z)); - } - this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ + z).setType(this.leafType); - } - } - if (this.randGenerator.nextInt(100) >= 30) { - if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY + y, blockPositionZ - z).isEmpty()) { - if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY + y, blockPositionZ - z))) { - this.undo.put(this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ - z)); - } - this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ - z).setType(this.leafType); - } - } - if (this.randGenerator.nextInt(100) >= 30) { - if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY - y, blockPositionZ + z).isEmpty()) { - if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY - y, blockPositionZ + z))) { - this.undo.put(this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ + z)); - } - this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ + z).setType(this.leafType); - } - } - if (this.randGenerator.nextInt(100) >= 30) { - if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY - y, blockPositionZ - z).isEmpty()) { - if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY - y, blockPositionZ - z))) { - this.undo.put(this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ - z)); - } - this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ - z).setType(this.leafType); - } - } - if (this.randGenerator.nextInt(100) >= 30) { - if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY - y, blockPositionZ + z).isEmpty()) { - if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY - y, blockPositionZ + z))) { - this.undo.put(this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ + z)); - } - this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ + z).setType(this.leafType); - } - } - if (this.randGenerator.nextInt(100) >= 30) { - if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY - y, blockPositionZ - z).isEmpty()) { - if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY - y, blockPositionZ - z))) { - this.undo.put(this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ - z)); - } - this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ - z).setType(this.leafType); - } - } - } - } - } - } - } - - /** - * Code Concerning Root Generation. - * - * @param xDirection - * @param zDirection - */ - private void rootCreate(final int xDirection, final int zDirection) { - // Sets Origin. - final int originX = blockPositionX; - final int originY = blockPositionY; - final int originZ = blockPositionZ; - - // Generates the number of roots to create. - final int roots = this.randGenerator.nextInt(this.maxRoots - this.minRoots + 1) + this.minRoots; - - // A roots preference to move along the X and Y axis. - - - // Loops for each root to be created. - for (int i = 0; i < roots; i++) { - // Pushes the root'world starting point out from the center of the tree. - for (int t = 0; t < this.thickness - 1; t++) { - blockPositionX = blockPositionX + xDirection; - blockPositionZ = blockPositionZ + zDirection; - } - - // Generate directional preference between 30% and 70% - final int xPreference = this.randGenerator.nextInt(30) + 40; - final int zPreference = this.randGenerator.nextInt(30) + 40; - - for (int j = 0; j < this.rootLength; j++) { - // For the purposes of this algorithm, logs aren't considered solid. - - // If not solid then... - // Save for undo function - if (!isLog(this.getBlockType(blockPositionX, blockPositionY, blockPositionZ))) { - this.undo.put(this.clampY(blockPositionX, blockPositionY, blockPositionZ)); - - // Place log block. - this.clampY(blockPositionX, blockPositionY, blockPositionZ).setType(this.woodType); - } else { - // If solid then... - // End loop - break; - } - - // Checks is block below is solid - if (this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).isEmpty() || this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType() == Material.WATER || this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType() == Material.SNOW || isLog(this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType())) { - // Mos down if solid. - blockPositionY = blockPositionY - 1; - if (this.rootFloat) { - if (this.randGenerator.nextInt(100) < xPreference) { - blockPositionX = blockPositionX + xDirection; - } - if (this.randGenerator.nextInt(100) < zPreference) { - blockPositionZ = blockPositionZ + zDirection; - } - } - } else { - // If solid then move. - if (this.randGenerator.nextInt(100) < xPreference) { - blockPositionX = blockPositionX + xDirection; - } - if (this.randGenerator.nextInt(100) < zPreference) { - blockPositionZ = blockPositionZ + zDirection; - } - // Checks if new location is solid, if not then move down. - if (this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).isEmpty() || this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType() == Material.WATER || this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType() == Material.SNOW || isLog(this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType())) { - blockPositionY = blockPositionY - 1; - } - } - } - - // Reset origin. - blockPositionX = originX; - blockPositionY = originY; - blockPositionZ = originZ; - - } - } - - private void rootGen() { - // Quadrant 1 - this.rootCreate(1, 1); - - // Quadrant 2 - this.rootCreate(-1, 1); - - // Quadrant 3 - this.rootCreate(1, -1); - - // Quadrant 4 - this.rootCreate(-1, -1); - } - - private void trunkCreate() { - // Creates true circle discs of the set size using the wood type selected. - final double bSquared = Math.pow(this.thickness + 0.5, 2); - - for (int x = this.thickness; x >= 0; x--) { - final double xSquared = Math.pow(x, 2); - - for (int z = this.thickness; z >= 0; z--) { - if ((xSquared + Math.pow(z, 2)) <= bSquared) { - // If block is air, then create a block. - if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY, blockPositionZ + z).isEmpty()) { - // Adds block to undo function. - if (!isLog(this.getBlockType(blockPositionX + x, blockPositionY, blockPositionZ + z))) { - this.undo.put(this.clampY(blockPositionX + x, blockPositionY, blockPositionZ + z)); - } - // Creates block. - this.clampY(blockPositionX + x, blockPositionY, blockPositionZ + z).setType(this.woodType); - } - if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY, blockPositionZ - z).isEmpty()) { - if (!isLog(this.getBlockType(blockPositionX + x, blockPositionY, blockPositionZ - z))) { - this.undo.put(this.clampY(blockPositionX + x, blockPositionY, blockPositionZ - z)); - } - this.clampY(blockPositionX + x, blockPositionY, blockPositionZ - z).setType(this.woodType); - } - if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY, blockPositionZ + z).isEmpty()) { - if (!isLog(this.getBlockType(blockPositionX - x, blockPositionY, blockPositionZ + z))) { - this.undo.put(this.clampY(blockPositionX - x, blockPositionY, blockPositionZ + z)); - } - this.clampY(blockPositionX - x, blockPositionY, blockPositionZ + z).setType(this.woodType); - } - if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY, blockPositionZ - z).isEmpty()) { - if (!isLog(this.getBlockType(blockPositionX - x, blockPositionY, blockPositionZ - z))) { - this.undo.put(this.clampY(blockPositionX - x, blockPositionY, blockPositionZ - z)); - } - this.clampY(blockPositionX - x, blockPositionY, blockPositionZ - z).setType(this.woodType); - } - } - } - } - } - - /* - * - * Code Concerning Trunk Generation - */ - private void trunkGen() { - // Sets Origin - final int originX = blockPositionX; - final int originY = blockPositionY; - final int originZ = blockPositionZ; - - // ---------- - // Main Trunk - // ---------- - // Sets directional preferences. - int xPreference = this.randGenerator.nextInt(this.slopeChance); - int zPreference = this.randGenerator.nextInt(this.slopeChance); - - // Sets direction. - int xDirection = 1; - if (this.randGenerator.nextInt(100) < 50) { - xDirection = -1; - } - - int zDirection = 1; - if (this.randGenerator.nextInt(100) < 50) { - zDirection = -1; - } - - // Generates a height for trunk. - int height = this.randGenerator.nextInt(this.heightMaximum - this.heightMinimum + 1) + this.heightMinimum; - - for (int p = 0; p < height; p++) { - if (p > 3) { - if (this.randGenerator.nextInt(100) <= this.twistChance) { - xDirection *= -1; - } - if (this.randGenerator.nextInt(100) <= this.twistChance) { - zDirection *= -1; - } - if (this.randGenerator.nextInt(100) < xPreference) { - blockPositionX += xDirection; - } - if (this.randGenerator.nextInt(100) < zPreference) { - blockPositionZ += zDirection; - } - } - - // Creates trunk section - this.trunkCreate(); - - // Mos up for next section - blockPositionY = blockPositionY + 1; - } - - // Generates branches at top of trunk for each quadrant. - this.branchCreate(1, 1); - this.branchCreate(-1, 1); - this.branchCreate(1, -1); - this.branchCreate(-1, -1); - - // Reset Origin for next trunk. - blockPositionX = originX; - blockPositionY = originY + 4; - blockPositionZ = originZ; - - // --------------- - // Secondary Trunk - // --------------- - // Sets directional preferences. - xPreference = this.randGenerator.nextInt(this.slopeChance); - zPreference = this.randGenerator.nextInt(this.slopeChance); - - // Sets direction. - xDirection = 1; - if (this.randGenerator.nextInt(100) < 50) { - xDirection = -1; - } - - zDirection = 1; - if (this.randGenerator.nextInt(100) < 50) { - zDirection = -1; - } - - // Generates a height for trunk. - height = this.randGenerator.nextInt(this.heightMaximum - this.heightMinimum + 1) + this.heightMinimum; - - if (height > 4) { - for (int p = 0; p < height; p++) { - if (this.randGenerator.nextInt(100) <= this.twistChance) { - xDirection *= -1; - } - if (this.randGenerator.nextInt(100) <= this.twistChance) { - zDirection *= -1; - } - if (this.randGenerator.nextInt(100) < xPreference) { - blockPositionX = blockPositionX + 1 * xDirection; - } - if (this.randGenerator.nextInt(100) < zPreference) { - blockPositionZ = blockPositionZ + 1 * zDirection; - } - - // Creates a trunk section - this.trunkCreate(); - - // Mos up for next section - blockPositionY = blockPositionY + 1; - } - - // Generates branches at top of trunk for each quadrant. - this.branchCreate(1, 1); - this.branchCreate(-1, 1); - this.branchCreate(1, -1); - this.branchCreate(-1, -1); - } - } - - @Override - protected final void arrow(final SnipeData v) { - this.undo = new Undo(); - - this.branchBlocks.clear(); - - // Sets the location variables. - blockPositionX = this.getTargetBlock().getX(); - blockPositionY = this.getTargetBlock().getY() + this.startHeight; - blockPositionZ = this.getTargetBlock().getZ(); - - // Generates the roots. - this.rootGen(); - - // Generates the trunk, which also generates branches. - this.trunkGen(); - - // Each branch block was saved in an array. This is now fed through an array. - // This array takes each branch block and constructs a leaf node around it. - for (final Block block : this.branchBlocks) { - blockPositionX = block.getX(); - blockPositionY = block.getY(); - blockPositionZ = block.getZ(); - this.leafNodeCreate(); - } - - // Ends the undo function and mos on. - v.owner().storeUndo(this.undo); - } - - // The Powder currently does nothing extra. - @Override - protected final void powder(final SnipeData v) { - this.arrow(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - try { - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "This brush takes the following parameters:"); - v.sendMessage(ChatColor.AQUA + "lt# - leaf type (data value)"); - v.sendMessage(ChatColor.AQUA + "wt# - wood type (data value)"); - v.sendMessage(ChatColor.AQUA + "tt# - tree thickness (whote number)"); - v.sendMessage(ChatColor.AQUA + "rfX - root float (true or false)"); - v.sendMessage(ChatColor.AQUA + "sh# - starting height (whole number)"); - v.sendMessage(ChatColor.AQUA + "rl# - root length (whole number)"); - v.sendMessage(ChatColor.AQUA + "ts# - trunk slope chance (0-100)"); - v.sendMessage(ChatColor.AQUA + "bl# - branch length (whole number)"); - v.sendMessage(ChatColor.AQUA + "info2 - more parameters"); - return; - } - - if (parameter.equalsIgnoreCase("info2")) { - v.sendMessage(ChatColor.GOLD + "This brush takes the following parameters:"); - v.sendMessage(ChatColor.AQUA + "minr# - minimum roots (whole number)"); - v.sendMessage(ChatColor.AQUA + "maxr# - maximum roots (whole number)"); - v.sendMessage(ChatColor.AQUA + "minh# - minimum height (whole number)"); - v.sendMessage(ChatColor.AQUA + "maxh# - maximum height (whole number)"); - v.sendMessage(ChatColor.AQUA + "minl# - minimum leaf node size (whole number)"); - v.sendMessage(ChatColor.AQUA + "maxl# - maximum leaf node size (whole number)"); - v.sendMessage(ChatColor.AQUA + "default - restore default params"); - return; - } - if (parameter.startsWith("lt")) { // Leaf Type - this.leafType = BukkitAdapter.adapt(BlockTypes.parse(parameter.replace("lt", ""))); - v.sendMessage(ChatColor.BLUE + "Leaf Type set to " + this.leafType); - } else if (parameter.startsWith("wt")) { // Wood Type - this.woodType = BukkitAdapter.adapt(BlockTypes.parse(parameter.replace("wt", ""))); - v.sendMessage(ChatColor.BLUE + "Wood Type set to " + this.woodType); - } else if (parameter.startsWith("tt")) { // Tree Thickness - this.thickness = Integer.parseInt(parameter.replace("tt", "")); - v.sendMessage(ChatColor.BLUE + "Thickness set to " + this.thickness); - } else if (parameter.startsWith("rf")) { // Root Float - this.rootFloat = Boolean.parseBoolean(parameter.replace("rf", "")); - v.sendMessage(ChatColor.BLUE + "Floating Roots set to " + this.rootFloat); - } else if (parameter.startsWith("sh")) { // Starting Height - this.startHeight = Integer.parseInt(parameter.replace("sh", "")); - v.sendMessage(ChatColor.BLUE + "Starting Height set to " + this.startHeight); - } else if (parameter.startsWith("rl")) { // Root Length - this.rootLength = Integer.parseInt(parameter.replace("rl", "")); - v.sendMessage(ChatColor.BLUE + "Root Length set to " + this.rootLength); - } else if (parameter.startsWith("minr")) { // Minimum Roots - this.minRoots = Integer.parseInt(parameter.replace("minr", "")); - if (this.minRoots > this.maxRoots) { - this.minRoots = this.maxRoots; - v.sendMessage(ChatColor.RED + "Minimum Roots can't exceed Maximum Roots, has been set to " + this.minRoots + " Instead!"); - } else { - v.sendMessage(ChatColor.BLUE + "Minimum Roots set to " + this.minRoots); - } - } else if (parameter.startsWith("maxr")) { // Maximum Roots - this.maxRoots = Integer.parseInt(parameter.replace("maxr", "")); - if (this.minRoots > this.maxRoots) { - this.maxRoots = this.minRoots; - v.sendMessage(ChatColor.RED + "Maximum Roots can't be lower than Minimum Roots, has been set to " + this.minRoots + " Instead!"); - } else { - v.sendMessage(ChatColor.BLUE + "Maximum Roots set to " + this.maxRoots); - } - } else if (parameter.startsWith("ts")) { // Trunk Slope Chance - this.slopeChance = Integer.parseInt(parameter.replace("ts", "")); - v.sendMessage(ChatColor.BLUE + "Trunk Slope set to " + this.slopeChance); - } else if (parameter.startsWith("minh")) { // Height Minimum - this.heightMinimum = Integer.parseInt(parameter.replace("minh", "")); - if (this.heightMinimum > this.heightMaximum) { - this.heightMinimum = this.heightMaximum; - v.sendMessage(ChatColor.RED + "Minimum Height exceed than Maximum Height, has been set to " + this.heightMinimum + " Instead!"); - } else { - v.sendMessage(ChatColor.BLUE + "Minimum Height set to " + this.heightMinimum); - } - } else if (parameter.startsWith("maxh")) { // Height Maximum - this.heightMaximum = Integer.parseInt(parameter.replace("maxh", "")); - if (this.heightMinimum > this.heightMaximum) { - this.heightMaximum = this.heightMinimum; - v.sendMessage(ChatColor.RED + "Maximum Height can't be lower than Minimum Height, has been set to " + this.heightMaximum + " Instead!"); - } else { - v.sendMessage(ChatColor.BLUE + "Maximum Roots set to " + this.heightMaximum); - } - } else if (parameter.startsWith("bl")) { // Branch Length - this.branchLength = Integer.parseInt(parameter.replace("bl", "")); - v.sendMessage(ChatColor.BLUE + "Branch Length set to " + this.branchLength); - } else if (parameter.startsWith("maxl")) { // Leaf Node Max Size - this.nodeMax = Integer.parseInt(parameter.replace("maxl", "")); - v.sendMessage(ChatColor.BLUE + "Leaf Max Thickness set to " + this.nodeMax + " (Default 4)"); - } else if (parameter.startsWith("minl")) { // Leaf Node Min Size - this.nodeMin = Integer.parseInt(parameter.replace("minl", "")); - v.sendMessage(ChatColor.BLUE + "Leaf Min Thickness set to " + this.nodeMin + " (Default 3)"); - - // ------- - // Presets - // ------- - } else if (parameter.startsWith("default")) { // Default settings. - this.leafType = Material.OAK_LEAVES; - this.woodType = Material.OAK_WOOD; - this.rootFloat = false; - this.startHeight = 0; - this.rootLength = 9; - this.maxRoots = 2; - this.minRoots = 1; - this.thickness = 1; - this.slopeChance = 40; - this.heightMinimum = 14; - this.heightMaximum = 18; - this.branchLength = 8; - this.nodeMax = 4; - this.nodeMin = 3; - v.sendMessage(ChatColor.GOLD + "Brush reset to default parameters."); - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } catch (final Exception exception) { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! \"" + par[i] + "\" is not a valid statement. Please use the 'info' parameter to display parameter info."); - } - - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.generatetree"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/HeatRayBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/HeatRayBrush.java deleted file mode 100644 index 39e3350ce..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/HeatRayBrush.java +++ /dev/null @@ -1,179 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.util.Vector; -import org.bukkit.util.noise.PerlinNoiseGenerator; - -import java.util.ArrayList; -import java.util.Random; - -public class HeatRayBrush extends Brush { - -/* private enum FlameableBlock - { - WOOD(Material.WOOD), SAPLING(Material.SAPLING), LOG(Material.LOG), LEAVES(Material.LEAVES), SPONGE(Material.SPONGE), WEB(Material.WEB), LONG_GRASS(Material.LONG_GRASS), DEAD_BUSH(Material.DEAD_BUSH), WOOL(Material.WOOL), YELLOW_FLOWER(Material.YELLOW_FLOWER), RED_ROSE(Material.RED_ROSE), TORCH(Material.TORCH), FIRE(Material.FIRE), WOOD_STAIRS(Material.WOOD_STAIRS), CROPS(Material.CROPS), SIGN_POST(Material.SIGN_POST), WOODEN_DOOR(Material.WOODEN_DOOR), LADDER(Material.LADDER), WALL_SIGN(Material.WALL_SIGN), WOOD_PLATE(Material.WOOD_PLATE), SNOW(Material.SNOW), ICE(Material.ICE), SUGAR_CANE_BLOCK(Material.SUGAR_CANE_BLOCK), FENCE(Material.FENCE), TRAP_DOOR(Material.TRAP_DOOR), VINE(Material.VINE), FENCE_GATE(Material.FENCE_GATE), WATER_LILLY(Material.WATER_LILY); - - private Material material; - - FlameableBlock(final Material material) - { - this.material = material; - } - }*/ - - private static final double REQUIRED_OBSIDIAN_DENSITY = 0.6; - private static final double REQUIRED_COBBLE_DENSITY = 0.5; - private static final double REQUIRED_FIRE_DENSITY = -0.25; - private static final double REQUIRED_AIR_DENSITY = 0; - - private static final ArrayList FLAMABLE_BLOCKS = new ArrayList<>(); - - static { - for (Material m : Material.values()) { - if (!m.isLegacy() && m.isBlock() && m.isFlammable()) { - FLAMABLE_BLOCKS.add(m); - } - } - } - - private int octaves = 5; - private double frequency = 1; - private double amplitude = 0.3; - - - /** - * Default Constructor. - */ - public HeatRayBrush() { - this.setName("Heat Ray"); - } - - /** - * Heat Ray executer. - * - * @param v - */ - public final void heatRay(final SnipeData v) { - final PerlinNoiseGenerator generator = new PerlinNoiseGenerator(new Random()); - - final Vector targetLocation = this.getTargetBlock().getLocation().toVector(); - final Location currentLocation = new Location(this.getTargetBlock().getWorld(), 0, 0, 0); - final Undo undo = new Undo(); - Block currentBlock; - - for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) { - for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) { - for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) { - currentLocation.setX(this.getTargetBlock().getX() + x); - currentLocation.setY(this.getTargetBlock().getY() + y); - currentLocation.setZ(this.getTargetBlock().getZ() + z); - - if (currentLocation.toVector().isInSphere(targetLocation, v.getBrushSize())) { - currentBlock = currentLocation.getBlock(); - if (currentBlock.getType() == Material.CHEST) { - continue; - } - - if (currentBlock.isLiquid()) { - undo.put(currentBlock); - currentBlock.setType(Material.AIR); - continue; - } - - if (HeatRayBrush.FLAMABLE_BLOCKS.contains(currentBlock.getType())) { - undo.put(currentBlock); - currentBlock.setType(Material.FIRE); - continue; - } - - if (!currentBlock.getType().equals(Material.AIR)) { - final double airDensity = generator.noise(currentLocation.getX(), currentLocation.getY(), currentLocation.getZ(), this.octaves, this.frequency, this.amplitude); - final double fireDensity = generator.noise(currentLocation.getX(), currentLocation.getY(), currentLocation.getZ(), this.octaves, this.frequency, this.amplitude); - final double cobbleDensity = generator.noise(currentLocation.getX(), currentLocation.getY(), currentLocation.getZ(), this.octaves, this.frequency, this.amplitude); - final double obsidianDensity = generator.noise(currentLocation.getX(), currentLocation.getY(), currentLocation.getZ(), this.octaves, this.frequency, this.amplitude); - - if (obsidianDensity >= HeatRayBrush.REQUIRED_OBSIDIAN_DENSITY) { - undo.put(currentBlock); - if (currentBlock.getType() != Material.OBSIDIAN) { - currentBlock.setType(Material.OBSIDIAN); - } - } else if (cobbleDensity >= HeatRayBrush.REQUIRED_COBBLE_DENSITY) { - undo.put(currentBlock); - if (currentBlock.getType() != Material.COBBLESTONE) { - currentBlock.setType(Material.COBBLESTONE); - } - } else if (fireDensity >= HeatRayBrush.REQUIRED_FIRE_DENSITY) { - undo.put(currentBlock); - if (currentBlock.getType() != Material.FIRE) { - currentBlock.setType(Material.FIRE); - } - } else if (airDensity >= HeatRayBrush.REQUIRED_AIR_DENSITY) { - undo.put(currentBlock); - if (!currentBlock.isEmpty()) { - currentBlock.setType(Material.AIR); - } - } - } - } - - } - } - } - - v.owner().storeUndo(undo); - } - - @Override - protected final void arrow(final SnipeData v) { - this.heatRay(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.heatRay(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.custom(ChatColor.GREEN + "Octaves: " + this.octaves); - vm.custom(ChatColor.GREEN + "Amplitude: " + this.amplitude); - vm.custom(ChatColor.GREEN + "Frequency: " + this.frequency); - vm.size(); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i].toLowerCase(); - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Heat Ray brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b hr oct[int] -- Octaves parameter for the noise generator."); - v.sendMessage(ChatColor.AQUA + "/b hr amp[float] -- Amplitude parameter for the noise generator."); - v.sendMessage(ChatColor.AQUA + "/b hr freq[float] -- Frequency parameter for the noise generator."); - } - if (parameter.startsWith("oct")) { - this.octaves = Integer.parseInt(parameter.replace("oct", "")); - v.getVoxelMessage().custom(ChatColor.GREEN + "Octaves: " + this.octaves); - } else if (parameter.startsWith("amp")) { - this.amplitude = Double.parseDouble(parameter.replace("amp", "")); - v.getVoxelMessage().custom(ChatColor.GREEN + "Amplitude: " + this.amplitude); - } else if (parameter.startsWith("freq")) { - this.frequency = Double.parseDouble(parameter.replace("freq", "")); - v.getVoxelMessage().custom(ChatColor.GREEN + "Frequency: " + this.frequency); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.heatray"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/IBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/IBrush.java deleted file mode 100644 index b2cfd6107..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/IBrush.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeAction; -import com.thevoxelbox.voxelsniper.SnipeData; - -/** - * Brush Interface. - */ -public interface IBrush { - - /** - * @param vm Message object - */ - void info(Message vm); - - /** - * Handles parameters passed to brushes. - * - * @param par Array of string containing parameters - * @param v Snipe Data - */ - void parameters(String[] par, SnipeData v); - - boolean perform(SnipeAction action, SnipeData data, AsyncBlock targetBlock, AsyncBlock lastBlock); - - /** - * @return The name of the Brush - */ - String getName(); - - /** - * @param name New name for the Brush - */ - void setName(String name); - - /** - * @return The name of the category the brush is in. - */ - String getBrushCategory(); - - /** - * @return Permission node required to use this brush - */ - String getPermissionNode(); -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java deleted file mode 100644 index 231217225..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; -import org.bukkit.util.BlockIterator; -import org.bukkit.util.NumberConversions; -import org.bukkit.util.Vector; - -import java.util.Random; - -public class JaggedLineBrush extends PerformBrush { - private static final Vector HALF_BLOCK_OFFSET = new Vector(0.5, 0.5, 0.5); - private static final int RECURSION_MIN = 1; - private static final int RECURSION_DEFAULT = 3; - private static final int RECURSION_MAX = 10; - private static final int SPREAD_DEFAULT = 3; - private Random random = new Random(); - private Vector originCoords; - private Vector targetCoords = new Vector(); - private int recursion = RECURSION_DEFAULT; - private int spread = SPREAD_DEFAULT; - - public JaggedLineBrush() { - this.setName("Jagged Line"); - } - - private void jaggedP(SnipeData v) { - final Vector originClone = this.originCoords.clone().add(JaggedLineBrush.HALF_BLOCK_OFFSET); - final Vector targetClone = this.targetCoords.clone().add(JaggedLineBrush.HALF_BLOCK_OFFSET); - - final Vector direction = targetClone.clone().subtract(originClone); - final double length = this.targetCoords.distance(this.originCoords); - - if (length == 0) { - this.current.perform((AsyncBlock) this.targetCoords.toLocation(this.getWorld()).getBlock()); - } else { - for (final BlockIterator iterator = new BlockIterator(this.getWorld(), originClone, direction, 0, NumberConversions.round(length)); iterator.hasNext(); ) { - final Block block = iterator.next(); - for (int i = 0; i < recursion; i++) { - this.current.perform(this.clampY(Math.round(block.getX() + this.random.nextInt(spread * 2) - spread), Math.round(block.getY() + this.random.nextInt(spread * 2) - spread), Math.round(block.getZ() + this.random.nextInt(spread * 2) - spread))); - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - public final void arrow(SnipeData v) { - if (originCoords == null) { - originCoords = new Vector(); - } - this.originCoords = this.getTargetBlock().getLocation().toVector(); - v.sendMessage(ChatColor.DARK_PURPLE + "First point selected."); - } - - @Override - public final void powder(SnipeData v) { - if (originCoords == null) { - v.sendMessage(ChatColor.RED + "Warning: You did not select a first coordinate with the arrow"); - } else { - this.targetCoords = this.getTargetBlock().getLocation().toVector(); - this.jaggedP(v); - } - - } - - @Override - public final void info(Message vm) { - vm.brushName(this.getName()); - vm.custom(ChatColor.GRAY + String.format("Recursion set to: %d", this.recursion)); - vm.custom(ChatColor.GRAY + String.format("Spread set to: %d", this.spread)); - } - - @Override - public final void parameters(String[] par, SnipeData v) { - for (String parameter : par) { - try { - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Jagged Line Brush instructions: Right click first point with the arrow. Right click with powder to draw a jagged line to set the second point."); - v.sendMessage(ChatColor.AQUA + "/b j r# - sets the number of recursions (default 3, must be 1-10)"); - v.sendMessage(ChatColor.AQUA + "/b j s# - sets the spread (default 3, must be 1-10)"); - return; - } - if (parameter.startsWith("r")) { - final int temp = Integer.parseInt(parameter.substring(1)); - if (temp >= RECURSION_MIN && temp <= RECURSION_MAX) { - this.recursion = temp; - v.sendMessage(ChatColor.GREEN + "Recursion set to: " + this.recursion); - } else { - v.sendMessage(ChatColor.RED + "ERROR: Recursion must be " + RECURSION_MIN + "-" + RECURSION_MAX); - } - - return; - } - if (parameter.startsWith("s")) { - this.spread = Integer.parseInt(parameter.substring(1)); - v.sendMessage(ChatColor.GREEN + "Spread set to: " + this.spread); - } - } catch (Exception exception) { - v.sendMessage(ChatColor.RED + String.format("Exception while parsing parameter: %s", parameter)); - exception.printStackTrace(); - } - } - - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.jaggedline"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JockeyBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JockeyBrush.java deleted file mode 100644 index da7194364..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JockeyBrush.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent; - -import java.util.List; - -public class JockeyBrush extends Brush { - private static final int ENTITY_STACK_LIMIT = 50; - private JockeyType jockeyType = JockeyType.NORMAL_ALL_ENTITIES; - private Entity jockeyedEntity = null; - - public JockeyBrush() { - this.setName("Jockey"); - } - - private void sitOn(final SnipeData v) { - final Chunk targetChunk = this.getWorld().getChunkAt(this.getTargetBlock().getLocation()); - final int targetChunkX = targetChunk.getX(); - final int targetChunkZ = targetChunk.getZ(); - - double range = Double.MAX_VALUE; - Entity closest = null; - - for (int x = targetChunkX - 1; x <= targetChunkX + 1; x++) { - for (int y = targetChunkZ - 1; y <= targetChunkZ + 1; y++) { - for (final Entity entity : this.getWorld().getChunkAt(x, y).getEntities()) { - if (entity.getEntityId() == v.owner().getPlayer().getEntityId()) { - continue; - } - - if (jockeyType == JockeyType.NORMAL_PLAYER_ONLY || jockeyType == JockeyType.INVERSE_PLAYER_ONLY) { - if (!(entity instanceof Player)) { - continue; - } - } - - final Location entityLocation = entity.getLocation(); - final double entityDistance = entityLocation.distance(v.owner().getPlayer().getLocation()); - - if (entityDistance < range) { - range = entityDistance; - closest = entity; - } - } - } - } - - if (closest != null) { - final Player player = v.owner().getPlayer(); - final PlayerTeleportEvent playerTeleportEvent = new PlayerTeleportEvent(player, player.getLocation(), closest.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); - - Bukkit.getPluginManager().callEvent(playerTeleportEvent); - - if (!playerTeleportEvent.isCancelled()) { - if (jockeyType == JockeyType.INVERSE_PLAYER_ONLY || jockeyType == JockeyType.INVERSE_ALL_ENTITIES) { - player.addPassenger(closest); - } else { - closest.addPassenger(player); - jockeyedEntity = closest; - } - v.sendMessage(ChatColor.GREEN + "You are now saddles on entity: " + closest.getEntityId()); - } - } else { - v.sendMessage(ChatColor.RED + "Could not find any entities"); - } - } - - private void stack(final SnipeData v) { - final int brushSizeDoubled = v.getBrushSize() * 2; - - List nearbyEntities = v.owner().getPlayer().getNearbyEntities(brushSizeDoubled, brushSizeDoubled, brushSizeDoubled); - Entity lastEntity = v.owner().getPlayer(); - int stackHeight = 0; - - for (Entity entity : nearbyEntities) { - if (!(stackHeight >= ENTITY_STACK_LIMIT)) { - if (jockeyType == JockeyType.STACK_ALL_ENTITIES) { - lastEntity.addPassenger(entity); - lastEntity = entity; - stackHeight++; - } else if (jockeyType == JockeyType.STACK_PLAYER_ONLY) { - if (entity instanceof Player) { - lastEntity.addPassenger(entity); - lastEntity = entity; - stackHeight++; - } - } else { - v.owner().getPlayer().sendMessage("You broke stack! :O"); - } - } else { - return; - } - } - - } - - @Override - protected final void arrow(final SnipeData v) { - if (jockeyType == JockeyType.STACK_ALL_ENTITIES || jockeyType == JockeyType.STACK_PLAYER_ONLY) { - stack(v); - } else { - this.sitOn(v); - } - } - - @Override - protected final void powder(final SnipeData v) { - if (jockeyType == JockeyType.INVERSE_PLAYER_ONLY || jockeyType == JockeyType.INVERSE_ALL_ENTITIES) { - v.owner().getPlayer().eject(); - v.owner().getPlayer().sendMessage(ChatColor.GOLD + "The guy on top of you has been ejected!"); - } else { - if (jockeyedEntity != null) { - jockeyedEntity.eject(); - jockeyedEntity = null; - v.owner().getPlayer().sendMessage(ChatColor.GOLD + "You have been ejected!"); - } - } - - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.custom("Current jockey mode: " + ChatColor.GREEN + jockeyType.toString()); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - - try { - boolean inverse = false; - boolean playerOnly = false; - boolean stack = false; - for (String parameter : par) { - if (parameter.startsWith("-i:")) { - inverse = parameter.endsWith("y"); - } - - if (parameter.startsWith("-po:")) { - playerOnly = parameter.endsWith("y"); - } - if (parameter.startsWith("-s:")) { - stack = parameter.endsWith("y"); - } - - } - - if (inverse) { - if (playerOnly) { - jockeyType = JockeyType.INVERSE_PLAYER_ONLY; - } else { - jockeyType = JockeyType.INVERSE_ALL_ENTITIES; - } - } else if (stack) { - if (playerOnly) { - jockeyType = JockeyType.STACK_PLAYER_ONLY; - } else { - jockeyType = JockeyType.STACK_ALL_ENTITIES; - } - } else { - if (playerOnly) { - jockeyType = JockeyType.NORMAL_PLAYER_ONLY; - } else { - jockeyType = JockeyType.NORMAL_ALL_ENTITIES; - } - } - - v.sendMessage("Current jockey mode: " + ChatColor.GREEN + jockeyType.toString()); - } catch (Exception exception) { - v.sendMessage("Error while parsing your arguments."); - exception.printStackTrace(); - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.jockey"; - } - - /** - * Available types of jockey modes. - */ - private enum JockeyType { - NORMAL_ALL_ENTITIES("Normal (All)"), NORMAL_PLAYER_ONLY("Normal (Player only)"), INVERSE_ALL_ENTITIES("Inverse (All)"), INVERSE_PLAYER_ONLY("Inverse (Player only)"), STACK_ALL_ENTITIES("Stack (All)"), STACK_PLAYER_ONLY("Stack (Player only)"); - private String name; - - JockeyType(String name) { - this.name = name; - } - - @Override - public String toString() { - return this.name; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LightningBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LightningBrush.java deleted file mode 100644 index 8c123fa4c..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LightningBrush.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - -public class LightningBrush extends Brush { - - public LightningBrush() { - this.setName("Lightning"); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.brushMessage("Lightning Brush! Please use in moderation."); - } - - @Override - protected final void arrow(final SnipeData v) { - this.getWorld().strikeLightning(this.getTargetBlock().getLocation()); - } - - @Override - protected final void powder(final SnipeData v) { - this.getWorld().strikeLightning(this.getTargetBlock().getLocation()); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.lightning"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LineBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LineBrush.java deleted file mode 100644 index 9adf92ff0..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LineBrush.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.boydti.fawe.bukkit.wrapper.AsyncWorld; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; -import org.bukkit.util.BlockIterator; -import org.bukkit.util.NumberConversions; -import org.bukkit.util.Vector; - -public class LineBrush extends PerformBrush { - private static final Vector HALF_BLOCK_OFFSET = new Vector(0.5, 0.5, 0.5); - private Vector originCoords = null; - private Vector targetCoords = new Vector(); - private AsyncWorld targetWorld; - - public LineBrush() { - this.setName("Line"); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Line Brush instructions: Right click first point with the arrow. Right click with powder to draw a line to set the second point."); - } - } - - private void linePowder(final SnipeData v) { - final Vector originClone = this.originCoords.clone().add(LineBrush.HALF_BLOCK_OFFSET); - final Vector targetClone = this.targetCoords.clone().add(LineBrush.HALF_BLOCK_OFFSET); - - final Vector direction = targetClone.clone().subtract(originClone); - final double length = this.targetCoords.distance(this.originCoords); - - if (length == 0) { - this.current.perform((AsyncBlock) this.targetCoords.toLocation(this.targetWorld).getBlock()); - } else { - for (final BlockIterator blockIterator = new BlockIterator(this.targetWorld, originClone, direction, 0, NumberConversions.round(length)); blockIterator.hasNext(); ) { - final AsyncBlock currentBlock = (AsyncBlock) blockIterator.next(); - this.current.perform(currentBlock); - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.originCoords = this.getTargetBlock().getLocation().toVector(); - this.targetWorld = this.getTargetBlock().getWorld(); - v.owner().getPlayer().sendMessage(ChatColor.DARK_PURPLE + "First point selected."); - } - - @Override - protected final void powder(final SnipeData v) { - if (this.originCoords == null || !this.getTargetBlock().getWorld().equals(this.targetWorld)) { - v.owner().getPlayer().sendMessage(ChatColor.RED + "Warning: You did not select a first coordinate with the arrow"); - } else { - this.targetCoords = this.getTargetBlock().getLocation().toVector(); - this.linePowder(v); - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.line"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/MoveBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/MoveBrush.java deleted file mode 100644 index 236e2d794..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/MoveBrush.java +++ /dev/null @@ -1,251 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.boydti.fawe.bukkit.wrapper.AsyncBlockState; -import com.boydti.fawe.bukkit.wrapper.AsyncWorld; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockState; - -import java.util.ArrayList; -import java.util.HashSet; - -/** - * Moves a selection blockPositionY a certain amount. - * - * @author MikeMatrix - */ -public class MoveBrush extends Brush { - /** - * Saved direction. - */ - private final int[] moveDirections = {0, 0, 0}; - /** - * Saved selection. - */ - private Selection selection = null; - - public MoveBrush() { - this.setName("Move"); - } - - /** - * Moves the given selection blockPositionY the amount given in direction and saves an undo for the player. - * - * @param v - * @param selection - * @param direction - */ - @SuppressWarnings("deprecation") - private void moveSelection(final SnipeData v, final Selection selection, final int[] direction) { - if (selection.getBlockStates().size() > 0) { - final AsyncWorld world = selection.getBlockStates().get(0).getWorld(); - - final Undo undo = new Undo(); - final HashSet undoSet = new HashSet<>(); - - final Selection newSelection = new Selection(); - final Location movedLocation1 = selection.getLocation1(); - movedLocation1.add(direction[0], direction[1], direction[2]); - final Location movedLocation2 = selection.getLocation2(); - movedLocation2.add(direction[0], direction[1], direction[2]); - newSelection.setLocation1(movedLocation1); - newSelection.setLocation2(movedLocation2); - try { - newSelection.calculateRegion(); - } catch (final Exception exception) { - v.getVoxelMessage().brushMessage("The new Selection has more blocks than the original selection. This should never happen!"); - } - - for (final BlockState blockState : selection.getBlockStates()) { - undoSet.add(blockState.getBlock()); - } - for (final BlockState blockState : newSelection.getBlockStates()) { - undoSet.add(blockState.getBlock()); - } - - for (final Block block : undoSet) { - undo.put(block); - } - v.owner().storeUndo(undo); - - for (final BlockState blockState : selection.getBlockStates()) { - blockState.getBlock().setType(Material.AIR); - } - for (final AsyncBlockState blockState : selection.getBlockStates()) { - final AsyncBlock affectedBlock = world.getBlockAt(blockState.getX() + direction[0], blockState.getY() + direction[1], blockState.getZ() + direction[2]); - affectedBlock.setTypeId(blockState.getTypeId()); - affectedBlock.setPropertyId(blockState.getPropertyId()); - } - } - } - - @Override - protected final void arrow(final SnipeData v) { - if (this.selection == null) { - this.selection = new Selection(); - } - this.selection.setLocation1(this.getTargetBlock().getLocation()); - v.getVoxelMessage().brushMessage("Point 1 set."); - - try { - if (this.selection.calculateRegion()) { - this.moveSelection(v, this.selection, this.moveDirections); - this.selection = null; - } - } catch (final Exception exception) { - v.sendMessage(exception.getMessage()); - } - } - - @Override - protected final void powder(final SnipeData v) { - if (this.selection == null) { - this.selection = new Selection(); - } - this.selection.setLocation2(this.getTargetBlock().getLocation()); - v.getVoxelMessage().brushMessage("Point 2 set."); - - try { - if (this.selection.calculateRegion()) { - this.moveSelection(v, this.selection, this.moveDirections); - this.selection = null; - } - } catch (final Exception exception) { - v.sendMessage(exception.getMessage()); - } - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.custom(ChatColor.BLUE + "Move selection blockPositionY " + ChatColor.GOLD + "x:" + this.moveDirections[0] + " y:" + this.moveDirections[1] + " z:" + this.moveDirections[2]); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - if (par[i].equalsIgnoreCase("info")) { - v.getVoxelMessage().custom(ChatColor.GOLD + this.getName() + " Parameters:"); - v.getVoxelMessage().custom(ChatColor.AQUA + "/b mv x[int] -- set the x direction (positive => east)"); - v.getVoxelMessage().custom(ChatColor.AQUA + "/b mv y[int] -- set the y direction (positive => up)"); - v.getVoxelMessage().custom(ChatColor.AQUA + "/b mv z[int] -- set the z direction (positive => south)"); - v.getVoxelMessage().custom(ChatColor.AQUA + "/b mv reset -- reset the brush (x:0 y:0 z:0)"); - v.getVoxelMessage().custom(ChatColor.AQUA + "Use arrow and gunpowder to define two points."); - } - if (par[i].equalsIgnoreCase("reset")) { - this.moveDirections[0] = 0; - this.moveDirections[1] = 0; - this.moveDirections[2] = 0; - v.getVoxelMessage().custom(ChatColor.AQUA + "X direction set to: " + this.moveDirections[0]); - v.getVoxelMessage().custom(ChatColor.AQUA + "Y direction set to: " + this.moveDirections[1]); - v.getVoxelMessage().custom(ChatColor.AQUA + "Z direction set to: " + this.moveDirections[2]); - } - if (par[i].toLowerCase().startsWith("x")) { - this.moveDirections[0] = Integer.parseInt(par[i].substring(1)); - v.getVoxelMessage().custom(ChatColor.AQUA + "X direction set to: " + this.moveDirections[0]); - } else if (par[i].toLowerCase().startsWith("y")) { - this.moveDirections[1] = Integer.parseInt(par[i].substring(1)); - v.getVoxelMessage().custom(ChatColor.AQUA + "Y direction set to: " + this.moveDirections[1]); - } else if (par[i].toLowerCase().startsWith("z")) { - this.moveDirections[2] = Integer.parseInt(par[i].substring(1)); - v.getVoxelMessage().custom(ChatColor.AQUA + "Z direction set to: " + this.moveDirections[2]); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.move"; - } - - /** - * Selection Helper class. - * - * @author MikeMatrix - */ - private class Selection { - /** - * Maximum amount of Blocks allowed blockPositionY the Selection. - */ - private static final int MAX_BLOCK_COUNT = 5000000; - /** - * Calculated BlockStates of the selection. - */ - private final ArrayList blockStates = new ArrayList<>(); - private Location location1 = null; - private Location location2 = null; - - /** - * Calculates region, then saves all Blocks as BlockState. - * - * @return boolean success. - * @throws Exception Message to be sent to the player. - */ - public boolean calculateRegion() throws Exception { - if (this.location1 != null && this.location2 != null) { - if (this.location1.getWorld().equals(this.location2.getWorld())) { - final int lowX = Math.min(this.location1.getBlockX(), this.location2.getBlockX()); - final int lowY = Math.min(this.location1.getBlockY(), this.location2.getBlockY()); - final int lowZ = Math.min(this.location1.getBlockZ(), this.location2.getBlockZ()); - final int highX = Math.max(this.location1.getBlockX(), this.location2.getBlockX()); - final int highY = Math.max(this.location1.getBlockY(), this.location2.getBlockY()); - final int highZ = Math.max(this.location1.getBlockZ(), this.location2.getBlockZ()); - if (Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY) > Selection.MAX_BLOCK_COUNT) { - throw new Exception(ChatColor.RED + "Selection size above hardcoded limit of 5000000, please use a smaller selection."); - } - final AsyncWorld world = (AsyncWorld) this.location1.getWorld(); - for (int y = lowY; y <= highY; y++) { - for (int x = lowX; x <= highX; x++) { - for (int z = lowZ; z <= highZ; z++) { - this.blockStates.add(world.getBlockAt(x, y, z).getState()); - } - } - } - return true; - } - } - return false; - } - - /** - * @return ArrayList calculated BlockStates of defined region. - */ - public ArrayList getBlockStates() { - return this.blockStates; - } - - /** - * @return Location - */ - public Location getLocation1() { - return this.location1; - } - - /** - * @param location1 - */ - public void setLocation1(final Location location1) { - this.location1 = location1; - } - - /** - * @return Location - */ - public Location getLocation2() { - return this.location2; - } - - /** - * @param location2 - */ - public void setLocation2(final Location location2) { - this.location2 = location2; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OceanBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OceanBrush.java deleted file mode 100644 index d5dbfea87..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OceanBrush.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.boydti.fawe.bukkit.wrapper.AsyncWorld; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.block.Block; - - -public class OceanBrush extends Brush { - private static final int WATER_LEVEL_DEFAULT = 62; // y=63 -- we are using array indices here - private static final int WATER_LEVEL_MIN = 12; - private static final int LOW_CUT_LEVEL = 12; - - private int waterLevel = WATER_LEVEL_DEFAULT; - private boolean coverFloor = false; - - public OceanBrush() { - this.setName("OCEANATOR 5000(tm)"); - } - - private int getHeight(final int bx, final int bz) { - for (int y = this.getWorld().getHighestBlockYAt(bx, bz); y > 0; y--) { - final Material material = this.clampY(bx, y, bz).getType(); - if (material.isSolid()) { - return y; - } - } - return 0; - } - - protected final void oceanator(final SnipeData v, final Undo undo) { - final AsyncWorld world = this.getWorld(); - - final int minX = (int) Math.floor((this.getTargetBlock().getX() - v.getBrushSize())); - final int minZ = (int) Math.floor((this.getTargetBlock().getZ() - v.getBrushSize())); - final int maxX = (int) Math.floor((this.getTargetBlock().getX() + v.getBrushSize())); - final int maxZ = (int) Math.floor((this.getTargetBlock().getZ() + v.getBrushSize())); - - for (int x = minX; x <= maxX; x++) { - for (int z = minZ; z <= maxZ; z++) { - final int currentHeight = getHeight(x, z); - final int wLevelDiff = currentHeight - (this.waterLevel - 1); - final int newSeaFloorLevel = Math.max((this.waterLevel - wLevelDiff), LOW_CUT_LEVEL); - - final int highestY = this.getWorld().getHighestBlockYAt(x, z); - - // go down from highest Y block down to new sea floor - for (int y = highestY; y > newSeaFloorLevel; y--) { - final Block block = world.getBlockAt(x, y, z); - if (!block.getType().equals(Material.AIR)) { - undo.put(block); - block.setType(Material.AIR); - } - } - - // go down from water level to new sea level - for (int y = this.waterLevel; y > newSeaFloorLevel; y--) { - final Block block = world.getBlockAt(x, y, z); - if (!block.getType().equals(Material.WATER)) { - // do not put blocks into the undo we already put into - if (!block.getType().equals(Material.AIR)) { - undo.put(block); - } - block.setType(Material.WATER); - } - } - - // cover the sea floor of required - if (this.coverFloor && (newSeaFloorLevel < this.waterLevel)) { - AsyncBlock block = world.getBlockAt(x, newSeaFloorLevel, z); - if (block.getTypeId() != v.getVoxelId()) { - undo.put(block); - block.setTypeId(v.getVoxelId()); - } - } - } - } - } - - @Override - protected final void arrow(final SnipeData v) { - Undo undo = new Undo(); - this.oceanator(v, undo); - v.owner().storeUndo(undo); - } - - @Override - protected final void powder(final SnipeData v) { - arrow(v); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 0; i < par.length; i++) { - final String parameter = par[i]; - - try { - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.BLUE + "Parameters:"); - v.sendMessage(ChatColor.GREEN + "-wlevel # " + ChatColor.BLUE + "-- Sets the water level (e.g. -wlevel 64)"); - v.sendMessage(ChatColor.GREEN + "-cfloor [y|n] " + ChatColor.BLUE + "-- Enables or disables sea floor cover (e.g. -cfloor y) (Cover material will be your voxel material)"); - } else if (parameter.equalsIgnoreCase("-wlevel")) { - if ((i + 1) >= par.length) { - v.sendMessage(ChatColor.RED + "Missing parameter. Correct syntax: -wlevel [#] (e.g. -wlevel 64)"); - continue; - } - - int temp = Integer.parseInt(par[++i]); - - if (temp <= WATER_LEVEL_MIN) { - v.sendMessage(ChatColor.RED + "Error: Your specified water level was below 12."); - continue; - } - - this.waterLevel = temp - 1; - v.sendMessage(ChatColor.BLUE + "Water level set to " + ChatColor.GREEN + (waterLevel + 1)); // +1 since we are working with 0-based array indices - } else if (parameter.equalsIgnoreCase("-cfloor") || parameter.equalsIgnoreCase("-coverfloor")) { - if ((i + 1) >= par.length) { - v.sendMessage(ChatColor.RED + "Missing parameter. Correct syntax: -cfloor [y|n] (e.g. -cfloor y)"); - continue; - } - - this.coverFloor = par[++i].equalsIgnoreCase("y"); - v.sendMessage(ChatColor.BLUE + String.format("Floor cover %s.", ChatColor.GREEN + (this.coverFloor ? "enabled" : "disabled"))); - } - } catch (Exception exception) { - v.sendMessage(ChatColor.RED + String.format("Error while parsing parameter: %s", parameter)); - exception.printStackTrace(); - } - } - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.custom(ChatColor.BLUE + "Water level set to " + ChatColor.GREEN + (waterLevel + 1)); // +1 since we are working with 0-based array indices - vm.custom(ChatColor.BLUE + String.format("Floor cover %s.", ChatColor.GREEN + (this.coverFloor ? "enabled" : "disabled"))); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.ocean"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java deleted file mode 100644 index 7a7be93fa..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java +++ /dev/null @@ -1,211 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.world.block.BlockID; -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.registry.BlockMaterial; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; - -public class OverlayBrush extends PerformBrush { - private static final int DEFAULT_DEPTH = 3; - private int depth = DEFAULT_DEPTH; - private boolean allBlocks = false; - - public OverlayBrush() { - this.setName("Overlay (Topsoil Filling)"); - } - - private void overlay(final SnipeData v) { - final int brushSize = v.getBrushSize(); - final double brushSizeSquared = Math.pow(brushSize + 0.5, 2); - - - for (int z = brushSize; z >= -brushSize; z--) { - for (int x = brushSize; x >= -brushSize; x--) { - // check if column is valid - // column is valid if it has no solid block right above the clicked layer - final int materialId = this.getBlockIdAt(this.getTargetBlock().getX() + x, - this.getTargetBlock().getY() + 1, this.getTargetBlock().getZ() + z); - if (isIgnoredBlock(materialId)) { - if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared) { - for (int y = this.getTargetBlock().getY(); y > 0; y--) { - // check for surface - final int layerBlockId = - this.getBlockIdAt(this.getTargetBlock().getX() + x, y, - this.getTargetBlock().getZ() + z); - if (!isIgnoredBlock(layerBlockId)) { - for (int currentDepth = y; - y - currentDepth < depth; currentDepth--) { - final int currentBlockId = - this.getBlockIdAt(this.getTargetBlock().getX() + x, - currentDepth, this.getTargetBlock().getZ() + z); - if (isOverrideableMaterial(currentBlockId)) { - this.current.perform( - this.clampY(this.getTargetBlock().getX() + x, - currentDepth, this.getTargetBlock().getZ() + z)); - } - } - break; - } - } - } - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - @SuppressWarnings("deprecation") - private boolean isIgnoredBlock(int materialId) { - BlockType type = BlockTypes.get(materialId); - switch (type.getInternalId()) { - case BlockID.WATER: - case BlockID.LAVA: - case BlockID.CACTUS: - return true; - default: - BlockMaterial mat = type.getMaterial(); - return mat.isTranslucent(); - } - } - - @SuppressWarnings("deprecation") - private boolean isOverrideableMaterial(int materialId) { - BlockMaterial mat = BlockTypes.get(materialId).getMaterial(); - if (allBlocks && !(mat.isAir())) { - return true; - } - - return !mat.isFragileWhenPushed() && mat.isFullCube(); - } - - private void overlayTwo(final SnipeData v) { - final int brushSize = v.getBrushSize(); - final double brushSizeSquared = Math.pow(brushSize + 0.5, 2); - final int[][] memory = new int[brushSize * 2 + 1][brushSize * 2 + 1]; - - for (int z = brushSize; z >= -brushSize; z--) { - for (int x = brushSize; x >= -brushSize; x--) { - boolean surfaceFound = false; - for (int y = this.getTargetBlock().getY(); - y > 0 && !surfaceFound; y--) { // start scanning from the height you clicked at - if (memory[x + brushSize][z + brushSize] - != 1) { // if haven't already found the surface in this column - if ((Math.pow(x, 2) + Math.pow(z, 2)) - <= brushSizeSquared) { // if inside of the column... - if (!this.getBlockAt(this.getTargetBlock().getX() + x, y - 1, - this.getTargetBlock().getZ() + z) - .isEmpty()) { // if not a floating block (like one of Notch'world pools) - if (this.getBlockAt(this.getTargetBlock().getX() + x, y + 1, - this.getTargetBlock().getZ() + z) - .isEmpty()) { // must start at surface... this prevents it filling stuff in if - // you click in a wall and it starts out below surface. - if (!this.allBlocks) { // if the override parameter has not been activated, go to the switch that filters out manmade stuff. - - BlockType type = BukkitAdapter.asBlockType((this - .getBlockType(this.getTargetBlock().getX() + x, y, - this.getTargetBlock().getZ() + z))); - BlockMaterial mat = type.getMaterial(); - if (mat.isSolid() && mat.isFullCube() && !mat - .hasContainer()) { - for (int d = 1; (d < this.depth + 1); d++) { - this.current.perform( - this.clampY(this.getTargetBlock().getX() + x, - y + d, this.getTargetBlock().getZ() - + z)); // fills down as many layers as you specify - // in parameters - memory[x + brushSize][z + brushSize] = - 1; // stop it from checking any other blocks in this vertical 1x1 column. - } - surfaceFound = true; - - } - } else { - for (int d = 1; (d < this.depth + 1); d++) { - this.current.perform( - this.clampY(this.getTargetBlock().getX() + x, y + d, - this.getTargetBlock().getZ() - + z)); // fills down as many layers as you specify in - // parameters - memory[x + brushSize][z + brushSize] = - 1; // stop it from checking any other blocks in this vertical 1x1 column. - } - surfaceFound = true; - } - - } - } - } - } - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.overlay(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.overlayTwo(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Overlay brush parameters:"); - v.sendMessage(ChatColor.AQUA - + "d[number] (ex: d3) How many blocks deep you want to replace from the surface."); - v.sendMessage(ChatColor.BLUE - + "all (ex: /b over all) Sets the brush to overlay over ALL materials, not just natural surface ones (will no longer ignore trees and buildings). The parameter /some will set it back to default."); - return; - } - if (parameter.startsWith("d")) { - try { - this.depth = Integer.parseInt(parameter.replace("d", "")); - - if (this.depth < 1) { - this.depth = 1; - } - - v.sendMessage(ChatColor.AQUA + "Depth set to " + this.depth); - } catch (NumberFormatException e) { - v.sendMessage(ChatColor.RED + "Depth isn't a number."); - } - } else if (parameter.startsWith("all")) { - this.allBlocks = true; - v.sendMessage(ChatColor.BLUE + "Will overlay over any block." + this.depth); - } else if (parameter.startsWith("some")) { - this.allBlocks = false; - v.sendMessage( - ChatColor.BLUE + "Will overlay only natural block types." + this.depth); - } else { - v.sendMessage(ChatColor.RED - + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.overlay"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PaintingBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PaintingBrush.java deleted file mode 100644 index 8e060b079..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PaintingBrush.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.PaintingWrapper; -import com.thevoxelbox.voxelsniper.SnipeData; - -/** - * Painting scrolling Brush. - * - * @author Voxel - */ -public class PaintingBrush extends Brush { - - public PaintingBrush() { - this.setName("Painting"); - } - - /** - * Scroll painting forward. - * - * @param v Sniper caller - */ - @Override - protected final void arrow(final SnipeData v) { - PaintingWrapper.paint(v.owner().getPlayer(), true, false, 0); - } - - /** - * Scroll painting backwards. - * - * @param v Sniper caller - */ - @Override - protected final void powder(final SnipeData v) { - PaintingWrapper.paint(v.owner().getPlayer(), true, true, 0); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.painting"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PullBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PullBrush.java deleted file mode 100644 index 8b4d9c451..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PullBrush.java +++ /dev/null @@ -1,311 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.ChatColor; - -import java.util.HashSet; - - -public class PullBrush extends Brush { - private final HashSet surface = new HashSet<>(); - private int vh; - private double c1 = 1; - private double c2 = 0; - - /** - * Default Constructor. - */ - public PullBrush() { - this.setName("Soft Selection"); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - vm.height(); - vm.custom(ChatColor.AQUA + "Pinch " + (-this.c1 + 1)); - vm.custom(ChatColor.AQUA + "Bubble " + this.c2); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - try { - final double pinch = Double.parseDouble(par[1]); - final double bubble = Double.parseDouble(par[2]); - this.c1 = 1 - pinch; - this.c2 = bubble; - } catch (final Exception exception) { - v.sendMessage(ChatColor.RED + "Invalid brush parameters!"); - } - } - - /** - * @param t - * @return double - */ - private double getStr(final double t) { - final double lt = 1 - t; - return (lt * lt * lt) + 3 * (lt * lt) * t * this.c1 + 3 * lt * (t * t) * this.c2; // My + (t * ((By + (t * ((c2 + (t * (0 - c2))) - By))) - My)); - } - - /** - * @param v - */ - private void getSurface(final SnipeData v) { - this.surface.clear(); - - final double bSquared = Math.pow(v.getBrushSize() + 0.5, 2); - for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) { - final double zSquared = Math.pow(z, 2); - final int actualZ = this.getTargetBlock().getZ() + z; - for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) { - final double xSquared = Math.pow(x, 2); - final int actualX = this.getTargetBlock().getX() + x; - for (int y = -v.getBrushSize(); y <= v.getBrushSize(); y++) { - final double volume = (xSquared + Math.pow(y, 2) + zSquared); - if (volume <= bSquared) { - if (this.isSurface(actualX, this.getTargetBlock().getY() + y, actualZ)) { - this.surface.add(new BlockWrapper(this.clampY(actualX, this.getTargetBlock().getY() + y, actualZ), this.getStr(((volume / bSquared))))); - } - } - } - } - } - } - - /** - * @param x - * @param y - * @param z - * @return boolean - */ - private boolean isSurface(final int x, final int y, final int z) { - return !this.getBlockAt(x, y, z).isEmpty() && ((this.getBlockAt(x, y - 1, z).isEmpty()) || (this.getBlockAt(x, y + 1, z).isEmpty()) || (this.getBlockAt(x + 1, y, z).isEmpty()) || (this.getBlockAt(x - 1, y, z).isEmpty()) || (this.getBlockAt(x, y, z + 1).isEmpty()) || (this.getBlockAt(x, y, z - 1).isEmpty())); - - } - - @SuppressWarnings("deprecation") - private void setBlock(final BlockWrapper block) { - final AsyncBlock currentBlock = this.clampY(block.getX(), block.getY() + (int) (this.vh * block.getStr()), block.getZ()); - if (this.getBlockAt(block.getX(), block.getY() - 1, block.getZ()).isEmpty()) { - currentBlock.setTypeId(block.getId()); - currentBlock.setPropertyId(block.getD()); - for (int y = block.getY(); y < currentBlock.getY(); y++) { - this.setBlockIdAt(block.getZ(), block.getX(), y, BlockTypes.AIR.getInternalId()); - } - } else { - currentBlock.setTypeId(block.getId()); - currentBlock.setPropertyId(block.getD()); - for (int y = block.getY() - 1; y < currentBlock.getY(); y++) { - final AsyncBlock current = this.clampY(block.getX(), y, block.getZ()); - current.setTypeId(block.getId()); - current.setPropertyId(block.getD()); - } - } - } - - @SuppressWarnings("deprecation") - private void setBlockDown(final BlockWrapper block) { - final AsyncBlock currentBlock = this.clampY(block.getX(), block.getY() + (int) (this.vh * block.getStr()), block.getZ()); - currentBlock.setTypeId(block.getId()); - currentBlock.setPropertyId(block.getD()); - for (int y = block.getY(); y > currentBlock.getY(); y--) { - this.setBlockIdAt(block.getZ(), block.getX(), y, BlockTypes.AIR.getInternalId()); - } - // } - } - - @Override - protected final void arrow(final SnipeData v) { - this.vh = v.getVoxelHeight(); - this.getSurface(v); - - if (this.vh > 0) { - for (final BlockWrapper block : this.surface) { - this.setBlock(block); - } - } else if (this.vh < 0) { - for (final BlockWrapper block : this.surface) { - this.setBlockDown(block); - } - } - } - - @SuppressWarnings("deprecation") - @Override - protected final void powder(final SnipeData v) { - this.vh = v.getVoxelHeight(); - - this.surface.clear(); - - int lastY; - int newY; - int lastStr; - double str; - final double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2); - - int id; - - // Are we pulling up ? - if (this.vh > 0) { - - // Z - Axis - for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) { - - final int zSquared = z * z; - final int actualZ = this.getTargetBlock().getZ() + z; - - // X - Axis - for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) { - - final int xSquared = x * x; - final int actualX = this.getTargetBlock().getX() + x; - - // Down the Y - Axis - for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) { - - final double volume = zSquared + xSquared + (y * y); - - // Is this in the range of the brush? - if (volume <= brushSizeSquared && !this.getWorld().getBlockAt(actualX, this.getTargetBlock().getY() + y, actualZ).isEmpty()) { - - int actualY = this.getTargetBlock().getY() + y; - - // Starting strength and new Position - str = this.getStr(volume / brushSizeSquared); - lastStr = (int) (this.vh * str); - lastY = actualY + lastStr; - - this.clampY(actualX, lastY, actualZ).setTypeId(this.getWorld().getBlockAt(actualX, actualY, actualZ).getTypeId()); - - if (str == 1) { - str = 0.8; - } - - while (lastStr > 0) { - if (actualY < this.getTargetBlock().getY()) { - str = str * str; - } - lastStr = (int) (this.vh * str); - newY = actualY + lastStr; - id = this.getWorld().getBlockAt(actualX, actualY, actualZ).getTypeId(); - for (int i = newY; i < lastY; i++) { - this.clampY(actualX, i, actualZ).setTypeId(id); - } - lastY = newY; - actualY--; - } - break; - } - } - } - } - } else { - for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) { - final double zSquared = Math.pow(z, 2); - final int actualZ = this.getTargetBlock().getZ() + z; - for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) { - final double xSquared = Math.pow(x, 2); - final int actualX = this.getTargetBlock().getX() + x; - for (int y = -v.getBrushSize(); y <= v.getBrushSize(); y++) { - double volume = (xSquared + Math.pow(y, 2) + zSquared); - if (volume <= brushSizeSquared && !this.getWorld().getBlockAt(actualX, this.getTargetBlock().getY() + y, actualZ).isEmpty()) { - final int actualY = this.getTargetBlock().getY() + y; - lastY = actualY + (int) (this.vh * this.getStr(volume / brushSizeSquared)); - this.clampY(actualX, lastY, actualZ).setTypeId(this.getWorld().getBlockAt(actualX, actualY, actualZ).getTypeId()); - y++; - volume = (xSquared + Math.pow(y, 2) + zSquared); - while (volume <= brushSizeSquared) { - final int blockY = this.getTargetBlock().getY() + y + (int) (this.vh * this.getStr(volume / brushSizeSquared)); - final int blockId = this.getWorld().getBlockAt(actualX, this.getTargetBlock().getY() + y, actualZ).getTypeId(); - for (int i = blockY; i < lastY; i++) { - this.clampY(actualX, i, actualZ).setTypeId(blockId); - } - lastY = blockY; - y++; - volume = (xSquared + Math.pow(y, 2) + zSquared); - } - break; - } - } - } - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.pull"; - } - - - private final class BlockWrapper { - - private final int id; - private final int d; - private final double str; - private final int x; - private final int y; - private final int z; - - /** - * @param block - * @param st - */ - @SuppressWarnings("deprecation") - public BlockWrapper(final AsyncBlock block, final double st) { - this.id = block.getTypeId(); - this.d = block.getPropertyId(); - this.x = block.getX(); - this.y = block.getY(); - this.z = block.getZ(); - this.str = st; - } - - /** - * @return the d - */ - public int getD() { - return this.d; - } - - /** - * @return the id - */ - public int getId() { - return this.id; - } - - /** - * @return the str - */ - public double getStr() { - return this.str; - } - - /** - * @return the x - */ - public int getX() { - return this.x; - } - - /** - * @return the y - */ - public int getY() { - return this.y; - } - - /** - * @return the z - */ - public int getZ() { - return this.z; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PunishBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PunishBrush.java deleted file mode 100644 index 6e0229ca4..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PunishBrush.java +++ /dev/null @@ -1,320 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.block.data.BlockData; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.Vector; - -import java.util.List; -import java.util.Random; - -public class PunishBrush extends PerformBrush { - private static final int MAXIMAL_RANDOM_TELEPORTATION_RANGE = 400; - private static final int TICKS_PER_SECOND = 20; - private static final int INFINIPUNISH_SIZE = -3; - private static final int DEFAULT_PUNISH_LEVEL = 10; - private static final int DEFAULT_PUSNIH_DURATION = 60; - private Punishment punishment = Punishment.FIRE; - private int punishLevel = DEFAULT_PUNISH_LEVEL; - private int punishDuration = DEFAULT_PUSNIH_DURATION; - private boolean specificPlayer = false; - private String punishPlayerName = ""; - private boolean hypnoAffectLandscape = false; - private boolean hitsSelf = false; - - /** - * Default Constructor. - */ - public PunishBrush() { - this.setName("Punish"); - } - - @SuppressWarnings("deprecation") - private void applyPunishment(final LivingEntity entity, final SnipeData v) { - switch (this.punishment) { - case FIRE: - entity.setFireTicks(PunishBrush.TICKS_PER_SECOND * this.punishDuration); - break; - case LIGHTNING: - entity.getWorld().strikeLightning(entity.getLocation()); - break; - case BLINDNESS: - entity.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case DRUNK: - entity.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case SLOW: - entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case JUMP: - entity.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case ABSORPTION: - entity.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case DAMAGE_RESISTANCE: - entity.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case FAST_DIGGING: - entity.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case FIRE_RESISTANCE: - entity.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case HEAL: - entity.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case HEALTH_BOOST: - entity.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case HUNGER: - entity.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case INCREASE_DAMAGE: - entity.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case INVISIBILITY: - entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case NIGHT_VISION: - entity.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case POISON: - entity.addPotionEffect(new PotionEffect(PotionEffectType.POISON, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case REGENERATION: - entity.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case SATURATION: - entity.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case SLOW_DIGGING: - entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case SPEED: - entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case WATER_BREATHING: - entity.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case WEAKNESS: - entity.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case WITHER: - entity.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case KILL: - entity.setHealth(0d); - break; - case RANDOMTP: - final Random random = new Random(); - final Location targetLocation = entity.getLocation(); - targetLocation.setX(targetLocation.getX() + (random.nextInt(MAXIMAL_RANDOM_TELEPORTATION_RANGE) - (MAXIMAL_RANDOM_TELEPORTATION_RANGE / 2))); - targetLocation.setZ(targetLocation.getZ() + (random.nextInt(PunishBrush.MAXIMAL_RANDOM_TELEPORTATION_RANGE) - PunishBrush.MAXIMAL_RANDOM_TELEPORTATION_RANGE / 2)); - entity.teleport(targetLocation); - break; - case ALL_POTION: - entity.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - entity.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - entity.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, PunishBrush.TICKS_PER_SECOND * this.punishDuration, this.punishLevel), true); - break; - case FORCE: - final Vector playerVector = this.getTargetBlock().getLocation().toVector(); - final Vector direction = entity.getLocation().toVector().clone(); - direction.subtract(playerVector); - final double length = direction.length(); - final double stregth = (1 - (length / v.getBrushSize())) * this.punishLevel; - direction.normalize(); - direction.multiply(stregth); - entity.setVelocity(direction); - break; - case HYPNO: - if (entity instanceof Player) { - final Location location = entity.getLocation(); - Location target = location.clone(); - for (int z = this.punishLevel; z >= -this.punishLevel; z--) { - for (int x = this.punishLevel; x >= -this.punishLevel; x--) { - for (int y = this.punishLevel; y >= -this.punishLevel; y--) { - target.setX(location.getX() + x); - target.setY(location.getY() + y); - target.setZ(location.getZ() + z); - if (this.hypnoAffectLandscape && target.getBlock().isEmpty()) { - continue; - } - target = location.clone(); - target.add(x, y, z); - Player plr = ((Player) entity); - BlockData bd = BukkitAdapter.adapt(BlockState.getFromInternalId(v.getVoxelId() + (v.getPropertyId() << BlockTypes.BIT_OFFSET))); - plr.sendBlockChange(target, bd); - } - } - } - } - break; - default: - Bukkit.getLogger().warning("Could not determine the punishment of punish brush!"); - break; - } - } - - @Override - protected final void arrow(final SnipeData v) { - if (!v.owner().getPlayer().hasPermission("voxelsniper.punish")) { - v.sendMessage("The server says no!"); - return; - } - - this.punishDuration = v.getVoxelHeight(); - this.punishLevel = v.getcCen(); - - if (this.specificPlayer) { - final Player punishedPlayer = Bukkit.getPlayer(this.punishPlayerName); - if (punishedPlayer == null) { - v.sendMessage("No player " + this.punishPlayerName + " found."); - return; - } - - this.applyPunishment(punishedPlayer, v); - return; - } - - final int brushSizeSquare = v.getBrushSize() * v.getBrushSize(); - final Location targetLocation = new Location(v.getWorld(), this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ()); - - final List entities = v.getWorld().getLivingEntities(); - int numPunishApps = 0; - for (final LivingEntity entity : entities) { - if (v.owner().getPlayer() != entity || hitsSelf) { - if (v.getBrushSize() >= 0) { - try { - if (entity.getLocation().distanceSquared(targetLocation) <= brushSizeSquare) { - numPunishApps++; - this.applyPunishment(entity, v); - } - } catch (final Exception exception) { - exception.printStackTrace(); - v.sendMessage("An error occurred."); - return; - } - } else if (v.getBrushSize() == PunishBrush.INFINIPUNISH_SIZE) { - numPunishApps++; - this.applyPunishment(entity, v); - } - } - } - v.sendMessage(ChatColor.DARK_RED + "Punishment applied to " + numPunishApps + " living entities."); - } - - @Override - protected final void powder(final SnipeData v) { - if (!v.owner().getPlayer().hasPermission("voxelsniper.punish")) { - v.sendMessage("The server says no!"); - return; - } - - final int brushSizeSquare = v.getBrushSize() * v.getBrushSize(); - final Location targetLocation = new Location(v.getWorld(), this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ()); - - final List entities = v.getWorld().getLivingEntities(); - - for (final LivingEntity entity : entities) { - if (entity.getLocation().distanceSquared(targetLocation) < brushSizeSquare) { - entity.setFireTicks(0); - entity.removePotionEffect(PotionEffectType.BLINDNESS); - entity.removePotionEffect(PotionEffectType.CONFUSION); - entity.removePotionEffect(PotionEffectType.SLOW); - entity.removePotionEffect(PotionEffectType.JUMP); - } - } - - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.custom(ChatColor.GREEN + "Punishment: " + this.punishment.toString()); - vm.size(); - vm.center(); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i].toLowerCase(); - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Punish Brush Options:"); - v.sendMessage(ChatColor.AQUA + "Punishments can be set via /b p [punishment]"); - v.sendMessage(ChatColor.AQUA + "Punishment level can be set with /vc [level]"); - v.sendMessage(ChatColor.AQUA + "Punishment duration in seconds can be set with /vh [duration]"); - v.sendMessage(ChatColor.AQUA + "Parameter -toggleHypnoLandscape will make Hypno punishment only affect landscape."); - v.sendMessage(ChatColor.AQUA + "Parameter -toggleSM [playername] will make punishbrush only affect that player."); - v.sendMessage(ChatColor.AQUA + "Parameter -toggleSelf will toggle whether you get hit as well."); - v.sendMessage(ChatColor.AQUA + "Available Punishment Options:"); - final StringBuilder punishmentOptions = new StringBuilder(); - for (final Punishment punishment : Punishment.values()) { - if (punishmentOptions.length() != 0) { - punishmentOptions.append(" | "); - } - punishmentOptions.append(punishment.name()); - } - v.sendMessage(ChatColor.GOLD + punishmentOptions.toString()); - return; - } else if (parameter.equalsIgnoreCase("-toggleSM")) { - this.specificPlayer = !this.specificPlayer; - if (this.specificPlayer) { - try { - this.punishPlayerName = par[++i]; - } catch (final IndexOutOfBoundsException exception) { - v.sendMessage(ChatColor.AQUA + "You have to specify a player name after -toggleSM if you want to turn the specific player feature on."); - } - } - } else if (parameter.equalsIgnoreCase("-toggleSelf")) { - this.hitsSelf = !this.hitsSelf; - if (hitsSelf) { - v.sendMessage(ChatColor.AQUA + "Your punishments will now affect you too!"); - } else { - v.sendMessage(ChatColor.AQUA + "Your punishments will no longer affect you!"); - } - } else if (parameter.equalsIgnoreCase("-toggleHypnoLandscape")) { - this.hypnoAffectLandscape = !this.hypnoAffectLandscape; - } else { - try { - this.punishment = Punishment.valueOf(parameter.toUpperCase()); - v.sendMessage(ChatColor.AQUA + this.punishment.name().toLowerCase() + " punishment selected."); - } catch (final IllegalArgumentException exception) { - v.sendMessage(ChatColor.AQUA + "No such Punishment."); - } - } - } - - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.punish"; - } - - private enum Punishment { - // Monofraps - FIRE, LIGHTNING, BLINDNESS, DRUNK, KILL, RANDOMTP, ALL_POTION, - // Deamon - SLOW, JUMP, ABSORPTION, DAMAGE_RESISTANCE, FAST_DIGGING, FIRE_RESISTANCE, HEAL, HEALTH_BOOST, HUNGER, INCREASE_DAMAGE, INVISIBILITY, NIGHT_VISION, POISON, REGENERATION, - SATURATION, SLOW_DIGGING, SPEED, WATER_BREATHING, WEAKNESS, WITHER, - // MikeMatrix - FORCE, HYPNO - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RandomErodeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RandomErodeBrush.java deleted file mode 100644 index 4cc354f90..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RandomErodeBrush.java +++ /dev/null @@ -1,357 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; - -import java.util.Random; - -public class RandomErodeBrush extends Brush { - private final double trueCircle = 0.5; - private BlockWrapper[][][] snap; - private BlockWrapper[][][] firstSnap; - private int bsize; - private int erodeFace; - private int fillFace; - private int erodeRecursion = 1; - private int fillRecursion = 1; - private Random generator = new Random(); - - public RandomErodeBrush() { - this.setName("RandomErode"); - } - - private boolean erode(final int x, final int y, final int z) { - if (this.snap[x][y][z].isSolid()) { - int d = 0; - if (!this.snap[x + 1][y][z].isSolid()) { - d++; - } - if (!this.snap[x - 1][y][z].isSolid()) { - d++; - } - if (!this.snap[x][y + 1][z].isSolid()) { - d++; - } - if (!this.snap[x][y - 1][z].isSolid()) { - d++; - } - if (!this.snap[x][y][z + 1].isSolid()) { - d++; - } - if (!this.snap[x][y][z - 1].isSolid()) { - d++; - } - return (d >= this.erodeFace); - } else { - return false; - } - } - - private boolean fill(final int x, final int y, final int z) { - if (this.snap[x][y][z].isSolid()) { - return false; - } else { - int d = 0; - if (this.snap[x + 1][y][z].isSolid()) { - this.snap[x][y][z].setId(this.snap[x + 1][y][z].getNativeBlock().getTypeId()); - d++; - } - if (this.snap[x - 1][y][z].isSolid()) { - this.snap[x][y][z].setId(this.snap[x - 1][y][z].getNativeBlock().getTypeId()); - d++; - } - if (this.snap[x][y + 1][z].isSolid()) { - this.snap[x][y][z].setId(this.snap[x][y + 1][z].getNativeBlock().getTypeId()); - d++; - } - if (this.snap[x][y - 1][z].isSolid()) { - this.snap[x][y][z].setId(this.snap[x][y - 1][z].getNativeBlock().getTypeId()); - d++; - } - if (this.snap[x][y][z + 1].isSolid()) { - this.snap[x][y][z].setId(this.snap[x][y][z + 1].getNativeBlock().getTypeId()); - d++; - } - if (this.snap[x][y][z - 1].isSolid()) { - this.snap[x][y][z].setId(this.snap[x][y][z - 1].getNativeBlock().getTypeId()); - d++; - } - return (d >= this.fillFace); - } - } - - private void getMatrix() { - int brushSize = ((this.bsize + 1) * 2) + 1; - - if (this.snap.length == 0) { - this.snap = new BlockWrapper[brushSize][brushSize][brushSize]; - - int sx = this.getTargetBlock().getX() - (this.bsize + 1); - - for (int x = 0; x < this.snap.length; x++) { - int sz = this.getTargetBlock().getZ() - (this.bsize + 1); - for (int z = 0; z < this.snap.length; z++) { - int sy = this.getTargetBlock().getY() - (this.bsize + 1); - for (int y = 0; y < this.snap.length; y++) { - this.snap[x][y][z] = new BlockWrapper(this.clampY(sx, sy, sz)); - sy++; - } - sz++; - } - sx++; - } - this.firstSnap = this.snap.clone(); - } else { - this.snap = new BlockWrapper[brushSize][brushSize][brushSize]; - - int sx = this.getTargetBlock().getX() - (this.bsize + 1); - - for (int x = 0; x < this.snap.length; x++) { - int sz = this.getTargetBlock().getZ() - (this.bsize + 1); - for (int z = 0; z < this.snap.length; z++) { - int sy = this.getTargetBlock().getY() - (this.bsize + 1); - for (int y = 0; y < this.snap.length; y++) { - this.snap[x][y][z] = new BlockWrapper(this.clampY(sx, sy, sz)); - sy++; - } - sz++; - } - sx++; - } - } - } - - @SuppressWarnings("deprecation") - private void rerosion(final SnipeData v) { - final Undo undo = new Undo(); - - if (this.erodeFace >= 0 && this.erodeFace <= 6) { - for (int currentErodeRecursion = 0; currentErodeRecursion < this.erodeRecursion; currentErodeRecursion++) { - this.getMatrix(); - - final double brushSizeSquared = Math.pow(this.bsize + this.trueCircle, 2); - for (int z = 1; z < this.snap.length - 1; z++) { - - final double zSquared = Math.pow(z - (this.bsize + 1), 2); - for (int x = 1; x < this.snap.length - 1; x++) { - - final double xSquared = Math.pow(x - (this.bsize + 1), 2); - for (int y = 1; y < this.snap.length - 1; y++) { - - if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= brushSizeSquared)) { - if (this.erode(x, y, z)) { - this.snap[x][y][z].getNativeBlock().setTypeId(BlockTypes.AIR.getInternalId()); - } - } - } - } - } - } - } - if (this.fillFace >= 0 && this.fillFace <= 6) { - final double brushSizeSquared = Math.pow(this.bsize + 0.5, 2); - - for (int currentFillRecursion = 0; currentFillRecursion < this.fillRecursion; currentFillRecursion++) { - this.getMatrix(); - - for (int z = 1; z < this.snap.length - 1; z++) { - - final double zSquared = Math.pow(z - (this.bsize + 1), 2); - for (int x = 1; x < this.snap.length - 1; x++) { - - final double xSquared = Math.pow(x - (this.bsize + 1), 2); - for (int y = 1; y < this.snap.length - 1; y++) { - - if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= brushSizeSquared)) { - if (this.fill(x, y, z)) { - this.snap[x][y][z].getNativeBlock().setTypeId(this.snap[x][y][z].getId()); - } - } - } - } - } - } - } - - for (BlockWrapper[][] firstSnapSlice : this.firstSnap) { - for (BlockWrapper[] firstSnapString : firstSnapSlice) { - for (final BlockWrapper block : firstSnapString) { - if (block.getI() != block.getNativeBlock().getTypeId()) { - undo.put(block.getNativeBlock()); - } - } - } - } - - v.owner().storeUndo(undo); - } - - @SuppressWarnings("deprecation") - private void rfilling(final SnipeData v) { - final Undo undo = new Undo(); - - if (this.fillFace >= 0 && this.fillFace <= 6) { - final double bSquared = Math.pow(this.bsize + 0.5, 2); - - for (int currentFillRecursion = 0; currentFillRecursion < this.fillRecursion; currentFillRecursion++) { - this.getMatrix(); - - for (int z = 1; z < this.snap.length - 1; z++) { - final double zSquared = Math.pow(z - (this.bsize + 1), 2); - for (int x = 1; x < this.snap.length - 1; x++) { - final double xSquared = Math.pow(x - (this.bsize + 1), 2); - for (int y = 1; y < this.snap.length - 1; y++) { - if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= bSquared)) { - if (this.fill(x, y, z)) { - this.snap[x][y][z].getNativeBlock().setTypeId(this.snap[x][y][z].getId()); - } - } - } - } - } - } - } - if (this.erodeFace >= 0 && this.erodeFace <= 6) { - final double bSquared = Math.pow(this.bsize + this.trueCircle, 2); - - for (int currentErodeRecursion = 0; currentErodeRecursion < this.erodeRecursion; currentErodeRecursion++) { - this.getMatrix(); - - for (int z = 1; z < this.snap.length - 1; z++) { - - final double zSquared = Math.pow(z - (this.bsize + 1), 2); - for (int x = 1; x < this.snap.length - 1; x++) { - - final double xSquared = Math.pow(x - (this.bsize + 1), 2); - for (int y = 1; y < this.snap.length - 1; y++) { - - if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= bSquared)) { - if (this.erode(x, y, z)) { - this.snap[x][y][z].getNativeBlock().setTypeId(BlockTypes.AIR.getInternalId()); - } - } - } - } - } - } - } - - for (BlockWrapper[][] firstSnapSlice : this.firstSnap) { - for (BlockWrapper[] firstSnapString : firstSnapSlice) { - for (final BlockWrapper block : firstSnapString) { - if (block.getI() != block.getNativeBlock().getTypeId()) { - undo.put(block.getNativeBlock()); - } - } - } - } - - v.owner().storeUndo(undo); - } - - @Override - protected final void arrow(final SnipeData v) { - this.bsize = v.getBrushSize(); - - this.snap = new BlockWrapper[0][0][0]; - - this.erodeFace = this.generator.nextInt(5) + 1; - this.fillFace = this.generator.nextInt(3) + 3; - this.erodeRecursion = this.generator.nextInt(3); - this.fillRecursion = this.generator.nextInt(3); - - if (this.fillRecursion == 0 && this.erodeRecursion == 0) { // if they are both zero, it will lead to a null pointer exception. Still want to give them a - // chance to be zero though, for more interestingness -Gav - this.erodeRecursion = this.generator.nextInt(2) + 1; - this.fillRecursion = this.generator.nextInt(2) + 1; - } - - this.rerosion(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.bsize = v.getBrushSize(); - - this.snap = new BlockWrapper[0][0][0]; - - this.erodeFace = this.generator.nextInt(3) + 3; - this.fillFace = this.generator.nextInt(5) + 1; - this.erodeRecursion = this.generator.nextInt(3); - this.fillRecursion = this.generator.nextInt(3); - if (this.fillRecursion == 0 && this.erodeRecursion == 0) { // if they are both zero, it will lead to a null pointer exception. Still want to give them a - // chance to be zero though, for more interestingness -Gav - this.erodeRecursion = this.generator.nextInt(2) + 1; - this.fillRecursion = this.generator.nextInt(2) + 1; - } - - this.rfilling(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.randomerode"; - } - - private class BlockWrapper { - private boolean solid; - private AsyncBlock nativeBlock; - private int id; - private int i; - - public BlockWrapper(final AsyncBlock bl) { - this.setNativeBlock(bl); - this.setI(bl.getTypeId()); - switch (bl.getType()) { - case AIR: - case WATER: - case LAVA: - this.setSolid(false); - break; - default: - this.setSolid(true); - } - } - - public boolean isSolid() { - return solid; - } - - public void setSolid(boolean solid) { - this.solid = solid; - } - - public AsyncBlock getNativeBlock() { - return nativeBlock; - } - - public void setNativeBlock(AsyncBlock nativeBlock) { - this.nativeBlock = nativeBlock; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public int getI() { - return i; - } - - public void setI(int i) { - this.i = i; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RegenerateChunkBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RegenerateChunkBrush.java deleted file mode 100644 index 4653caee2..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RegenerateChunkBrush.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.Chunk; - -/** - * Regenerates the target chunk. - * - * @author Mick - */ -public class RegenerateChunkBrush extends Brush { - - public RegenerateChunkBrush() { - this.setName("Chunk Generator 40k"); - } - - private void generateChunk(final SnipeData v) { - final Chunk chunk = this.getTargetBlock().getChunk(); - final Undo undo = new Undo(); - - for (int z = CHUNK_SIZE; z >= 0; z--) { - for (int x = CHUNK_SIZE; x >= 0; x--) { - for (int y = this.getWorld().getMaxHeight(); y >= 0; y--) { - undo.put(chunk.getBlock(x, y, z)); - } - } - } - v.owner().storeUndo(undo); - - v.sendMessage("Generate that chunk! " + chunk.getX() + " " + chunk.getZ()); - this.getWorld().regenerateChunk(chunk.getX(), chunk.getZ()); - this.getWorld().refreshChunk(chunk.getX(), chunk.getZ()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.generateChunk(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.generateChunk(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.brushMessage("Tread lightly."); - vm.brushMessage("This brush will melt your spleen and sell your kidneys."); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.regeneratechunk"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java deleted file mode 100644 index c0c5ff7b9..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; - - -public class RingBrush extends PerformBrush { - private double trueCircle; - private double innerSize; - - public RingBrush() { - this.setName("Ring"); - } - - private void ring(SnipeData v, AsyncBlock targetBlock) { - final int brushSize = v.getBrushSize(); - final double outerSquared = Math.pow(brushSize + this.trueCircle, 2); - final double innerSquared = Math.pow(this.innerSize, 2); - - for (int x = brushSize; x >= 0; x--) { - final double xSquared = Math.pow(x, 2); - for (int z = brushSize; z >= 0; z--) { - final double ySquared = Math.pow(z, 2); - if (xSquared + ySquared <= outerSquared && xSquared + ySquared >= innerSquared) { - current.perform(targetBlock.getRelative(x, 0, z)); - current.perform(targetBlock.getRelative(x, 0, -z)); - current.perform(targetBlock.getRelative(-x, 0, z)); - current.perform(targetBlock.getRelative(-x, 0, -z)); - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(SnipeData v) { - this.ring(v, this.getTargetBlock()); - } - - @Override - protected final void powder(SnipeData v) { - this.ring(v, this.getLastBlock()); - } - - @Override - public final void info(Message vm) { - vm.brushName(this.getName()); - vm.size(); - vm.custom(ChatColor.AQUA + "The inner radius is " + ChatColor.RED + this.innerSize); - } - - @Override - public final void parameters(String[] par, SnipeData v) { - for (int i = 1; i < par.length; i++) { - if (par[i].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Ring Brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b ri true -- will use a true circle algorithm instead of the skinnier version with classic sniper nubs. /b ri false will switch back. (false is default)"); - v.sendMessage(ChatColor.AQUA + "/b ri ir2.5 -- will set the inner radius to 2.5 units"); - return; - } else if (par[i].startsWith("true")) { - this.trueCircle = 0.5; - v.sendMessage(ChatColor.AQUA + "True circle mode ON."); - } else if (par[i].startsWith("false")) { - this.trueCircle = 0; - v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); - } else if (par[i].startsWith("ir")) { - try { - this.innerSize = Double.parseDouble(par[i].replace("ir", "")); - v.sendMessage(ChatColor.AQUA + "The inner radius has been set to " + ChatColor.RED + this.innerSize); - } catch (Exception exception) { - v.sendMessage(ChatColor.RED + "The parameters included are invalid."); - } - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.ring"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DBrush.java deleted file mode 100644 index 187f75e09..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DBrush.java +++ /dev/null @@ -1,171 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.util.BlockWrapper; -import org.bukkit.ChatColor; - - -public class Rot2DBrush extends Brush { - private int mode = 0; - private int bSize; - private int brushSize; - private BlockWrapper[][][] snap; - private double se; - - public Rot2DBrush() { - this.setName("2D Rotation"); - } - - @SuppressWarnings("deprecation") - private void getMatrix() { - this.brushSize = (this.bSize * 2) + 1; - - this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize]; - - final double brushSizeSquared = Math.pow(this.bSize + 0.5, 2); - int sx = this.getTargetBlock().getX() - this.bSize; - int sy = this.getTargetBlock().getY() - this.bSize; - int sz = this.getTargetBlock().getZ() - this.bSize; - - for (int x = 0; x < this.snap.length; x++) { - sz = this.getTargetBlock().getZ() - this.bSize; - final double xSquared = Math.pow(x - this.bSize, 2); - for (int y = 0; y < this.snap.length; y++) { - sy = this.getTargetBlock().getY() - this.bSize; - if (xSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared) { - for (int z = 0; z < this.snap.length; z++) { - final AsyncBlock block = this.clampY(sx, sy, sz); // why is this not sx + x, sy + y sz + z? - this.snap[x][z][y] = new BlockWrapper(block); - block.setTypeId(BlockTypes.AIR.getInternalId()); - sy++; - } - } - sz++; - } - sx++; - } - } - - private void rotate(final SnipeData v) { - final double brushSiyeSquared = Math.pow(this.bSize + 0.5, 2); - final double cos = Math.cos(this.se); - final double sin = Math.sin(this.se); - final boolean[][] doNotFill = new boolean[this.snap.length][this.snap.length]; - // I put y in the inside loop, since it doesn't have any power functions, should be much faster. - // Also, new array keeps track of which x and z coords are being assigned in the rotated space so that we can - // do a targeted filling of only those columns later that were left out. - - for (int x = 0; x < this.snap.length; x++) { - final int xx = x - this.bSize; - final double xSquared = Math.pow(xx, 2); - - for (int y = 0; y < this.snap.length; y++) { - final int zz = y - this.bSize; - - if (xSquared + Math.pow(zz, 2) <= brushSiyeSquared) { - final double newX = (xx * cos) - (zz * sin); - final double newZ = (xx * sin) + (zz * cos); - - doNotFill[(int) newX + this.bSize][(int) newZ + this.bSize] = true; - - for (int currentY = 0; currentY < this.snap.length; currentY++) { - final int yy = currentY - this.bSize; - final BlockWrapper block = this.snap[x][currentY][y]; - - if (BlockTypes.get(block.getId()).getMaterial().isAir()) { - continue; - } - this.setBlockIdAndDataAt(this.getTargetBlock().getX() + (int) newX, this.getTargetBlock().getY() + yy, this.getTargetBlock().getZ() + (int) newZ, block.getId(), block.getPropertyId()); - } - } - } - } - for (int x = 0; x < this.snap.length; x++) { - final double xSquared = Math.pow(x - this.bSize, 2); - final int fx = x + this.getTargetBlock().getX() - this.bSize; - - for (int z = 0; z < this.snap.length; z++) { - if (xSquared + Math.pow(z - this.bSize, 2) <= brushSiyeSquared) { - final int fz = z + this.getTargetBlock().getZ() - this.bSize; - - if (!doNotFill[x][z]) { - // smart fill stuff - - for (int y = 0; y < this.snap.length; y++) { - final int fy = y + this.getTargetBlock().getY() - this.bSize; - - final int a = this.getBlockIdAt(fx + 1, fy, fz); - final int aData = this.getBlockDataAt(fx + 1, fy, fz); - final int d = this.getBlockIdAt(fx - 1, fy, fz); - final int dData = this.getBlockDataAt(fx - 1, fy, fz); - final int c = this.getBlockIdAt(fx, fy, fz + 1); - final int b = this.getBlockIdAt(fx, fy, fz - 1); - final int bData = this.getBlockDataAt(fx, fy, fz - 1); - - int winner; - int winnerData; - - if (a == b || a == c || a == d) { // I figure that since we are already narrowing it down to ONLY the holes left behind, it - // should - // be fine to do all 5 checks needed to be legit about it. - winner = a; - winnerData = aData; - } else if (b == d || c == d) { - winner = d; - winnerData = dData; - } else { - winner = b; // blockPositionY making this default, it will also automatically cover situations where B = C; - winnerData = bData; - } - - this.setBlockIdAndDataAt(fx, fy, fz, winner, winnerData); - } - } - } - } - } - } - - @Override - protected final void arrow(final SnipeData v) { - this.bSize = v.getBrushSize(); - - if (this.mode == 0) { - this.getMatrix(); - this.rotate(v); - } else { - v.sendMessage(ChatColor.RED + "Something went wrong."); - } - } - - @Override - protected final void powder(final SnipeData v) { - this.bSize = v.getBrushSize(); - - if (this.mode == 0) { - this.getMatrix(); - this.rotate(v); - } else { - v.sendMessage(ChatColor.RED + "Something went wrong."); - } - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - this.se = Math.toRadians(Double.parseDouble(par[1])); - v.sendMessage(ChatColor.GREEN + "Angle set to " + this.se); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.rot2d"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DvertBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DvertBrush.java deleted file mode 100644 index ad0944e31..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DvertBrush.java +++ /dev/null @@ -1,174 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.util.BlockWrapper; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; - -// The X Y and Z variable names in this file do NOT MAKE ANY SENSE. Do not attempt to actually figure out what on earth is going on here. Just go to the -// original 2d horizontal brush if you wish to make anything similar to this, and start there. I didn't bother renaming everything. -public class Rot2DvertBrush extends Brush { - private int mode = 0; - private int bSize; - private BlockWrapper[][][] snap; - private double se; - - public Rot2DvertBrush() { - this.setName("2D Rotation"); - } - - @SuppressWarnings("deprecation") - private void getMatrix() { - int brushSize = (this.bSize * 2) + 1; - - this.snap = new BlockWrapper[brushSize][brushSize][brushSize]; - - int sx = this.getTargetBlock().getX() - this.bSize; - - for (int x = 0; x < this.snap.length; x++) { - int sz = this.getTargetBlock().getZ() - this.bSize; - - for (int z = 0; z < this.snap.length; z++) { - int sy = this.getTargetBlock().getY() - this.bSize; - - for (int y = 0; y < this.snap.length; y++) { - final AsyncBlock block = this.clampY(sx, sy, sz); // why is this not sx + x, sy + y sz + z? - this.snap[x][y][z] = new BlockWrapper(block); - block.setTypeId(BlockTypes.AIR.getInternalId()); - sy++; - } - - sz++; - } - sx++; - } - } - - private void rotate() { - final double brushSizeSquared = Math.pow(this.bSize + 0.5, 2); - final double cos = Math.cos(this.se); - final double sin = Math.sin(this.se); - final boolean[][] doNotFill = new boolean[this.snap.length][this.snap.length]; - // I put y in the inside loop, since it doesn't have any power functions, should be much faster. - // Also, new array keeps track of which x and z coords are being assigned in the rotated space so that we can - // do a targeted filling of only those columns later that were left out. - - for (int x = 0; x < this.snap.length; x++) { - final int xx = x - this.bSize; - final double xSquared = Math.pow(xx, 2); - - for (int z = 0; z < this.snap.length; z++) { - final int zz = z - this.bSize; - - if (xSquared + Math.pow(zz, 2) <= brushSizeSquared) { - final double newX = (xx * cos) - (zz * sin); - final double newZ = (xx * sin) + (zz * cos); - - doNotFill[(int) newX + this.bSize][(int) newZ + this.bSize] = true; - - for (int y = 0; y < this.snap.length; y++) { - final int yy = y - this.bSize; - - final BlockWrapper block = this.snap[y][x][z]; - if (BlockTypes.get(block.getId()).getMaterial().isAir()) { - continue; - } - this.setBlockIdAndDataAt(this.getTargetBlock().getX() + yy, this.getTargetBlock().getY() + (int) newX, this.getTargetBlock().getZ() + (int) newZ, block.getId(), block.getPropertyId()); - } - } - } - } - - for (int x = 0; x < this.snap.length; x++) { - final double xSquared = Math.pow(x - this.bSize, 2); - final int fx = x + this.getTargetBlock().getX() - this.bSize; - - for (int z = 0; z < this.snap.length; z++) { - if (xSquared + Math.pow(z - this.bSize, 2) <= brushSizeSquared) { - final int fz = z + this.getTargetBlock().getZ() - this.bSize; - - if (!doNotFill[x][z]) { - // smart fill stuff - for (int y = 0; y < this.snap.length; y++) { - final int fy = y + this.getTargetBlock().getY() - this.bSize; - - final int a = this.getBlockIdAt(fy, fx + 1, fz); - final int aData = this.getBlockDataAt(fy, fx + 1, fz); - final int d = this.getBlockIdAt(fy, fx - 1, fz); - final int dData = this.getBlockDataAt(fy, fx - 1, fz); - final int c = this.getBlockIdAt(fy, fx, fz + 1); - final int b = this.getBlockIdAt(fy, fx, fz - 1); - final int bData = this.getBlockDataAt(fy, fx, fz - 1); - - int winner; - int winnerData; - - if (a == b || a == c || a == d) { // I figure that since we are already narrowing it down to ONLY the holes left behind, it - // should - // be fine to do all 5 checks needed to be legit about it. - winner = a; - winnerData = aData; - } else if (b == d || c == d) { - winner = d; - winnerData = dData; - } else { - winner = b; // blockPositionY making this default, it will also automatically cover situations where B = C; - winnerData = bData; - } - - this.setBlockIdAndDataAt(fy, fx, fz, winner, winnerData); - } - } - } - } - } - } - - @Override - protected final void arrow(final SnipeData v) { - this.bSize = v.getBrushSize(); - - if (this.mode == 0) { - this.getMatrix(); - this.rotate(); - } else { - v.owner().getPlayer().sendMessage(ChatColor.RED + "Something went wrong."); - } - } - - @Override - protected final void powder(final SnipeData v) { - this.bSize = v.getBrushSize(); - - if (this.mode == 0) { - this.getMatrix(); - this.rotate(); - } else { - v.owner().getPlayer().sendMessage(ChatColor.RED + "Something went wrong."); - } - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - try { - this.se = Math.toRadians(Double.parseDouble(par[1])); - v.sendMessage(ChatColor.GREEN + "Angle set to " + this.se); - } catch (Exception _ex) { - v.sendMessage("Exception while parsing parameter: " + par[1]); - Bukkit.getLogger().severe(_ex.getMessage()); - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.rot2dvert"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot3DBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot3DBrush.java deleted file mode 100644 index 651401d7b..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot3DBrush.java +++ /dev/null @@ -1,231 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import com.thevoxelbox.voxelsniper.util.BlockWrapper; -import org.bukkit.ChatColor; - -public class Rot3DBrush extends Brush { - private final int mode = 0; - private int bSize; - private int brushSize; - private BlockWrapper[][][] snap; - private double seYaw; - private double sePitch; - private double seRoll; - - public Rot3DBrush() { - this.setName("3D Rotation"); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.brushMessage("Rotates Yaw (XZ), then Pitch(XY), then Roll(ZY), in order."); - } - - // after all rotations, compare snapshot to new state of world, and store changed blocks to undo? - // --> agreed. Do what erode does and store one snapshot with Block pointers and int id of what the block started with, afterwards simply go thru that - // matrix and compare Block.getId with 'id' if different undo.add( new BlockWrapper ( Block, oldId ) ) - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - // which way is clockwise is less obvious for roll and pitch... should probably fix that / make it clear - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Rotate brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "p[0-359] -- set degrees of pitch rotation (rotation about the Z axis)."); - v.sendMessage(ChatColor.BLUE + "r[0-359] -- set degrees of roll rotation (rotation about the X axis)."); - v.sendMessage(ChatColor.LIGHT_PURPLE + "y[0-359] -- set degrees of yaw rotation (Rotation about the Y axis)."); - - return; - } else if (parameter.startsWith("p")) { - this.sePitch = Math.toRadians(Double.parseDouble(parameter.replace("p", ""))); - v.sendMessage(ChatColor.AQUA + "Around Z-axis degrees set to " + this.sePitch); - if (this.sePitch < 0 || this.sePitch > 359) { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Angles must be from 1-359"); - } - } else if (parameter.startsWith("r")) { - this.seRoll = Math.toRadians(Double.parseDouble(parameter.replace("r", ""))); - v.sendMessage(ChatColor.AQUA + "Around X-axis degrees set to " + this.seRoll); - if (this.seRoll < 0 || this.seRoll > 359) { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Angles must be from 1-359"); - } - } else if (parameter.startsWith("y")) { - this.seYaw = Math.toRadians(Double.parseDouble(parameter.replace("y", ""))); - v.sendMessage(ChatColor.AQUA + "Around Y-axis degrees set to " + this.seYaw); - if (this.seYaw < 0 || this.seYaw > 359) { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Angles must be from 1-359"); - } - } - } - } - - @SuppressWarnings("deprecation") - private void getMatrix() { // only need to do once. But y needs to change + sphere - final double brushSizeSquared = Math.pow(this.bSize + 0.5, 2); - this.brushSize = (this.bSize * 2) + 1; - - this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize]; - - int sx = this.getTargetBlock().getX() - this.bSize; - //int sy = this.getTargetBlock().getY() - this.bSize; Not used - int sz = this.getTargetBlock().getZ() - this.bSize; - - for (int x = 0; x < this.snap.length; x++) { - final double xSquared = Math.pow(x - this.bSize, 2); - sz = this.getTargetBlock().getZ() - this.bSize; - - for (int z = 0; z < this.snap.length; z++) { - final double zSquared = Math.pow(z - this.bSize, 2); - sz = this.getTargetBlock().getY() - this.bSize; - - for (int y = 0; y < this.snap.length; y++) { - if (xSquared + zSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared) { - final AsyncBlock block = this.clampY(sx, sz, sz); - this.snap[x][y][z] = new BlockWrapper(block); - block.setTypeId(BlockTypes.AIR.getInternalId()); - sz++; - } - } - - sz++; - } - sx++; - } - - } - - 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 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 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. - final double brushSizeSquared = Math.pow(this.bSize + 0.5, 2); - final double cosYaw = Math.cos(this.seYaw); - final double sinYaw = Math.sin(this.seYaw); - final double cosPitch = Math.cos(this.sePitch); - final double sinPitch = Math.sin(this.sePitch); - final double cosRoll = Math.cos(this.seRoll); - final double sinRoll = Math.sin(this.seRoll); - final boolean[][][] doNotFill = new boolean[this.snap.length][this.snap.length][this.snap.length]; - final Undo undo = new Undo(); - - for (int x = 0; x < this.snap.length; x++) { - final int xx = x - this.bSize; - final double xSquared = Math.pow(xx, 2); - - for (int z = 0; z < this.snap.length; z++) { - final int zz = z - this.bSize; - final double zSquared = Math.pow(zz, 2); - final double newxzX = (xx * cosYaw) - (zz * sinYaw); - final double newxzZ = (xx * sinYaw) + (zz * cosYaw); - - for (int y = 0; y < this.snap.length; y++) { - final int yy = y - this.bSize; - if (xSquared + zSquared + Math.pow(yy, 2) <= brushSizeSquared) { - undo.put(this.clampY(this.getTargetBlock().getX() + xx, this.getTargetBlock().getY() + yy, this.getTargetBlock().getZ() + zz)); // just store - // whole sphere in undo, too complicated otherwise, since this brush both adds and remos things unpredictably. - - final double newxyX = (newxzX * cosPitch) - (yy * sinPitch); - final double newxyY = (newxzX * sinPitch) + (yy * cosPitch); // calculates all three in succession in precise math space - final double newyzY = (newxyY * cosRoll) - (newxzZ * sinRoll); - final double newyzZ = (newxyY * sinRoll) + (newxzZ * cosRoll); - - doNotFill[(int) newxyX + this.bSize][(int) newyzY + this.bSize][(int) newyzZ + this.bSize] = true; // only rounds off to nearest - // block - // after all three, though. - - final BlockWrapper block = this.snap[x][y][z]; - if (BlockTypes.get(block.getId()).getMaterial().isAir()) { - continue; - } - this.setBlockIdAndDataAt(this.getTargetBlock().getX() + (int) newxyX, this.getTargetBlock().getY() + (int) newyzY, this.getTargetBlock().getZ() + (int) newyzZ, block.getId(), block.getPropertyId()); - } - } - } - } - - for (int x = 0; x < this.snap.length; x++) { - final double xSquared = Math.pow(x - this.bSize, 2); - final int fx = x + this.getTargetBlock().getX() - this.bSize; - - for (int z = 0; z < this.snap.length; z++) { - final double zSquared = Math.pow(z - this.bSize, 2); - final int fz = z + this.getTargetBlock().getZ() - this.bSize; - - for (int y = 0; y < this.snap.length; y++) { - if (xSquared + zSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared) { - if (!doNotFill[x][y][z]) { - // smart fill stuff - final int fy = y + this.getTargetBlock().getY() - this.bSize; - final int a = this.getBlockIdAt(fx + 1, fy, fz); - final int aData = this.getBlockDataAt(fx + 1, fy, fz); - final int d = this.getBlockIdAt(fx - 1, fy, fz); - final int dData = this.getBlockDataAt(fx - 1, fy, fz); - final int c = this.getBlockIdAt(fx, fy, fz + 1); - final int b = this.getBlockIdAt(fx, fy, fz - 1); - final int bData = this.getBlockDataAt(fx, fy, fz - 1); - - int winner; - int winnerData; - - if (a == b || a == c || a == d) { // I figure that since we are already narrowing it down to ONLY the holes left behind, it - // should - // be fine to do all 5 checks needed to be legit about it. - winner = a; - winnerData = aData; - } else if (b == d || c == d) { - winner = d; - winnerData = dData; - } else { - winner = b; // blockPositionY making this default, it will also automatically cover situations where B = C; - winnerData = bData; - } - - this.setBlockIdAndDataAt(fx, fy, fz, winner, winnerData); - } - } - } - } - } - v.owner().storeUndo(undo); - } - - @Override - protected final void arrow(final SnipeData v) { - this.bSize = v.getBrushSize(); - - if (this.mode == 0) { - this.getMatrix(); - this.rotate(v); - } else { - v.owner().getPlayer().sendMessage(ChatColor.RED + "Something went wrong."); - } - } - - @Override - protected final void powder(final SnipeData v) { - this.bSize = v.getBrushSize(); - - if (this.mode == 0) { - this.getMatrix(); - this.rotate(v); - } else { - v.owner().getPlayer().sendMessage(ChatColor.RED + "Something went wrong."); - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.rot3d"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RulerBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RulerBrush.java deleted file mode 100644 index ce89391d6..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RulerBrush.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.util.Vector; - -public class RulerBrush extends Brush { - private boolean first = true; - private Vector coords = new Vector(0, 0, 0); - - private int xOff = 0; - private int yOff = 0; - private int zOff = 0; - - public RulerBrush() { - this.setName("Ruler"); - } - - @Override - protected final void arrow(final SnipeData v) { - final int voxelMaterialId = v.getVoxelId(); - this.coords = this.getTargetBlock().getLocation().toVector(); - - if (this.xOff == 0 && this.yOff == 0 && this.zOff == 0) { - v.sendMessage(ChatColor.DARK_PURPLE + "First point selected."); - this.first = !this.first; - } else { - final Undo undo = new Undo(); - - undo.put(this.clampY(this.getTargetBlock().getX() + this.xOff, this.getTargetBlock().getY() + this.yOff, this.getTargetBlock().getZ() + this.zOff)); - this.setBlockIdAt(this.getTargetBlock().getZ() + this.zOff, this.getTargetBlock().getX() + this.xOff, this.getTargetBlock().getY() + this.yOff, voxelMaterialId); - v.owner().storeUndo(undo); - } - } - - @Override - protected final void powder(final SnipeData v) { - if (this.coords == null || this.coords.lengthSquared() == 0) { - v.sendMessage(ChatColor.RED + "Warning: You did not select a first coordinate with the arrow. Comparing to point 0,0,0 instead."); - return; - } - - v.sendMessage(ChatColor.BLUE + "Format = (second coord - first coord)"); - v.sendMessage(ChatColor.AQUA + "X change: " + (this.getTargetBlock().getX() - this.coords.getX())); - v.sendMessage(ChatColor.AQUA + "Y change: " + (this.getTargetBlock().getY() - this.coords.getY())); - v.sendMessage(ChatColor.AQUA + "Z change: " + (this.getTargetBlock().getZ() - this.coords.getZ())); - final double distance = (double) (Math.round(this.getTargetBlock().getLocation().toVector().subtract(this.coords).length() * 100) / 100); - final double blockDistance = (double) (Math.round((Math.abs(Math.max(Math.max(Math.abs(this.getTargetBlock().getX() - coords.getX()), Math.abs(this.getTargetBlock().getY() - this.coords.getY())), Math.abs(this.getTargetBlock().getZ() - this.coords.getZ()))) + 1) * 100) / 100); - - v.sendMessage(ChatColor.AQUA + "Euclidean distance = " + distance); - v.sendMessage(ChatColor.AQUA + "Block distance = " + blockDistance); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.voxel(); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Ruler Brush instructions: Right click first point with the arrow. Right click with powder for distances from that block (can repeat without getting a new first block.) For placing blocks, use arrow and input the desired coordinates with parameters."); - v.sendMessage(ChatColor.LIGHT_PURPLE + "/b r x[x value] y[y value] z[z value] -- Will place blocks one at a time of the type you have set with /v at the location you click + this many units away. If you don't include a value, it will be zero. Don't include ANY values, and the brush will just measure distance."); - v.sendMessage(ChatColor.BLUE + "/b r ruler -- will reset the tool to just measure distances, not layout blocks."); - - return; - } else if (parameter.startsWith("x")) { - this.xOff = Integer.parseInt(parameter.replace("x", "")); - v.sendMessage(ChatColor.AQUA + "X offset set to " + this.xOff); - } else if (parameter.startsWith("y")) { - this.yOff = Integer.parseInt(parameter.replace("y", "")); - v.sendMessage(ChatColor.AQUA + "Y offset set to " + this.yOff); - } else if (parameter.startsWith("z")) { - this.zOff = Integer.parseInt(parameter.replace("z", "")); - v.sendMessage(ChatColor.AQUA + "Z offset set to " + this.zOff); - } else if (parameter.startsWith("ruler")) { - this.zOff = 0; - this.yOff = 0; - this.xOff = 0; - v.sendMessage(ChatColor.BLUE + "Ruler mode."); - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.ruler"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java deleted file mode 100644 index 4920a10d3..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.block.BlockFace; - -public class ScannerBrush extends Brush { - - private static final int DEPTH_MIN = 1; - private static final int DEPTH_DEFAULT = 24; - private static final int DEPTH_MAX = 64; - - private int depth = DEPTH_DEFAULT; - private Material checkFor = Material.AIR; - - public ScannerBrush() { - this.setName("Scanner"); - } - - private int clamp(int value, int min, int max) { - if (value < min) { - return min; - } else { - return Math.min(value, max); - } - } - - private void scan(SnipeData v, BlockFace bf) { - if (bf == null) { - return; - } - - switch (bf) { - case NORTH: - // Scan south - for (int i = 1; i < this.depth + 1; i++) { - if (this.clampY(this.getTargetBlock().getX() + i, this.getTargetBlock().getY(), - this.getTargetBlock().getZ()).getType() == this.checkFor) { - v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i - + " blocks."); - return; - } - } - v.sendMessage(ChatColor.GRAY + "Nope."); - break; - - case SOUTH: - // Scan north - for (int i = 1; i < this.depth + 1; i++) { - if (this.clampY(this.getTargetBlock().getX() - i, this.getTargetBlock().getY(), - this.getTargetBlock().getZ()).getType() == this.checkFor) { - v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i - + " blocks."); - return; - } - } - v.sendMessage(ChatColor.GRAY + "Nope."); - break; - - case EAST: - // Scan west - for (int i = 1; i < this.depth + 1; i++) { - if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), - this.getTargetBlock().getZ() + i).getType() == this.checkFor) { - v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i - + " blocks."); - return; - } - } - v.sendMessage(ChatColor.GRAY + "Nope."); - break; - - case WEST: - // Scan east - for (int i = 1; i < this.depth + 1; i++) { - if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), - this.getTargetBlock().getZ() - i).getType() == this.checkFor) { - v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i - + " blocks."); - return; - } - } - v.sendMessage(ChatColor.GRAY + "Nope."); - break; - - case UP: - // Scan down - for (int i = 1; i < this.depth + 1; i++) { - if (this.getTargetBlock().getY() - i <= 0) { - break; - } - if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() - i, - this.getTargetBlock().getZ()).getType() == this.checkFor) { - v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i - + " blocks."); - return; - } - } - v.sendMessage(ChatColor.GRAY + "Nope."); - break; - - case DOWN: - // Scan up - for (int i = 1; i < this.depth + 1; i++) { - if (this.getTargetBlock().getY() + i >= v.getWorld().getMaxHeight()) { - break; - } - if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() + i, - this.getTargetBlock().getZ()).getType() == this.checkFor) { - v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i - + " blocks."); - return; - } - } - v.sendMessage(ChatColor.GRAY + "Nope."); - break; - - default: - break; - } - } - - @SuppressWarnings("deprecation") - @Override - protected final void arrow(SnipeData v) { - this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId())); - this.scan(v, this.getTargetBlock().getFace(this.getLastBlock())); - } - - @SuppressWarnings("deprecation") - @Override - protected final void powder(SnipeData v) { - this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId())); - this.scan(v, this.getTargetBlock().getFace(this.getLastBlock())); - } - - @Override - public final void info(Message vm) { - vm.brushName(this.getName()); - vm.custom(ChatColor.GREEN + "Scanner depth set to " + this.depth); - vm.custom(ChatColor.GREEN + "Scanner scans for " + this.checkFor + " (change with /v #)"); - } - - @Override - public final void parameters(String[] par, SnipeData v) { - for (int i = 1; i < par.length; i++) { - if (par[i].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Scanner brush Parameters:"); - v.sendMessage(ChatColor.AQUA - + "/b sc d# -- will set the search depth to #. Clamps to 1 - 64."); - return; - } - if (par[i].startsWith("d")) { - this.depth = this - .clamp(Integer.parseInt(par[i].substring(1)), DEPTH_MIN, DEPTH_MAX); - v.sendMessage(ChatColor.AQUA + "Scanner depth set to " + this.depth); - } else { - v.sendMessage(ChatColor.RED - + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.scanner"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetBrush.java deleted file mode 100644 index 144901b57..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetBrush.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; - - -public class SetBrush extends PerformBrush { - private static final int SELECTION_SIZE_MAX = 5000000; - private Block block = null; - - public SetBrush() { - this.setName("Set"); - } - - private boolean set(final Block bl, final SnipeData v) { - if (this.block == null) { - this.block = bl; - return true; - } else { - if (!this.block.getWorld().getName().equals(bl.getWorld().getName())) { - v.sendMessage(ChatColor.RED + "You selected points in different worlds!"); - this.block = null; - return true; - } - final int lowX = Math.min(this.block.getX(), bl.getX()); - final int lowY = Math.min(this.block.getY(), bl.getY()); - final int lowZ = Math.min(this.block.getZ(), bl.getZ()); - final int highX = Math.max(this.block.getX(), bl.getX()); - final int highY = Math.max(this.block.getY(), bl.getY()); - final int highZ = Math.max(this.block.getZ(), bl.getZ()); - - if (Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY) > SELECTION_SIZE_MAX) { - v.sendMessage(ChatColor.RED + "Selection size above hardcoded limit of 5000000, please use a smaller selection."); - } else { - for (int y = lowY; y <= highY; y++) { - for (int x = lowX; x <= highX; x++) { - for (int z = lowZ; z <= highZ; z++) { - this.current.perform(this.clampY(x, y, z)); - } - } - } - } - - this.block = null; - return false; - } - } - - @Override - protected final void arrow(final SnipeData v) { - if (this.set(this.getTargetBlock(), v)) { - v.sendMessage(ChatColor.GRAY + "Point one"); - } else { - v.owner().storeUndo(this.current.getUndo()); - } - } - - @Override - protected final void powder(final SnipeData v) { - if (this.set(this.getLastBlock(), v)) { - v.sendMessage(ChatColor.GRAY + "Point one"); - } else { - v.owner().storeUndo(this.current.getUndo()); - } - } - - @Override - public final void info(final Message vm) { - this.block = null; - vm.brushName(this.getName()); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - super.parameters(par, v); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.set"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneFlipBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneFlipBrush.java deleted file mode 100644 index 7c5cd07f3..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneFlipBrush.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.block.Block; - - -public class SetRedstoneFlipBrush extends Brush { - private Block block = null; - private Undo undo; - private boolean northSouth = true; - - public SetRedstoneFlipBrush() { - this.setName("Set Redstone Flip"); - } - - private boolean set(final Block bl) { - if (this.block == null) { - this.block = bl; - return true; - } else { - this.undo = new Undo(); - final int lowX = Math.min(this.block.getX(), bl.getX()); - final int lowY = Math.min(this.block.getY(), bl.getY()); - final int lowZ = Math.min(this.block.getZ(), bl.getZ()); - final int highX = Math.max(this.block.getX(), bl.getX()); - final int highY = Math.max(this.block.getY(), bl.getY()); - final int highZ = Math.max(this.block.getZ(), bl.getZ()); - - for (int y = lowY; y <= highY; y++) { - for (int x = lowX; x <= highX; x++) { - for (int z = lowZ; z <= highZ; z++) { - this.perform(this.clampY(x, y, z)); - } - } - } - this.block = null; - return false; - } - } - - @SuppressWarnings("deprecation") - private void perform(final AsyncBlock bl) { - if (bl.getType() == Material.REPEATER) { - if (this.northSouth) { - if ((bl.getPropertyId() % 4) == 1) { - this.undo.put(bl); - bl.setPropertyId((bl.getPropertyId() + 2)); - } else if ((bl.getPropertyId() % 4) == 3) { - this.undo.put(bl); - bl.setPropertyId((bl.getPropertyId() - 2)); - } - } else { - if ((bl.getPropertyId() % 4) == 2) { - this.undo.put(bl); - bl.setPropertyId((bl.getPropertyId() - 2)); - } else if ((bl.getPropertyId() % 4) == 0) { - this.undo.put(bl); - bl.setPropertyId((bl.getPropertyId() + 2)); - } - } - } - } - - @Override - protected final void arrow(final SnipeData v) { - if (this.set(this.getTargetBlock())) { - v.sendMessage(ChatColor.GRAY + "Point one"); - } else { - v.owner().storeUndo(this.undo); - } - } - - @Override - protected final void powder(final SnipeData v) { - if (this.set(this.getLastBlock())) { - v.sendMessage(ChatColor.GRAY + "Point one"); - } else { - v.owner().storeUndo(this.undo); - } - } - - @Override - public final void info(final Message vm) { - this.block = null; - vm.brushName(this.getName()); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - if (par[i].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Set Repeater Flip Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b setrf -- valid direction inputs are(n,s,e,world), Set the direction that you wish to flip your repeaters, defaults to north/south."); - return; - } - if (par[i].startsWith("n") || par[i].startsWith("s") || par[i].startsWith("ns")) { - this.northSouth = true; - v.sendMessage(ChatColor.AQUA + "Flip direction set to north/south"); - } else if (par[i].startsWith("e") || par[i].startsWith("world") || par[i].startsWith("ew")) { - this.northSouth = false; - v.sendMessage(ChatColor.AQUA + "Flip direction set to east/west."); - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.setredstoneflip"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneRotateBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneRotateBrush.java deleted file mode 100644 index f0ad155bc..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneRotateBrush.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.block.Block; - - -public class SetRedstoneRotateBrush extends Brush { - private Block block = null; - private Undo undo; - - public SetRedstoneRotateBrush() { - this.setName("Set Redstone Rotate"); - } - - private boolean set(final Block bl) { - if (this.block == null) { - this.block = bl; - return true; - } else { - this.undo = new Undo(); - final int lowX = Math.min(this.block.getX(), bl.getX()); - final int lowY = Math.min(this.block.getY(), bl.getY()); - final int lowZ = Math.min(this.block.getZ(), bl.getZ()); - final int highX = Math.max(this.block.getX(), bl.getX()); - final int highY = Math.max(this.block.getY(), bl.getY()); - final int highZ = Math.max(this.block.getZ(), bl.getZ()); - - for (int y = lowY; y <= highY; y++) { - for (int x = lowX; x <= highX; x++) { - for (int z = lowZ; z <= highZ; z++) { - this.perform(this.clampY(x, y, z)); - } - } - } - this.block = null; - return false; - } - } - - @SuppressWarnings("deprecation") - private void perform(final AsyncBlock bl) { - if (bl.getType() == Material.REPEATER) { - this.undo.put(bl); - bl.setPropertyId((((bl.getPropertyId() % 4) + 1 < 5) ? (bl.getPropertyId() + 1) : (bl.getPropertyId() - 4))); - } - } - - @Override - protected final void arrow(final SnipeData v) { - if (this.set(this.getTargetBlock())) { - v.owner().getPlayer().sendMessage(ChatColor.GRAY + "Point one"); - } else { - v.owner().storeUndo(this.undo); - } - } - - @Override - protected final void powder(final SnipeData v) { - if (this.set(this.getLastBlock())) { - v.owner().getPlayer().sendMessage(ChatColor.GRAY + "Point one"); - } else { - v.owner().storeUndo(this.undo); - } - } - - @Override - public final void info(final Message vm) { - this.block = null; - vm.brushName(this.getName()); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - super.parameters(par, v); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.setredstonerotate"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellBallBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellBallBrush.java deleted file mode 100644 index d3be7c2fc..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellBallBrush.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; - -/** - * THIS BRUSH SHOULD NOT USE PERFORMERS. - * - * @author Voxel - */ -public class ShellBallBrush extends Brush { - - public ShellBallBrush() { - this.setName("Shell Ball"); - } - - // parameters isn't an abstract method, gilt. You can just leave it out if there are none. - private void bShell(final SnipeData v, Block targetBlock) { - final int brushSize = v.getBrushSize(); - final int brushSizeDoubled = 2 * brushSize; - final int[][][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; // Array that holds the original materials plus a buffer - final int[][][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1]; // Array that holds the hollowed materials - - int blockPositionX = targetBlock.getX(); - int blockPositionY = targetBlock.getY(); - int blockPositionZ = targetBlock.getZ(); - // Log current materials into oldmats - for (int x = 0; x <= 2 * (brushSize + 1); x++) { - for (int y = 0; y <= 2 * (brushSize + 1); y++) { - for (int z = 0; z <= 2 * (brushSize + 1); z++) { - oldMaterials[x][y][z] = this.getBlockIdAt(blockPositionX - brushSize - 1 + x, blockPositionY - brushSize - 1 + y, blockPositionZ - brushSize - 1 + z); - } - } - } - - // Log current materials into newmats - for (int x = 0; x <= brushSizeDoubled; x++) { - for (int y = 0; y <= brushSizeDoubled; y++) { - System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0, - brushSizeDoubled + 1); - } - } - - int temp; - - // Hollow Brush Area - for (int x = 0; x <= brushSizeDoubled; x++) { - for (int y = 0; y <= brushSizeDoubled; y++) { - for (int z = 0; z <= brushSizeDoubled; z++) { - temp = 0; - - if (oldMaterials[x + 1 + 1][y + 1][z + 1] == v.getReplaceId()) { - temp++; - } - if (oldMaterials[x + 1 - 1][y + 1][z + 1] == v.getReplaceId()) { - temp++; - } - if (oldMaterials[x + 1][y + 1 + 1][z + 1] == v.getReplaceId()) { - temp++; - } - if (oldMaterials[x + 1][y + 1 - 1][z + 1] == v.getReplaceId()) { - temp++; - } - if (oldMaterials[x + 1][y + 1][z + 1 + 1] == v.getReplaceId()) { - temp++; - } - if (oldMaterials[x + 1][y + 1][z + 1 - 1] == v.getReplaceId()) { - temp++; - } - - if (temp == 0) { - newMaterials[x][y][z] = v.getVoxelId(); - } - } - } - } - - // Make the changes - final Undo undo = new Undo(); - final double rSquared = Math.pow(brushSize + 0.5, 2); - - for (int x = brushSizeDoubled; x >= 0; x--) { - final double xSquared = Math.pow(x - brushSize, 2); - - for (int y = 0; y <= 2 * brushSize; y++) { - final double ySquared = Math.pow(y - brushSize, 2); - - for (int z = 2 * brushSize; z >= 0; z--) { - if (xSquared + ySquared + Math.pow(z - brushSize, 2) <= rSquared) { - if (this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - brushSize + y, blockPositionZ - brushSize + z) != newMaterials[x][y][z]) { - undo.put(this.clampY(blockPositionX - brushSize + x, blockPositionY - brushSize + y, blockPositionZ - brushSize + z)); - } - this.setBlockIdAt(blockPositionZ - brushSize + z, blockPositionX - brushSize + x, blockPositionY - brushSize + y, newMaterials[x][y][z]); - } - } - } - } - v.owner().storeUndo(undo); - - // This is needed because most uses of this brush will not be sible to the sible sniper. - v.owner().getPlayer().sendMessage(ChatColor.AQUA + "Shell complete."); - } - - @Override - protected final void arrow(final SnipeData v) { - this.bShell(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.bShell(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - vm.voxel(); - vm.replace(); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.shellball"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellSetBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellSetBrush.java deleted file mode 100644 index 701840f7b..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellSetBrush.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; - -import java.util.ArrayList; - - -public class ShellSetBrush extends Brush { - private static final int MAX_SIZE = 5000000; - private Block block = null; - - public ShellSetBrush() { - this.setName("Shell Set"); - } - - @SuppressWarnings("deprecation") - private boolean set(final Block bl, final SnipeData v) { - if (this.block == null) { - this.block = bl; - return true; - } else { - if (!this.block.getWorld().getName().equals(bl.getWorld().getName())) { - v.sendMessage(ChatColor.RED + "You selected points in different worlds!"); - this.block = null; - return true; - } - - final int lowX = Math.min(this.block.getX(), bl.getX()); - final int lowY = Math.min(this.block.getY(), bl.getY()); - final int lowZ = Math.min(this.block.getZ(), bl.getZ()); - final int highX = Math.max(this.block.getX(), bl.getX()); - final int highY = Math.max(this.block.getY(), bl.getY()); - final int highZ = Math.max(this.block.getZ(), bl.getZ()); - - int selectionSize = Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY); - if (selectionSize > MAX_SIZE) { - v.sendMessage(ChatColor.RED + "Selection size above hardcoded limit of 5000000, please use a smaller selection."); - } else { - final ArrayList blocks = new ArrayList<>(selectionSize / 2); - for (int y = lowY; y <= highY; y++) { - for (int x = lowX; x <= highX; x++) { - for (int z = lowZ; z <= highZ; z++) { - if (this.getWorld().getBlockAt(x, y, z).getTypeId() == v.getReplaceId()) { - continue; - } else if (this.getWorld().getBlockAt(x + 1, y, z).getTypeId() == v.getReplaceId()) { - continue; - } else if (this.getWorld().getBlockAt(x - 1, y, z).getTypeId() == v.getReplaceId()) { - continue; - } else if (this.getWorld().getBlockAt(x, y, z + 1).getTypeId() == v.getReplaceId()) { - continue; - } else if (this.getWorld().getBlockAt(x, y, z - 1).getTypeId() == v.getReplaceId()) { - continue; - } else if (this.getWorld().getBlockAt(x, y + 1, z).getTypeId() == v.getReplaceId()) { - continue; - } else if (this.getWorld().getBlockAt(x, y - 1, z).getTypeId() == v.getReplaceId()) { - continue; - } else { - blocks.add(this.getWorld().getBlockAt(x, y, z)); - } - } - } - } - - final Undo undo = new Undo(); - for (final AsyncBlock currentBlock : blocks) { - if (currentBlock.getTypeId() != v.getVoxelId()) { - undo.put(currentBlock); - currentBlock.setTypeId(v.getVoxelId()); - } - } - v.owner().storeUndo(undo); - v.sendMessage(ChatColor.AQUA + "Shell complete."); - } - - this.block = null; - return false; - } - } - - @Override - protected final void arrow(final SnipeData v) { - if (this.set(this.getTargetBlock(), v)) { - v.owner().getPlayer().sendMessage(ChatColor.GRAY + "Point one"); - } - } - - @Override - protected final void powder(final SnipeData v) { - if (this.set(this.getLastBlock(), v)) { - v.owner().getPlayer().sendMessage(ChatColor.GRAY + "Point one"); - } - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - vm.voxel(); - vm.replace(); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.shellset"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellVoxelBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellVoxelBrush.java deleted file mode 100644 index 402280f5c..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellVoxelBrush.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; - -/** - * THIS BRUSH SHOULD NOT USE PERFORMERS. - * - * @author Voxel - */ -public class ShellVoxelBrush extends Brush { - - public ShellVoxelBrush() { - this.setName("Shell Voxel"); - } - - private void vShell(final SnipeData v, Block targetBlock) { - final int brushSize = v.getBrushSize(); - final int brushSizeSquared = 2 * brushSize; - final int[][][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; // Array that holds the original materials plus a buffer - final int[][][] newMaterials = new int[2 * brushSize + 1][2 * brushSize + 1][2 * brushSize + 1]; // Array that holds the hollowed materials - - int blockPositionX = targetBlock.getX(); - int blockPositionY = targetBlock.getY(); - int blockPositionZ = targetBlock.getZ(); - // Log current materials into oldmats - for (int x = 0; x <= 2 * (brushSize + 1); x++) { - for (int y = 0; y <= 2 * (brushSize + 1); y++) { - for (int z = 0; z <= 2 * (brushSize + 1); z++) { - oldMaterials[x][y][z] = this.getBlockIdAt(blockPositionX - brushSize - 1 + x, blockPositionY - brushSize - 1 + y, blockPositionZ - brushSize - 1 + z); - } - } - } - - // Log current materials into newmats - for (int x = 0; x <= brushSizeSquared; x++) { - for (int y = 0; y <= brushSizeSquared; y++) { - System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0, - brushSizeSquared + 1); - } - } - int temp; - - // Hollow Brush Area - for (int x = 0; x <= brushSizeSquared; x++) { - for (int z = 0; z <= brushSizeSquared; z++) { - for (int y = 0; y <= brushSizeSquared; y++) { - temp = 0; - - if (oldMaterials[x + 1 + 1][z + 1][y + 1] == v.getReplaceId()) { - temp++; - } - if (oldMaterials[x + 1 - 1][z + 1][y + 1] == v.getReplaceId()) { - temp++; - } - if (oldMaterials[x + 1][z + 1 + 1][y + 1] == v.getReplaceId()) { - temp++; - } - if (oldMaterials[x + 1][z + 1 - 1][y + 1] == v.getReplaceId()) { - temp++; - } - if (oldMaterials[x + 1][z + 1][y + 1 + 1] == v.getReplaceId()) { - temp++; - } - if (oldMaterials[x + 1][z + 1][y + 1 - 1] == v.getReplaceId()) { - temp++; - } - - if (temp == 0) { - newMaterials[x][z][y] = v.getVoxelId(); - } - } - } - } - - // Make the changes - final Undo undo = new Undo(); - - for (int x = brushSizeSquared; x >= 0; x--) { - for (int y = 0; y <= brushSizeSquared; y++) { - for (int z = brushSizeSquared; z >= 0; z--) { - if (this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - brushSize + y, blockPositionZ - brushSize + z) != newMaterials[x][y][z]) { - undo.put(this.clampY(blockPositionX - brushSize + x, blockPositionY - brushSize + y, blockPositionZ - brushSize + z)); - } - this.setBlockIdAt(blockPositionZ - brushSize + z, blockPositionX - brushSize + x, blockPositionY - brushSize + y, newMaterials[x][y][z]); - } - } - } - v.owner().storeUndo(undo); - - v.owner().getPlayer().sendMessage(ChatColor.AQUA + "Shell complete."); - } - - @Override - protected final void arrow(final SnipeData v) { - this.vShell(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.vShell(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - vm.voxel(); - vm.replace(); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Shell Voxel Parameters:"); - } else { - v.sendMessage(ChatColor.RED + "Invalid parameter - see the info message for help."); - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.shellvoxel"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SignOverwriteBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SignOverwriteBrush.java deleted file mode 100644 index 23aacafd7..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SignOverwriteBrush.java +++ /dev/null @@ -1,374 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import org.bukkit.ChatColor; -import org.bukkit.block.BlockState; -import org.bukkit.block.Sign; - -import java.io.*; -import java.util.Arrays; - -/** - * Overwrites signs. - * - * @author Monofraps - */ -public class SignOverwriteBrush extends Brush { - private static final int MAX_SIGN_LINE_LENGTH = 15; - private static final int NUM_SIGN_LINES = 4; - // these are no array indices - private static final int SIGN_LINE_1 = 1; - private static final int SIGN_LINE_2 = 2; - private static final int SIGN_LINE_3 = 3; - private static final int SIGN_LINE_4 = 4; - private String[] signTextLines = new String[NUM_SIGN_LINES]; - private boolean[] signLinesEnabled = new boolean[NUM_SIGN_LINES]; - private boolean rangedMode = false; - - public SignOverwriteBrush() { - this.setName("Sign Overwrite Brush"); - - clearBuffer(); - resetStates(); - } - - /** - * Sets the text of a given sign. - * - * @param sign - */ - private void setSignText(final Sign sign) { - for (int i = 0; i < this.signTextLines.length; i++) { - if (this.signLinesEnabled[i]) { - sign.setLine(i, this.signTextLines[i]); - } - } - - sign.update(); - } - - /** - * Sets the text of the target sign if the target block is a sign. - * - * @param v - */ - private void setSingle(final SnipeData v) { - if (this.getTargetBlock().getState() instanceof Sign) { - setSignText((Sign) this.getTargetBlock().getState()); - } else { - v.sendMessage(ChatColor.RED + "Target block is not a sign."); - return; - } - } - - /** - * Sets all signs in a range of box{x=z=brushSize*2+1 ; z=voxelHeight*2+1}. - * - * @param v - */ - private void setRanged(final SnipeData v) { - final int minX = getTargetBlock().getX() - v.getBrushSize(); - final int maxX = getTargetBlock().getX() + v.getBrushSize(); - final int minY = getTargetBlock().getY() - v.getVoxelHeight(); - final int maxY = getTargetBlock().getY() + v.getVoxelHeight(); - final int minZ = getTargetBlock().getZ() - v.getBrushSize(); - final int maxZ = getTargetBlock().getZ() + v.getBrushSize(); - - boolean signFound = false; // indicates whether or not a sign was set - - for (int x = minX; x <= maxX; x++) { - for (int y = minY; y <= maxY; y++) { - for (int z = minZ; z <= maxZ; z++) { - BlockState blockState = this.getWorld().getBlockAt(x, y, z).getState(); - if (blockState instanceof Sign) { - setSignText((Sign) blockState); - signFound = true; - } - } - } - } - - if (!signFound) { - v.sendMessage(ChatColor.RED + "Did not found any sign in selection box."); - } - } - - @Override - protected final void arrow(final SnipeData v) { - if (this.rangedMode) { - setRanged(v); - } else { - setSingle(v); - } - } - - @Override - protected final void powder(final SnipeData v) { - if (this.getTargetBlock().getState() instanceof Sign) { - Sign sign = (Sign) this.getTargetBlock().getState(); - - for (int i = 0; i < this.signTextLines.length; i++) { - if (this.signLinesEnabled[i]) { - this.signTextLines[i] = sign.getLine(i); - } - } - - displayBuffer(v); - } else { - v.sendMessage(ChatColor.RED + "Target block is not a sign."); - } - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - boolean textChanged = false; - - for (int i = 0; i < par.length; i++) { - String parameter = par[i]; - - try { - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.AQUA + "Sign Overwrite Brush Powder/Arrow:"); - v.sendMessage(ChatColor.BLUE + "The arrow writes the internal line buffer to the target sign."); - v.sendMessage(ChatColor.BLUE + "The powder reads the text of the target sign into the internal buffer."); - v.sendMessage(ChatColor.AQUA + "Sign Overwrite Brush Parameters:"); - v.sendMessage(ChatColor.GREEN + "-1[:(enabled|disabled)] ... " + ChatColor.BLUE + "-- Sets the text of the first sign line. (e.g. -1 Blah Blah)"); - v.sendMessage(ChatColor.GREEN + "-2[:(enabled|disabled)] ... " + ChatColor.BLUE + "-- Sets the text of the second sign line. (e.g. -2 Blah Blah)"); - v.sendMessage(ChatColor.GREEN + "-3[:(enabled|disabled)] ... " + ChatColor.BLUE + "-- Sets the text of the third sign line. (e.g. -3 Blah Blah)"); - v.sendMessage(ChatColor.GREEN + "-4[:(enabled|disabled)] ... " + ChatColor.BLUE + "-- Sets the text of the fourth sign line. (e.g. -4 Blah Blah)"); - v.sendMessage(ChatColor.GREEN + "-clear " + ChatColor.BLUE + "-- Clears the line buffer. (Alias: -c)"); - v.sendMessage(ChatColor.GREEN + "-clearall " + ChatColor.BLUE + "-- Clears the line buffer and sets all lines back to enabled. (Alias: -ca)"); - v.sendMessage(ChatColor.GREEN + "-multiple [on|off] " + ChatColor.BLUE + "-- Enables or disables ranged mode. (Alias: -m) (see Wiki for more information)"); - v.sendMessage(ChatColor.GREEN + "-save (name) " + ChatColor.BLUE + "-- Save you buffer to a file named [name]. (Alias: -s)"); - v.sendMessage(ChatColor.GREEN + "-open (name) " + ChatColor.BLUE + "-- Loads a buffer from a file named [name]. (Alias: -o)"); - } else if (parameter.startsWith("-1")) { - textChanged = true; - i = parseSignLineFromParam(par, SIGN_LINE_1, v, i); - } else if (parameter.startsWith("-2")) { - textChanged = true; - i = parseSignLineFromParam(par, SIGN_LINE_2, v, i); - } else if (parameter.startsWith("-3")) { - textChanged = true; - i = parseSignLineFromParam(par, SIGN_LINE_3, v, i); - } else if (parameter.startsWith("-4")) { - textChanged = true; - i = parseSignLineFromParam(par, SIGN_LINE_4, v, i); - } else if (parameter.equalsIgnoreCase("-clear") || parameter.equalsIgnoreCase("-c")) { - clearBuffer(); - v.sendMessage(ChatColor.BLUE + "Internal text buffer cleard."); - } else if (parameter.equalsIgnoreCase("-clearall") || parameter.equalsIgnoreCase("-ca")) { - clearBuffer(); - resetStates(); - v.sendMessage(ChatColor.BLUE + "Internal text buffer cleard and states back to enabled."); - } else if (parameter.equalsIgnoreCase("-multiple") || parameter.equalsIgnoreCase("-m")) { - if ((i + 1) >= par.length) { - v.sendMessage(ChatColor.RED + String.format("Missing parameter after %s.", parameter)); - continue; - } - - rangedMode = (par[++i].equalsIgnoreCase("on") || par[++i].equalsIgnoreCase("yes")); - v.sendMessage(ChatColor.BLUE + String.format("Ranged mode is %s", ChatColor.GREEN + (rangedMode ? "enabled" : "disabled"))); - if (this.rangedMode) { - v.sendMessage(ChatColor.GREEN + "Brush size set to " + ChatColor.RED + v.getBrushSize()); - v.sendMessage(ChatColor.AQUA + "Brush height set to " + ChatColor.RED + v.getVoxelHeight()); - } - } else if (parameter.equalsIgnoreCase("-save") || parameter.equalsIgnoreCase("-s")) { - if ((i + 1) >= par.length) { - v.sendMessage(ChatColor.RED + String.format("Missing parameter after %s.", parameter)); - continue; - } - - String fileName = par[++i]; - saveBufferToFile(fileName, v); - } else if (parameter.equalsIgnoreCase("-open") || parameter.equalsIgnoreCase("-o")) { - if ((i + 1) >= par.length) { - v.sendMessage(ChatColor.RED + String.format("Missing parameter after %s.", parameter)); - continue; - } - - String fileName = par[++i]; - loadBufferFromFile(fileName, "", v); - textChanged = true; - } - } catch (Exception exception) { - v.sendMessage(ChatColor.RED + String.format("Error while parsing parameter %s", parameter)); - exception.printStackTrace(); - } - } - - if (textChanged) { - displayBuffer(v); - } - } - - /** - * Parses parameter input text of line [param:lineNumber]. - * Iterates though the given array until the next top level param (a parameter which starts - * with a dash -) is found. - * - * @param params - * @param lineNumber - * @param v - * @param i - * @return - */ - private int parseSignLineFromParam(final String[] params, final int lineNumber, final SnipeData v, int i) { - final int lineIndex = lineNumber - 1; - final String parameter = params[i]; - - boolean statusSet = false; - - if (parameter.contains(":")) { - this.signLinesEnabled[lineIndex] = parameter.substring(parameter.indexOf(":")).equalsIgnoreCase(":enabled"); - v.sendMessage(ChatColor.BLUE + "Line " + lineNumber + " is " + ChatColor.GREEN + (this.signLinesEnabled[lineIndex] ? "enabled" : "disabled")); - statusSet = true; - } - - if ((i + 1) >= params.length) { - // return if the user just wanted to set the status - if (statusSet) { - return i; - } - - v.sendMessage(ChatColor.RED + "Warning: No text after -" + lineNumber + ". Setting buffer text to \"\" (empty string)"); - signTextLines[lineIndex] = ""; - return i; - } - - StringBuilder newText = new StringBuilder(); - - // go through the array until the next top level parameter is found - for (i++; i < params.length; i++) { - final String currentParameter = params[i]; - - if (currentParameter.startsWith("-")) { - i--; - break; - } else { - newText.append(currentParameter).append(" "); - } - } - - newText = new StringBuilder(ChatColor.translateAlternateColorCodes('&', newText.toString())); - - // remove last space or return if the string is empty and the user just wanted to set the status - if ((newText.length() > 0) && newText.toString().endsWith(" ")) { - newText = new StringBuilder(newText.substring(0, newText.length() - 1)); - } else if (newText.length() == 0) { - if (statusSet) { - return i; - } - v.sendMessage(ChatColor.RED + "Warning: No text after -" + lineNumber + ". Setting buffer text to \"\" (empty string)"); - } - - // check the line length and cut the text if needed - if (newText.length() > MAX_SIGN_LINE_LENGTH) { - v.sendMessage(ChatColor.RED + "Warning: Text on line " + lineNumber + " exceeds the maximum line length of " + MAX_SIGN_LINE_LENGTH + " characters. Your text will be cut."); - newText = new StringBuilder(newText.substring(0, MAX_SIGN_LINE_LENGTH)); - } - - this.signTextLines[lineIndex] = newText.toString(); - return i; - } - - private void displayBuffer(final SnipeData v) { - v.sendMessage(ChatColor.BLUE + "Buffer text set to: "); - for (int i = 0; i < this.signTextLines.length; i++) { - v.sendMessage((this.signLinesEnabled[i] ? ChatColor.GREEN + "(E): " : ChatColor.RED + "(D): ") + ChatColor.BLACK + this.signTextLines[i]); - } - } - - /** - * Saves the buffer to file. - * - * @param fileName - * @param v - */ - private void saveBufferToFile(final String fileName, final SnipeData v) { - final File store = new File(VoxelSniper.getInstance().getDataFolder() + "/" + fileName + ".vsign"); - if (store.exists()) { - v.sendMessage("This file already exists."); - return; - } - - try { - store.createNewFile(); - try (FileWriter outFile = new FileWriter(store); BufferedWriter outStream = new BufferedWriter(outFile)) { - for (int i = 0; i < this.signTextLines.length; i++) { - outStream.write(this.signLinesEnabled[i] + "\n"); - outStream.write(this.signTextLines[i] + "\n"); - } - } - - v.sendMessage(ChatColor.BLUE + "File saved successfully."); - } catch (IOException exception) { - v.sendMessage(ChatColor.RED + "Failed to save file. " + exception.getMessage()); - exception.printStackTrace(); - } - } - - /** - * Loads a buffer from a file. - * - * @param fileName - * @param userDomain - * @param v - */ - private void loadBufferFromFile(final String fileName, final String userDomain, final SnipeData v) { - final File store = new File(VoxelSniper.getInstance().getDataFolder() + "/" + fileName + ".vsign"); - if (!store.exists()) { - v.sendMessage("This file does not exist."); - return; - } - - try (FileReader inFile = new FileReader(store); BufferedReader inStream = new BufferedReader(inFile)) { - - for (int i = 0; i < this.signTextLines.length; i++) { - this.signLinesEnabled[i] = Boolean.parseBoolean(inStream.readLine()); - this.signTextLines[i] = inStream.readLine(); - } - - v.sendMessage(ChatColor.BLUE + "File loaded successfully."); - } catch (IOException exception) { - v.sendMessage(ChatColor.RED + "Failed to load file. " + exception.getMessage()); - exception.printStackTrace(); - } - } - - /** - * Clears the internal text buffer. (Sets it to empty strings) - */ - private void clearBuffer() { - Arrays.fill(this.signTextLines, ""); - } - - /** - * Resets line enabled states to enabled. - */ - private void resetStates() { - Arrays.fill(this.signLinesEnabled, true); - } - - @Override - public final void info(final Message vm) { - vm.brushName("Sign Overwrite Brush"); - - vm.custom(ChatColor.BLUE + "Buffer text: "); - for (int i = 0; i < this.signTextLines.length; i++) { - vm.custom((this.signLinesEnabled[i] ? ChatColor.GREEN + "(E): " : ChatColor.RED + "(D): ") + ChatColor.BLACK + this.signTextLines[i]); - } - - vm.custom(ChatColor.BLUE + String.format("Ranged mode is %s", ChatColor.GREEN + (rangedMode ? "enabled" : "disabled"))); - if (rangedMode) { - vm.size(); - vm.height(); - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.signoverwrite"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnipeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnipeBrush.java deleted file mode 100644 index 141642d9c..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnipeBrush.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; - - -public class SnipeBrush extends PerformBrush { - - public SnipeBrush() { - this.setName("Snipe"); - } - - @Override - protected final void arrow(final SnipeData v) { - this.current.perform(this.getTargetBlock()); - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void powder(final SnipeData v) { - this.current.perform(this.getLastBlock()); - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.snipe"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java deleted file mode 100644 index 0188ad5b3..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - - -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; - - -public class SnowConeBrush extends Brush { - @SuppressWarnings("deprecation") - private void addSnow(final SnipeData v, Block targetBlock) { - int brushSize; - int blockPositionX = targetBlock.getX(); - int blockPositionY = targetBlock.getY(); - int blockPositionZ = targetBlock.getZ(); - if (targetBlock.isEmpty()) { - brushSize = 0; - } else { - brushSize = this.clampY(blockPositionX, blockPositionY, blockPositionZ).getPropertyId() + 1; - } - - 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[][] yOffset = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; - // prime the arrays - - for (int x = 0; x <= brushSizeDoubled; x++) { - for (int z = 0; z <= brushSizeDoubled; z++) { - boolean flag = true; - - for (int i = 0; i < 10; i++) { // overlay - if (flag) { - if ((this.getBlockAt(blockPositionX - brushSize + x, blockPositionY - i, blockPositionZ - brushSize + z).isEmpty() || this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - i, blockPositionZ - brushSize + z) == BlockTypes.SNOW.getInternalId()) && !this.getBlockAt(blockPositionX - brushSize + x, blockPositionY - i - 1, blockPositionZ - brushSize + z).isEmpty() && this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - i - 1, blockPositionZ - brushSize + z) != BlockTypes.SNOW.getInternalId()) { - flag = false; - yOffset[x][z] = i; - } - } - } - 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 - for (int x = 0; x <= brushSizeDoubled; x++) { - final double xSquared = Math.pow(x - brushSize, 2); - - for (int z = 0; z <= 2 * brushSize; z++) { - final double zSquared = Math.pow(z - brushSize, 2); - final double dist = Math.pow(xSquared + zSquared, .5); // distance from center of array - final int snowData = brushSize - (int) Math.ceil(dist); - - 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; - } - break; - 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 - - if (snowData > snowConeData[x][z]) { - BlockType blockType = - BlockTypes.get(snowCone[x][z]); - if (blockType.getMaterial().isAir()) { - snowConeData[x][z] = snowData; - snowCone[x][z] = BlockTypes.SNOW.getInternalId(); - - snowConeData[x][z] = snowData; - } else if (blockType == BlockTypes.SNOW_BLOCK) { - 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(); - } - } - break; - } - } - } - } - - final Undo undo = new Undo(); - - 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]) { - 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]); - - } - } - v.owner().storeUndo(undo); - } - - @Override - protected final void arrow(final SnipeData v) { - } - - @Override - protected final void powder(final SnipeData v) { - if (getTargetBlock().getType() == Material.SNOW) { - this.addSnow(v, this.getTargetBlock()); - } else { - Block blockAbove = getTargetBlock().getRelative(BlockFace.UP); - if (blockAbove != null && BukkitAdapter.adapt(blockAbove.getType()).getMaterial() - .isAir()) { - addSnow(v, blockAbove); - } else { - v.owner().getPlayer() - .sendMessage(ChatColor.RED + "Error: Center block neither snow nor air."); - } - } - } - - @Override - public final void info(final Message vm) { - vm.brushName("Snow Cone"); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Snow Cone Parameters:"); - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.snowcone"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SpiralStaircaseBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SpiralStaircaseBrush.java deleted file mode 100644 index c76f92963..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SpiralStaircaseBrush.java +++ /dev/null @@ -1,535 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.extension.input.InputParseException; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; - -public class SpiralStaircaseBrush extends Brush { - private String stairtype = "block"; // "block" 1x1 blocks (default), "step" alternating step double step, "stair" staircase with blocks on corners - private String sdirect = "c"; // "c" clockwise (default), "cc" counter-clockwise - private String sopen = "n"; // "n" north (default), "e" east, "world" south, "world" west - - public SpiralStaircaseBrush() { - this.setName("Spiral Staircase"); - } - - private void buildStairWell(final SnipeData v, Block targetBlock) { - if (v.getVoxelHeight() < 1) { - v.setVoxelHeight(1); - v.sendMessage(ChatColor.RED + "VoxelHeight must be a natural number! Set to 1."); - } - - final int[][][] spiral = new int[2 * v.getBrushSize() + 1][v.getVoxelHeight()][2 * v.getBrushSize() + 1]; - - // locate first block in staircase - // Note to self, fix these - int startX; - int startZ; - int y = 0; - - if (this.sdirect.equalsIgnoreCase("cc")) { - if (this.sopen.equalsIgnoreCase("n")) { - startX = 0; - startZ = 2 * v.getBrushSize(); - } else if (this.sopen.equalsIgnoreCase("e")) { - startX = 0; - startZ = 0; - } else if (this.sopen.equalsIgnoreCase("s")) { - startX = 2 * v.getBrushSize(); - startZ = 0; - } else { - startX = 2 * v.getBrushSize(); - startZ = 2 * v.getBrushSize(); - } - } else { - if (this.sopen.equalsIgnoreCase("n")) { - startX = 0; - startZ = 0; - } else if (this.sopen.equalsIgnoreCase("e")) { - startX = 2 * v.getBrushSize(); - startZ = 0; - } else if (this.sopen.equalsIgnoreCase("s")) { - startX = 2 * v.getBrushSize(); - startZ = 2 * v.getBrushSize(); - } else { - startX = 0; - startZ = 2 * v.getBrushSize(); - } - } - - int xOffset = 0; - int zOffset = 0; - int toggle = 0; - while (y < v.getVoxelHeight()) { - if (this.stairtype.equalsIgnoreCase("block")) { - // 1x1x1 voxel material steps - spiral[startX + xOffset][y][startZ + zOffset] = 1; - y++; - } else if (this.stairtype.equalsIgnoreCase("step")) { - // alternating step-doublestep, uses data value to determine type - switch (toggle) { - case 0: - toggle = 2; - spiral[startX + xOffset][y][startZ + zOffset] = 1; - break; - case 1: - toggle = 2; - spiral[startX + xOffset][y][startZ + zOffset] = 1; - break; - case 2: - toggle = 1; - spiral[startX + xOffset][y][startZ + zOffset] = 2; - y++; - break; - default: - break; - } - - } - - // Adjust horizontal position and do stair-option array stuff - if (startX + xOffset == 0) { // All North - if (startZ + zOffset == 0) { // NORTHEAST - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 1; - } - if (this.sdirect.equalsIgnoreCase("c")) { - xOffset++; - } else { - zOffset++; - } - } else if (startZ + zOffset == 2 * v.getBrushSize()) { // NORTHWEST - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 1; - } - if (this.sdirect.equalsIgnoreCase("c")) { - zOffset--; - } else { - xOffset++; - } - } else { // JUST PLAIN NORTH - if (this.sdirect.equalsIgnoreCase("c")) { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 5; - y++; - } - zOffset--; - } else { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 4; - y++; - } - zOffset++; - } - } - } else if (startX + xOffset == 2 * v.getBrushSize()) { // ALL SOUTH - if (startZ + zOffset == 0) { // SOUTHEAST - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 1; - } - if (this.sdirect.equalsIgnoreCase("c")) { - zOffset++; - } else { - xOffset--; - } - } else if (startZ + zOffset == 2 * v.getBrushSize()) { // SOUTHWEST - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 1; - } - if (this.sdirect.equalsIgnoreCase("c")) { - xOffset--; - } else { - zOffset--; - } - } else { // JUST PLAIN SOUTH - if (this.sdirect.equalsIgnoreCase("c")) { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 4; - y++; - } - zOffset++; - } else { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 5; - y++; - } - zOffset--; - } - } - } else if (startZ + zOffset == 0) { // JUST PLAIN EAST - if (this.sdirect.equalsIgnoreCase("c")) { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 2; - y++; - } - xOffset++; - } else { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 3; - y++; - } - xOffset--; - } - } else { // JUST PLAIN WEST - if (this.sdirect.equalsIgnoreCase("c")) { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 3; - y++; - } - xOffset--; - } else { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 2; - y++; - } - xOffset++; - } - } - } - - final Undo undo = new Undo(); - // Make the changes - - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int i = v.getVoxelHeight() - 1; i >= 0; i--) { - for (int z = 2 * v.getBrushSize(); z >= 0; z--) { - int blockPositionX = targetBlock.getX(); - int blockPositionY = targetBlock.getY(); - int blockPositionZ = targetBlock.getZ(); - switch (spiral[x][i][z]) { - case 0: - if (i != v.getVoxelHeight() - 1) { - if (!((this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) && spiral[x][i + 1][z] == 1)) { - this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY + i, BlockTypes.AIR.getInternalId()); - } - - } else { - this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY + i, BlockTypes.AIR.getInternalId()); - } - - break; - case 1: - if (this.stairtype.equalsIgnoreCase("block")) { - this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY + i, v.getVoxelId()); - } else if (this.stairtype.equalsIgnoreCase("step")) { - this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 44, v.getPropertyId()); - } else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY + i - 1, v.getVoxelId()); - - } - break; - case 2: - if (this.stairtype.equalsIgnoreCase("step")) { - this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 43, v.getPropertyId()); - } else if (this.stairtype.equalsIgnoreCase("woodstair")) { - this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 53, 0); - } else if (this.stairtype.equalsIgnoreCase("cobblestair")) { - this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 67, 0); - } - break; - default: - if (this.stairtype.equalsIgnoreCase("woodstair")) { - this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 53, (spiral[x][i][z] - 2)); - } else if (this.stairtype.equalsIgnoreCase("cobblestair")) { - this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 67, (spiral[x][i][z] - 2)); - } - break; - } - } - } - } - v.owner().storeUndo(undo); - } - - private void digStairWell(final SnipeData v, Block targetBlock) { - if (v.getVoxelHeight() < 1) { - v.setVoxelHeight(1); - v.sendMessage(ChatColor.RED + "VoxelHeight must be a natural number! Set to 1."); - } - - // initialize array - final int[][][] spiral = new int[2 * v.getBrushSize() + 1][v.getVoxelHeight()][2 * v.getBrushSize() + 1]; - - // locate first block in staircase - // Note to self, fix these - int startX; - int startZ; - - if (this.sdirect.equalsIgnoreCase("cc")) { - if (this.sopen.equalsIgnoreCase("n")) { - startX = 0; - startZ = 2 * v.getBrushSize(); - } else if (this.sopen.equalsIgnoreCase("e")) { - startX = 0; - startZ = 0; - } else if (this.sopen.equalsIgnoreCase("s")) { - startX = 2 * v.getBrushSize(); - startZ = 0; - } else { - startX = 2 * v.getBrushSize(); - startZ = 2 * v.getBrushSize(); - } - } else { - if (this.sopen.equalsIgnoreCase("n")) { - startX = 0; - startZ = 0; - } else if (this.sopen.equalsIgnoreCase("e")) { - startX = 2 * v.getBrushSize(); - startZ = 0; - } else if (this.sopen.equalsIgnoreCase("s")) { - startX = 2 * v.getBrushSize(); - startZ = 2 * v.getBrushSize(); - } else { - startX = 0; - startZ = 2 * v.getBrushSize(); - } - } - - int xOffset = 0; - int zOffset = 0; - int toggle = 0; - int y = 0; - while (y < v.getVoxelHeight()) { - if (this.stairtype.equalsIgnoreCase("block")) { - // 1x1x1 voxel material steps - spiral[startX + xOffset][y][startZ + zOffset] = 1; - y++; - } else if (this.stairtype.equalsIgnoreCase("step")) { - // alternating step-doublestep, uses data value to determine type - switch (toggle) { - case 0: - toggle = 2; - spiral[startX + xOffset][y][startZ + zOffset] = 2; - break; - case 1: - toggle = 2; - spiral[startX + xOffset][y][startZ + zOffset] = 2; - break; - case 2: - toggle = 1; - spiral[startX + xOffset][y][startZ + zOffset] = 1; - y++; - break; - default: - break; - } - - } - - // Adjust horizontal position and do stair-option array stuff - if (startX + xOffset == 0) { // All North - if (startZ + zOffset == 0) { // NORTHEAST - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 1; - } - if (this.sdirect.equalsIgnoreCase("c")) { - xOffset++; - } else { - zOffset++; - } - } else if (startZ + zOffset == 2 * v.getBrushSize()) { // NORTHWEST - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 1; - } - if (this.sdirect.equalsIgnoreCase("c")) { - zOffset--; - } else { - xOffset++; - } - } else { // JUST PLAIN NORTH - if (this.sdirect.equalsIgnoreCase("c")) { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 4; - y++; - } - zOffset--; - } else { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 5; - y++; - } - zOffset++; - } - } - - } else if (startX + xOffset == 2 * v.getBrushSize()) { // ALL SOUTH - if (startZ + zOffset == 0) { // SOUTHEAST - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 1; - } - if (this.sdirect.equalsIgnoreCase("c")) { - zOffset++; - } else { - xOffset--; - } - } else if (startZ + zOffset == 2 * v.getBrushSize()) { // SOUTHWEST - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 1; - } - if (this.sdirect.equalsIgnoreCase("c")) { - xOffset--; - } else { - zOffset--; - } - } else { // JUST PLAIN SOUTH - if (this.sdirect.equalsIgnoreCase("c")) { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 5; - y++; - } - zOffset++; - } else { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 4; - y++; - } - zOffset--; - } - } - - } else if (startZ + zOffset == 0) { // JUST PLAIN EAST - if (this.sdirect.equalsIgnoreCase("c")) { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 3; - y++; - } - xOffset++; - } else { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 2; - y++; - } - xOffset--; - } - } else { // JUST PLAIN WEST - if (this.sdirect.equalsIgnoreCase("c")) { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 2; - y++; - } - xOffset--; - } else { - if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - spiral[startX + xOffset][y][startZ + zOffset] = 3; - y++; - } - xOffset++; - } - } - - } - - final Undo undo = new Undo(); - // Make the changes - - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - - for (int i = v.getVoxelHeight() - 1; i >= 0; i--) { - - for (int z = 2 * v.getBrushSize(); z >= 0; z--) { - - int blockPositionX = targetBlock.getX(); - int blockPositionY = targetBlock.getY(); - int blockPositionZ = targetBlock.getZ(); - switch (spiral[x][i][z]) { - case 0: - this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY - i, BlockTypes.AIR.getInternalId()); - break; - case 1: - if (this.stairtype.equalsIgnoreCase("block")) { - this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY - i, v.getVoxelId()); - } else if (this.stairtype.equalsIgnoreCase("step")) { - this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 44, v.getPropertyId()); - } else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) { - this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY - i, v.getVoxelId()); - } - break; - case 2: - if (this.stairtype.equalsIgnoreCase("step")) { - this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 43, v.getPropertyId()); - } else if (this.stairtype.equalsIgnoreCase("woodstair")) { - this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 53, 0); - } else if (this.stairtype.equalsIgnoreCase("cobblestair")) { - this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 67, 0); - } - break; - default: - if (this.stairtype.equalsIgnoreCase("woodstair")) { - this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 53, (spiral[x][i][z] - 2)); - } else if (this.stairtype.equalsIgnoreCase("cobblestair")) { - this.setBlockLegacy(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY - i, 67, (spiral[x][i][z] - 2)); - } - break; - } - } - } - } - v.owner().storeUndo(undo); - } - - @Override - protected final void arrow(final SnipeData v) { - this.digStairWell(v, this.getTargetBlock()); // make stairwell below target - } - - @Override - protected final void powder(final SnipeData v) { - this.buildStairWell(v, this.getLastBlock()); // make stairwell above target - } - - @Override - public final void info(final Message vm) { - vm.brushName("Spiral Staircase"); - vm.size(); - vm.voxel(); - vm.height(); - vm.data(); - vm.custom(ChatColor.BLUE + "Staircase type: " + this.stairtype); - vm.custom(ChatColor.BLUE + "Staircase turns: " + this.sdirect); - vm.custom(ChatColor.BLUE + "Staircase opens: " + this.sopen); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Spiral Staircase Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b sstair 'block' (default) | step' | 'woodstair' | 'cobblestair' -- set the type of staircase"); - v.sendMessage(ChatColor.AQUA + "/b sstair 'c' (default) | 'cc' -- set the turning direction of staircase"); - v.sendMessage(ChatColor.AQUA + "/b sstair 'n' (default) | 'e' | 's' | 'world' -- set the opening direction of staircase"); - return; - } - - for (int i = 1; i < par.length; i++) { - // stairs - // step/slab - - try { - this.stairtype = par[i].toLowerCase().intern(); - v.sendMessage(ChatColor.BLUE + "Staircase type: " + this.stairtype); - return; - } catch (InputParseException ignore) { - } - if (par[i].equalsIgnoreCase("block") || par[i].equalsIgnoreCase("step") || par[i].equalsIgnoreCase("woodstair") || par[i].equalsIgnoreCase("cobblestair")) { - this.stairtype = par[i].toLowerCase().intern(); - v.sendMessage(ChatColor.BLUE + "Staircase type: " + this.stairtype); - } else if (par[i].equalsIgnoreCase("c") || par[i].equalsIgnoreCase("cc")) { - this.sdirect = par[i]; - v.sendMessage(ChatColor.BLUE + "Staircase turns: " + this.sdirect); - } else if (par[i].equalsIgnoreCase("n") || par[i].equalsIgnoreCase("e") || par[i].equalsIgnoreCase("s") || par[i].equalsIgnoreCase("world")) { - this.sopen = par[i]; - v.sendMessage(ChatColor.BLUE + "Staircase opens: " + this.sopen); - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.spiralstaircase"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterBallBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterBallBrush.java deleted file mode 100644 index dd8eb0970..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterBallBrush.java +++ /dev/null @@ -1,217 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; - -import java.util.Random; - - -public class SplatterBallBrush extends PerformBrush { - private static final int GROW_PERCENT_MIN = 1; - private static final int GROW_PERCENT_DEFAULT = 1000; - private static final int GROW_PERCENT_MAX = 9999; - private static final int SEED_PERCENT_MIN = 1; - private static final int SEED_PERCENT_DEFAULT = 1000; - private static final int SEED_PERCENT_MAX = 9999; - private static final int SPLATREC_PERCENT_MIN = 1; - private static final int SPLATREC_PERCENT_DEFAULT = 3; - private static final int SPLATREC_PERCENT_MAX = 10; - private int seedPercent; // Chance block on first pass is made active - private int growPercent; // chance block on recursion pass is made active - private int splatterRecursions; // How many times you grow the seeds - private Random generator = new Random(); - - public SplatterBallBrush() { - this.setName("Splatter Ball"); - } - - private void splatterBall(final SnipeData v, AsyncBlock targetBlock) { - if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) { - v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Seed percent set to: 10%"); - this.seedPercent = SEED_PERCENT_DEFAULT; - } - if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) { - v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Growth percent set to: 10%"); - this.growPercent = GROW_PERCENT_DEFAULT; - } - if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) { - v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Recursions set to: 3"); - this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; - } - - final int[][][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; - - // Seed the array - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - for (int z = 2 * v.getBrushSize(); z >= 0; z--) { - if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) { - splat[x][y][z] = 1; - } - } - } - } - // Grow the seeds - final int gref = this.growPercent; - final int[][][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; - int growcheck; - - for (int r = 0; r < this.splatterRecursions; r++) { - this.growPercent = gref - ((gref / this.splatterRecursions) * (r)); - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - for (int z = 2 * v.getBrushSize(); z >= 0; z--) { - tempSplat[x][y][z] = splat[x][y][z]; // prime tempsplat - - growcheck = 0; - if (splat[x][y][z] == 0) { - if (x != 0 && splat[x - 1][y][z] == 1) { - growcheck++; - } - if (y != 0 && splat[x][y - 1][z] == 1) { - growcheck++; - } - if (z != 0 && splat[x][y][z - 1] == 1) { - growcheck++; - } - if (x != 2 * v.getBrushSize() && splat[x + 1][y][z] == 1) { - growcheck++; - } - if (y != 2 * v.getBrushSize() && splat[x][y + 1][z] == 1) { - growcheck++; - } - if (z != 2 * v.getBrushSize() && splat[x][y][z + 1] == 1) { - growcheck++; - } - } - - if (growcheck >= GROW_PERCENT_MIN && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) { - tempSplat[x][y][z] = 1; // prevent bleed into splat - } - - } - } - } - // integrate tempsplat back into splat at end of iteration - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - if (2 * v.getBrushSize() + 1 >= 0) { - System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, - 2 * v.getBrushSize() + 1); - } - } - } - } - this.growPercent = gref; - // Fill 1x1x1 holes - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - for (int z = 2 * v.getBrushSize(); z >= 0; z--) { - if (splat[Math.max(x - 1, 0)][y][z] == 1 && splat[Math.min(x + 1, 2 * v.getBrushSize())][y][z] == 1 && splat[x][Math.max(0, y - 1)][z] == 1 && splat[x][Math.min(2 * v.getBrushSize(), y + 1)][z] == 1) { - splat[x][y][z] = 1; - } - } - } - } - - // Make the changes - final double rSquared = Math.pow(v.getBrushSize() + 1, 2); - - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - final double xSquared = Math.pow(x - v.getBrushSize() - 1, 2); - - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - final double ySquared = Math.pow(y - v.getBrushSize() - 1, 2); - - for (int z = 2 * v.getBrushSize(); z >= 0; z--) { - if (splat[x][y][z] == 1 && xSquared + ySquared + Math.pow(z - v.getBrushSize() - 1, 2) <= rSquared) { - current.perform(targetBlock.getRelative(-v.getBrushSize() + x, -v.getBrushSize() + y, -v.getBrushSize() + z)); - } - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.splatterBall(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.splatterBall(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) { - this.seedPercent = SEED_PERCENT_DEFAULT; - } - if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) { - this.growPercent = GROW_PERCENT_DEFAULT; - } - if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) { - this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; - } - vm.brushName("Splatter Ball"); - vm.size(); - vm.custom(ChatColor.BLUE + "Seed percent set to: " + this.seedPercent / 100 + "%"); - vm.custom(ChatColor.BLUE + "Growth percent set to: " + this.growPercent / 100 + "%"); - vm.custom(ChatColor.BLUE + "Recursions set to: " + this.splatterRecursions); - - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Splatter Ball brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b sb s[int] -- set a seed percentage (1-9999). 100 = 1% Default is 1000"); - v.sendMessage(ChatColor.AQUA + "/b sb g[int] -- set a growth percentage (1-9999). Default is 1000"); - v.sendMessage(ChatColor.AQUA + "/b sb r[int] -- set a recursion (1-10). Default is 3"); - return; - } else if (parameter.startsWith("s")) { - final double temp = Integer.parseInt(parameter.replace("s", "")); - - if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%"); - this.seedPercent = (int) temp; - } else { - v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!"); - } - } else if (parameter.startsWith("g")) { - final double temp = Integer.parseInt(parameter.replace("g", "")); - - if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%"); - this.growPercent = (int) temp; - } else { - v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!"); - } - } else if (parameter.startsWith("r")) { - final int temp = Integer.parseInt(parameter.replace("r", "")); - - if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp); - this.splatterRecursions = temp; - } else { - v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); - } - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.splatterball"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterDiscBrush.java deleted file mode 100644 index 0243e90d1..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterDiscBrush.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; - -import java.util.Random; - - -public class SplatterDiscBrush extends PerformBrush { - private static final int GROW_PERCENT_MIN = 1; - private static final int GROW_PERCENT_DEFAULT = 1000; - private static final int GROW_PERCENT_MAX = 9999; - private static final int SEED_PERCENT_MIN = 1; - private static final int SEED_PERCENT_DEFAULT = 1000; - private static final int SEED_PERCENT_MAX = 9999; - private static final int SPLATREC_PERCENT_MIN = 1; - private static final int SPLATREC_PERCENT_DEFAULT = 3; - private static final int SPLATREC_PERCENT_MAX = 10; - private int seedPercent; // Chance block on first pass is made active - private int growPercent; // chance block on recursion pass is made active - private int splatterRecursions; // How many times you grow the seeds - private Random generator = new Random(); - - public SplatterDiscBrush() { - this.setName("Splatter Disc"); - } - - private void splatterDisc(final SnipeData v, AsyncBlock targetBlock) { - if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) { - v.sendMessage(ChatColor.BLUE + "Seed percent set to: 10%"); - this.seedPercent = SEED_PERCENT_DEFAULT; - } - if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) { - v.sendMessage(ChatColor.BLUE + "Growth percent set to: 10%"); - this.growPercent = GROW_PERCENT_DEFAULT; - } - if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) { - v.sendMessage(ChatColor.BLUE + "Recursions set to: 3"); - this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; - } - final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; - - // Seed the array - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - - if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) { - splat[x][y] = 1; - - } - } - } - // Grow the seeds - final int gref = this.growPercent; - int growcheck; - final int[][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; - for (int r = 0; r < this.splatterRecursions; r++) { - - this.growPercent = gref - ((gref / this.splatterRecursions) * (r)); - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - tempSplat[x][y] = splat[x][y]; // prime tempsplat - - growcheck = 0; - if (splat[x][y] == 0) { - if (x != 0 && splat[x - 1][y] == 1) { - growcheck++; - } - if (y != 0 && splat[x][y - 1] == 1) { - growcheck++; - } - if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) { - growcheck++; - } - if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) { - growcheck++; - } - } - - if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) { - tempSplat[x][y] = 1; // prevent bleed into splat - } - } - } - - // integrate tempsplat back into splat at end of iteration - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - if (2 * v.getBrushSize() + 1 >= 0) { - System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1); - } - } - } - this.growPercent = gref; - // Fill 1x1 holes - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - if (splat[Math.max(x - 1, 0)][y] == 1 && splat[Math.min(x + 1, 2 * v.getBrushSize())][y] == 1 && splat[x][Math.max(0, y - 1)] == 1 && splat[x][Math.min(2 * v.getBrushSize(), y + 1)] == 1) { - splat[x][y] = 1; - } - } - } - - // Make the changes - final double rSquared = Math.pow(v.getBrushSize() + 1, 2); - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - final double xSquared = Math.pow(x - v.getBrushSize() - 1, 2); - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - if (splat[x][y] == 1 && xSquared + Math.pow(y - v.getBrushSize() - 1, 2) <= rSquared) { - current.perform(targetBlock.getRelative(x - v.getBrushSize(), 0, y - v.getBrushSize())); - } - } - } - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.splatterDisc(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.splatterDisc(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) { - this.seedPercent = SEED_PERCENT_DEFAULT; - } - if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) { - this.growPercent = GROW_PERCENT_DEFAULT; - } - if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) { - this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; - } - vm.brushName("Splatter Disc"); - vm.size(); - vm.custom(ChatColor.BLUE + "Seed percent set to: " + this.seedPercent / 100 + "%"); - vm.custom(ChatColor.BLUE + "Growth percent set to: " + this.growPercent / 100 + "%"); - vm.custom(ChatColor.BLUE + "Recursions set to: " + this.splatterRecursions); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Splatter Disc brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b sd s[int] -- set a seed percentage (1-9999). 100 = 1% Default is 1000"); - v.sendMessage(ChatColor.AQUA + "/b sd g[int] -- set a growth percentage (1-9999). Default is 1000"); - v.sendMessage(ChatColor.AQUA + "/b sd r[int] -- set a recursion (1-10). Default is 3"); - return; - } else if (parameter.startsWith("s")) { - final double temp = Integer.parseInt(parameter.replace("s", "")); - if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%"); - this.seedPercent = (int) temp; - } else { - v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!"); - } - } else if (parameter.startsWith("g")) { - final double temp = Integer.parseInt(parameter.replace("g", "")); - if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%"); - this.growPercent = (int) temp; - } else { - v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!"); - } - } else if (parameter.startsWith("r")) { - final int temp = Integer.parseInt(parameter.replace("r", "")); - if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp); - this.splatterRecursions = temp; - } else { - v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); - } - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.splatterdisc"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java deleted file mode 100644 index ae01e60ed..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java +++ /dev/null @@ -1,341 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.registry.BlockMaterial; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; - -import java.util.Random; - -public class SplatterOverlayBrush extends PerformBrush { - private static final int GROW_PERCENT_MIN = 1; - private static final int GROW_PERCENT_DEFAULT = 1000; - private static final int GROW_PERCENT_MAX = 9999; - private static final int SEED_PERCENT_MIN = 1; - private static final int SEED_PERCENT_DEFAULT = 1000; - private static final int SEED_PERCENT_MAX = 9999; - private static final int SPLATREC_PERCENT_MIN = 1; - private static final int SPLATREC_PERCENT_DEFAULT = 3; - private static final int SPLATREC_PERCENT_MAX = 10; - private int seedPercent; // Chance block on first pass is made active - private int growPercent; // chance block on recursion pass is made active - private int splatterRecursions; // How many times you grow the seeds - private int yOffset = 0; - private boolean randomizeHeight = false; - private Random generator = new Random(); - private int depth = 3; - private boolean allBlocks = false; - - public SplatterOverlayBrush() { - this.setName("Splatter Overlay"); - } - - @SuppressWarnings("deprecation") - private void sOverlay(final SnipeData v) { - - // Splatter Time - final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; - // Seed the array - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) { - splat[x][y] = 1; - } - } - } - // Grow the seeds - final int gref = this.growPercent; - final int[][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; - int growcheck; - - for (int r = 0; r < this.splatterRecursions; r++) { - this.growPercent = gref - ((gref / this.splatterRecursions) * (r)); - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - tempSplat[x][y] = splat[x][y]; // prime tempsplat - - growcheck = 0; - if (splat[x][y] == 0) { - if (x != 0 && splat[x - 1][y] == 1) { - growcheck++; - } - if (y != 0 && splat[x][y - 1] == 1) { - growcheck++; - } - if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) { - growcheck++; - } - if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) { - growcheck++; - } - } - - if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) { - tempSplat[x][y] = 1; // prevent bleed into splat - } - } - } - // integrate tempsplat back into splat at end of iteration - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - if (2 * v.getBrushSize() + 1 >= 0) { - System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1); - } - } - } - this.growPercent = gref; - - final int[][] memory = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; - final double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2); - - for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) { - for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) { - for (int y = this.getTargetBlock().getY(); y > 0; y--) { - // start scanning from the height you clicked at - if (memory[x + v.getBrushSize()][z + v.getBrushSize()] != 1) { - // if haven't already found the surface in this column - if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared && splat[x + v.getBrushSize()][z + v.getBrushSize()] == 1) { - // if inside of the column && if to be splattered - final int check = this.getBlockIdAt(this.getTargetBlock().getX() + x, y + 1, this.getTargetBlock().getZ() + z); - if (check == 0 || check == 8 || check == 9) { - // must start at surface... this prevents it filling stuff in if you click in a wall - // and it starts out below surface. - if (!this.allBlocks) { - // if the override parameter has not been activated, go to the switch that filters out manmade stuff. - BlockType type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z)); - BlockMaterial mat = type.getMaterial(); - if (mat.isSolid() && mat.isFullCube() && !mat.hasContainer()) { - final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth; - - for (int d = this.depth - 1; ((this.depth - d) <= depth); d--) { - if (!this.clampY(this.getTargetBlock().getX() + x, y - d, this.getTargetBlock().getZ() + z).isEmpty()) { - // fills down as many layers as you specify in parameters - this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y - d + yOffset, this.getTargetBlock().getZ() + z)); - // stop it from checking any other blocks in this vertical 1x1 column. - memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; - } - } - } - } else { - final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth; - for (int d = this.depth - 1; ((this.depth - d) <= depth); d--) { - if (!this.clampY(this.getTargetBlock().getX() + x, y - d, this.getTargetBlock().getZ() + z).isEmpty()) { - // fills down as many layers as you specify in parameters - this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y - d + yOffset, this.getTargetBlock().getZ() + z)); - // stop it from checking any other blocks in this vertical 1x1 column. - memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; - } - } - } - } - } - } - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - private void soverlayTwo(final SnipeData v) { - // Splatter Time - final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; - // Seed the array - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) { - splat[x][y] = 1; - } - } - } - // Grow the seeds - final int gref = this.growPercent; - final int[][] tempsplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; - int growcheck; - - for (int r = 0; r < this.splatterRecursions; r++) { - this.growPercent = gref - ((gref / this.splatterRecursions) * (r)); - - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - tempsplat[x][y] = splat[x][y]; // prime tempsplat - - growcheck = 0; - if (splat[x][y] == 0) { - if (x != 0 && splat[x - 1][y] == 1) { - growcheck++; - } - if (y != 0 && splat[x][y - 1] == 1) { - growcheck++; - } - if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) { - growcheck++; - } - if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) { - growcheck++; - } - } - - if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) { - tempsplat[x][y] = 1; // prevent bleed into splat - } - - } - - } - // integrate tempsplat back into splat at end of iteration - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - if (2 * v.getBrushSize() + 1 >= 0) { - System.arraycopy(tempsplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1); - } - } - } - this.growPercent = gref; - - final int[][] memory = new int[v.getBrushSize() * 2 + 1][v.getBrushSize() * 2 + 1]; - final double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2); - - for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) { - for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) { - for (int y = this.getTargetBlock().getY(); y > 0; y--) { // start scanning from the height you clicked at - if (memory[x + v.getBrushSize()][z + v.getBrushSize()] != 1) { // if haven't already found the surface in this column - if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared && splat[x + v.getBrushSize()][z + v.getBrushSize()] == 1) { // if inside of the column...&& if to be splattered - if (!this.getBlockAt(this.getTargetBlock().getX() + x, y - 1, this.getTargetBlock().getZ() + z).isEmpty()) { // if not a floating block (like one of Notch'world pools) - if (this.getBlockAt(this.getTargetBlock().getX() + x, y + 1, this.getTargetBlock().getZ() + z).isEmpty()) { // must start at surface... this prevents it filling stuff in if - // you click in a wall and it starts out below surface. - if (!this.allBlocks) { // if the override parameter has not been activated, go to the switch that filters out manmade stuff. - - BlockType type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z)); - BlockMaterial mat = type.getMaterial(); - if (mat.isSolid() && mat.isFullCube() && !mat.hasContainer()) { - final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth; - for (int d = 1; (d < depth + 1); d++) { - this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y + d + yOffset, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify - // in parameters - memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column. - } - } - } else { - final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth; - for (int d = 1; (d < depth + 1); d++) { - this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y + d + yOffset, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify in - // parameters - memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column. - } - } - } - } - } - } - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.sOverlay(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.soverlayTwo(v); - } - - @Override - public final void info(final Message vm) { - if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) { - this.seedPercent = SEED_PERCENT_DEFAULT; - } - if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) { - this.growPercent = GROW_PERCENT_DEFAULT; - } - if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) { - this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; - } - vm.brushName(this.getName()); - vm.size(); - vm.custom(ChatColor.BLUE + "Seed percent set to: " + this.seedPercent / 100 + "%"); - vm.custom(ChatColor.BLUE + "Growth percent set to: " + this.growPercent / 100 + "%"); - vm.custom(ChatColor.BLUE + "Recursions set to: " + this.splatterRecursions); - vm.custom(ChatColor.BLUE + "Y-Offset set to: " + this.yOffset); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - try { - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Splatter Overlay brush parameters:"); - v.sendMessage(ChatColor.AQUA + "d[number] (ex: d3) How many blocks deep you want to replace from the surface."); - v.sendMessage(ChatColor.BLUE + "all (ex: /b over all) Sets the brush to overlay over ALL materials, not just natural surface ones (will no longer ignore trees and buildings). The parameter /some will set it back to default."); - v.sendMessage(ChatColor.AQUA + "/b sover s[int] -- set a seed percentage (1-9999). 100 = 1% Default is 1000"); - v.sendMessage(ChatColor.AQUA + "/b sover g[int] -- set a growth percentage (1-9999). Default is 1000"); - v.sendMessage(ChatColor.AQUA + "/b sover r[int] -- set a recursion (1-10). Default is 3"); - return; - } else if (parameter.startsWith("d")) { - this.depth = Integer.parseInt(parameter.replace("d", "")); - v.sendMessage(ChatColor.AQUA + "Depth set to " + this.depth); - if (this.depth < 1) { - this.depth = 1; - } - } else if (parameter.startsWith("all")) { - this.allBlocks = true; - v.sendMessage(ChatColor.BLUE + "Will overlay over any block." + this.depth); - } else if (parameter.startsWith("some")) { - this.allBlocks = false; - v.sendMessage(ChatColor.BLUE + "Will overlay only natural block types." + this.depth); - } else if (par[i].startsWith("s")) { - final double temp = Integer.parseInt(parameter.replace("s", "")); - if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%"); - this.seedPercent = (int) temp; - } else { - v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!"); - } - } else if (parameter.startsWith("g")) { - final double temp = Integer.parseInt(parameter.replace("g", "")); - if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%"); - this.growPercent = (int) temp; - } else { - v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!"); - } - } else if (parameter.startsWith("randh")) { - randomizeHeight = !randomizeHeight; - v.sendMessage(ChatColor.RED + "RandomizeHeight set to: " + randomizeHeight); - } else if (parameter.startsWith("r")) { - final int temp = Integer.parseInt(parameter.replace("r", "")); - if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp); - this.splatterRecursions = temp; - } else { - v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); - } - } else if (parameter.startsWith("yoff")) { - final int temp = Integer.parseInt(parameter.replace("yoff", "")); - if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Y-Offset set to: " + temp); - this.yOffset = temp; - } else { - v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); - } - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } catch (Exception exception) { - v.sendMessage(String.format("An error occurred while processing parameter %s.", parameter)); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.splatteroverlay"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelBrush.java deleted file mode 100644 index 19a9dfb36..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelBrush.java +++ /dev/null @@ -1,207 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; - -import java.util.Random; - - -public class SplatterVoxelBrush extends PerformBrush { - private static final int GROW_PERCENT_MIN = 1; - private static final int GROW_PERCENT_DEFAULT = 1000; - private static final int GROW_PERCENT_MAX = 9999; - private static final int SEED_PERCENT_MIN = 1; - private static final int SEED_PERCENT_DEFAULT = 1000; - private static final int SEED_PERCENT_MAX = 9999; - private static final int SPLATREC_PERCENT_MIN = 1; - private static final int SPLATREC_PERCENT_DEFAULT = 3; - private static final int SPLATREC_PERCENT_MAX = 10; - private int seedPercent; // Chance block on first pass is made active - private int growPercent; // chance block on recursion pass is made active - private int splatterRecursions; // How many times you grow the seeds - private Random generator = new Random(); - - public SplatterVoxelBrush() { - this.setName("Splatter Voxel"); - } - - private void vSplatterBall(final SnipeData v, AsyncBlock targetBlock) { - if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) { - v.sendMessage(ChatColor.BLUE + "Seed percent set to: 10%"); - this.seedPercent = SEED_PERCENT_DEFAULT; - } - if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) { - v.sendMessage(ChatColor.BLUE + "Growth percent set to: 10%"); - this.growPercent = GROW_PERCENT_DEFAULT; - } - if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) { - v.sendMessage(ChatColor.BLUE + "Recursions set to: 3"); - this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; - } - final int[][][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; - - // Seed the array - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - for (int z = 2 * v.getBrushSize(); z >= 0; z--) { - if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) { - splat[x][y][z] = 1; - } - } - } - } - // Grow the seeds - final int gref = this.growPercent; - final int[][][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; - int growcheck; - - for (int r = 0; r < this.splatterRecursions; r++) { - this.growPercent = gref - ((gref / this.splatterRecursions) * (r)); - - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - for (int z = 2 * v.getBrushSize(); z >= 0; z--) { - tempSplat[x][y][z] = splat[x][y][z]; // prime tempsplat - - growcheck = 0; - if (splat[x][y][z] == 0) { - if (x != 0 && splat[x - 1][y][z] == 1) { - growcheck++; - } - if (y != 0 && splat[x][y - 1][z] == 1) { - growcheck++; - } - if (z != 0 && splat[x][y][z - 1] == 1) { - growcheck++; - } - if (x != 2 * v.getBrushSize() && splat[x + 1][y][z] == 1) { - growcheck++; - } - if (y != 2 * v.getBrushSize() && splat[x][y + 1][z] == 1) { - growcheck++; - } - if (z != 2 * v.getBrushSize() && splat[x][y][z + 1] == 1) { - growcheck++; - } - } - - if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) { - tempSplat[x][y][z] = 1; // prevent bleed into splat - } - - } - } - } - // integrate tempsplat back into splat at end of iteration - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - if (2 * v.getBrushSize() + 1 >= 0) { - System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, - 2 * v.getBrushSize() + 1); - } - } - } - } - this.growPercent = gref; - // Fill 1x1x1 holes - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - for (int z = 2 * v.getBrushSize(); z >= 0; z--) { - if (splat[Math.max(x - 1, 0)][y][z] == 1 && splat[Math.min(x + 1, 2 * v.getBrushSize())][y][z] == 1 && splat[x][Math.max(0, y - 1)][z] == 1 && splat[x][Math.min(2 * v.getBrushSize(), y + 1)][z] == 1) { - splat[x][y][z] = 1; - } - } - } - } - - // Make the changes - - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - for (int z = 2 * v.getBrushSize(); z >= 0; z--) { - if (splat[x][y][z] == 1) { - current.perform(targetBlock.getRelative(-v.getBrushSize() + x, -v.getBrushSize() + z, -v.getBrushSize() + y)); - } - } - } - } - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.vSplatterBall(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.vSplatterBall(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) { - this.seedPercent = SEED_PERCENT_DEFAULT; - } - if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) { - this.growPercent = GROW_PERCENT_DEFAULT; - } - if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) { - this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; - } - vm.brushName("Splatter Voxel"); - vm.size(); - vm.custom(ChatColor.BLUE + "Seed percent set to: " + this.seedPercent / 100 + "%"); - vm.custom(ChatColor.BLUE + "Growth percent set to: " + this.growPercent / 100 + "%"); - vm.custom(ChatColor.BLUE + "Recursions set to: " + this.splatterRecursions); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Splatter Voxel brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b sv s[int] -- set a seed percentage (1-9999). 100 = 1% Default is 1000"); - v.sendMessage(ChatColor.AQUA + "/b sv g[int] -- set a growth percentage (1-9999). Default is 1000"); - v.sendMessage(ChatColor.AQUA + "/b sv r[int] -- set a recursion (1-10). Default is 3"); - return; - } else if (parameter.startsWith("s")) { - final double temp = Integer.parseInt(parameter.replace("s", "")); - if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%"); - this.seedPercent = (int) temp; - } else { - v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!"); - } - } else if (parameter.startsWith("g")) { - final double temp = Integer.parseInt(parameter.replace("g", "")); - if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%"); - this.growPercent = (int) temp; - } else { - v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!"); - } - } else if (parameter.startsWith("r")) { - final int temp = Integer.parseInt(parameter.replace("r", "")); - if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp); - this.splatterRecursions = temp; - } else { - v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); - } - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.splattervoxel"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelDiscBrush.java deleted file mode 100644 index e9157cbfd..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelDiscBrush.java +++ /dev/null @@ -1,190 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; - -import java.util.Random; - - -public class SplatterVoxelDiscBrush extends PerformBrush { - private static final int GROW_PERCENT_MIN = 1; - private static final int GROW_PERCENT_DEFAULT = 1000; - private static final int GROW_PERCENT_MAX = 9999; - private static final int SEED_PERCENT_MIN = 1; - private static final int SEED_PERCENT_DEFAULT = 1000; - private static final int SEED_PERCENT_MAX = 9999; - private static final int SPLATREC_PERCENT_MIN = 1; - private static final int SPLATREC_PERCENT_DEFAULT = 3; - private static final int SPLATREC_PERCENT_MAX = 10; - private int seedPercent; // Chance block on first pass is made active - private int growPercent; // chance block on recursion pass is made active - private int splatterRecursions; // How many times you grow the seeds - private Random generator = new Random(); - - public SplatterVoxelDiscBrush() { - this.setName("Splatter Voxel Disc"); - } - - private void vSplatterDisc(final SnipeData v, Block targetBlock) { - if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) { - v.sendMessage(ChatColor.BLUE + "Seed percent set to: 10%"); - this.seedPercent = SEED_PERCENT_DEFAULT; - } - if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) { - v.sendMessage(ChatColor.BLUE + "Growth percent set to: 10%"); - this.growPercent = GROW_PERCENT_DEFAULT; - } - if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) { - v.sendMessage(ChatColor.BLUE + "Recursions set to: 3"); - this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; - } - final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; - - // Seed the array - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) { - splat[x][y] = 1; - } - } - } - // Grow the seeds - final int gref = this.growPercent; - final int[][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; - int growcheck; - - for (int r = 0; r < this.splatterRecursions; r++) { - this.growPercent = gref - ((gref / this.splatterRecursions) * (r)); - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - tempSplat[x][y] = splat[x][y]; // prime tempsplat - - growcheck = 0; - if (splat[x][y] == 0) { - if (x != 0 && splat[x - 1][y] == 1) { - growcheck++; - } - if (y != 0 && splat[x][y - 1] == 1) { - growcheck++; - } - if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) { - growcheck++; - } - if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) { - growcheck++; - } - } - - if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) { - tempSplat[x][y] = 1; // prevent bleed into splat - } - } - } - // integrate tempsplat back into splat at end of iteration - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - if (2 * v.getBrushSize() + 1 >= 0) { - System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1); - } - } - } - this.growPercent = gref; - // Fill 1x1 holes - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - if (splat[Math.max(x - 1, 0)][y] == 1 && splat[Math.min(x + 1, 2 * v.getBrushSize())][y] == 1 && splat[x][Math.max(0, y - 1)] == 1 && splat[x][Math.min(2 * v.getBrushSize(), y + 1)] == 1) { - splat[x][y] = 1; - } - } - } - - // Make the changes - - for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - for (int y = 2 * v.getBrushSize(); y >= 0; y--) { - if (splat[x][y] == 1) { - this.current.perform(this.clampY(targetBlock.getX() - v.getBrushSize() + x, targetBlock.getY(), targetBlock.getZ() - v.getBrushSize() + y)); - } - } - } - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.vSplatterDisc(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.vSplatterDisc(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) { - this.seedPercent = SEED_PERCENT_DEFAULT; - } - if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) { - this.growPercent = GROW_PERCENT_DEFAULT; - } - if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) { - this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; - } - vm.brushName("Splatter Voxel Disc"); - vm.size(); - vm.custom(ChatColor.BLUE + "Seed percent set to: " + this.seedPercent / 100 + "%"); - vm.custom(ChatColor.BLUE + "Growth percent set to: " + this.growPercent / 100 + "%"); - vm.custom(ChatColor.BLUE + "Recursions set to: " + this.splatterRecursions); - - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - - for (int i = 1; i < par.length; i++) { - final String parameter = par[i]; - - if (parameter.equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Splatter Voxel Disc brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b svd s[int] -- set a seed percentage (1-9999). 100 = 1% Default is 1000"); - v.sendMessage(ChatColor.AQUA + "/b svd g[int] -- set a growth percentage (1-9999). Default is 1000"); - v.sendMessage(ChatColor.AQUA + "/b svd r[int] -- set a recursion (1-10). Default is 3"); - return; - } else if (parameter.startsWith("s")) { - final double temp = Integer.parseInt(parameter.replace("s", "")); - if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%"); - this.seedPercent = (int) temp; - } else { - v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!"); - } - } else if (parameter.startsWith("g")) { - final double temp = Integer.parseInt(parameter.replace("g", "")); - if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%"); - this.growPercent = (int) temp; - } else { - v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!"); - } - } else if (parameter.startsWith("r")) { - final int temp = Integer.parseInt(parameter.replace("r", "")); - if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) { - v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp); - this.splatterRecursions = temp; - } else { - v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); - } - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.splattervoxeldisc"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplineBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplineBrush.java deleted file mode 100644 index 1b7d60bdd..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplineBrush.java +++ /dev/null @@ -1,248 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; - -import java.util.ArrayList; - -/** - * FOR ANY BRUSH THAT USES A SPLINE, EXTEND THAT BRUSH FROM THIS BRUSH!!! That way, the spline calculations are already there. Also, the UI for - * the splines will be included. - * - * @author psanker - */ -public class SplineBrush extends PerformBrush { - private final ArrayList endPts = new ArrayList<>(); - private final ArrayList ctrlPts = new ArrayList<>(); - protected ArrayList spline = new ArrayList<>(); - protected boolean set; - protected boolean ctrl; - protected String[] sparams = {"ss", "sc", "clear"}; - - public SplineBrush() { - this.setName("Spline"); - } - - public final void addToSet(final SnipeData v, final boolean ep, Block targetBlock) { - if (ep) { - if (this.endPts.contains(targetBlock) || this.endPts.size() == 2) { - return; - } - - this.endPts.add(targetBlock); - v.sendMessage(ChatColor.GRAY + "Added block " + ChatColor.RED + "(" + targetBlock.getX() + ", " + targetBlock.getY() + ", " + targetBlock.getZ() + ") " + ChatColor.GRAY + "to endpoint selection"); - return; - } - - if (this.ctrlPts.contains(targetBlock) || this.ctrlPts.size() == 2) { - return; - } - - this.ctrlPts.add(targetBlock); - v.sendMessage(ChatColor.GRAY + "Added block " + ChatColor.RED + "(" + targetBlock.getX() + ", " + targetBlock.getY() + ", " + targetBlock.getZ() + ") " + ChatColor.GRAY - + "to control point selection"); - } - - public final void removeFromSet(final SnipeData v, final boolean ep, Block targetBlock) { - if (ep) { - if (!this.endPts.contains(targetBlock)) { - v.sendMessage(ChatColor.RED + "That block is not in the endpoint selection set."); - return; - } - - this.endPts.add(targetBlock); - v.sendMessage(ChatColor.GRAY + "Removed block " + ChatColor.RED + "(" + targetBlock.getX() + ", " + targetBlock.getY() + ", " + targetBlock.getZ() + ") " + ChatColor.GRAY - + "from endpoint selection"); - return; - } - - if (!this.ctrlPts.contains(targetBlock)) { - v.sendMessage(ChatColor.RED + "That block is not in the control point selection set."); - return; - } - - this.ctrlPts.remove(targetBlock); - v.sendMessage(ChatColor.GRAY + "Removed block " + ChatColor.RED + "(" + targetBlock.getX() + ", " + targetBlock.getY() + ", " + targetBlock.getZ() + ") " + ChatColor.GRAY - + "from control point selection"); - } - - public final boolean spline(final Point start, final Point end, final Point c1, final Point c2, final SnipeData v) { - this.spline.clear(); - - try { - final Point c = (c1.subtract(start)).multiply(3); - final Point b = ((c2.subtract(c1)).multiply(3)).subtract(c); - final Point a = ((end.subtract(start)).subtract(c)).subtract(b); - - for (double t = 0.0; t < 1.0; t += 0.01) { - final int px = (int) Math.round((a.getX() * (t * t * t)) + (b.getX() * (t * t)) + (c.getX() * t) + this.endPts.get(0).getX()); - final int py = (int) Math.round((a.getY() * (t * t * t)) + (b.getY() * (t * t)) + (c.getY() * t) + this.endPts.get(0).getY()); - final int pz = (int) Math.round((a.getZ() * (t * t * t)) + (b.getZ() * (t * t)) + (c.getZ() * t) + this.endPts.get(0).getZ()); - - if (!this.spline.contains(new Point(px, py, pz))) { - this.spline.add(new Point(px, py, pz)); - } - } - - return true; - } catch (final Exception exception) { - v.sendMessage(ChatColor.RED + "Not enough points selected; " + this.endPts.size() + " endpoints, " + this.ctrlPts.size() + " control points"); - return false; - } - } - - protected final void render(final SnipeData v) { - if (this.spline.isEmpty()) { - return; - } - - for (final Point point : this.spline) { - this.current.perform(this.clampY(point.getX(), point.getY(), point.getZ())); - } - - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - if (this.set) { - this.removeFromSet(v, true, this.getTargetBlock()); - } else if (this.ctrl) { - this.removeFromSet(v, false, this.getTargetBlock()); - } - } - - protected final void clear(final SnipeData v) { - this.spline.clear(); - this.ctrlPts.clear(); - this.endPts.clear(); - v.sendMessage(ChatColor.GRAY + "Bezier curve cleared."); - } - - @Override - protected final void powder(final SnipeData v) { - if (this.set) { - this.addToSet(v, true, this.getTargetBlock()); - } - if (this.ctrl) { - this.addToSet(v, false, this.getTargetBlock()); - } - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - - if (this.set) { - vm.custom(ChatColor.GRAY + "Endpoint selection mode ENABLED."); - } else if (this.ctrl) { - vm.custom(ChatColor.GRAY + "Control point selection mode ENABLED."); - } else { - vm.custom(ChatColor.AQUA + "No selection mode enabled."); - } - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - if (par[i].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Spline brush parameters"); - v.sendMessage(ChatColor.AQUA + "ss: Enable endpoint selection mode for desired curve"); - v.sendMessage(ChatColor.AQUA + "sc: Enable control point selection mode for desired curve"); - v.sendMessage(ChatColor.AQUA + "clear: Clear out the curve selection"); - v.sendMessage(ChatColor.AQUA + "ren: Render curve from control points"); - return; - } - if (par[i].equalsIgnoreCase("sc")) { - if (!this.ctrl) { - this.set = false; - this.ctrl = true; - v.sendMessage(ChatColor.GRAY + "Control point selection mode ENABLED."); - } else { - this.ctrl = false; - v.sendMessage(ChatColor.AQUA + "Control point selection mode disabled."); - } - } else if (par[i].equalsIgnoreCase("ss")) { - if (!this.set) { - this.set = true; - this.ctrl = false; - v.sendMessage(ChatColor.GRAY + "Endpoint selection mode ENABLED."); - } else { - this.set = false; - v.sendMessage(ChatColor.AQUA + "Endpoint selection mode disabled."); - } - } else if (par[i].equalsIgnoreCase("clear")) { - this.clear(v); - } else if (par[i].equalsIgnoreCase("ren")) { - if (this.spline(new Point(this.endPts.get(0)), new Point(this.endPts.get(1)), new Point(this.ctrlPts.get(0)), new Point(this.ctrlPts.get(1)), v)) { - this.render(v); - } - } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.spline"; - } - - // Vector class for splines - protected class Point { - private int x; - private int y; - private int z; - - public Point(final Block b) { - this.setX(b.getX()); - this.setY(b.getY()); - this.setZ(b.getZ()); - } - - public Point(final int x, final int y, final int z) { - this.setX(x); - this.setY(y); - this.setZ(z); - } - - public final Point add(final Point p) { - return new Point(this.getX() + p.getX(), this.getY() + p.getY(), this.getZ() + p.getZ()); - } - - public final Point multiply(final int scalar) { - return new Point(this.getX() * scalar, this.getY() * scalar, this.getZ() * scalar); - } - - public final Point subtract(final Point p) { - return new Point(this.getX() - p.getX(), this.getY() - p.getY(), this.getZ() - p.getZ()); - } - - public int getX() { - return x; - } - - public void setX(int x) { - this.x = x; - } - - public int getY() { - return y; - } - - public void setY(int y) { - this.y = y; - } - - public int getZ() { - return z; - } - - public void setZ(int z) { - this.z = z; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StampBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StampBrush.java deleted file mode 100644 index febd39ba5..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StampBrush.java +++ /dev/null @@ -1,235 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; - -import java.util.HashSet; - -public class StampBrush extends Brush { - protected HashSet clone = new HashSet<>(); - protected HashSet fall = new HashSet<>(); - protected HashSet drop = new HashSet<>(); - protected HashSet solid = new HashSet<>(); - protected Undo undo; - protected boolean sorted = false; - protected StampType stamp = StampType.DEFAULT; - - public StampBrush() { - this.setName("Stamp"); - } - - - public final void reSort() { - this.sorted = false; - } - - protected final boolean falling(final int id) { - return (id > 7 && id < 14); - } - - protected final boolean fallsOff(final int id) { - return (BlockTypes.get(id).getMaterial().isFragileWhenPushed()); - } - - @SuppressWarnings("deprecation") - protected final void setBlock(final BlockWrapper cb) { - final AsyncBlock block = this.clampY(this.getTargetBlock().getX() + cb.x, this.getTargetBlock().getY() + cb.y, this.getTargetBlock().getZ() + cb.z); - this.undo.put(block); - block.setTypeId(cb.id); - block.setPropertyId(cb.d); - } - - @SuppressWarnings("deprecation") - protected final void setBlockFill(final BlockWrapper cb) { - final AsyncBlock block = this.clampY(this.getTargetBlock().getX() + cb.x, this.getTargetBlock().getY() + cb.y, this.getTargetBlock().getZ() + cb.z); - if (block.isEmpty()) { - this.undo.put(block); - block.setTypeId(cb.id); - block.setPropertyId(cb.d); - } - } - - protected final void setStamp(final StampType type) { - this.stamp = type; - } - - protected final void stamp(final SnipeData v) { - this.undo = new Undo(); - - if (this.sorted) { - for (final BlockWrapper block : this.solid) { - this.setBlock(block); - } - for (final BlockWrapper block : this.drop) { - this.setBlock(block); - } - for (final BlockWrapper block : this.fall) { - this.setBlock(block); - } - } else { - this.fall.clear(); - this.drop.clear(); - this.solid.clear(); - for (final BlockWrapper block : this.clone) { - if (this.fallsOff(block.id)) { - this.fall.add(block); - } else if (this.falling(block.id)) { - this.drop.add(block); - } else { - this.solid.add(block); - this.setBlock(block); - } - } - for (final BlockWrapper block : this.drop) { - this.setBlock(block); - } - for (final BlockWrapper block : this.fall) { - this.setBlock(block); - } - this.sorted = true; - } - - v.owner().storeUndo(this.undo); - } - - protected final void stampFill(final SnipeData v) { - - this.undo = new Undo(); - - if (this.sorted) { - for (final BlockWrapper block : this.solid) { - this.setBlockFill(block); - } - for (final BlockWrapper block : this.drop) { - this.setBlockFill(block); - } - for (final BlockWrapper block : this.fall) { - this.setBlockFill(block); - } - } else { - this.fall.clear(); - this.drop.clear(); - this.solid.clear(); - for (final BlockWrapper block : this.clone) { - if (this.fallsOff(block.id)) { - this.fall.add(block); - } else if (this.falling(block.id)) { - this.drop.add(block); - } else if (block.id != 0) { - this.solid.add(block); - this.setBlockFill(block); - } - } - for (final BlockWrapper block : this.drop) { - this.setBlockFill(block); - } - for (final BlockWrapper block : this.fall) { - this.setBlockFill(block); - } - this.sorted = true; - } - - v.owner().storeUndo(this.undo); - } - - protected final void stampNoAir(final SnipeData v) { - - this.undo = new Undo(); - - if (this.sorted) { - for (final BlockWrapper block : this.solid) { - this.setBlock(block); - } - for (final BlockWrapper block : this.drop) { - this.setBlock(block); - } - for (final BlockWrapper block : this.fall) { - this.setBlock(block); - } - } else { - this.fall.clear(); - this.drop.clear(); - this.solid.clear(); - for (final BlockWrapper block : this.clone) { - if (this.fallsOff(block.id)) { - this.fall.add(block); - } else if (this.falling(block.id)) { - this.drop.add(block); - } else if (block.id != 0) { - this.solid.add(block); - this.setBlock(block); - } - } - for (final BlockWrapper block : this.drop) { - this.setBlock(block); - } - for (final BlockWrapper block : this.fall) { - this.setBlock(block); - } - this.sorted = true; - } - - v.owner().storeUndo(this.undo); - } - - @Override - protected final void arrow(final SnipeData v) { - switch (this.stamp) { - case DEFAULT: - this.stamp(v); - break; - - case NO_AIR: - this.stampNoAir(v); - break; - - case FILL: - this.stampFill(v); - break; - - default: - v.sendMessage(ChatColor.DARK_RED + "Error while stamping! Report"); - break; - } - } - - @Override - protected void powder(final SnipeData v) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void info(final Message vm) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.stamp"; - } - - protected enum StampType { - NO_AIR, FILL, DEFAULT - } - - - protected class BlockWrapper { - public int id; - public int x; - public int y; - public int z; - public int d; - - public BlockWrapper(final AsyncBlock b, final int blx, final int bly, final int blz) { - this.id = b.getTypeId(); - this.d = b.getPropertyId(); - this.x = blx; - this.y = bly; - this.z = blz; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilBrush.java deleted file mode 100644 index 1a6e9b82f..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilBrush.java +++ /dev/null @@ -1,362 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.boydti.fawe.object.FaweInputStream; -import com.boydti.fawe.object.FaweOutputStream; -import com.boydti.fawe.object.io.PGZIPOutputStream; -import com.google.common.io.Files; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; - -import java.io.*; -import java.util.zip.GZIPInputStream; - -/** - * This is paste only currently. Assumes files exist, and thus has no usefulness until I add in saving stencils later. Uses sniper-exclusive stencil format: 3 - * shorts for X,Z,Y size of cuboid 3 shorts for X,Z,Y offsets from the -X,-Z,-Y corner. This is the reference point for pasting, corresponding to where you - * click your brush. 1 long integer saying how many runs of blocks are in the schematic (data is compressed into runs) 1 per run: ( 1 boolean: true = compressed - * line ahead, false = locally unique block ahead. This wastes a bit instead of a byte, and overall saves space, as long as at least 1/8 of all RUNS are going - * to be size 1, which in Minecraft is almost definitely true. IF boolean was true, next unsigned byte stores the number of consecutive blocks of the same type, - * up to 256. IF boolean was false, there is no byte here, goes straight to ID and data instead, which applies to just one block. 2 bytes to identify type of - * block. First byte is ID, second is data. This applies to every one of the line of consecutive blocks if boolean was true. ) - *

- * TODO: Make limit a config option - * - * @author Gavjenks - */ -public class StencilBrush extends Brush { - private byte pasteOption = 1; // 0 = full, 1 = fill, 2 = replace - private String filename = "NoFileLoaded"; - private short x; - private short z; - private short y; - private short xRef; - private short zRef; - private short yRef; - private byte pasteParam = 0; - private int[] firstPoint = new int[3]; - private int[] secondPoint = new int[3]; - private int[] pastePoint = new int[3]; - private byte point = 1; - -public StencilBrush() { - this.setName("Stencil"); - } - - @SuppressWarnings("deprecation") - private void stencilPaste(final SnipeData v) { - if (this.filename.matches("NoFileLoaded")) { - v.sendMessage(ChatColor.RED + "You did not specify a filename. This is required."); - return; - } - - final Undo undo = new Undo(); - final File file = new File("plugins/VoxelSniper/stencils/" + this.filename + ".vstencil"); - - if (file.exists()) { - try (final FaweInputStream in = new FaweInputStream(new DataInputStream(new GZIPInputStream(new BufferedInputStream(new FileInputStream(file)))))) { - - this.x = in.readShort(); - this.z = in.readShort(); - this.y = in.readShort(); - - this.xRef = in.readShort(); - this.zRef = in.readShort(); - this.yRef = in.readShort(); - - final int numRuns = in.readInt(); - - int currX = -this.xRef; // so if your ref point is +5 x, you want to start pasting -5 blocks from the clicked point (the reference) to get the - // corner, for example. - int currZ = -this.zRef; - int currY = -this.yRef; - int id; - int blockPositionX = getTargetBlock().getX(); - int blockPositionY = getTargetBlock().getY(); - int blockPositionZ = getTargetBlock().getZ(); - if (this.pasteOption == 0) { - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = in.readVarInt(); - for (int j = 0; j < numLoops; j++) { - undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ)); - this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id); - currX++; - if (currX == this.x - this.xRef) { - currX = -this.xRef; - currZ++; - if (currZ == this.z - this.zRef) { - currZ = -this.zRef; - currY++; - } - } - } - } else { - undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ)); - int combined = in.readVarInt(); - this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(combined); - currX++; - if (currX == this.x - this.xRef) { - currX = -this.xRef; - currZ++; - if (currZ == this.z - this.zRef) { - currZ = -this.zRef; - currY++; - } - } - } - } - } else if (this.pasteOption == 1) { - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readVarInt()); - for (int j = 0; j < numLoops; j++) { - - if (!BlockTypes.getFromStateId(id).getMaterial().isAir() && this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).isEmpty()) { - undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ)); - this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id); - } - currX++; - if (currX == this.x - this.xRef) { - currX = -this.xRef; - currZ++; - if (currZ == this.z - this.zRef) { - currZ = -this.zRef; - currY++; - } - } - } - } else { - id = (in.readVarInt()); - if (!BlockTypes.getFromStateId(id).getMaterial().isAir() && this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).isEmpty()) { - undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ)); - // v.sendMessage("currX:" + currX + " currZ:"+currZ + " currY:" + currY + " id:" + id + " data:" + data); - this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id); - } - currX++; - if (currX == this.x - this.xRef) { - currX = -this.xRef; - currZ++; - if (currZ == this.z - this.zRef) { - currZ = -this.zRef; - currY++; - } - } - } - } - } else { // replace - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readVarInt()); - for (int j = 0; j < (numLoops); j++) { - if (!BlockTypes.getFromStateId(id).getMaterial().isAir()) { - undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ)); - this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id); - } - currX++; - if (currX == this.x - this.xRef) { - currX = -this.xRef; - currZ++; - if (currZ == this.z - this.zRef) { - currZ = -this.zRef; - currY++; - } - } - } - } else { - id = (in.readVarInt()); - if (id != 0) { - undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ)); - this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id); - } - currX++; - if (currX == this.x) { - currX = 0; - currZ++; - if (currZ == this.z) { - currZ = 0; - currY++; - } - } - } - } - } - in.close(); - v.owner().storeUndo(undo); - - } catch (final Exception exception) { - v.sendMessage(ChatColor.RED + "Something went wrong."); - exception.printStackTrace(); - } - } else { - v.sendMessage(ChatColor.RED + "You need to type a stencil name / your specified stencil does not exist."); - } - } - - @SuppressWarnings("UnstableApiUsage") - private void stencilSave(final SnipeData v) { - - final File file = new File("plugins/VoxelSniper/stencils/" + this.filename + ".vstencil"); - try { - this.x = (short) (Math.abs((this.firstPoint[0] - this.secondPoint[0])) + 1); - this.z = (short) (Math.abs((this.firstPoint[1] - this.secondPoint[1])) + 1); - this.y = (short) (Math.abs((this.firstPoint[2] - this.secondPoint[2])) + 1); - this.xRef = (short) ((this.firstPoint[0] > this.secondPoint[0]) ? (this.pastePoint[0] - this.secondPoint[0]) : (this.pastePoint[0] - this.firstPoint[0])); - this.zRef = (short) ((this.firstPoint[1] > this.secondPoint[1]) ? (this.pastePoint[1] - this.secondPoint[1]) : (this.pastePoint[1] - this.firstPoint[1])); - this.yRef = (short) ((this.firstPoint[2] > this.secondPoint[2]) ? (this.pastePoint[2] - this.secondPoint[2]) : (this.pastePoint[2] - this.firstPoint[2])); - - if ((this.x * this.y * this.z) > 50000) { - v.sendMessage(ChatColor.AQUA + "Volume exceeds maximum limit."); - return; - } - - Files.createParentDirs(file); - file.createNewFile(); - try (FaweOutputStream out = new FaweOutputStream(new DataOutputStream(new PGZIPOutputStream(new BufferedOutputStream(new FileOutputStream(file)))))) { - int blockPositionX = Math.min(this.firstPoint[0], this.secondPoint[0]); - int blockPositionZ = Math.min(this.firstPoint[1], this.secondPoint[1]); - int blockPositionY = Math.min(this.firstPoint[2], this.secondPoint[2]); - out.writeShort(this.x); - out.writeShort(this.z); - out.writeShort(this.y); - out.writeShort(this.xRef); - out.writeShort(this.zRef); - out.writeShort(this.yRef); - - v.sendMessage(ChatColor.AQUA + "Volume: " + this.x * this.z * this.y + " blockPositionX:" + blockPositionX + " blockPositionZ:" + blockPositionZ + " blockPositionY:" + blockPositionY); - - int[] blockArray = new int[this.x * this.z * this.y]; - byte[] runSizeArray = new byte[this.x * this.z * this.y]; - - int lastId = (this.getWorld().getBlockAt(blockPositionX, blockPositionY, blockPositionZ).getCombinedId()); - int thisId; - int counter = 0; - int arrayIndex = 0; - for (int y = 0; y < this.y; y++) { - for (int z = 0; z < this.z; z++) { - for (int x = 0; x < this.x; x++) { - AsyncBlock currentBlock = getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ + z); - thisId = (currentBlock.getCombinedId()); - if (thisId != lastId || counter == 255) { - blockArray[arrayIndex] = lastId; - runSizeArray[arrayIndex] = (byte) (counter - 128); - arrayIndex++; - counter = 1; - lastId = thisId; - } else { - counter++; - lastId = thisId; - } - } - } - } - blockArray[arrayIndex] = lastId; // saving last run, which will always be left over. - runSizeArray[arrayIndex] = (byte) (counter - 128); - - out.writeInt(arrayIndex + 1); - // v.sendMessage("number of runs = " + arrayIndex); - for (int i = 0; i < arrayIndex + 1; i++) { - if (runSizeArray[i] > -127) { - out.writeBoolean(true); - out.writeByte(runSizeArray[i]); - out.writeVarInt(blockArray[i]); - } else { - out.writeBoolean(false); - out.writeVarInt(blockArray[i]); - } - } - - v.sendMessage(ChatColor.BLUE + "Saved as '" + this.filename + "'."); - } - - } catch (final Exception exception) { - v.sendMessage(ChatColor.RED + "Something went wrong."); - exception.printStackTrace(); - } - } - - @Override - protected final void arrow(final SnipeData v) { // will be used to copy/save later on? - if (this.point == 1) { - this.firstPoint[0] = this.getTargetBlock().getX(); - this.firstPoint[1] = this.getTargetBlock().getZ(); - this.firstPoint[2] = this.getTargetBlock().getY(); - v.sendMessage(ChatColor.GRAY + "First point"); - v.sendMessage("X:" + this.firstPoint[0] + " Z:" + this.firstPoint[1] + " Y:" + this.firstPoint[2]); - this.point = 2; - } else if (this.point == 2) { - this.secondPoint[0] = this.getTargetBlock().getX(); - this.secondPoint[1] = this.getTargetBlock().getZ(); - this.secondPoint[2] = this.getTargetBlock().getY(); - if ((Math.abs(this.firstPoint[0] - this.secondPoint[0]) * Math.abs(this.firstPoint[1] - this.secondPoint[1]) * Math.abs(this.firstPoint[2] - this.secondPoint[2])) > 5000000) { - v.sendMessage(ChatColor.DARK_RED + "Area selected is too large. (Limit is 5,000,000 blocks)"); - this.point = 1; - } else { - v.sendMessage(ChatColor.GRAY + "Second point"); - v.sendMessage("X:" + this.secondPoint[0] + " Z:" + this.secondPoint[1] + " Y:" + this.secondPoint[2]); - this.point = 3; - } - } else if (this.point == 3) { - this.pastePoint[0] = this.getTargetBlock().getX(); - this.pastePoint[1] = this.getTargetBlock().getZ(); - this.pastePoint[2] = this.getTargetBlock().getY(); - v.sendMessage(ChatColor.GRAY + "Paste Reference point"); - v.sendMessage("X:" + this.pastePoint[0] + " Z:" + this.pastePoint[1] + " Y:" + this.pastePoint[2]); - this.point = 1; - - this.stencilSave(v); - } - } - - @Override - protected final void powder(final SnipeData v) { // will be used to paste later on - this.stencilPaste(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.custom("File loaded: " + this.filename); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Stencil brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b schem [optional: 'full' 'fill' or 'replace', with fill as default] [name] -- Loads the specified schematic. Allowed size of schematic is based on rank. Full/fill/replace must come first. Full = paste all blocks, fill = paste only into air blocks, replace = paste full blocks in only, but replace anything in their way."); - v.sendMessage(ChatColor.BLUE + "Size of the stencils you are allowed to paste depends on rank (member / lite, sniper, curator, admin)"); - return; - } else if (par[1].equalsIgnoreCase("full")) { - this.pasteOption = 0; - this.pasteParam = 1; - } else if (par[1].equalsIgnoreCase("fill")) { - this.pasteOption = 1; - this.pasteParam = 1; - } else if (par[1].equalsIgnoreCase("replace")) { - this.pasteOption = 2; - this.pasteParam = 1; - } - try { - this.filename = par[1 + this.pasteParam]; - final File file = new File("plugins/VoxelSniper/stencils/" + this.filename + ".vstencil"); - if (file.exists()) { - v.sendMessage(ChatColor.RED + "Stencil '" + this.filename + "' exists and was loaded. Make sure you are using powder if you do not want any chance of overwriting the file."); - } else { - v.sendMessage(ChatColor.AQUA + "Stencil '" + this.filename + "' does not exist. Ready to be saved to, but cannot be pasted."); - } - } catch (final Exception exception) { - v.sendMessage(ChatColor.RED + "You need to type a stencil name."); - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.stencil"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilListBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilListBrush.java deleted file mode 100644 index 40550c890..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilListBrush.java +++ /dev/null @@ -1,763 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.ChatColor; - -import java.io.BufferedInputStream; -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.util.HashMap; -import java.util.Scanner; - -public class StencilListBrush extends Brush { - private byte pasteOption = 1; // 0 = full, 1 = fill, 2 = replace - private String filename = "NoFileLoaded"; - private short x; - private short z; - private short y; - private short xRef; - private short zRef; - private short yRef; - private byte pasteParam = 0; - private HashMap stencilList = new HashMap<>(); - - public StencilListBrush() { - this.setName("StencilList"); - } - - private String readRandomStencil() { - double rand = Math.random() * (this.stencilList.size()); - final int choice = (int) rand; - return this.stencilList.get(choice); - } - - private void readStencilList() { - final File file = new File("plugins/VoxelSniper/stencilLists/" + this.filename + ".txt"); - if (file.exists()) { - try { - final Scanner scanner = new Scanner(file); - int counter = 0; - while (scanner.hasNext()) { - this.stencilList.put(counter, scanner.nextLine()); - counter++; - } - scanner.close(); - } catch (final Exception exception) { - exception.printStackTrace(); - } - } - } - - @SuppressWarnings("deprecation") - private void stencilPaste(final SnipeData v) { - if (this.filename.matches("NoFileLoaded")) { - v.sendMessage(ChatColor.RED + "You did not specify a filename for the list. This is required."); - return; - } - - final String stencilName = this.readRandomStencil(); - v.sendMessage(stencilName); - - final Undo undo = new Undo(); - final File file = new File("plugins/VoxelSniper/stencils/" + stencilName + ".vstencil"); - - if (file.exists()) { - try (final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)))){ - this.x = in.readShort(); - this.z = in.readShort(); - this.y = in.readShort(); - - this.xRef = in.readShort(); - this.zRef = in.readShort(); - this.yRef = in.readShort(); - - final int numRuns = in.readInt(); - // Something here that checks ranks using sanker'world thingie he added to Sniper and boots you out with error message if too big. - final int volume = this.x * this.y * this.z; - v.owner().getPlayer().sendMessage(ChatColor.AQUA + this.filename + " pasted. Volume is " + volume + " blocks."); - - int currX = -this.xRef; // so if your ref point is +5 x, you want to start pasting -5 blocks from the clicked point (the reference) to get the - // corner, for example. - int currZ = -this.zRef; - int currY = -this.yRef; - int id; - int data; - if (this.pasteOption == 0) { - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readByte() + 128); - data = (in.readByte() + 128); - for (int j = 0; j < numLoops; j++) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, data, false); - currX++; - if (currX == this.x - this.xRef) { - currX = -this.xRef; - currZ++; - if (currZ == this.z - this.zRef) { - currZ = -this.zRef; - currY++; - } - } - } - } else { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId((in.readByte() + 128), (in.readByte() + 128), false); - currX++; - if (currX == this.x - this.xRef) { - currX = -this.xRef; - currZ++; - if (currZ == this.z - this.zRef) { - currZ = -this.zRef; - currY++; - } - } - } - } - } else if (this.pasteOption == 1) { - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readByte() + 128); - data = (in.readByte() + 128); - for (int j = 0; j < numLoops; j++) { - if (id != 0 && this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).isEmpty()) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, (data), false); - } - currX++; - if (currX == this.x - this.xRef) { - currX = -this.xRef; - currZ++; - if (currZ == this.z - this.zRef) { - currZ = -this.zRef; - currY++; - } - } - } - } else { - id = (in.readByte() + 128); - data = (in.readByte() + 128); - if (id != 0 && this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).isEmpty()) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, (data), false); - } - currX++; - if (currX == this.x - this.xRef) { - currX = -this.xRef; - currZ++; - if (currZ == this.z - this.zRef) { - currZ = -this.zRef; - currY++; - } - } - } - } - } else { // replace - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readByte() + 128); - data = (in.readByte() + 128); - for (int j = 0; j < (numLoops); j++) { - if (id != 0) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, data, false); - } - currX++; - if (currX == this.x - this.xRef) { - currX = -this.xRef; - currZ++; - if (currZ == this.z - this.zRef) { - currZ = -this.zRef; - currY++; - } - } - } - } else { - id = (in.readByte() + 128); - data = (in.readByte() + 128); - if (id != 0) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, data, false); - } - currX++; - if (currX == this.x) { - currX = 0; - currZ++; - if (currZ == this.z) { - currZ = 0; - currY++; - } - } - } - } - } - in.close(); - v.owner().storeUndo(undo); - - } catch (final Exception exception) { - v.owner().getPlayer().sendMessage(ChatColor.RED + "Something went wrong."); - exception.printStackTrace(); - } - } else { - v.owner().getPlayer().sendMessage(ChatColor.RED + "You need to type a stencil name / your specified stencil does not exist."); - } - } - - @SuppressWarnings("deprecation") - private void stencilPaste180(final SnipeData v) { - if (this.filename.matches("NoFileLoaded")) { - v.owner().getPlayer().sendMessage(ChatColor.RED + "You did not specify a filename for the list. This is required."); - return; - } - - final String stencilName = this.readRandomStencil(); - - final Undo undo = new Undo(); - final File file = new File("plugins/VoxelSniper/stencils/" + stencilName + ".vstencil"); - - if (file.exists()) { - try (final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)))) { - - this.x = in.readShort(); - this.z = in.readShort(); - this.y = in.readShort(); - - this.xRef = in.readShort(); - this.zRef = in.readShort(); - this.yRef = in.readShort(); - - final int numRuns = in.readInt(); - // Something here that checks ranks using sanker'world thingie he added to Sniper and boots you out with error message if too big. - final int volume = this.x * this.y * this.z; - v.owner().getPlayer().sendMessage(ChatColor.AQUA + this.filename + " pasted. Volume is " + volume + " blocks."); - - int currX = +this.xRef; // so if your ref point is +5 x, you want to start pasting -5 blocks from the clicked point (the reference) to get the - // corner, for example. - int currZ = +this.zRef; - int currY = -this.yRef; - int id; - int data; - if (this.pasteOption == 0) { - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readByte() + 128); - data = (in.readByte() + 128); - for (int j = 0; j < numLoops; j++) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, data, false); - currX--; - if (currX == -this.x + this.xRef) { - currX = this.xRef; - currZ--; - if (currZ == -this.z + this.zRef) { - currZ = +this.zRef; - currY++; - } - } - } - } else { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId((in.readByte() + 128), (in.readByte() + 128), false); - currX--; - if (currX == -this.x + this.xRef) { - currX = this.xRef; - currZ--; - if (currZ == -this.z + this.zRef) { - currZ = +this.zRef; - currY++; - } - } - } - } - } else if (this.pasteOption == 1) { - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readByte() + 128); - data = (in.readByte() + 128); - for (int j = 0; j < numLoops; j++) { - if (id != 0 && this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).isEmpty()) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, (data), false); - } - currX--; - if (currX == -this.x + this.xRef) { - currX = this.xRef; - currZ--; - if (currZ == -this.z + this.zRef) { - currZ = +this.zRef; - currY++; - } - } - } - } else { - id = (in.readByte() + 128); - data = (in.readByte() + 128); - if (id != 0 && this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).isEmpty()) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, (data), false); - } - currX--; - if (currX == -this.x + this.xRef) { - currX = this.xRef; - currZ--; - if (currZ == -this.z + this.zRef) { - currZ = +this.zRef; - currY++; - } - } - } - } - } else { // replace - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readByte() + 128); - data = (in.readByte() + 128); - for (int j = 0; j < (numLoops); j++) { - if (id != 0) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, data, false); - } - currX--; - if (currX == -this.x + this.xRef) { - currX = this.xRef; - currZ--; - if (currZ == -this.z + this.zRef) { - currZ = +this.zRef; - currY++; - } - } - } - } else { - id = (in.readByte() + 128); - data = (in.readByte() + 128); - if (id != 0) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, data, false); - } - currX--; - if (currX == -this.x + this.xRef) { - currX = this.xRef; - currZ--; - if (currZ == -this.z + this.zRef) { - currZ = +this.zRef; - currY++; - } - } - } - } - } - in.close(); - v.owner().storeUndo(undo); - - } catch (final Exception exception) { - v.owner().getPlayer().sendMessage(ChatColor.RED + "Something went wrong."); - exception.printStackTrace(); - } - } else { - v.owner().getPlayer().sendMessage(ChatColor.RED + "You need to type a stencil name / your specified stencil does not exist."); - } - } - - @SuppressWarnings("deprecation") - private void stencilPaste270(final SnipeData v) { - if (this.filename.matches("NoFileLoaded")) { - v.owner().getPlayer().sendMessage(ChatColor.RED + "You did not specify a filename for the list. This is required."); - return; - } - - final String stencilName = this.readRandomStencil(); - - final Undo undo = new Undo(); - final File file = new File("plugins/VoxelSniper/stencils/" + stencilName + ".vstencil"); - - if (file.exists()) { - try (final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)))) { - - this.x = in.readShort(); - this.z = in.readShort(); - this.y = in.readShort(); - - this.xRef = in.readShort(); - this.zRef = in.readShort(); - this.yRef = in.readShort(); - - final int numRuns = in.readInt(); - // Something here that checks ranks using sanker'world thingie he added to Sniper and boots you out with error message if too big. - final int volume = this.x * this.y * this.z; - v.owner().getPlayer().sendMessage(ChatColor.AQUA + this.filename + " pasted. Volume is " + volume + " blocks."); - - int currX = +this.zRef; // so if your ref point is +5 x, you want to start pasting -5 blocks from the clicked point (the reference) to get the - // corner, for example. - int currZ = -this.xRef; - int currY = -this.yRef; - int id; - int data; - if (this.pasteOption == 0) { - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readByte() + 128); - data = (in.readByte() + 128); - for (int j = 0; j < numLoops; j++) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, data, false); - currZ++; - if (currZ == this.x - this.xRef) { - currZ = -this.xRef; - currX--; - if (currX == -this.z + this.zRef) { - currX = +this.zRef; - currY++; - } - } - } - } else { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId((in.readByte() + 128), (in.readByte() + 128), false); - currZ++; - currZ++; - if (currZ == this.x - this.xRef) { - currZ = -this.xRef; - currX--; - if (currX == -this.z + this.zRef) { - currX = +this.zRef; - currY++; - } - } - } - } - } else if (this.pasteOption == 1) { - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readByte() + 128); - data = (in.readByte() + 128); - for (int j = 0; j < numLoops; j++) { - if (id != 0 && this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).isEmpty()) { // no reason to paste air over - // air, and it prevents us - // most of the time from - // having to even check the - // block. - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, (data), false); - } - currZ++; - if (currZ == this.x - this.xRef) { - currZ = -this.xRef; - currX--; - if (currX == -this.z + this.zRef) { - currX = +this.zRef; - currY++; - } - } - } - } else { - id = (in.readByte() + 128); - data = (in.readByte() + 128); - if (id != 0 && this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).isEmpty()) { // no reason to paste air over - // air, and it prevents us most of - // the time from having to even - // check the block. - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, (data), false); - } - currZ++; - if (currZ == this.x - this.xRef) { - currZ = -this.xRef; - currX--; - if (currX == -this.z + this.zRef) { - currX = +this.zRef; - currY++; - } - } - } - } - } else { // replace - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readByte() + 128); - data = (in.readByte() + 128); - for (int j = 0; j < (numLoops); j++) { - if (id != 0) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, data, false); - } - currZ++; - if (currZ == this.x - this.xRef) { - currZ = -this.xRef; - currX--; - if (currX == -this.z + this.zRef) { - currX = +this.zRef; - currY++; - } - } - } - } else { - id = (in.readByte() + 128); - data = (in.readByte() + 128); - if (id != 0) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, data, false); - } - currZ++; - if (currZ == this.x - this.xRef) { - currZ = -this.xRef; - currX--; - if (currX == -this.z + this.zRef) { - currX = +this.zRef; - currY++; - } - } - } - } - } - in.close(); - v.owner().storeUndo(undo); - - } catch (final Exception exception) { - v.owner().getPlayer().sendMessage(ChatColor.RED + "Something went wrong."); - exception.printStackTrace(); - } - } else { - v.owner().getPlayer().sendMessage(ChatColor.RED + "You need to type a stencil name / your specified stencil does not exist."); - } - } - - @SuppressWarnings("deprecation") - private void stencilPaste90(final SnipeData v) { - if (this.filename.matches("NoFileLoaded")) { - v.sendMessage(ChatColor.RED + "You did not specify a filename for the list. This is required."); - return; - } - - final String stencilName = this.readRandomStencil(); - - final Undo undo = new Undo(); - final File file = new File("plugins/VoxelSniper/stencils/" + stencilName + ".vstencil"); - - if (file.exists()) { - try { - final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); - - this.x = in.readShort(); - this.z = in.readShort(); - this.y = in.readShort(); - - this.xRef = in.readShort(); - this.zRef = in.readShort(); - this.yRef = in.readShort(); - - final int numRuns = in.readInt(); - // Something here that checks ranks using sanker'world thingie he added to Sniper and boots you out with error message if too big. - final int volume = this.x * this.y * this.z; - v.sendMessage(ChatColor.AQUA + this.filename + " pasted. Volume is " + volume + " blocks."); - - int currX = -this.zRef; // so if your ref point is +5 x, you want to start pasting -5 blocks from the clicked point (the reference) to get the - // corner, for example. - int currZ = +this.xRef; - int currY = -this.yRef; - int id; - int data; - if (this.pasteOption == 0) { - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readByte() + 128); - data = (in.readByte() + 128); - for (int j = 0; j < numLoops; j++) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, data, false); - currZ--; - if (currZ == -this.x + this.xRef) { - currZ = this.xRef; - currX++; - if (currX == this.z - this.zRef) { - currX = -this.zRef; - currY++; - } - } - } - } else { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId((in.readByte() + 128), (in.readByte() + 128), false); - currZ--; - if (currZ == -this.x + this.xRef) { - currZ = this.xRef; - currX++; - if (currX == this.z - this.zRef) { - currX = -this.zRef; - currY++; - } - } - } - } - } else if (this.pasteOption == 1) { - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readByte() + 128); - data = (in.readByte() + 128); - for (int j = 0; j < numLoops; j++) { - if (id != 0 && this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).isEmpty()) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, (data), false); - } - currZ--; - if (currZ == -this.x + this.xRef) { - currZ = this.xRef; - currX++; - if (currX == this.z - this.zRef) { - currX = -this.zRef; - currY++; - } - } - } - } else { - id = (in.readByte() + 128); - data = (in.readByte() + 128); - if (id != 0 && this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).isEmpty()) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, (data), false); - } - currZ--; - if (currZ == -this.x + this.xRef) { - currZ = this.xRef; - currX++; - if (currX == this.z - this.zRef) { - currX = -this.zRef; - currY++; - } - } - } - } - } else { // replace - for (int i = 1; i < numRuns + 1; i++) { - if (in.readBoolean()) { - final int numLoops = in.readByte() + 128; - id = (in.readByte() + 128); - data = (in.readByte() + 128); - for (int j = 0; j < (numLoops); j++) { - if (id != 0) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, data, false); - } - currZ--; - if (currZ == -this.x + this.xRef) { - currZ = this.xRef; - currX++; - if (currX == this.z - this.zRef) { - currX = -this.zRef; - currY++; - } - } - } - } else { - id = (in.readByte() + 128); - data = (in.readByte() + 128); - if (id != 0) { - undo.put(this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ)); - this.clampY(this.getTargetBlock().getX() + currX, this.getTargetBlock().getY() + currY, this.getTargetBlock().getZ() + currZ).setTypeIdAndPropertyId(id, data, false); - } - currZ--; - if (currZ == -this.x + this.xRef) { - currZ = this.xRef; - currX++; - if (currX == this.z - this.zRef) { - currX = -this.zRef; - currY++; - } - } - } - } - } - in.close(); - v.owner().storeUndo(undo); - - } catch (final Exception exception) { - v.sendMessage(ChatColor.RED + "Something went wrong."); - exception.printStackTrace(); - } - } else { - v.owner().getPlayer().sendMessage(ChatColor.RED + "You need to type a stencil name / your specified stencil does not exist."); - } - } - - private void stencilPasteRotation(final SnipeData v) { - // just randomly chooses a rotation and then calls stencilPaste. - this.readStencilList(); - final double random = Math.random(); - if (random < 0.26) { - this.stencilPaste(v); - } else if (random < 0.51) { - this.stencilPaste90(v); - } else if (random < 0.76) { - this.stencilPaste180(v); - } else { - this.stencilPaste270(v); - } - - } - - @Override - protected final void arrow(final SnipeData v) { - this.stencilPaste(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.stencilPasteRotation(v); - } - - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.custom("File loaded: " + this.filename); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Stencil List brush Parameters:"); - v.sendMessage(ChatColor.AQUA + "/b schem [optional: 'full' 'fill' or 'replace', with fill as default] [name] -- Loads the specified stencil list. Full/fill/replace must come first. Full = paste all blocks, fill = paste only into air blocks, replace = paste full blocks in only, but replace anything in their way."); - return; - } else if (par[1].equalsIgnoreCase("full")) { - this.pasteOption = 0; - this.pasteParam = 1; - } else if (par[1].equalsIgnoreCase("fill")) { - this.pasteOption = 1; - this.pasteParam = 1; - } else if (par[1].equalsIgnoreCase("replace")) { - this.pasteOption = 2; - this.pasteParam = 1; - } - try { - this.filename = par[1 + this.pasteParam]; - final File file = new File("plugins/VoxelSniper/stencilLists/" + this.filename + ".txt"); - if (file.exists()) { - v.sendMessage(ChatColor.RED + "Stencil List '" + this.filename + "' exists and was loaded."); - this.readStencilList(); - } else { - v.sendMessage(ChatColor.AQUA + "Stencil List '" + this.filename + "' does not exist. This brush will not function without a valid stencil list."); - this.filename = "NoFileLoaded"; - } - } catch (final Exception exception) { - v.sendMessage(ChatColor.RED + "You need to type a stencil name."); - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.stencillist"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ThreePointCircleBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ThreePointCircleBrush.java deleted file mode 100644 index 3a5c5500f..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ThreePointCircleBrush.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; -import org.bukkit.util.NumberConversions; -import org.bukkit.util.Vector; - -public class ThreePointCircleBrush extends PerformBrush { - private Vector coordsOne; - private Vector coordsTwo; - private Vector coordsThree; - private Tolerance tolerance = Tolerance.DEFAULT; - - /** - * Default Constructor. - */ - public ThreePointCircleBrush() { - this.setName("3-Point Circle"); - } - - @Override - protected final void arrow(final SnipeData v) { - if (this.coordsOne == null) { - this.coordsOne = this.getTargetBlock().getLocation().toVector(); - v.sendMessage(ChatColor.GRAY + "First Corner set."); - } else if (this.coordsTwo == null) { - this.coordsTwo = this.getTargetBlock().getLocation().toVector(); - v.sendMessage(ChatColor.GRAY + "Second Corner set."); - } else if (this.coordsThree == null) { - this.coordsThree = this.getTargetBlock().getLocation().toVector(); - v.sendMessage(ChatColor.GRAY + "Third Corner set."); - } else { - this.coordsOne = this.getTargetBlock().getLocation().toVector(); - this.coordsTwo = null; - this.coordsThree = null; - v.sendMessage(ChatColor.GRAY + "First Corner set."); - } - } - - @Override - protected final void powder(final SnipeData v) { - if (this.coordsOne == null || this.coordsTwo == null || this.coordsThree == null) { - return; - } - - // Calculate triangle defining vectors - final Vector vectorOne = this.coordsTwo.clone(); - vectorOne.subtract(this.coordsOne); - final Vector vectorTwo = this.coordsThree.clone(); - vectorTwo.subtract(this.coordsOne); - final Vector vectorThree = this.coordsThree.clone(); - vectorThree.subtract(vectorTwo); - - // Redundant data check - if (vectorOne.length() == 0 || vectorTwo.length() == 0 || vectorThree.length() == 0 || vectorOne.angle(vectorTwo) == 0 || vectorOne.angle(vectorThree) == 0 || vectorThree.angle(vectorTwo) == 0) { - - v.sendMessage(ChatColor.RED + "ERROR: Invalid points, try again."); - this.coordsOne = null; - this.coordsTwo = null; - this.coordsThree = null; - return; - } - - // Calculate normal vector of the plane. - final Vector normalVector = vectorOne.clone(); - normalVector.crossProduct(vectorTwo); - - // Calculate constant term of the plane. - final double planeConstant = normalVector.getX() * this.coordsOne.getX() + normalVector.getY() * this.coordsOne.getY() + normalVector.getZ() * this.coordsOne.getZ(); - - final Vector midpointOne = this.coordsOne.getMidpoint(this.coordsTwo); - final Vector midpointTwo = this.coordsOne.getMidpoint(this.coordsThree); - - // Find perpendicular vectors to two sides in the plane - final Vector perpendicularOne = normalVector.clone(); - perpendicularOne.crossProduct(vectorOne); - final Vector perpendicularTwo = normalVector.clone(); - perpendicularTwo.crossProduct(vectorTwo); - - // determine value of parametric variable at intersection of two perpendicular bisectors - final Vector tNumerator = midpointTwo.clone(); - tNumerator.subtract(midpointOne); - tNumerator.crossProduct(perpendicularTwo); - final Vector tDenominator = perpendicularOne.clone(); - tDenominator.crossProduct(perpendicularTwo); - final double t = tNumerator.length() / tDenominator.length(); - - // Calculate Circumcenter and Brushcenter. - final Vector circumcenter = new Vector(); - circumcenter.copy(perpendicularOne); - circumcenter.multiply(t); - circumcenter.add(midpointOne); - - final Vector brushCenter = new Vector(Math.round(circumcenter.getX()), Math.round(circumcenter.getY()), Math.round(circumcenter.getZ())); - - // Calculate radius of circumcircle and determine brushsize - final double radius = circumcenter.distance(new Vector(this.coordsOne.getX(), this.coordsOne.getY(), this.coordsOne.getZ())); - final int brushSize = NumberConversions.ceil(radius) + 1; - - for (int x = -brushSize; x <= brushSize; x++) { - for (int y = -brushSize; y <= brushSize; y++) { - for (int z = -brushSize; z <= brushSize; z++) { - // Calculate distance from center - final double tempDistance = Math.pow(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2), .5); - - // gets corner-on blocks - final double cornerConstant = normalVector.getX() * (circumcenter.getX() + x) + normalVector.getY() * (circumcenter.getY() + y) + normalVector.getZ() * (circumcenter.getZ() + z); - - // gets center-on blocks - final double centerConstant = normalVector.getX() * (circumcenter.getX() + x + .5) + normalVector.getY() * (circumcenter.getY() + y + .5) + normalVector.getZ() * (circumcenter.getZ() + z + .5); - - // Check if point is within sphere and on plane (some tolerance given) - if (tempDistance <= radius && (Math.abs(cornerConstant - planeConstant) < this.tolerance.getValue() || Math.abs(centerConstant - planeConstant) < this.tolerance.getValue())) { - this.current.perform(this.clampY(brushCenter.getBlockX() + x, brushCenter.getBlockY() + y, brushCenter.getBlockZ() + z)); - } - - } - } - } - - v.sendMessage(ChatColor.GREEN + "Done."); - v.owner().storeUndo(this.current.getUndo()); - - // Reset Brush - this.coordsOne = null; - this.coordsTwo = null; - this.coordsThree = null; - - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - switch (this.tolerance) { - case ACCURATE: - vm.custom(ChatColor.GOLD + "Mode: Accurate"); - break; - case DEFAULT: - vm.custom(ChatColor.GOLD + "Mode: Default"); - break; - case SMOOTH: - vm.custom(ChatColor.GOLD + "Mode: Smooth"); - break; - default: - vm.custom(ChatColor.GOLD + "Mode: Unknown"); - break; - } - - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.YELLOW + "3-Point Circle Brush instructions: Select three corners with the arrow brush, then generate the Circle with the powder brush."); - StringBuilder toleranceOptions = new StringBuilder(); - for (final Tolerance tolerance : Tolerance.values()) { - if (toleranceOptions.length() > 0) { - toleranceOptions.append("|"); - } - toleranceOptions.append(tolerance.name().toLowerCase()); - } - v.sendMessage(ChatColor.GOLD + "/b tpc " + toleranceOptions + " -- Toggle the calculations to emphasize accuracy or smoothness"); - return; - } - - for (int i = 1; i < par.length; i++) { - final String parameter = par[i].toUpperCase(); - try { - this.tolerance = Tolerance.valueOf(parameter); - v.sendMessage(ChatColor.AQUA + "Brush set to " + this.tolerance.name().toLowerCase() + " tolerance."); - return; - } catch (final IllegalArgumentException exception) { - v.getVoxelMessage().brushMessage("No such tolerance."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.threepointcircle"; - } - - /** - * Enumeration on Tolerance values. - * - * @author MikeMatrix - */ - private enum Tolerance { - DEFAULT(1000), - ACCURATE(10), - SMOOTH(2000); - private int value; - - Tolerance(final int value) { - this.value = value; - } - - public int getValue() { - return this.value; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TreeSnipeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TreeSnipeBrush.java deleted file mode 100644 index f2ad22f41..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TreeSnipeBrush.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.boydti.fawe.bukkit.wrapper.AsyncBlockState; -import com.google.common.base.Objects; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import com.thevoxelbox.voxelsniper.util.UndoDelegate; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.TreeType; -import org.bukkit.block.BlockFace; - -public class TreeSnipeBrush extends Brush { - private TreeType treeType = TreeType.TREE; - - public TreeSnipeBrush() { - this.setName("Tree Snipe"); - } - - @SuppressWarnings("deprecation") - private void single(final SnipeData v, AsyncBlock targetBlock) { - UndoDelegate undoDelegate = new UndoDelegate(targetBlock.getWorld()); - AsyncBlock blockBelow = targetBlock.getRelative(BlockFace.DOWN); - AsyncBlockState currentState = blockBelow.getState(); - undoDelegate.setBlock(blockBelow); - blockBelow.setType(Material.GRASS); - this.getWorld().generateTree(targetBlock.getLocation(), this.treeType, undoDelegate); - Undo undo = undoDelegate.getUndo(); - blockBelow.setTypeIdAndPropertyId(currentState.getTypeId(), currentState.getPropertyId(), true); - undo.put(blockBelow); - v.owner().storeUndo(undo); - } - - private int getYOffset() { - for (int i = 1; i < (getTargetBlock().getWorld().getMaxHeight() - 1 - getTargetBlock().getY()); i++) { - if (Objects.equal(getTargetBlock().getRelative(0, i + 1, 0).getType(), Material.AIR)) { - return i; - } - } - return 0; - } - - private void printTreeType(final Message vm) { - String printout = ""; - - boolean delimiterHelper = true; - for (final TreeType treeType : TreeType.values()) { - if (delimiterHelper) { - delimiterHelper = false; - } else { - printout += ", "; - } - printout += ((treeType.equals(this.treeType)) ? ChatColor.GRAY + treeType.name().toLowerCase() : ChatColor.DARK_GRAY + treeType.name().toLowerCase()) + ChatColor.WHITE; - } - - vm.custom(printout); - } - - @Override - protected final void arrow(final SnipeData v) { - AsyncBlock targetBlock = getTargetBlock().getRelative(0, getYOffset(), 0); - this.single(v, targetBlock); - } - - @Override - protected final void powder(final SnipeData v) { - this.single(v, getTargetBlock()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - this.printTreeType(vm); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - if (par[i].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Tree snipe brush:"); - v.sendMessage(ChatColor.AQUA + "/b t treetype"); - this.printTreeType(v.getVoxelMessage()); - return; - } - try { - this.treeType = TreeType.valueOf(par[i].toUpperCase()); - this.printTreeType(v.getVoxelMessage()); - } catch (final IllegalArgumentException exception) { - v.getVoxelMessage().brushMessage("No such tree type."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.treesnipe"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TriangleBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TriangleBrush.java deleted file mode 100644 index ac0a7d276..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TriangleBrush.java +++ /dev/null @@ -1,293 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; - -public class TriangleBrush extends PerformBrush { - private double[] coordsOne = new double[3]; // Three corners - private double[] coordsTwo = new double[3]; - private double[] coordsThree = new double[3]; - private int cornernumber = 1; - private double[] currentCoords = new double[3]; // For loop tracking - private double[] vectorOne = new double[3]; // Point 1 to 2 - private double[] vectorTwo = new double[3]; // Point 1 to 3 - private double[] vectorThree = new double[3]; // Point 2 to 3, for area calculations - private double[] normalVector = new double[3]; - - public TriangleBrush() { - this.setName("Triangle"); - } - - private void triangleA(final SnipeData v) { - switch (this.cornernumber) { - case 1: - this.coordsOne[0] = this.getTargetBlock().getX() + .5 * this.getTargetBlock().getX() / Math.abs(this.getTargetBlock().getX()); // I hate you sometimes, Notch. Really? Every quadrant is - // different? - this.coordsOne[1] = this.getTargetBlock().getY() + .5; - this.coordsOne[2] = this.getTargetBlock().getZ() + .5 * this.getTargetBlock().getZ() / Math.abs(this.getTargetBlock().getZ()); - this.cornernumber = 2; - v.sendMessage(ChatColor.GRAY + "First Corner set."); - break; - case 2: - this.coordsTwo[0] = this.getTargetBlock().getX() + .5 * this.getTargetBlock().getX() / Math.abs(this.getTargetBlock().getX()); // I hate you sometimes, Notch. Really? Every quadrant is - // different? - this.coordsTwo[1] = this.getTargetBlock().getY() + .5; - this.coordsTwo[2] = this.getTargetBlock().getZ() + .5 * this.getTargetBlock().getZ() / Math.abs(this.getTargetBlock().getZ()); - this.cornernumber = 3; - v.sendMessage(ChatColor.GRAY + "Second Corner set."); - break; - case 3: - this.coordsThree[0] = this.getTargetBlock().getX() + .5 * this.getTargetBlock().getX() / Math.abs(this.getTargetBlock().getX()); // I hate you sometimes, Notch. Really? Every quadrant is - // different? - this.coordsThree[1] = this.getTargetBlock().getY() + .5; - this.coordsThree[2] = this.getTargetBlock().getZ() + .5 * this.getTargetBlock().getZ() / Math.abs(this.getTargetBlock().getZ()); - this.cornernumber = 1; - v.sendMessage(ChatColor.GRAY + "Third Corner set."); - break; - default: - break; - - } - - } - - private void triangleP(final SnipeData v) { - double lengthOne; - double lengthTwo; - double lengthThree; - double heronBig; - - // Calculate slope vectors - for (int i = 0; i < 3; i++) { - this.vectorOne[i] = this.coordsTwo[i] - this.coordsOne[i]; - this.vectorTwo[i] = this.coordsThree[i] - this.coordsOne[i]; - this.vectorThree[i] = this.coordsThree[i] - this.coordsTwo[i]; - } - - // Calculate the cross product of vectorone and vectortwo - this.normalVector[0] = this.vectorOne[1] * this.vectorTwo[2] - this.vectorOne[2] * this.vectorTwo[1]; - this.normalVector[1] = this.vectorOne[2] * this.vectorTwo[0] - this.vectorOne[0] * this.vectorTwo[2]; - this.normalVector[2] = this.vectorOne[0] * this.vectorTwo[1] - this.vectorOne[1] * this.vectorTwo[0]; - - // Calculate magnitude of slope vectors - lengthOne = Math.pow(Math.pow(this.vectorOne[0], 2) + Math.pow(this.vectorOne[1], 2) + Math.pow(this.vectorOne[2], 2), .5); - lengthTwo = Math.pow(Math.pow(this.vectorTwo[0], 2) + Math.pow(this.vectorTwo[1], 2) + Math.pow(this.vectorTwo[2], 2), .5); - lengthThree = Math.pow(Math.pow(this.vectorThree[0], 2) + Math.pow(this.vectorThree[1], 2) + Math.pow(this.vectorThree[2], 2), .5); - - // Bigger vector determines brush size - final int brushSize = (int) Math.ceil(Math.max(lengthOne, lengthTwo)); - - // Calculate constant term - final double planeConstant = this.normalVector[0] * this.coordsOne[0] + this.normalVector[1] * this.coordsOne[1] + this.normalVector[2] * this.coordsOne[2]; - - // Calculate the area of the full triangle - heronBig = .25 * Math.pow(Math.pow(Math.pow(lengthOne, 2) + Math.pow(lengthTwo, 2) + Math.pow(lengthThree, 2), 2) - 2 * (Math.pow(lengthOne, 4) + Math.pow(lengthTwo, 4) + Math.pow(lengthThree, 4)), .5); - - if (lengthOne == 0 || lengthTwo == 0 || (this.coordsOne[0] == 0 && this.coordsOne[1] == 0 && this.coordsOne[2] == 0) || (this.coordsTwo[0] == 0 && this.coordsTwo[1] == 0 && this.coordsTwo[2] == 0) || (this.coordsThree[0] == 0 && this.coordsThree[1] == 0 && this.coordsThree[2] == 0)) { - v.sendMessage(ChatColor.RED + "ERROR: Invalid corners, please try again."); - } else { - // Make the Changes - final double[] cVectorOne = new double[3]; - final double[] cVectorTwo = new double[3]; - final double[] cVectorThree = new double[3]; - - for (int y = -brushSize; y <= brushSize; y++) { // X DEPENDENT - for (int z = -brushSize; z <= brushSize; z++) { - this.currentCoords[1] = this.coordsOne[1] + y; - this.currentCoords[2] = this.coordsOne[2] + z; - this.currentCoords[0] = (planeConstant - this.normalVector[1] * this.currentCoords[1] - this.normalVector[2] * this.currentCoords[2]) / this.normalVector[0]; - - // Area of triangle currentcoords, coordsone, coordstwo - for (int i = 0; i < 3; i++) { - cVectorOne[i] = this.coordsTwo[i] - this.coordsOne[i]; - cVectorTwo[i] = this.currentCoords[i] - this.coordsOne[i]; - cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i]; - } - double cLengthOne = Math.pow(Math.pow(cVectorOne[0], 2) + Math.pow(cVectorOne[1], 2) + Math.pow(cVectorOne[2], 2), .5); - double cLengthTwo = Math.pow(Math.pow(cVectorTwo[0], 2) + Math.pow(cVectorTwo[1], 2) + Math.pow(cVectorTwo[2], 2), .5); - double cLengthThree = Math.pow(Math.pow(cVectorThree[0], 2) + Math.pow(cVectorThree[1], 2) + Math.pow(cVectorThree[2], 2), .5); - - final double heronOne = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); - - // Area of triangle currentcoords, coordsthree, coordstwo - for (int i = 0; i < 3; i++) { - cVectorOne[i] = this.coordsTwo[i] - this.coordsThree[i]; - cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i]; - cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i]; - } - cLengthOne = Math.pow(Math.pow(cVectorOne[0], 2) + Math.pow(cVectorOne[1], 2) + Math.pow(cVectorOne[2], 2), .5); - cLengthTwo = Math.pow(Math.pow(cVectorTwo[0], 2) + Math.pow(cVectorTwo[1], 2) + Math.pow(cVectorTwo[2], 2), .5); - cLengthThree = Math.pow(Math.pow(cVectorThree[0], 2) + Math.pow(cVectorThree[1], 2) + Math.pow(cVectorThree[2], 2), .5); - final double heronTwo = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); - - // Area of triangle currentcoords, coordsthree, coordsone - for (int i = 0; i < 3; i++) { - cVectorOne[i] = this.coordsOne[i] - this.coordsThree[i]; - cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i]; - cVectorThree[i] = this.currentCoords[i] - this.coordsOne[i]; - } - cLengthOne = Math.pow(Math.pow(cVectorOne[0], 2) + Math.pow(cVectorOne[1], 2) + Math.pow(cVectorOne[2], 2), .5); - cLengthTwo = Math.pow(Math.pow(cVectorTwo[0], 2) + Math.pow(cVectorTwo[1], 2) + Math.pow(cVectorTwo[2], 2), .5); - cLengthThree = Math.pow(Math.pow(cVectorThree[0], 2) + Math.pow(cVectorThree[1], 2) + Math.pow(cVectorThree[2], 2), .5); - final double heronThree = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); - - final double barycentric = (heronOne + heronTwo + heronThree) / heronBig; - - if (barycentric <= 1.1) { - - this.current.perform(this.clampY((int) this.currentCoords[0], (int) this.currentCoords[1], (int) this.currentCoords[2])); - - } - - } - } // END X DEPENDENT - - for (int x = -brushSize; x <= brushSize; x++) { // Y DEPENDENT - for (int z = -brushSize; z <= brushSize; z++) { - this.currentCoords[0] = this.coordsOne[0] + x; - this.currentCoords[2] = this.coordsOne[2] + z; - this.currentCoords[1] = (planeConstant - this.normalVector[0] * this.currentCoords[0] - this.normalVector[2] * this.currentCoords[2]) / this.normalVector[1]; - - // Area of triangle currentcoords, coordsone, coordstwo - for (int i = 0; i < 3; i++) { - cVectorOne[i] = this.coordsTwo[i] - this.coordsOne[i]; - cVectorTwo[i] = this.currentCoords[i] - this.coordsOne[i]; - cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i]; - } - double cLengthOne = Math.pow(Math.pow(cVectorOne[0], 2) + Math.pow(cVectorOne[1], 2) + Math.pow(cVectorOne[2], 2), .5); - double cLengthTwo = Math.pow(Math.pow(cVectorTwo[0], 2) + Math.pow(cVectorTwo[1], 2) + Math.pow(cVectorTwo[2], 2), .5); - double cLengthThree = Math.pow(Math.pow(cVectorThree[0], 2) + Math.pow(cVectorThree[1], 2) + Math.pow(cVectorThree[2], 2), .5); - - final double heronOne = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); - - // Area of triangle currentcoords, coordsthree, coordstwo - for (int i = 0; i < 3; i++) { - cVectorOne[i] = this.coordsTwo[i] - this.coordsThree[i]; - cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i]; - cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i]; - } - cLengthOne = Math.pow(Math.pow(cVectorOne[0], 2) + Math.pow(cVectorOne[1], 2) + Math.pow(cVectorOne[2], 2), .5); - cLengthTwo = Math.pow(Math.pow(cVectorTwo[0], 2) + Math.pow(cVectorTwo[1], 2) + Math.pow(cVectorTwo[2], 2), .5); - cLengthThree = Math.pow(Math.pow(cVectorThree[0], 2) + Math.pow(cVectorThree[1], 2) + Math.pow(cVectorThree[2], 2), .5); - final double heronTwo = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); - - // Area of triangle currentcoords, coordsthree, coordsone - for (int i = 0; i < 3; i++) { - cVectorOne[i] = this.coordsOne[i] - this.coordsThree[i]; - cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i]; - cVectorThree[i] = this.currentCoords[i] - this.coordsOne[i]; - } - cLengthOne = Math.pow(Math.pow(cVectorOne[0], 2) + Math.pow(cVectorOne[1], 2) + Math.pow(cVectorOne[2], 2), .5); - cLengthTwo = Math.pow(Math.pow(cVectorTwo[0], 2) + Math.pow(cVectorTwo[1], 2) + Math.pow(cVectorTwo[2], 2), .5); - cLengthThree = Math.pow(Math.pow(cVectorThree[0], 2) + Math.pow(cVectorThree[1], 2) + Math.pow(cVectorThree[2], 2), .5); - final double heronThree = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); - - final double barycentric = (heronOne + heronTwo + heronThree) / heronBig; - - if (barycentric <= 1.1) { - - this.current.perform(this.clampY((int) this.currentCoords[0], (int) this.currentCoords[1], (int) this.currentCoords[2])); - - } - - } - } // END Y DEPENDENT - for (int x = -brushSize; x <= brushSize; x++) { // Z DEPENDENT - for (int y = -brushSize; y <= brushSize; y++) { - this.currentCoords[0] = this.coordsOne[0] + x; - this.currentCoords[1] = this.coordsOne[1] + y; - this.currentCoords[2] = (planeConstant - this.normalVector[0] * this.currentCoords[0] - this.normalVector[1] * this.currentCoords[1]) / this.normalVector[2]; - - // Area of triangle currentcoords, coordsone, coordstwo - for (int i = 0; i < 3; i++) { - cVectorOne[i] = this.coordsTwo[i] - this.coordsOne[i]; - cVectorTwo[i] = this.currentCoords[i] - this.coordsOne[i]; - cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i]; - } - double cLengthOne = Math.pow(Math.pow(cVectorOne[0], 2) + Math.pow(cVectorOne[1], 2) + Math.pow(cVectorOne[2], 2), .5); - double cLengthTwo = Math.pow(Math.pow(cVectorTwo[0], 2) + Math.pow(cVectorTwo[1], 2) + Math.pow(cVectorTwo[2], 2), .5); - double cLengthThree = Math.pow(Math.pow(cVectorThree[0], 2) + Math.pow(cVectorThree[1], 2) + Math.pow(cVectorThree[2], 2), .5); - - final double heronOne = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); - - // Area of triangle currentcoords, coordsthree, coordstwo - for (int i = 0; i < 3; i++) { - cVectorOne[i] = this.coordsTwo[i] - this.coordsThree[i]; - cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i]; - cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i]; - } - cLengthOne = Math.pow(Math.pow(cVectorOne[0], 2) + Math.pow(cVectorOne[1], 2) + Math.pow(cVectorOne[2], 2), .5); - cLengthTwo = Math.pow(Math.pow(cVectorTwo[0], 2) + Math.pow(cVectorTwo[1], 2) + Math.pow(cVectorTwo[2], 2), .5); - cLengthThree = Math.pow(Math.pow(cVectorThree[0], 2) + Math.pow(cVectorThree[1], 2) + Math.pow(cVectorThree[2], 2), .5); - final double heronTwo = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); - - // Area of triangle currentcoords, coordsthree, coordsone - for (int i = 0; i < 3; i++) { - cVectorOne[i] = this.coordsOne[i] - this.coordsThree[i]; - cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i]; - cVectorThree[i] = this.currentCoords[i] - this.coordsOne[i]; - } - cLengthOne = Math.pow(Math.pow(cVectorOne[0], 2) + Math.pow(cVectorOne[1], 2) + Math.pow(cVectorOne[2], 2), .5); - cLengthTwo = Math.pow(Math.pow(cVectorTwo[0], 2) + Math.pow(cVectorTwo[1], 2) + Math.pow(cVectorTwo[2], 2), .5); - cLengthThree = Math.pow(Math.pow(cVectorThree[0], 2) + Math.pow(cVectorThree[1], 2) + Math.pow(cVectorThree[2], 2), .5); - final double heronThree = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); - - final double barycentric = (heronOne + heronTwo + heronThree) / heronBig; - - // VoxelSniper.log.info("Bary: "+barycentric+", hb: "+heronbig+", h1: "+heronone+", h2: "+herontwo+", h3: "+heronthree); - - if (barycentric <= 1.1) { - this.current.perform(this.clampY((int) this.currentCoords[0], (int) this.currentCoords[1], (int) this.currentCoords[2])); - } - } - } // END Z DEPENDENT - - v.owner().storeUndo(this.current.getUndo()); - - } - - // RESET BRUSH - this.coordsOne[0] = 0; - this.coordsOne[1] = 0; - this.coordsOne[2] = 0; - this.coordsTwo[0] = 0; - this.coordsTwo[1] = 0; - this.coordsTwo[2] = 0; - this.coordsThree[0] = 0; - this.coordsThree[1] = 0; - this.coordsThree[2] = 0; - - this.cornernumber = 1; - - } - - @Override - protected final void arrow(final SnipeData v) { - this.triangleA(v); - } - - @Override - protected final void powder(final SnipeData v) { // Add a point - this.triangleP(v); - } - - - @Override - public final void info(final Message vm) { // Make the triangle - vm.brushName(this.getName()); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - if (par[1].equalsIgnoreCase("info")) { - v.sendMessage(ChatColor.GOLD + "Triangle Brush instructions: Select three corners with the arrow brush, then generate the triangle with the powder brush."); - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.triangle"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/UnderlayBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/UnderlayBrush.java deleted file mode 100644 index db38e29ff..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/UnderlayBrush.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.registry.BlockMaterial; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.ChatColor; - -public class UnderlayBrush extends PerformBrush { - private static final int DEFAULT_DEPTH = 3; - private int depth = DEFAULT_DEPTH; - private boolean allBlocks = false; - - public UnderlayBrush() { - this.setName("Underlay (Reverse Overlay)"); - } - - @SuppressWarnings("deprecation") - private void underlay(final SnipeData v) { - final int[][] memory = new int[v.getBrushSize() * 2 + 1][v.getBrushSize() * 2 + 1]; - final double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2); - - for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) { - for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) { - for (int y = this.getTargetBlock().getY(); y < this.getTargetBlock().getY() + this.depth; y++) { // start scanning from the height you clicked at - if (memory[x + v.getBrushSize()][z + v.getBrushSize()] != 1) { // if haven't already found the surface in this column - if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared) { // if inside of the column... - if (!this.allBlocks) { // if the override parameter has not been activated, go to the switch that filters out manmade stuff. - int id = this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z); - BlockMaterial mat = BlockTypes.get(id).getMaterial(); - if (!mat.isReplacedDuringPlacement() && mat.isFullCube()) { - for (int d = 0; (d < this.depth); d++) { - if (!this.clampY(this.getTargetBlock().getX() + x, y + d, this.getTargetBlock().getZ() + z).isEmpty()) { - this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y + d, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify in - // parameters - memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column. - } - } - break; - - } - } else { - for (int d = 0; (d < this.depth); d++) { - if (!this.clampY(this.getTargetBlock().getX() + x, y + d, this.getTargetBlock().getZ() + z).isEmpty()) { - this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y + d, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify in - // parameters - memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column. - } - } - } - } - - } - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - private void underlay2(final SnipeData v) { - final int[][] memory = new int[v.getBrushSize() * 2 + 1][v.getBrushSize() * 2 + 1]; - final double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2); - - for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) { - for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) { - for (int y = this.getTargetBlock().getY(); y < this.getTargetBlock().getY() + this.depth; y++) { // start scanning from the height you clicked at - if (memory[x + v.getBrushSize()][z + v.getBrushSize()] != 1) { // if haven't already found the surface in this column - if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared) { // if inside of the column... - - if (!this.allBlocks) { // if the override parameter has not been activated, go to the switch that filters out manmade stuff. - - int id = this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z); - BlockMaterial mat = BlockTypes.get(id).getMaterial(); - if (!mat.isReplacedDuringPlacement() && mat.isFullCube()) { - for (int d = -1; (d < this.depth - 1); d++) { - this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y - d, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify in - // parameters - memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column. - } - break; - } - } else { - for (int d = -1; (d < this.depth - 1); d++) { - this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y - d, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify in - // parameters - memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column. - } - } - } - } - } - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - public final void arrow(final SnipeData v) { - this.underlay(v); - } - - @Override - public final void powder(final SnipeData v) { - this.underlay2(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - for (int i = 1; i < par.length; i++) { - if (par[i].equalsIgnoreCase("info")) { - v.owner().getPlayer().sendMessage(ChatColor.GOLD + "Reverse Overlay brush parameters:"); - v.owner().getPlayer().sendMessage(ChatColor.AQUA + "d[number] (ex: d3) The number of blocks thick to change."); - v.owner().getPlayer().sendMessage(ChatColor.BLUE + "all (ex: /b reover all) Sets the brush to affect ALL materials"); - if (this.depth < 1) { - this.depth = 1; - } - return; - } - if (par[i].startsWith("d")) { - this.depth = Integer.parseInt(par[i].replace("d", "")); - v.owner().getPlayer().sendMessage(ChatColor.AQUA + "Depth set to " + this.depth); - } else if (par[i].startsWith("all")) { - this.allBlocks = true; - v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Will underlay over any block." + this.depth); - } else if (par[i].startsWith("some")) { - this.allBlocks = false; - v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Will underlay only natural block types." + this.depth); - } else { - v.owner().getPlayer().sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.underlay"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoltMeterBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoltMeterBrush.java deleted file mode 100644 index 2ded259b0..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoltMeterBrush.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; - -public class VoltMeterBrush extends Brush { - - public VoltMeterBrush() { - this.setName("VoltMeter"); - } - - private void data(final SnipeData v) { - final AsyncBlock block = this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ()); - final int data = block.getPropertyId(); - v.sendMessage(ChatColor.AQUA + "Blocks until repeater needed: " + data); - } - - private void volt(final SnipeData v) { - final Block block = this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ()); - final boolean indirect = block.isBlockIndirectlyPowered(); - final boolean direct = block.isBlockPowered(); - v.sendMessage(ChatColor.AQUA + "Direct Power? " + direct + " Indirect Power? " + indirect); - v.sendMessage(ChatColor.BLUE + "Top Direct? " + block.isBlockFacePowered(BlockFace.UP) + " Top Indirect? " + block.isBlockFaceIndirectlyPowered(BlockFace.UP)); - v.sendMessage(ChatColor.BLUE + "Bottom Direct? " + block.isBlockFacePowered(BlockFace.DOWN) + " Bottom Indirect? " + block.isBlockFaceIndirectlyPowered(BlockFace.DOWN)); - v.sendMessage(ChatColor.BLUE + "East Direct? " + block.isBlockFacePowered(BlockFace.EAST) + " East Indirect? " + block.isBlockFaceIndirectlyPowered(BlockFace.EAST)); - v.sendMessage(ChatColor.BLUE + "West Direct? " + block.isBlockFacePowered(BlockFace.WEST) + " West Indirect? " + block.isBlockFaceIndirectlyPowered(BlockFace.WEST)); - v.sendMessage(ChatColor.BLUE + "North Direct? " + block.isBlockFacePowered(BlockFace.NORTH) + " North Indirect? " + block.isBlockFaceIndirectlyPowered(BlockFace.NORTH)); - v.sendMessage(ChatColor.BLUE + "South Direct? " + block.isBlockFacePowered(BlockFace.SOUTH) + " South Indirect? " + block.isBlockFaceIndirectlyPowered(BlockFace.SOUTH)); - } - - @Override - protected final void arrow(final SnipeData v) { - this.volt(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.data(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.brushMessage("Right click with arrow to see if blocks/faces are powered. Powder measures wire current."); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.voltmeter"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelBrush.java deleted file mode 100644 index 473e7e469..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelBrush.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; - - -public class VoxelBrush extends PerformBrush { - - public VoxelBrush() { - this.setName("Voxel"); - } - - private void voxel(final SnipeData v) { - for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) { - for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) { - for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) { - this.current.perform(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + z, this.getTargetBlock().getZ() + y)); - } - } - } - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.voxel(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.voxel(v); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.voxel"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscBrush.java deleted file mode 100644 index 11f0c780d..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscBrush.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; - - -public class VoxelDiscBrush extends PerformBrush { - - public VoxelDiscBrush() { - this.setName("Voxel Disc"); - } - - private void disc(final SnipeData v, AsyncBlock targetBlock) { - for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) { - for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) { - current.perform(targetBlock.getRelative(x, 0, z)); - } - } - v.owner().storeUndo(this.current.getUndo()); - } - - @Override - protected final void arrow(final SnipeData v) { - this.disc(v, this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.disc(v, this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.voxeldisc"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscFaceBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscFaceBrush.java deleted file mode 100644 index d6b795863..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscFaceBrush.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; - - -public class VoxelDiscFaceBrush extends PerformBrush { - - public VoxelDiscFaceBrush() { - this.setName("Voxel Disc Face"); - } - - private void disc(final SnipeData v, Block targetBlock) { - for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) { - for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) { - this.current.perform(this.clampY(targetBlock.getX() + x, targetBlock.getY(), targetBlock.getZ() + y)); - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - private void discNS(final SnipeData v, Block targetBlock) { - for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) { - for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) { - this.current.perform(this.clampY(targetBlock.getX() + x, targetBlock.getY() + y, targetBlock.getZ())); - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - private void discEW(final SnipeData v, Block targetBlock) { - for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) { - for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) { - this.current.perform(this.clampY(targetBlock.getX(), targetBlock.getY() + x, targetBlock.getZ() + y)); - } - } - - v.owner().storeUndo(this.current.getUndo()); - } - - private void pre(final SnipeData v, final BlockFace bf, Block targetBlock) { - if (bf == null) { - return; - } - switch (bf) { - case NORTH: - case SOUTH: - this.discNS(v, targetBlock); - break; - - case EAST: - case WEST: - this.discEW(v, targetBlock); - break; - - case UP: - case DOWN: - this.disc(v, targetBlock); - break; - - default: - break; - } - } - - @Override - protected final void arrow(final SnipeData v) { - this.pre(v, this.getTargetBlock().getFace(this.getLastBlock()), this.getTargetBlock()); - } - - @Override - protected final void powder(final SnipeData v) { - this.pre(v, this.getTargetBlock().getFace(this.getLastBlock()), this.getLastBlock()); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - vm.size(); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.voxeldiscface"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WallSider.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WallSider.java deleted file mode 100644 index 6f086f76c..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WallSider.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.ChatColor; -import org.bukkit.block.Block; -import org.bukkit.util.Vector; - -public class WallSider extends Brush { - - private static String[] facings = new String[]{"north", "east", "south", "west", "relative to player"}; - private short c; - private short d; - private double e; - private boolean f; - private boolean g; - private boolean h; - - public WallSider() { - this.c = 4; - this.d = 1; - this.e = 0.0; - this.setName("WallSider"); - } - - private void a(final SnipeData snipeData, final Block block, final boolean b) { - final double n = (snipeData.getBrushSize() + this.e) * (snipeData.getBrushSize() + this.e); - final Vector vector; - final Vector clone = (vector = block.getLocation().toVector()).clone(); - int c; - if (this.c == 4) { - double n2; - if ((n2 = (snipeData.owner().getPlayer().getLocation().getYaw() - 90.0f) % 360.0f) < 0.0) { - n2 += 360.0; - } - c = ((0.0 >= n2 && n2 < 45.0) ? 2 : ((45.0 >= n2 && n2 < 135.0) ? 3 : ((135.0 >= n2 && n2 < 225.0) ? 0 : ((225.0 >= n2 && n2 < 315.0) ? 1 : ((315.0 >= n2 && n2 < 360.0) ? 2 : -1))))); - } else { - c = this.c; - } - int n3 = c; - if (b) { - n3 = (short) ((n3 + 2) % 4); - } - int n4 = 98; - if (n3 == 0 || n3 == 2) { - n4 = 97; - } - for (int i = -snipeData.getBrushSize(); i <= snipeData.getBrushSize(); ++i) { - if (n4 == 97) { - clone.setX(vector.getX() + i); - } else { - clone.setZ(vector.getZ() + i); - } - for (int j = -snipeData.getBrushSize(); j <= snipeData.getBrushSize(); ++j) { - clone.setY(vector.getY() + j); - if (vector.distanceSquared(clone) <= n) { - for (short n5 = 0; n5 < this.d; ++n5) { - if (n4 == 97) { - clone.setZ(vector.getZ() + ((n3 == 2) ? n5 : (-n5))); - } else { - clone.setX(vector.getX() + ((n3 == 1) ? n5 : (-n5))); - } - final AsyncBlock block2 = this.getWorld().getBlockAt(clone.getBlockX(), clone.getBlockY(), clone.getBlockZ()); - if ((this.f && block2.getTypeId() == snipeData.getReplaceId()) || (!this.f && (block2.getTypeId() != 0 || this.g))) { - block2.setTypeId(snipeData.getVoxelId()); - } - } - if (n4 == 97) { - clone.setZ(vector.getZ()); - } else { - clone.setX(vector.getX()); - } - } - } - } - } - - @Override - protected final void arrow(final SnipeData snipeData) { - this.a(snipeData, this.getTargetBlock(), false); - } - - @Override - protected final void powder(final SnipeData snipeData) { - this.a(snipeData, this.getTargetBlock(), true); - } - - public final void parameters(final String[] array, final SnipeData snipeData) { - for (int i = 1; i < array.length; ++i) { - final String lowerCase; - if ((lowerCase = array[i].toLowerCase()).startsWith("d")) { - this.d = (short) Integer.parseInt(lowerCase.replace("d", "")); - snipeData.sendMessage(ChatColor.AQUA + "Depth set to " + this.d + " blocks"); - } else if (lowerCase.startsWith("s")) { - this.c = (short) Integer.parseInt(lowerCase.replace("s", "")); - if (this.c > 4 || this.c < 0) { - this.c = 4; - } - snipeData.sendMessage(ChatColor.AQUA + "Orientation set to " + facings[this.c]); - } else if (lowerCase.startsWith("true")) { - this.e = 0.5; - snipeData.sendMessage(ChatColor.AQUA + "True circle mode ON."); - } else if (lowerCase.startsWith("false")) { - this.e = 0.0; - snipeData.sendMessage(ChatColor.AQUA + "True circle mode OFF."); - } else if (lowerCase.startsWith("air")) { - this.g = true; - snipeData.sendMessage(ChatColor.AQUA + "Including air."); - } else if (lowerCase.startsWith("mm")) { - this.f = true; - snipeData.sendMessage(ChatColor.AQUA + "Replacing block."); - } - } - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.wallsider"; - } - - @Override - public void info(Message vm) { - // TODO Auto-generated method stub - - } - -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WarpBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WarpBrush.java deleted file mode 100644 index e242a5625..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WarpBrush.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - This file is part of VoxelSniper, licensed under the MIT License (MIT). - - Copyright (c) The VoxelBox - Copyright (c) contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - */ -package com.thevoxelbox.voxelsniper.brush; - -import com.boydti.fawe.object.RunnableVal; -import com.boydti.fawe.util.TaskManager; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -public class WarpBrush extends Brush { - - public WarpBrush() { - this.setName("Warp"); - } - - @Override - public final void info(final Message vm) { - vm.brushName(this.getName()); - } - - @Override - protected final void arrow(final SnipeData v) { - Player player = v.owner().getPlayer(); - Location location = this.getLastBlock().getLocation(); - Location playerLocation = player.getLocation(); - location.setPitch(playerLocation.getPitch()); - location.setYaw(playerLocation.getYaw()); - location.setWorld(Bukkit.getWorld(location.getWorld().getName())); - TaskManager.IMP.sync(new RunnableVal() { - @Override - public void run(Object value) { - player.teleport(location); - } - }); - } - - @Override - protected final void powder(final SnipeData v) { - Player player = v.owner().getPlayer(); - Location location = this.getLastBlock().getLocation(); - Location playerLocation = player.getLocation(); - location.setPitch(playerLocation.getPitch()); - location.setYaw(playerLocation.getYaw()); - location.setWorld(Bukkit.getWorld(location.getWorld().getName())); - TaskManager.IMP.sync(new RunnableVal() { - @Override - public void run(Object value) { - player.teleport(location); - } - }); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.warp"; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PatternPerformer.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PatternPerformer.java deleted file mode 100644 index 7ef13cfbb..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PatternPerformer.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.boydti.fawe.object.pattern.PatternTraverser; -import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector3; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - -public class PatternPerformer extends vPerformer { - private String info; - private Pattern pattern; - private Extent extent; - private final MutableBlockVector3 mutable = new MutableBlockVector3(); - - @Override - public void info(Message vm) { - vm.performerName(this.name + ": " + info); - vm.voxel(); - } - - @Override - public void init(SnipeData snipeData) { - this.w = snipeData.getWorld(); - this.extent = snipeData.getExtent(); - this.info = snipeData.getPatternInfo(); - this.pattern = snipeData.getPattern(); - new PatternTraverser(pattern).reset(extent); - } - - @Override - public void perform(AsyncBlock block) { - BlockVector3 bv = mutable.setComponents(block.getX(), block.getY(), block.getZ()); - try { - pattern.apply(extent, bv, bv); - } catch (WorldEditException e) { - throw new RuntimeException(e); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformBrush.java deleted file mode 100644 index 5a874f194..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformBrush.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - This file is part of VoxelSniper, licensed under the MIT License (MIT). -

- Copyright (c) The VoxelBox - Copyright (c) contributors -

- Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: -

- The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. -

- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.sk89q.worldedit.function.pattern.Pattern; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.brush.Brush; -import com.thevoxelbox.voxelsniper.event.SniperBrushChangedEvent; -import org.bukkit.Bukkit; - -import java.util.Arrays; - -public abstract class PerformBrush extends Brush implements Performer { - protected vPerformer current = new pMaterial(); - - public PerformBrush() { - } - - public static Class inject() { - return PerformBrush.class; - } - - public vPerformer getCurrentPerformer() { - return this.current; - } - - public void parse(String[] args, SnipeData v) { - String handle = args[0]; - if (PerformerE.has(handle)) { - vPerformer p = PerformerE.getPerformer(handle); - if (p != null) { - this.current = p; - SniperBrushChangedEvent event = new SniperBrushChangedEvent(v.owner(), v.owner().getCurrentToolId(), this, this); - Bukkit.getPluginManager().callEvent(event); - this.info(v.getVoxelMessage()); - this.current.info(v.getVoxelMessage()); - if (args.length > 1) { - String[] additionalArguments = Arrays.copyOfRange(args, 1, args.length); - this.parameters(this.hackTheArray(additionalArguments), v); - } - } else { - this.parameters(this.hackTheArray(args), v); - } - } else { - this.parameters(this.hackTheArray(args), v); - } - - } - - private String[] hackTheArray(String[] args) { - String[] returnValue = new String[args.length + 1]; - int i = 0; - - for (int argsLength = args.length; i < argsLength; ++i) { - String arg = args[i]; - returnValue[i + 1] = arg; - } - - return returnValue; - } - - public void initP(SnipeData v) { - Pattern pattern = v.getPattern(); - if (pattern != null) { - if (!(current instanceof PatternPerformer)) { - current = new PatternPerformer(); - } - } else if (current instanceof PatternPerformer) { - current = new pMaterial(); - } - this.current.init(v); - this.current.setUndo(); - } - - public void showInfo(Message vm) { - this.current.info(vm); - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/Performer.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/Performer.java deleted file mode 100644 index 94d4094d8..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/Performer.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public interface Performer { - - void parse(String[] args, SnipeData v); - - void showInfo(Message vm); -} 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 deleted file mode 100644 index 76faef954..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformerE.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import org.bukkit.ChatColor; - -import java.lang.reflect.InvocationTargetException; -import java.util.Map; -import java.util.TreeMap; -import java.util.logging.Level; -import java.util.logging.Logger; - - - -/* The m/i/c system of naming performers: [replacement-option][extras] - * - * placement-option is mandatory and can be material(m) [for /v], ink(i) [for /vi] or combo(c) [for both] - * replacement-option is optional and can be m [for /vr], i [for /vir] or c [for both] - * extras is optional and can be update(u) [for graphical glitch], physics(p) [for no-phys] or up [for both] - * - * new extra: n = no undo - * - * 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 complaining about keystrokes) - * - */ - -/* This enum is getting REALLY Long, would it be possible to algorithmically generate the full performer - * from the pieces? So if the performer name is of the for m*, you'll setTypeId whereas if it is of the - * form c* you'd setTypeIdAndPropertyId? Similarly, if the performer is of the form *p, any setTypeId's or setTypeIdAndPropertyId's - * will be set to false instead of true? The middle bits might be tougher, being of the form _m* perhaps? - * Regex to the rescue, am I right? - Giltwist - */ - -public enum PerformerE { - - MATERIAL(pMaterial.class, "m", "material"), - MATERIAL_NOPHYS(pMaterialNoPhys.class, "mp", "mat-nophys"), - MAT_MAT(pMatMat.class, "mm", "mat-mat"), - MAT_MAT_NOPHYS(pMatMatNoPhys.class, "mmp", "mat-mat-nophys"), - MAT_INK(pMatInk.class, "mi", "mat-ink"), - MAT_INK_NOPHYS(pMatInkNoPhys.class, "mip", "mat-ink-nophys"), - MAT_COMBO(pMatCombo.class, "mc", "mat-combo"), - MAT_COMBO_NOPHYS(pMatComboNophys.class, "mcp", "mat-combo-nophys"), - INK(pInk.class, "i", "ink"), - INK_MAT(pInkMat.class, "im", "ink-mat"), - INK_INK(pInkInk.class, "ii", "ink-ink"), - INK_COMBO(pInkCombo.class, "ic", "ink-combo"), - INK_INK_NOPHYS(pInkInkNoPhys.class, "iip", "ink-ink-nophys"), - INK_NOPHYS(pInkNoPhys.class, "ip", "ink-nophys"), - INK_MAT_NOPHYS(pInkMatNoPhys.class, "imp", "ink-mat-nophys"), - INK_COMBO_NOPHYS(pInkComboNoPhys.class, "icp", "ink-combo-nophys"), - COMBO(pCombo.class, "c", "combo"), - COMBO_NOPHYS(pComboNoPhys.class, "cp", "combo-nophys"), - COMBO_MAT(pComboMat.class, "cm", "combo-mat"), - COMBO_MAT_NOPHYS(pComboMatNoPhys.class, "cmp", "combo-mat-nophys"), - COMBO_INK(pComboInk.class, "ci", "combo-ink"), - COMBO_INK_NOPHYS(pComboInkNoPhys.class, "cip", "combo-ink-nophys"), - COMBO_COMBO(pComboCombo.class, "cc", "combo-combo"), - COMBO_COMBO_NOPHYS(pComboComboNoPhys.class, "ccp", "combo-combo-nophys"), - EXCLUDE_MATERIAL(pExcludeMat.class, "xm", "exclude-mat"), - EXCLUDE_INK(pExcludeInk.class, "xi", "exclude-ink"), - EXCLUDE_COMBO(pExcludeCombo.class, "xc", "exclude-combo"), - INCLUDE_MATERIAL(pIncludeMat.class, "nm", "include-mat"), - INCLUDE_INK(pIncludeInk.class, "ni", "include-ink"), - INCLUDE_COMBO(pIncludeCombo.class, "nc", "include-combo"), - MAT_NO_UNDO(pNoUndo.class, "noundo", "noundo"); - //Other Performers which don't exist yet but are required for a full set of possibilities that actually could potentially do something: - //List does not include any no-physics, unless materials are being placed (or combo), or any update unless ink is being placed (or combo) -Gavjenks - - //MAT_MAT_UPDATE( pMatMatUpdate.class, "mmu", "mat-mat-update" ), // place mat, replace mat, graphical update - //MAT_COMBO_UPDATE( pMatComboUpdate.class, "mcu", "mat-combo-update" ), // place mat, replace combo, graphical update - //MAT_COMBO_NOPHYS_UPDATE( pMatComboNoPhysUpdate.class, "mcup", "mat-combo-update-nophys"), // place mat, replace combo, update, no physics - //MAT_INK_UPDATE( pMatInkUpdate.class, "miu", "mat-ink-update"), // place mat, replace ink, graphical update - //MAT_INK_NOPHYS_UPDATE( pMatInkNoPhysUpdate.class, "miup", "mat-ink-update-nophys"), // place mat, replace ink, graphical update no physics - //INK_MAT_UPDATE( pInkMatUpdate.class, "imu", "ink-mat-update"), // place ink, replace mat, graphical update - //INK_INK_UPDATE( pInkInkUpdate.class, "iiu", "ink-ink-update"), // place ink, replace ink, graphical update - //INK_COMBO_UPDATE( pInkComboUpdate.class, "icu", "ink-combo-update"), // place ink, replace combo, graphical update - //COMBO_MAT_UPDATE( pComboMatUpdate.class, "cmu", "combo-mat-update"), // place combo, replace mat, graphical update - //COMBO_MAT_NOPHYS_UPDATE( pComboMatNoPhysUpdate.class, "cmup", "combo-mat-update-nophys"), // place combo, replace mat, graphical update, no physics - //COMBO_INK_UPDATE( pComboInkUpdate.class, "ciu", "combo-ink-update"), // place combo, replace ink, graphical update - //COMBO_INK_NOPHYS_UPDATE( pComboInkNoPhysUpdate.class, "ciup", "combo-ink-update-nophys"), // place combo, replace ink, graphical update, no physics - //COMBO_COMBO_UPDATE( pComboComboUpdate.class, "ccu", "combo-combo-update"), // place combo, replace combo, graphical update - //COMBO_COMBO_NOPHYS_UPDATE(pComboComboNoPhysUpdate.class, "ccup", "combo-combo-update-nophys"),// place combo, replace combo, graphical update, no physics - - public static String performer_list_short = ""; - public static String performer_list_long = ""; - private static Map performers; - private static Map long_names; - - static { - performers = new TreeMap<>(); - long_names = new TreeMap<>(); - - for (PerformerE pe : values()) { - performers.put(pe.short_name, pe.getPerformer()); - long_names.put(pe.long_name, pe.short_name); - performer_list_short = performer_list_short + ChatColor.GREEN + pe.short_name + ChatColor.RED + ", "; - performer_list_long = performer_list_long + ChatColor.GREEN + pe.long_name + ChatColor.RED + ", "; - } - performer_list_short = performer_list_short.substring(0, performer_list_short.length() - 2); - performer_list_long = performer_list_long.substring(0, performer_list_long.length() - 2); - } - - private Class pclass; - private String short_name; - private String long_name; - - PerformerE(Class c, String s, String l) { - pclass = c; - short_name = s; - long_name = l; - } - - public static vPerformer getPerformer(String s) { - if (performers.containsKey(s)) { - return performers.get(s); - } else { - return performers.get(long_names.get(s)); - } - } - - public static boolean has(String s) { - return performers.containsKey(s); - } - - private vPerformer getPerformer() { - vPerformer p; - try { - try { - p = pclass.getConstructor().newInstance(); - return p; - } catch (InstantiationException | IllegalAccessException | InvocationTargetException | IllegalArgumentException ex) { - Logger.getLogger(PerformerE.class.getName()).log(Level.SEVERE, null, ex); - } - } catch (NoSuchMethodException | SecurityException ex) { - Logger.getLogger(PerformerE.class.getName()).log(Level.SEVERE, null, ex); - } - return null; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pCombo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pCombo.java deleted file mode 100644 index 19697b650..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pCombo.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - -public class pCombo extends vPerformer { - - private int i; - private int d; - - public pCombo() { - name = "Combo"; - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.data(); - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - i = v.getVoxelId(); - d = v.getPropertyId(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - h.put(b); - b.setTypeIdAndPropertyId(i, d, true); - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboCombo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboCombo.java deleted file mode 100644 index ec39d01a4..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboCombo.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pComboCombo extends vPerformer { - - private int d; - private int dr; - private int i; - private int ir; - - public pComboCombo() { - name = "Combo-Combo"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - dr = v.getReplaceData(); - i = v.getVoxelId(); - ir = v.getReplaceId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.replace(); - vm.data(); - vm.replaceData(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() == ir && b.getPropertyId() == dr) { - h.put(b); - b.setTypeIdAndPropertyId(i, d, true); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboComboNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboComboNoPhys.java deleted file mode 100644 index 0034ab6c3..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboComboNoPhys.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pComboComboNoPhys extends vPerformer { - - private int d; - private int dr; - private int i; - private int ir; - - public pComboComboNoPhys() { - name = "Combo-Combo No-Physics"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - dr = v.getReplaceData(); - i = v.getVoxelId(); - ir = v.getReplaceId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.replace(); - vm.data(); - vm.replaceData(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() == ir && b.getPropertyId() == dr) { - h.put(b); - b.setTypeId(i); - b.setPropertyId(d); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInk.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInk.java deleted file mode 100644 index c4ad7e7f9..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInk.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pComboInk extends vPerformer { - - private int d; - private int dr; - private int i; - - public pComboInk() { - name = "Combo-Ink"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - dr = v.getReplaceData(); - i = v.getVoxelId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.data(); - vm.replaceData(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getPropertyId() == dr) { - h.put(b); - b.setTypeIdAndPropertyId(i, d, true); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInkNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInkNoPhys.java deleted file mode 100644 index baa1e7c41..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInkNoPhys.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pComboInkNoPhys extends vPerformer { - - private int d; - private int dr; - private int i; - - public pComboInkNoPhys() { - name = "Combo-Ink, No Physics"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - dr = v.getReplaceData(); - i = v.getVoxelId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.data(); - vm.replaceData(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getPropertyId() == dr) { - h.put(b); - b.setTypeIdAndPropertyId(i, d, false); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMat.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMat.java deleted file mode 100644 index c0fff13f1..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMat.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pComboMat extends vPerformer { - - private int d; - private int i; - private int ir; - - public pComboMat() { - name = "Combo-Mat"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - i = v.getVoxelId(); - ir = v.getReplaceId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.replace(); - vm.data(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() == ir) { - h.put(b); - b.setTypeIdAndPropertyId(i, d, true); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMatNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMatNoPhys.java deleted file mode 100644 index 86f95a92c..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMatNoPhys.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pComboMatNoPhys extends vPerformer { - - private int d; - private int i; - private int ir; - - public pComboMatNoPhys() { - name = "Combo-Mat, No Physics"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - i = v.getVoxelId(); - ir = v.getReplaceId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.replace(); - vm.data(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() == ir) { - h.put(b); - b.setTypeIdAndPropertyId(i, d, false); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoPhys.java deleted file mode 100644 index f591a1c50..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoPhys.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pComboNoPhys extends vPerformer { - - private int i; - private int d; - - public pComboNoPhys() { - name = "Combo NoPhysics"; - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.data(); - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - i = v.getVoxelId(); - d = v.getPropertyId(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - h.put(b); - b.setTypeIdAndPropertyId(i, d, false); - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoUndo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoUndo.java deleted file mode 100644 index c1d08f3e0..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoUndo.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pComboNoUndo extends vPerformer { - - private int i; - private int d; - - public pComboNoUndo() { - name = "Combo, No-Undo"; // made name more descriptive - Giltwist - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - i = v.getVoxelId(); - d = v.getPropertyId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.data(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() != i || b.getPropertyId() != d) { - b.setTypeIdAndPropertyId(i, d, true); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeCombo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeCombo.java deleted file mode 100644 index 1531dac22..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeCombo.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.util.VoxelList; - - -public class pExcludeCombo extends vPerformer { - - private VoxelList excludeList; - private int id; - private int data; - - public pExcludeCombo() { - name = "Exclude Combo"; - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxelList(); - vm.voxel(); - vm.data(); - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - id = v.getVoxelId(); - data = v.getPropertyId(); - excludeList = v.getVoxelList(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (!excludeList.contains(b.getBlockData())) { - h.put(b); - b.setTypeIdAndPropertyId(id, data, true); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeInk.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeInk.java deleted file mode 100644 index 412a608e9..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeInk.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.util.VoxelList; - - -public class pExcludeInk extends vPerformer { - - private VoxelList excludeList; - private int data; - - public pExcludeInk() { - name = "Exclude Ink"; - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxelList(); - vm.data(); - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - data = v.getPropertyId(); - excludeList = v.getVoxelList(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (!excludeList.contains(b.getBlockData())) { - h.put(b); - b.setPropertyId(data); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeMat.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeMat.java deleted file mode 100644 index 4eef243f8..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeMat.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.util.VoxelList; - - -public class pExcludeMat extends vPerformer { - - private VoxelList excludeList; - private int id; - - public pExcludeMat() { - name = "Exclude Material"; - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxelList(); - vm.voxel(); - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - id = v.getVoxelId(); - excludeList = v.getVoxelList(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (!excludeList.contains(b.getBlockData())) { - h.put(b); - b.setTypeId(id); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeCombo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeCombo.java deleted file mode 100644 index 58134f7ae..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeCombo.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.util.VoxelList; - - -public class pIncludeCombo extends vPerformer { - - private VoxelList includeList; - private int id; - private int data; - - public pIncludeCombo() { - name = "Include Combo"; - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxelList(); - vm.voxel(); - vm.data(); - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - id = v.getVoxelId(); - data = v.getPropertyId(); - includeList = v.getVoxelList(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (includeList.contains(b.getBlockData())) { - h.put(b); - b.setTypeIdAndPropertyId(id, data, true); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeInk.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeInk.java deleted file mode 100644 index f8828956a..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeInk.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.util.VoxelList; - - -public class pIncludeInk extends vPerformer { - - private VoxelList includeList; - private int data; - - public pIncludeInk() { - name = "Include Ink"; - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxelList(); - vm.data(); - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - data = v.getPropertyId(); - includeList = v.getVoxelList(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (includeList.contains(b.getBlockData())) { - h.put(b); - b.setPropertyId(data); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeMat.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeMat.java deleted file mode 100644 index 4684581fb..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeMat.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.util.VoxelList; - - -public class pIncludeMat extends vPerformer { - - private VoxelList includeList; - private int id; - - public pIncludeMat() { - name = "Include Material"; - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxelList(); - vm.voxel(); - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - id = v.getVoxelId(); - includeList = v.getVoxelList(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (includeList.contains(b.getBlockData())) { - h.put(b); - b.setTypeId(id); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInk.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInk.java deleted file mode 100644 index 4cec04c81..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInk.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pInk extends vPerformer { - - private int d; - - public pInk() { - name = "Ink"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.data(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - h.put(b); - b.setPropertyId(d); - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkCombo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkCombo.java deleted file mode 100644 index 81c603e21..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkCombo.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pInkCombo extends vPerformer { - - private int d; - private int dr; - private int ir; - - public pInkCombo() { - name = "Ink-Combo"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - dr = v.getReplaceData(); - ir = v.getReplaceId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.replace(); - vm.data(); - vm.replaceData(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() == ir && b.getPropertyId() == dr) { - h.put(b); - b.setPropertyId(d); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkComboNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkComboNoPhys.java deleted file mode 100644 index f3172ab95..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkComboNoPhys.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pInkComboNoPhys extends vPerformer { - - private int d; - private int dr; - private int ir; - - public pInkComboNoPhys() { - name = "Ink-Combo, No Physics"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - dr = v.getReplaceData(); - ir = v.getReplaceId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.replace(); - vm.data(); - vm.replaceData(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() == ir && b.getPropertyId() == dr) { - h.put(b); - b.setPropertyId(d); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInk.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInk.java deleted file mode 100644 index cf986654a..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInk.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pInkInk extends vPerformer { - - private int d; - private int dr; - - public pInkInk() { - name = "Ink-Ink"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - dr = v.getReplaceData(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.data(); - vm.replaceData(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getPropertyId() == dr) { - h.put(b); - b.setPropertyId(d); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInkNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInkNoPhys.java deleted file mode 100644 index dc1da32d8..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInkNoPhys.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pInkInkNoPhys extends vPerformer { - - private int d; - private int dr; - - public pInkInkNoPhys() { - name = "Ink-Ink, No Physics"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - dr = v.getReplaceData(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.data(); - vm.replaceData(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getPropertyId() == dr) { - h.put(b); - b.setPropertyId(d); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMat.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMat.java deleted file mode 100644 index 41a4b213f..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMat.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pInkMat extends vPerformer { - - private int d; - private int ir; - - public pInkMat() { - name = "Ink-Mat"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - ir = v.getReplaceId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.data(); - vm.replace(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() == ir) { - h.put(b); - b.setPropertyId(d); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMatNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMatNoPhys.java deleted file mode 100644 index a6c932c5f..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMatNoPhys.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pInkMatNoPhys extends vPerformer { - - private int d; - private int ir; - - public pInkMatNoPhys() { - name = "Ink-Mat, No Physics"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - ir = v.getReplaceId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.data(); - vm.replace(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() == ir) { - h.put(b); - b.setPropertyId(d); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoPhys.java deleted file mode 100644 index b27941c90..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoPhys.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pInkNoPhys extends vPerformer { - - private int d; - - public pInkNoPhys() { - name = "Ink, No Physics"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.data(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - h.put(b); - b.setPropertyId(d); - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoUndo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoUndo.java deleted file mode 100644 index 0cc598220..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoUndo.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pInkNoUndo extends vPerformer { - - private int d; - - public pInkNoUndo() { - name = "Ink, No-Undo"; // made name more descriptive - Giltwist - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - d = v.getPropertyId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.data(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getPropertyId() != d) { - b.setPropertyId(d); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatCombo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatCombo.java deleted file mode 100644 index 1cc30bbdf..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatCombo.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pMatCombo extends vPerformer { - - private int dr; - private int i; - private int ir; - - public pMatCombo() { - name = "Mat-Combo"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - dr = v.getReplaceData(); - i = v.getVoxelId(); - ir = v.getReplaceId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.replace(); - vm.replaceData(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() == ir && b.getPropertyId() == dr) { - h.put(b); - b.setTypeId(i); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatComboNophys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatComboNophys.java deleted file mode 100644 index 00ed5b0b2..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatComboNophys.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pMatComboNophys extends vPerformer { - - private int dr; - private int i; - private int ir; - - public pMatComboNophys() { - name = "Mat-Combo, No Physics"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - dr = v.getReplaceData(); - i = v.getVoxelId(); - ir = v.getReplaceId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.replace(); - vm.replaceData(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() == ir && b.getPropertyId() == dr) { - h.put(b); - b.setTypeId(i); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInk.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInk.java deleted file mode 100644 index d0d8dedf8..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInk.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pMatInk extends vPerformer { - - private int i; - private int dr; - - public pMatInk() { - name = "Mat-Ink"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - i = v.getVoxelId(); - dr = v.getReplaceData(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.replaceData(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getPropertyId() == dr) { - h.put(b); - b.setTypeId(i); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInkNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInkNoPhys.java deleted file mode 100644 index bb825b048..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInkNoPhys.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pMatInkNoPhys extends vPerformer { - - private int i; - private int dr; - - public pMatInkNoPhys() { - name = "Mat-Ink, No Physics"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - i = v.getVoxelId(); - dr = v.getReplaceData(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.replaceData(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getPropertyId() == dr) { - h.put(b); - b.setTypeId(i); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMat.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMat.java deleted file mode 100644 index 6faf085aa..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMat.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pMatMat extends vPerformer { - - private int i; - private int r; - - public pMatMat() { - name = "Mat-Mat"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - i = v.getVoxelId(); - r = v.getReplaceId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.replace(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() == r) { - h.put(b); - b.setTypeId(i); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMatNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMatNoPhys.java deleted file mode 100644 index 66f4760c3..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMatNoPhys.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pMatMatNoPhys extends vPerformer { - - private int i; - private int r; - - public pMatMatNoPhys() { - name = "Mat-Mat No-Physics"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - i = v.getVoxelId(); - r = v.getReplaceId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - vm.replace(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() == r) { - h.put(b); - b.setTypeId(i); - } - } - - @Override - public boolean isUsingReplaceMaterial() { - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterial.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterial.java deleted file mode 100644 index cf5e8d25e..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterial.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pMaterial extends vPerformer { - - private int i; - - public pMaterial() { - name = "Material"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - i = v.getVoxelId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() != i) { - h.put(b); - b.setTypeId(i); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterialNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterialNoPhys.java deleted file mode 100644 index 5471b0003..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterialNoPhys.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pMaterialNoPhys extends vPerformer { - private int i; - - public pMaterialNoPhys() { - name = "Set, No-Physics"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - i = v.getVoxelId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() != i) { - h.put(b); - b.setTypeId(i); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pNoUndo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pNoUndo.java deleted file mode 100644 index 0c524cc1e..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pNoUndo.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; - - -public class pNoUndo extends vPerformer { - - private int i; - - public pNoUndo() { - name = "BOMB SQUAD"; - } - - @Override - public void init(SnipeData v) { - w = v.getWorld(); - i = v.getVoxelId(); - } - - @Override - public void info(Message vm) { - vm.performerName(name); - vm.voxel(); - } - - @SuppressWarnings("deprecation") - @Override - public void perform(AsyncBlock b) { - if (b.getTypeId() != i) { - b.setTypeId(i); - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/vPerformer.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/vPerformer.java deleted file mode 100644 index 9f2be4a83..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/vPerformer.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.thevoxelbox.voxelsniper.brush.perform; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.thevoxelbox.voxelsniper.Message; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.World; - - -public abstract class vPerformer { - - public String name = "Performer"; - protected Undo h; - protected World w; - - public abstract void info(Message vm); - - public abstract void init(SnipeData v); - - public void setUndo() { - h = new Undo(); - } - - public abstract void perform(AsyncBlock b); - - public Undo getUndo() { - Undo temp = h; - h = null; - return temp; - } - - public boolean isUsingReplaceMaterial() { - return false; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushCommand.java deleted file mode 100644 index 4cf614640..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushCommand.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import com.thevoxelbox.voxelsniper.brush.IBrush; -import com.thevoxelbox.voxelsniper.brush.perform.Performer; -import com.thevoxelbox.voxelsniper.event.SniperBrushChangedEvent; -import com.thevoxelbox.voxelsniper.event.SniperBrushSizeChangedEvent; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import java.util.Arrays; - -public class VoxelBrushCommand extends VoxelCommand { - public VoxelBrushCommand(final VoxelSniper plugin) { - super("VoxelBrush", plugin); - setIdentifier("b"); - setPermission("voxelsniper.sniper"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - String currentToolId = sniper.getCurrentToolId(); - SnipeData snipeData = sniper.getSnipeData(currentToolId); - - if (args == null || args.length == 0) { - sniper.previousBrush(currentToolId); - sniper.displayInfo(); - return true; - } else if (args.length > 0) { - try { - int newBrushSize = Integer.parseInt(args[0]); - if (!player.hasPermission("voxelsniper.ignorelimitations") && newBrushSize > plugin.getVoxelSniperConfiguration().getLiteSniperMaxBrushSize()) { - player.sendMessage("Size is restricted to " + plugin.getVoxelSniperConfiguration().getLiteSniperMaxBrushSize() + " for you."); - newBrushSize = plugin.getVoxelSniperConfiguration().getLiteSniperMaxBrushSize(); - } - int originalSize = snipeData.getBrushSize(); - snipeData.setBrushSize(newBrushSize); - SniperBrushSizeChangedEvent event = new SniperBrushSizeChangedEvent(sniper, currentToolId, originalSize, snipeData.getBrushSize()); - Bukkit.getPluginManager().callEvent(event); - snipeData.getVoxelMessage().size(); - return true; - } catch (NumberFormatException ignored) { - } - - Class brush = plugin.getBrushManager().getBrushForHandle(args[0]); - if (brush != null) { - IBrush originalBrush = sniper.getBrush(currentToolId); - sniper.setBrush(currentToolId, brush); - - if (args.length > 1) { - IBrush currentBrush = sniper.getBrush(currentToolId); - if (currentBrush instanceof Performer) { - String[] parameters = Arrays.copyOfRange(args, 1, args.length); - ((Performer) currentBrush).parse(parameters, snipeData); - return true; - } else { - String[] parameters = hackTheArray(Arrays.copyOfRange(args, 1, args.length)); - currentBrush.parameters(parameters, snipeData); - return true; - } - } - SniperBrushChangedEvent event = new SniperBrushChangedEvent(sniper, currentToolId, originalBrush, sniper.getBrush(currentToolId)); - sniper.displayInfo(); - return true; - } else { - player.sendMessage("Couldn't find Brush for brush handle \"" + args[0] + "\""); - return true; - } - } - return false; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushToolCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushToolCommand.java deleted file mode 100644 index 3549a1d69..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushToolCommand.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.thevoxelbox.voxelsniper.SnipeAction; -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -public class VoxelBrushToolCommand extends VoxelCommand { - public VoxelBrushToolCommand(final VoxelSniper plugin) { - super("VoxelBrushTool", plugin); - setIdentifier("btool"); - setPermission("voxelsniper.sniper"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - - if (args != null && args.length > 0) { - if (args[0].equalsIgnoreCase("assign")) { - SnipeAction action; - if (args[1].equalsIgnoreCase("arrow")) { - action = SnipeAction.ARROW; - } else if (args[1].equalsIgnoreCase("powder")) { - action = SnipeAction.GUNPOWDER; - } else { - player.sendMessage("/btool assign "); - return true; - } - - if (args.length == 3 && args[2] != null && !args[2].isEmpty()) { - Material itemInHand = player.getItemInHand().getType(); - if (sniper.setTool(args[2], action, itemInHand)) { - player.sendMessage(itemInHand.name() + " has been assigned to '" + args[2] + "' as action " + action.name() + "."); - } else { - player.sendMessage("Couldn't assign tool."); - } - return true; - } - } else if (args[0].equalsIgnoreCase("remove")) { - if (args.length == 2 && args[1] != null && !args[1].isEmpty()) { - sniper.removeTool(args[1]); - return true; - } else { - Material itemInHand = player.getItemInHand().getType(); - if (sniper.getCurrentToolId() == null) { - player.sendMessage("Can't unassign default tool."); - return true; - } - sniper.removeTool(sniper.getCurrentToolId(), itemInHand); - return true; - } - } - } - player.sendMessage("/btool assign "); - player.sendMessage("/btool remove [toolid]"); - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelCenterCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelCenterCommand.java deleted file mode 100644 index a4f0a114d..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelCenterCommand.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -public class VoxelCenterCommand extends VoxelCommand { - public VoxelCenterCommand(final VoxelSniper plugin) { - super("VoxelCenter", plugin); - setIdentifier("vc"); - setPermission("voxelsniper.sniper"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - - try { - int center = Integer.parseInt(args[0]); - snipeData.setcCen(center); - snipeData.getVoxelMessage().center(); - return true; - } catch (final Exception exception) { - player.sendMessage(ChatColor.RED + "Invalid input."); - return true; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelChunkCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelChunkCommand.java deleted file mode 100644 index 9fd3ce608..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelChunkCommand.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.entity.Player; - -public class VoxelChunkCommand extends VoxelCommand { - public VoxelChunkCommand(final VoxelSniper plugin) { - super("VoxelChunk", plugin); - setIdentifier("vchunk"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - player.getWorld().refreshChunk(player.getLocation().getBlockX(), player.getLocation().getBlockZ()); - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelDefaultCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelDefaultCommand.java deleted file mode 100644 index f1f068a6d..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelDefaultCommand.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -public class VoxelDefaultCommand extends VoxelCommand { - public VoxelDefaultCommand(final VoxelSniper plugin) { - super("VoxelDefault", plugin); - setIdentifier("d"); - setPermission("voxelsniper.sniper"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - - sniper.reset(sniper.getCurrentToolId()); - player.sendMessage(ChatColor.AQUA + "Brush settings reset to their default values."); - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelGoToCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelGoToCommand.java deleted file mode 100644 index 5ca8055dd..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelGoToCommand.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -public class VoxelGoToCommand extends VoxelCommand { - public VoxelGoToCommand(final VoxelSniper plugin) { - super("VoxelGoTo", plugin); - setIdentifier("goto"); - setPermission("voxelsniper.sniper"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - try { - final int x = Integer.parseInt(args[0]); - final int z = Integer.parseInt(args[1]); - player.teleport(new Location(player.getWorld(), x, player.getWorld().getHighestBlockYAt(x, z), z)); - player.sendMessage(ChatColor.GREEN + "Woosh!"); - return true; - } catch (final Exception exception) { - player.sendMessage(ChatColor.RED + "Invalid syntax."); - return true; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelHeightCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelHeightCommand.java deleted file mode 100644 index 3b6977561..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelHeightCommand.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -public class VoxelHeightCommand extends VoxelCommand { - public VoxelHeightCommand(final VoxelSniper plugin) { - super("VoxelHeight", plugin); - setIdentifier("vh"); - setPermission("voxelsniper.sniper"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - - try { - int height = Integer.parseInt(args[0]); - snipeData.setVoxelHeight(height); - snipeData.getVoxelMessage().height(); - return true; - } catch (final Exception exception) { - player.sendMessage(ChatColor.RED + "Invalid input."); - return true; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkCommand.java deleted file mode 100644 index fabf429db..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkCommand.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.sk89q.worldedit.world.block.BlockState; -import com.thevoxelbox.voxelsniper.RangeBlockHelper; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.entity.Player; - -public class VoxelInkCommand extends VoxelCommand { - public VoxelInkCommand(final VoxelSniper plugin) { - super("VoxelInk", plugin); - setIdentifier("vi"); - setPermission("voxelsniper.sniper"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - - int dataValue; - - if (args.length == 0) { - AsyncBlock targetBlock = new RangeBlockHelper(player, sniper.getWorld()).getTargetBlock(); - if (targetBlock != null) { - dataValue = targetBlock.getPropertyId(); - } else { - return true; - } - } else { - try { - dataValue = Integer.parseInt(args[0]); - } catch (NumberFormatException exception) { - BlockState state = BlockState.get(args[0]); - if (state == null) { - player.sendMessage("Couldn't parse input."); - return true; - } else { - dataValue = state.getInternalPropertiesId(); - } - } - } - - SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - snipeData.setData(dataValue); - snipeData.getVoxelMessage().data(); - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkReplaceCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkReplaceCommand.java deleted file mode 100644 index de339bace..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkReplaceCommand.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.sk89q.worldedit.world.block.BlockState; -import com.thevoxelbox.voxelsniper.RangeBlockHelper; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.entity.Player; - -public class VoxelInkReplaceCommand extends VoxelCommand { - public VoxelInkReplaceCommand(final VoxelSniper plugin) { - super("VoxelInkReplace", plugin); - setIdentifier("vir"); - setPermission("voxelsniper.sniper"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - - int dataValue; - - if (args.length == 0) { - AsyncBlock targetBlock = new RangeBlockHelper(player, sniper.getWorld()).getTargetBlock(); - if (targetBlock != null) { - dataValue = targetBlock.getPropertyId(); - } else { - return true; - } - } else { - try { - dataValue = Integer.parseInt(args[0]); - } catch (NumberFormatException exception) { - BlockState state = BlockState.get(args[0]); - if (state == null) { - player.sendMessage("Couldn't parse input."); - return true; - } else { - dataValue = state.getInternalPropertiesId(); - } - } - } - - SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - snipeData.setReplaceData(dataValue); - snipeData.getVoxelMessage().replaceData(); - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelListCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelListCommand.java deleted file mode 100644 index e9dec9c31..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelListCommand.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.extent.NullExtent; -import com.sk89q.worldedit.function.mask.BlockMask; -import com.sk89q.worldedit.function.mask.BlockMaskBuilder; -import com.thevoxelbox.voxelsniper.RangeBlockHelper; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.entity.Player; - -public class VoxelListCommand extends VoxelCommand { - public VoxelListCommand(final VoxelSniper plugin) { - super("VoxelList", plugin); - setIdentifier("vl"); - setPermission("voxelsniper.sniper"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - - SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - if (args.length == 0) { - final RangeBlockHelper rangeBlockHelper = new RangeBlockHelper(player, sniper.getWorld()); - final AsyncBlock targetBlock = rangeBlockHelper.getTargetBlock(); - snipeData.getVoxelList().add(BukkitAdapter.adapt(targetBlock.getBlockData())); - snipeData.getVoxelMessage().voxelList(); - return true; - } else { - if (args[0].equalsIgnoreCase("clear")) { - snipeData.getVoxelList().clear(); - snipeData.getVoxelMessage().voxelList(); - return true; - } - } - - for (String string : args) { - boolean remove = false; - if (string.charAt(0) == '-') { - string = string.substring(1); - remove = true; - } - BlockMaskBuilder builder = new BlockMaskBuilder().addRegex(string); - BlockMask mask = builder.build(new NullExtent()); - if (remove) { - snipeData.getVoxelList().removeValue(mask); - } else { - snipeData.getVoxelList().add(mask); - } - } - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPaintCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPaintCommand.java deleted file mode 100644 index 8d073d808..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPaintCommand.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.thevoxelbox.voxelsniper.PaintingWrapper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -public class VoxelPaintCommand extends VoxelCommand { - public VoxelPaintCommand(final VoxelSniper plugin) { - super("VoxelPaint", plugin); - setIdentifier("paint"); - setPermission("voxelsniper.paint"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - if (args.length == 1) { - if (args[0].equalsIgnoreCase("back")) { - PaintingWrapper.paint(player, true, true, 0); - return true; - } else { - try { - PaintingWrapper.paint(player, false, false, Integer.parseInt(args[0])); - return true; - } catch (final Exception exception) { - player.sendMessage(ChatColor.RED + "Invalid input."); - return true; - } - } - } else { - PaintingWrapper.paint(player, true, false, 0); - return true; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPerformerCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPerformerCommand.java deleted file mode 100644 index a1c5d62eb..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPerformerCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import com.thevoxelbox.voxelsniper.brush.IBrush; -import com.thevoxelbox.voxelsniper.brush.perform.Performer; -import org.bukkit.entity.Player; - -import java.util.logging.Level; - -public class VoxelPerformerCommand extends VoxelCommand { - public VoxelPerformerCommand(final VoxelSniper plugin) { - super("VoxelPerformer", plugin); - setIdentifier("p"); - setPermission("voxelsniper.sniper"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - - try { - if (args == null || args.length == 0) { - IBrush brush = sniper.getBrush(sniper.getCurrentToolId()); - if (brush instanceof Performer) { - ((Performer) brush).parse(new String[]{"m"}, snipeData); - } else { - player.sendMessage("This brush is not a performer brush."); - } - } else { - IBrush brush = sniper.getBrush(sniper.getCurrentToolId()); - if (brush instanceof Performer) { - ((Performer) brush).parse(args, snipeData); - } else { - player.sendMessage("This brush is not a performer brush."); - } - } - return true; - } catch (Exception exception) { - plugin.getLogger().log(Level.WARNING, "Command error from " + player.getName(), exception); - return true; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelReplaceCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelReplaceCommand.java deleted file mode 100644 index 4bed75c2e..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelReplaceCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.RangeBlockHelper; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.entity.Player; - -public class VoxelReplaceCommand extends VoxelCommand -{ - public VoxelReplaceCommand(final VoxelSniper plugin) - { - super("VoxelReplace", plugin); - setIdentifier("vr"); - setPermission("voxelsniper.sniper"); - } - - @Override - public boolean onCommand(Player player, String[] args) - { - Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - - if (args.length == 0) - { - AsyncBlock targetBlock = new RangeBlockHelper(player, sniper.getWorld()).getTargetBlock(); - if (targetBlock != null) - { - snipeData.setReplaceId(targetBlock.getTypeId()); - snipeData.getVoxelMessage().replace(); - } - return true; - } - - BlockType weType = BlockTypes.parse(args[0]); - if (weType != null) - { - snipeData.setReplaceId(weType.getInternalId()); - snipeData.getVoxelMessage().replace(); - return true; - } - return false; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelSniperCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelSniperCommand.java deleted file mode 100644 index 6c5aae8ee..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelSniperCommand.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.google.common.base.Joiner; -import com.google.common.collect.Lists; -import com.google.common.collect.Multimap; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import com.thevoxelbox.voxelsniper.brush.IBrush; -import com.thevoxelbox.voxelsniper.brush.perform.PerformerE; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -import java.util.List; - -public class VoxelSniperCommand extends VoxelCommand { - - public VoxelSniperCommand(final VoxelSniper plugin) { - - super("VoxelSniper", plugin); - setIdentifier("vs"); - setPermission("voxelsniper.sniper"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - Sniper sniper = VoxelSniper.getInstance().getSniperManager().getSniperForPlayer(player); - - if (args.length >= 1) { - if (args[0].equalsIgnoreCase("brushes")) { - Multimap, String> registeredBrushesMultimap = VoxelSniper.getInstance().getBrushManager().getRegisteredBrushesMultimap(); - List allHandles = Lists.newLinkedList(); - for (Class brushClass : registeredBrushesMultimap.keySet()) { - allHandles.addAll(registeredBrushesMultimap.get(brushClass)); - } - player.sendMessage(Joiner.on(", ").skipNulls().join(allHandles)); - return true; - } else if (args[0].equalsIgnoreCase("range")) { - SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - if (args.length == 2) { - try { - int range = Integer.parseInt(args[1]); - if (range < 0) { - player.sendMessage("Negative values are not allowed."); - } - snipeData.setRange(range); - snipeData.setRanged(true); - snipeData.getVoxelMessage().toggleRange(); - - } catch (NumberFormatException exception) { - player.sendMessage("Can't parse number."); - } - return true; - } else { - snipeData.setRanged(!snipeData.isRanged()); - snipeData.getVoxelMessage().toggleRange(); - return true; - } - } else if (args[0].equalsIgnoreCase("perf")) { - player.sendMessage(ChatColor.AQUA + "Available performers (abbreviated):"); - player.sendMessage(PerformerE.performer_list_short); - return true; - } else if (args[0].equalsIgnoreCase("perflong")) { - player.sendMessage(ChatColor.AQUA + "Available performers:"); - player.sendMessage(PerformerE.performer_list_long); - return true; - } else if (args[0].equalsIgnoreCase("enable") && player.hasPermission("voxelsniper.command.vs.enable")) { - sniper.setEnabled(true); - player.sendMessage("VoxelSniper is " + (sniper.isEnabled() ? "enabled" : "disabled")); - return true; - } else if (args[0].equalsIgnoreCase("disable") && player.hasPermission("voxelsniper.command.vs.enable")) { - sniper.setEnabled(false); - player.sendMessage("VoxelSniper is " + (sniper.isEnabled() ? "enabled" : "disabled")); - return true; - } else if (args[0].equalsIgnoreCase("toggle") && player.hasPermission("voxelsniper.command.vs.enable")) { - sniper.setEnabled(!sniper.isEnabled()); - player.sendMessage("VoxelSniper is " + (sniper.isEnabled() ? "enabled" : "disabled")); - return true; - } - } - player.sendMessage(ChatColor.DARK_RED + "VoxelSniper - Current Brush Settings:"); - sniper.displayInfo(); - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoCommand.java deleted file mode 100644 index c22f2e6d5..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoCommand.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.boydti.fawe.config.BBC; -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.entity.Player; - -public class VoxelUndoCommand extends VoxelCommand { - public VoxelUndoCommand(final VoxelSniper plugin) { - super("VoxelUndo", plugin); - setIdentifier("u"); - setPermission("voxelsniper.sniper"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - - if (args.length == 1) { - try { - int amount = Integer.parseInt(args[0]); - sniper.undo(amount); - } catch (NumberFormatException exception) { - player.sendMessage("Number expected; string given."); - } - } else { - sniper.undo(); - } - return true; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoUserCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoUserCommand.java deleted file mode 100644 index 66904b681..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoUserCommand.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.thevoxelbox.voxelsniper.command; - -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -public class VoxelUndoUserCommand extends VoxelCommand { - public VoxelUndoUserCommand(final VoxelSniper plugin) { - super("VoxelUndoUser", plugin); - setIdentifier("uu"); - setPermission("voxelsniper.command.uu"); - } - - @Override - public boolean onCommand(Player player, String[] args) { - try { - plugin.getSniperManager().getSniperForPlayer(Bukkit.getPlayer(args[0])).undo(); - return true; - } catch (final Exception exception) { - player.sendMessage(ChatColor.GREEN + "Player not found."); - return true; - } - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelVoxelCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelVoxelCommand.java deleted file mode 100644 index 0efdfcd0b..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelVoxelCommand.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - This file is part of VoxelSniper, licensed under the MIT License (MIT). - - Copyright (c) The VoxelBox - Copyright (c) contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - */ - -package com.thevoxelbox.voxelsniper.command; - -import com.boydti.fawe.bukkit.favs.PatternUtil; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.thevoxelbox.voxelsniper.RangeBlockHelper; -import com.thevoxelbox.voxelsniper.SnipeData; -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - -public class VoxelVoxelCommand extends VoxelCommand { - public VoxelVoxelCommand(VoxelSniper plugin) { - super("VoxelVoxel", plugin); - this.setIdentifier("v"); - this.setPermission("voxelsniper.sniper"); - } - - public boolean onCommand(Player player, String[] args) { - Sniper sniper = this.plugin.getSniperManager().getSniperForPlayer(player); - SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - if(args.length == 0) { - Block block = (new RangeBlockHelper(player, sniper.getWorld())).getTargetBlock(); - Material blockType = block.getType(); - - BlockType weType = BukkitAdapter.adapt(blockType); - if(!player.hasPermission("voxelsniper.ignorelimitations") && WorldEdit.getInstance().getConfiguration().checkDisallowedBlocks(weType.getDefaultState())) { - player.sendMessage("You are not allowed to use " + blockType.name() + ". (WorldEdit config.yml)"); - return true; - } - - snipeData.setVoxelId(weType.getInternalId()); - snipeData.getVoxelMessage().voxel(); - snipeData.setPattern(null, null); - - return true; - } else { - BlockType weType = BlockTypes.parse(args[0]); - if(weType != null) { - if(!player.hasPermission("voxelsniper.ignorelimitations") && WorldEdit.getInstance().getConfiguration().checkDisallowedBlocks(weType.getDefaultState())) { - player.sendMessage("You are not allowed to use " + weType + "."); - return true; - } else { - snipeData.setVoxelId(weType.getInternalId()); - snipeData.getVoxelMessage().voxel(); - snipeData.setPattern(null, null); - return true; - } - } else { - PatternUtil.parsePattern(player, snipeData, args[0]); - return true; - } - } - } - - public static Class inject() { - return VoxelVoxelCommand.class; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushChangedEvent.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushChangedEvent.java deleted file mode 100644 index 37eb5f6d1..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushChangedEvent.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - This file is part of VoxelSniper, licensed under the MIT License (MIT). - - Copyright (c) The VoxelBox - Copyright (c) contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - */ -package com.thevoxelbox.voxelsniper.event; - -import com.boydti.fawe.Fawe; -import com.thevoxelbox.voxelsniper.Sniper; -import com.thevoxelbox.voxelsniper.brush.IBrush; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -public class SniperBrushChangedEvent extends Event { - private static final HandlerList handlers = new HandlerList(); - private final Sniper sniper; - private final IBrush originalBrush; - private final IBrush newBrush; - private final String toolId; - - public SniperBrushChangedEvent(Sniper sniper, String toolId, IBrush originalBrush, IBrush newBrush) { - super(!Fawe.isMainThread()); - this.sniper = sniper; - this.originalBrush = originalBrush; - this.newBrush = newBrush; - this.toolId = toolId; - } - - public static HandlerList getHandlerList() { - return handlers; - } - - public IBrush getOriginalBrush() { - return this.originalBrush; - } - - public IBrush getNewBrush() { - return this.newBrush; - } - - public Sniper getSniper() { - return this.sniper; - } - - public String getToolId() { - return this.toolId; - } - - public HandlerList getHandlers() { - return handlers; - } - - public static Class inject() { - return SniperBrushChangedEvent.class; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushSizeChangedEvent.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushSizeChangedEvent.java deleted file mode 100644 index d7513a6a4..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushSizeChangedEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.thevoxelbox.voxelsniper.event; - -import com.thevoxelbox.voxelsniper.Sniper; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -public class SniperBrushSizeChangedEvent extends Event { - private static final HandlerList handlers = new HandlerList(); - private final Sniper sniper; - private final int originalSize; - private final int newSize; - private final String toolId; - - public SniperBrushSizeChangedEvent(Sniper sniper, String toolId, int originalSize, int newSize) { - this.sniper = sniper; - this.originalSize = originalSize; - this.newSize = newSize; - this.toolId = toolId; - } - - public static HandlerList getHandlerList() { - return handlers; - } - - public int getOriginalSize() { - return originalSize; - } - - public int getNewSize() { - return newSize; - } - - public Sniper getSniper() { - return sniper; - } - - public String getToolId() { - return toolId; - } - - @Override - public HandlerList getHandlers() { - return handlers; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperMaterialChangedEvent.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperMaterialChangedEvent.java deleted file mode 100644 index 15d2e5a67..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperMaterialChangedEvent.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - This file is part of VoxelSniper, licensed under the MIT License (MIT). - - Copyright (c) The VoxelBox - Copyright (c) contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - */ - -package com.thevoxelbox.voxelsniper.event; - -import com.boydti.fawe.Fawe; -import com.thevoxelbox.voxelsniper.Sniper; -import org.bukkit.block.data.BlockData; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.bukkit.material.MaterialData; - -public class SniperMaterialChangedEvent extends Event { - private static final HandlerList handlers = new HandlerList(); - private final Sniper sniper; - private final BlockData originalMaterial; - private final BlockData newMaterial; - private final String toolId; - - public SniperMaterialChangedEvent(Sniper sniper, String toolId, BlockData originalMaterial, BlockData newMaterial) { - super(!Fawe.get().isMainThread()); - this.sniper = sniper; - this.originalMaterial = originalMaterial; - this.newMaterial = newMaterial; - this.toolId = toolId; - } - - public static HandlerList getHandlerList() { - return handlers; - } - - public BlockData getOriginalMaterial() { - return this.originalMaterial; - } - - public BlockData getNewMaterial() { - return this.newMaterial; - } - - public Sniper getSniper() { - return this.sniper; - } - - public String getToolId() { - return this.toolId; - } - - public HandlerList getHandlers() { - return handlers; - } - - public static Class inject() { - return SniperMaterialChangedEvent.class; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperReplaceMaterialChangedEvent.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperReplaceMaterialChangedEvent.java deleted file mode 100644 index fb65ad93b..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperReplaceMaterialChangedEvent.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.thevoxelbox.voxelsniper.event; - -import com.thevoxelbox.voxelsniper.Sniper; -import org.bukkit.block.data.BlockData; -import org.bukkit.event.HandlerList; - -public class SniperReplaceMaterialChangedEvent extends SniperMaterialChangedEvent { - private static final HandlerList handlers = new HandlerList(); - - public SniperReplaceMaterialChangedEvent(Sniper sniper, String toolId, BlockData originalMaterial, BlockData newMaterial) { - super(sniper, toolId, originalMaterial, newMaterial); - } - - public static HandlerList getHandlerList() { - return handlers; - } - - @Override - public HandlerList getHandlers() { - return handlers; - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/HelpJSAP.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/HelpJSAP.java deleted file mode 100644 index 83c6b29ff..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/HelpJSAP.java +++ /dev/null @@ -1,168 +0,0 @@ -package com.thevoxelbox.voxelsniper.jsap; - -import com.martiansoftware.jsap.JSAP; -import com.martiansoftware.jsap.JSAPException; -import com.martiansoftware.jsap.JSAPResult; -import com.martiansoftware.jsap.Switch; -import com.martiansoftware.util.StringUtils; -import org.bukkit.ChatColor; - -import java.io.IOException; -import java.net.URL; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -/** - * JSAP parser with help generating code. - * - * @author MikeMatrix - */ -public class HelpJSAP extends JSAP { - - private String name; - private String explanation; - private int screenWidth; - - /** - * @param name - * @param explanation - * @param screenWidth - */ - public HelpJSAP(String name, String explanation, int screenWidth) { - super(); - - this.name = name; - this.explanation = explanation; - this.screenWidth = screenWidth; - - try { - this.registerParameter(new Switch("help", JSAP.NO_SHORTFLAG, "help", "Displays this help page.")); - } catch (JSAPException ignored) { - } - } - - /** - * @param name - * @param explanation - * @param screenWidth - * @param resourceName - * @throws IOException if an I/O error occurs - * @throws JSAPException if the configuration is not valid - */ - public HelpJSAP(String name, String explanation, int screenWidth, String resourceName) throws IOException, JSAPException { - super(resourceName); - - this.name = name; - this.explanation = explanation; - this.screenWidth = screenWidth; - - try { - this.registerParameter(new Switch("help", JSAP.NO_SHORTFLAG, "help", "Displays this help page.")); - } catch (JSAPException ignored) { - } - } - - /** - * @param name - * @param explanation - * @param screenWidth - * @param jsapXML - * @throws IOException if an I/O error occurs - * @throws JSAPException if the configuration is not valid - */ - public HelpJSAP(String name, String explanation, int screenWidth, URL jsapXML) throws IOException, JSAPException { - super(jsapXML); - - this.name = name; - this.explanation = explanation; - this.screenWidth = screenWidth; - - try { - this.registerParameter(new Switch("help", JSAP.NO_SHORTFLAG, "help", "Displays this help page.")); - } catch (JSAPException ignored) { - } - } - - /** - * @return the explanation - */ - public final String getExplanation() { - return this.explanation; - } - - /** - * @param explanation the explanation to set - */ - public final void setExplanation(String explanation) { - this.explanation = explanation; - } - - /** - * @return the name - */ - public final String getName() { - return this.name; - } - - /** - * @param name the name to set - */ - public final void setName(String name) { - this.name = name; - } - - /** - * @return the screenWidth - */ - public final int getScreenWidth() { - return this.screenWidth; - } - - /** - * @param screenWidth the screenWidth to set - */ - public final void setScreenWidth(int screenWidth) { - this.screenWidth = screenWidth; - } - - /** - * @param jsapResult - * @return if something has been written on writer. - */ - public final List writeHelpOrErrorMessageIfRequired(JSAPResult jsapResult) { - if (!jsapResult.success() || jsapResult.getBoolean("help")) { - List returnValue = new LinkedList<>(); - // To avoid spurious missing argument errors we never print errors if help is required. - if (!jsapResult.getBoolean("help")) { - for (final Iterator err = jsapResult.getErrorMessageIterator(); err.hasNext(); ) { - returnValue.add(ChatColor.RED + "Error: " + ChatColor.DARK_RED + err.next()); - } - - return returnValue; - } - returnValue.add(ChatColor.GOLD + "Usage:"); - - List l = StringUtils.wrapToList(this.name + " " + this.getUsage(), this.screenWidth); - for (Object aL : l) { - returnValue.add(" " + aL.toString()); - } - - if (this.explanation != null) { - returnValue.add(""); - l = StringUtils.wrapToList(this.explanation, this.screenWidth); - for (Object aL : l) { - final String next = (String) aL; - returnValue.add(ChatColor.AQUA + next); - } - } - - returnValue.add(""); - returnValue.add(this.getHelp(this.screenWidth)); - return returnValue; - } - - return Collections.emptyList(); - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/NullableIntegerStringParser.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/NullableIntegerStringParser.java deleted file mode 100644 index d01d51a1a..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/NullableIntegerStringParser.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.thevoxelbox.voxelsniper.jsap; - -import com.martiansoftware.jsap.ParseException; -import com.martiansoftware.jsap.StringParser; - -/** - * A {@link com.martiansoftware.jsap.StringParser} for parsing Integers. The parse() method delegates the actual parsing to Integer.decode(String). - * - * @author Marty Lamb - * @see com.martiansoftware.jsap.StringParser - * @see Integer - */ -public class NullableIntegerStringParser extends StringParser { - - @SuppressWarnings("unused") - private static final NullableIntegerStringParser INSTANCE = new NullableIntegerStringParser(); - - /** - * Returns a {@link com.thevoxelbox.voxelsniper.jsap.NullableIntegerStringParser}. - *

- *

- * Convenient access to the only instance returned by this method is available through {@link com.martiansoftware.jsap.JSAP#INTEGER_PARSER}. - * - * @return a {@link com.thevoxelbox.voxelsniper.jsap.NullableIntegerStringParser}. - */ - public static NullableIntegerStringParser getParser() { - return new NullableIntegerStringParser(); - } - - /** - * Creates a new IntegerStringParser. - * - * @deprecated Use {@link #getParser()} or, even better, {@link com.martiansoftware.jsap.JSAP#INTEGER_PARSER}. - */ - public NullableIntegerStringParser() { - super(); - } - - /** - * Parses the specified argument into an Integer. This method delegates the parsing to Integer.decode(arg). If Integer.decode() - * throws a NumberFormatException, it is encapsulated into a ParseException and re-thrown. - * - * @param arg the argument to parse - * @return an Integer object with the value contained in the specified argument. - * @throws com.martiansoftware.jsap.ParseException if Integer.decode(arg) throws a NumberFormatException. - * @see Integer - * @see com.martiansoftware.jsap.StringParser#parse(String) - */ - @Override - public final Object parse(final String arg) throws ParseException { - if (arg == null) { - return null; - } - - Integer result; - try { - result = Integer.decode(arg); - } catch (NumberFormatException nfe) { - throw (new ParseException("Unable to convert '" + arg + "' to an Integer.", nfe)); - } - return (result); - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/BlockWrapper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/util/BlockWrapper.java deleted file mode 100644 index c1f80200d..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/BlockWrapper.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.thevoxelbox.voxelsniper.util; - -import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import org.bukkit.Material; -import org.bukkit.World; - -public class BlockWrapper { - - private int id; - private Material type; - private int x; - private int y; - private int z; - private int data; - private World world; - - public BlockWrapper(final AsyncBlock block) { - this.setId(block.getTypeId()); - this.setX(block.getX()); - this.setY(block.getY()); - this.setZ(block.getZ()); - this.setPropertyId(block.getPropertyId()); - this.setWorld(block.getWorld()); - } - - /** - * @return the data - */ - public final int getPropertyId() { - return this.data; - } - - /** - * @param data the data to set - */ - public final void setPropertyId(final int data) { - this.data = data; - } - - public Material getType() { - return type; - } - - public void setType(Material type) { - this.type = type; - } - - /** - * @return the id - */ - public final int getId() { - return this.id; - } - - /** - * @param id the id to set - */ - public final void setId(final int id) { - this.id = id; - } - - /** - * @return the world - */ - public final World getWorld() { - return this.world; - } - - /** - * @param world the world to set - */ - public final void setWorld(final World world) { - this.world = world; - } - - /** - * @return the x - */ - public final int getX() { - return this.x; - } - - /** - * @param x the x to set - */ - public final void setX(final int x) { - this.x = x; - } - - /** - * @return the y - */ - public final int getY() { - return this.y; - } - - /** - * @param y the y to set - */ - public final void setY(final int y) { - this.y = y; - } - - /** - * @return the z - */ - public final int getZ() { - return this.z; - } - - /** - * @param z the z to set - */ - public final void setZ(final int z) { - this.z = z; - } - -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/UndoDelegate.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/util/UndoDelegate.java deleted file mode 100644 index e9e30cffe..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/UndoDelegate.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.thevoxelbox.voxelsniper.util; - -import com.thevoxelbox.voxelsniper.Undo; -import org.bukkit.BlockChangeDelegate; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.block.data.BlockData; - -public class UndoDelegate implements BlockChangeDelegate { - private final World targetWorld; - private Undo currentUndo; - - public UndoDelegate(World targetWorld) { - this.targetWorld = targetWorld; - this.currentUndo = new Undo(); - } - - public Undo getUndo() { - final Undo pastUndo = currentUndo; - currentUndo = new Undo(); - return pastUndo; - } - - @SuppressWarnings("deprecation") - public boolean setBlock(Block b) { - this.currentUndo.put(this.targetWorld.getBlockAt(b.getLocation())); - this.targetWorld.getBlockAt(b.getLocation()).setBlockData(b.getBlockData()); - return true; - } - - @Override - public boolean setBlockData(int x, int y, int z, BlockData blockData) { - this.currentUndo.put(this.targetWorld.getBlockAt(x, y, z)); - this.targetWorld.getBlockAt(x, y, z).setBlockData(blockData); - return true; - } - - @Override - public BlockData getBlockData(int x, int y, int z) { - return this.targetWorld.getBlockAt(x, y, z).getBlockData(); - } - - @Override - public int getHeight() { - return this.targetWorld.getMaxHeight(); - } - - @Override - public boolean isEmpty(int x, int y, int z) { - return this.targetWorld.getBlockAt(x, y, z).isEmpty(); - } -} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/VoxelList.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/util/VoxelList.java deleted file mode 100644 index 729683a71..000000000 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/VoxelList.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.thevoxelbox.voxelsniper.util; - -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.extent.NullExtent; -import com.sk89q.worldedit.function.mask.BlockMask; -import com.sk89q.worldedit.world.block.BlockState; -import org.bukkit.block.data.BlockData; - -/** - * Container class for multiple ID/Datavalue pairs. - */ -public class VoxelList { - - private BlockMask mask = new BlockMask(new NullExtent()); - - /** - * Adds the specified id, data value pair to the VoxelList. A data value of -1 will operate on all data values of that id. - * - * @param i - */ - public void add(BlockState i) { - this.mask = mask.add(i); - } - - public void add(BlockMask mask) { - this.mask = (BlockMask) mask.tryCombine(mask); - } - - /** - * Removes the specified id, data value pair from the VoxelList. - * - * @return true if this list contained the specified element - */ - public boolean removeValue(final BlockState state) { - this.mask = mask.remove(state); - return true; - } - - public boolean removeValue(final BlockMask state) { - this.mask = (BlockMask) mask.tryCombine(state.inverse()); - return true; - } - - /** - * @param i - * @return true if this list contains the specified element - */ - public boolean contains(final BlockData i) { - return mask.test(BukkitAdapter.adapt(i)); - } - - /** - * Clears the VoxelList. - */ - public void clear() { - mask = mask.clear(); - } - - /** - * Returns true if this list contains no elements. - * - * @return true if this list contains no elements - */ - public boolean isEmpty() { - return mask.isEmpty(); - } - - /** - * Returns a defensive copy of the List with pairs. - * - * @return defensive copy of the List with pairs - */ - public String toString() { - return mask.toString(); - } - - -} diff --git a/favs/src/main/resources/LICENSE b/favs/src/main/resources/LICENSE deleted file mode 100644 index 612e425d2..000000000 --- a/favs/src/main/resources/LICENSE +++ /dev/null @@ -1,53 +0,0 @@ -License - -THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. - -BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. - -1. Definitions - -"Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. -"Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License. -"Distribute" means to make available to the public the original and copies of the Work through sale or other transfer of ownership. -"Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. -"Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. -"Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. -"You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. -"Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. -"Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. -2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. - -3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: - -to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; and, -to Distribute and Publicly Perform the Work including as incorporated in Collections. -The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats, but otherwise you have no rights to make Adaptations. Subject to 8(f), all rights not expressly granted by Licensor are hereby reserved, including but not limited to the rights set forth in Section 4(d). - -4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: - -You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested. -You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation. The exchange of the Work for other copyrighted works by means of digital file-sharing or otherwise shall not be considered to be intended for or directed toward commercial advantage or private monetary compensation, provided there is no payment of any monetary compensation in connection with the exchange of copyrighted works. -If You Distribute, or Publicly Perform the Work or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work. The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Collection, at a minimum such credit will appear, if a credit for all contributing authors of Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. -For the avoidance of doubt: - -Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; -Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License if Your exercise of such rights is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(b) and otherwise waives the right to collect royalties through any statutory or compulsory licensing scheme; and, -Voluntary License Schemes. The Licensor reserves the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License that is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(b). -Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. -5. Representations, Warranties and Disclaimer - -UNLESS OTHERWISE MUTUALLY AGREED BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. - -6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. Termination - -This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. -Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. -8. Miscellaneous - -Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. -If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. -No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. -This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. -The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. diff --git a/favs/src/main/resources/config.yml b/favs/src/main/resources/config.yml deleted file mode 100644 index ca761cbb6..000000000 --- a/favs/src/main/resources/config.yml +++ /dev/null @@ -1,4 +0,0 @@ -# Max. brush size for FAVS brushes -litesniper-max-brush-size: 30 -# Enable or disable the brush dump on login -message-on-login-enabled: true \ No newline at end of file diff --git a/favs/src/main/resources/plugin.yml b/favs/src/main/resources/plugin.yml deleted file mode 100644 index 25efa13d8..000000000 --- a/favs/src/main/resources/plugin.yml +++ /dev/null @@ -1,445 +0,0 @@ -name: FastAsyncVoxelSniper -main: com.thevoxelbox.voxelsniper.VoxelSniper -version: ${version} -description: Fast Async VoxelSniper -authors: [Empire92] -load: STARTUP -database: false -depend: [WorldEdit] -api-version: 1.13 -#softdepend: [WorldGuard, PlotSquared, MCore, Factions, GriefPrevention, Residence, Towny, PreciousStones] -commands: - '/p': - description: VoxelSniper perform command - aliases: [perform,/perform] - '/d': - description: VoxelSniper default command - aliases: [default,/default] - paint: - description: Change the selected painting to another painting. - usage: | - / - Example: / -- Cycles through paintings. You must be adjacent to the painting and aiming at it. - goto: - description: Warps to the specified coordinates. - permission: voxelsniper.goto - usage: | - / [X] [Z] - Example: / 100 -100 -- Takes the user to the coordinates X: 100, Z: -100. The Y-coordinate will always be 1 more than the Y-coordinate of the highest block at the X and Z-coordinates provided. - u: - description: Undoes the last snipe. - permission: voxelsniper.sniper - usage: | - / - Example: / -- Undoes your most recent snipe. - uu: - description: UndoUser undoes another sniper user's snipes. - permission: voxelsniper.command.uu - usage: | - / [playername] - Example: / bads -- Undoes BadSniper's last snipe. BadSniper must be online for name detection to function. Truncation allowed. - d: - description: VoxelSniper Default. - permission: voxelsniper.sniper - usage: | - / - Example: / -- Resets the brush settings to their default values. - p: - description: Voxelsniper performer. - permission: voxelsniper.sniper - aliases: [perf, performer] - usage: | - / - Example: / -- Sets the performer of the current brush to "m". - / - Example: / -- Sets the performer of the current brush to . - vs: - description: VoxelSniper Settings. - permission: voxelsniper.sniper - usage: | - / - Example: / -- Returns the current brush settings. - vc: - description: VoxelCentroid. - permission: voxelsniper.sniper - usage: | - / - Example: / -1 -- Sets the Clone Cylinder's Y value for the base relative to the Clone Point. - vh: - description: VoxelHeight. - permission: voxelsniper.sniper - usage: | - / [voxel-height] - Example: / -- Sets the brush height. - vi: - description: VoxelInk (Data Value). - permission: voxelsniper.sniper - usage: | - / [0-16] - Example: / -- sets a data value of 6 (e.g. pink wool). - vr: - description: VoxelReplace. - permission: voxelsniper.sniper - usage: | - / [0-159] - Example: / 12 -- Sets a replace brush to select sand blocks for replacement. - vl: - description: VoxelBlockExclusion list - permission: voxelsniper.sniper - usage: | - / - Example: / 89 -5 -- Adds glowstone to the voxel list and removes planks from the voxel list. - vir: - description: VoxelInkReplace. - permission: voxelsniper.sniper - usage: | - / [0-16] - Example: / 12 -- Sets a replace ink brush to select data 6 blocks for replacement. - v: - description: Voxel input. - permission: voxelsniper.sniper - usage: | - / [0-159] - Example: / 1 -- Loads the sniper with Stone blocks. - b: - description: Brush. - permission: voxelsniper.sniper - usage: | - / [brush-size] - Example: / 5 -- Sets a brush radius size of 5 (11 spaces across). - Example: / b cm -- Sets your brush to the Ball Brush with the combo-mat performer. - btool: - description: Brush Tool Command. - permission: voxelsniper.sniper - usage : | - / -- Prints out command usage information. - vchunk: - description: Update the chunk you are standing in. - usage: | - / - Example: / -- Loads the chunk you're standing in. -permissions: - fawe.voxelbrush: - default: op - children: - voxelsniper.brush.ball: true - voxelsniper.brush.biome: true - voxelsniper.brush.blendball: true - voxelsniper.brush.blenddisc: true - voxelsniper.brush.blendvoxel: true - voxelsniper.brush.blendvoxeldisc: true - voxelsniper.brush.blob: true - voxelsniper.brush.blockreset: true - voxelsniper.brush.blockresetsurface: true - voxelsniper.brush.canyon: true - voxelsniper.brush.canyonselection: true - voxelsniper.brush.checkervoxeldisc: true - voxelsniper.brush.cleansnow: true - voxelsniper.brush.clonestamp: true - voxelsniper.brush.copypasta: true - voxelsniper.brush.cylinder: true - voxelsniper.brush.disc: true - voxelsniper.brush.discface: true - voxelsniper.brush.dome: true - voxelsniper.brush.drain: true - voxelsniper.brush.ellipse: true - voxelsniper.brush.ellipsoid: true - voxelsniper.brush.eraser: true - voxelsniper.brush.erode: true - voxelsniper.brush.erodeblend: true - voxelsniper.brush.extrude: true - voxelsniper.brush.filldown: true - voxelsniper.brush.flatocean: true - voxelsniper.brush.heatray: true - voxelsniper.brush.jaggedline: true - voxelsniper.brush.line: true - voxelsniper.brush.move: true - voxelsniper.brush.ocean: true - voxelsniper.brush.overlay: true - voxelsniper.brush.pull: true - voxelsniper.brush.randomerode: true - voxelsniper.brush.ring: true - voxelsniper.brush.rot2d: true - voxelsniper.brush.rot2dvert: true - voxelsniper.brush.rot3d: true - voxelsniper.brush.ruler: true - voxelsniper.brush.scanner: true - voxelsniper.brush.set: true - voxelsniper.brush.setredstoneflip: true - voxelsniper.brush.setredstonerotate: true - voxelsniper.brush.shellball: true - voxelsniper.brush.shellset: true - voxelsniper.brush.shellvoxel: true - voxelsniper.brush.signoverwrite: true - voxelsniper.brush.snipe: true - voxelsniper.brush.snowcone: true - voxelsniper.brush.spiralstaircase: true - voxelsniper.brush.splatterball: true - voxelsniper.brush.splatterdisc: true - voxelsniper.brush.splatteroverlay: true - voxelsniper.brush.splattervoxel: true - voxelsniper.brush.splattervoxeldisc: true - voxelsniper.brush.spline: true - voxelsniper.brush.stamp: true - voxelsniper.brush.stencil: true - voxelsniper.brush.stencillist: true - voxelsniper.brush.threepointcircle: true - voxelsniper.brush.triangle: true - voxelsniper.brush.underlay: true - voxelsniper.brush.voltmeter: true - voxelsniper.brush.voxel: true - voxelsniper.brush.voxeldisc: true - voxelsniper.brush.voxeldiscface: true - voxelsniper.brush.warp: true - voxelsniper.brush.wallsider: true - voxelsniper.goto: true - voxelsniper.sniper: true - voxelsniper.sniper: - default: op - voxelsniper.ignorelimitations: - default: op - voxelsniper.goto: - default: op - voxelsniper.brush.*: - default: op - children: - voxelsniper.brush.ball: true - voxelsniper.brush.biome: true - voxelsniper.brush.blendball: true - voxelsniper.brush.blenddisc: true - voxelsniper.brush.blendvoxel: true - voxelsniper.brush.blendvoxeldisc: true - voxelsniper.brush.blob: true - voxelsniper.brush.blockreset: true - voxelsniper.brush.blockresetsurface: true - voxelsniper.brush.canyon: true - voxelsniper.brush.canyonselection: true - voxelsniper.brush.checkervoxeldisc: true - voxelsniper.brush.cleansnow: true - voxelsniper.brush.clonestamp: true - voxelsniper.brush.comet: true - voxelsniper.brush.copypasta: true - voxelsniper.brush.cylinder: true - voxelsniper.brush.disc: true - voxelsniper.brush.discface: true - voxelsniper.brush.dome: true - voxelsniper.brush.drain: true - voxelsniper.brush.ellipse: true - voxelsniper.brush.ellipsoid: true - voxelsniper.brush.entity: true - voxelsniper.brush.entityremoval: true - voxelsniper.brush.eraser: true - voxelsniper.brush.erode: true - voxelsniper.brush.erodeblend: true - voxelsniper.brush.extrude: true - voxelsniper.brush.filldown: true - voxelsniper.brush.flatocean: true - voxelsniper.brush.generatetree: true - voxelsniper.brush.heatray: true - voxelsniper.brush.jaggedline: true - voxelsniper.brush.jockey: true - voxelsniper.brush.lightning: true - voxelsniper.brush.line: true - voxelsniper.brush.move: true - voxelsniper.brush.ocean: true - voxelsniper.brush.overlay: true - voxelsniper.brush.painting: true - voxelsniper.brush.pull: true - voxelsniper.brush.punish: true - voxelsniper.brush.randomerode: true - voxelsniper.brush.regeneratechunk: true - voxelsniper.brush.ring: true - voxelsniper.brush.rot2d: true - voxelsniper.brush.rot2dvert: true - voxelsniper.brush.rot3d: true - voxelsniper.brush.ruler: true - voxelsniper.brush.scanner: true - voxelsniper.brush.set: true - voxelsniper.brush.setredstoneflip: true - voxelsniper.brush.setredstonerotate: true - voxelsniper.brush.shellball: true - voxelsniper.brush.shellset: true - voxelsniper.brush.shellvoxel: true - voxelsniper.brush.signoverwrite: true - voxelsniper.brush.snipe: true - voxelsniper.brush.snowcone: true - voxelsniper.brush.spiralstaircase: true - voxelsniper.brush.splatterball: true - voxelsniper.brush.splatterdisc: true - voxelsniper.brush.splatteroverlay: true - voxelsniper.brush.splattervoxel: true - voxelsniper.brush.splattervoxeldisc: true - voxelsniper.brush.spline: true - voxelsniper.brush.stamp: true - voxelsniper.brush.stencil: true - voxelsniper.brush.stencillist: true - voxelsniper.brush.threepointcircle: true - voxelsniper.brush.treesnipe: true - voxelsniper.brush.triangle: true - voxelsniper.brush.underlay: true - voxelsniper.brush.voltmeter: true - voxelsniper.brush.voxel: true - voxelsniper.brush.voxeldisc: true - voxelsniper.brush.voxeldiscface: true - voxelsniper.brush.warp: true - voxelsniper.brush.wallsider: true - voxelsniper.brush.ball: - default: op - voxelsniper.brush.biome: - default: op - voxelsniper.brush.blendball: - default: op - voxelsniper.brush.blenddisc: - default: op - voxelsniper.brush.blendvoxel: - default: op - voxelsniper.brush.blendvoxeldisc: - default: op - voxelsniper.brush.blob: - default: op - voxelsniper.brush.blockreset: - default: op - voxelsniper.brush.blockresetsurface: - default: op - voxelsniper.brush.canyon: - default: op - voxelsniper.brush.canyonselection: - default: op - voxelsniper.brush.checkervoxeldisc: - default: op - voxelsniper.brush.cleansnow: - default: op - voxelsniper.brush.clonestamp: - default: op - voxelsniper.brush.comet: - default: op - voxelsniper.brush.copypasta: - default: op - voxelsniper.brush.cylinder: - default: op - voxelsniper.brush.disc: - default: op - voxelsniper.brush.discface: - default: op - voxelsniper.brush.dome: - default: op - voxelsniper.brush.drain: - default: op - voxelsniper.brush.ellipse: - default: op - voxelsniper.brush.ellipsoid: - default: op - voxelsniper.brush.entity: - default: op - voxelsniper.brush.entityremoval: - default: op - voxelsniper.brush.eraser: - default: op - voxelsniper.brush.erode: - default: op - voxelsniper.brush.erodeblend: - default: op - voxelsniper.brush.extrude: - default: op - voxelsniper.brush.filldown: - default: op - voxelsniper.brush.flatocean: - default: op - voxelsniper.brush.generatetree: - default: op - voxelsniper.brush.heatray: - default: op - voxelsniper.brush.jaggedline: - default: op - voxelsniper.brush.jockey: - default: op - voxelsniper.brush.lightning: - default: op - voxelsniper.brush.line: - default: op - voxelsniper.brush.move: - default: op - voxelsniper.brush.ocean: - default: op - voxelsniper.brush.overlay: - default: op - voxelsniper.brush.painting: - default: op - voxelsniper.brush.pull: - default: op - voxelsniper.brush.punish: - default: op - voxelsniper.brush.randomerode: - default: op - voxelsniper.brush.regeneratechunk: - default: op - voxelsniper.brush.ring: - default: op - voxelsniper.brush.rot2d: - default: op - voxelsniper.brush.rot2dvert: - default: op - voxelsniper.brush.rot3d: - default: op - voxelsniper.brush.ruler: - default: op - voxelsniper.brush.scanner: - default: op - voxelsniper.brush.set: - default: op - voxelsniper.brush.setredstoneflip: - default: op - voxelsniper.brush.setredstonerotate: - default: op - voxelsniper.brush.shellball: - default: op - voxelsniper.brush.shellset: - default: op - voxelsniper.brush.shellvoxel: - default: op - voxelsniper.brush.signoverwrite: - default: op - voxelsniper.brush.snipe: - default: op - voxelsniper.brush.snowcone: - default: op - voxelsniper.brush.spiralstaircase: - default: op - voxelsniper.brush.splatterball: - default: op - voxelsniper.brush.splatterdisc: - default: op - voxelsniper.brush.splatteroverlay: - default: op - voxelsniper.brush.splattervoxel: - default: op - voxelsniper.brush.splattervoxeldisc: - default: op - voxelsniper.brush.spline: - default: op - voxelsniper.brush.stamp: - default: op - voxelsniper.brush.stencil: - default: op - voxelsniper.brush.stencillist: - default: op - voxelsniper.brush.threepointcircle: - default: op - voxelsniper.brush.treesnipe: - default: op - voxelsniper.brush.triangle: - default: op - voxelsniper.brush.underlay: - default: op - voxelsniper.brush.voltmeter: - default: op - voxelsniper.brush.voxel: - default: op - voxelsniper.brush.voxeldisc: - default: op - voxelsniper.brush.voxeldiscface: - default: op - voxelsniper.brush.wallsider: - default: op - voxelsniper.brush.warp: - default: op \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index ca59bb4b2..b29efe82f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,5 +7,3 @@ include 'worldedit-libs' include "worldedit-$it" } include "worldedit-libs:core:ap" - -include 'favs' From 9fb22020683c62f2487691e0cc7152c51b43e4b4 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Wed, 31 Jul 2019 19:06:31 -0400 Subject: [PATCH 7/9] Fix 1.14.4 compile # Conflicts: # worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java --- .../boydti/fawe/bukkit/beta/BukkitQueue.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) 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 c0b0fb4ef..14a172dbb 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 @@ -7,7 +7,7 @@ import com.boydti.fawe.beta.implementation.SimpleCharQueueExtent; import com.boydti.fawe.beta.implementation.WorldChunkCache; import com.boydti.fawe.bukkit.v1_14.adapter.BlockMaterial_1_14; import com.boydti.fawe.config.Settings; -import com.boydti.fawe.jnbt.anvil.BitArray4096; +import com.boydti.fawe.object.collection.BitArray4096; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.TaskManager; import com.sk89q.worldedit.bukkit.BukkitWorld; @@ -19,19 +19,15 @@ import net.jpountz.util.UnsafeUtils; import net.minecraft.server.v1_14_R1.Block; import net.minecraft.server.v1_14_R1.Chunk; import net.minecraft.server.v1_14_R1.ChunkCoordIntPair; -import net.minecraft.server.v1_14_R1.ChunkProviderServer; import net.minecraft.server.v1_14_R1.ChunkSection; -import net.minecraft.server.v1_14_R1.ChunkStatus; import net.minecraft.server.v1_14_R1.DataBits; import net.minecraft.server.v1_14_R1.DataPalette; import net.minecraft.server.v1_14_R1.DataPaletteBlock; import net.minecraft.server.v1_14_R1.DataPaletteLinear; import net.minecraft.server.v1_14_R1.GameProfileSerializer; import net.minecraft.server.v1_14_R1.IBlockData; -import net.minecraft.server.v1_14_R1.IChunkAccess; import net.minecraft.server.v1_14_R1.PlayerChunk; import net.minecraft.server.v1_14_R1.PlayerChunkMap; -import net.minecraft.server.v1_14_R1.ProtoChunkExtension; import net.minecraft.server.v1_14_R1.WorldServer; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_14_R1.CraftChunk; @@ -53,6 +49,16 @@ public class BukkitQueue extends SimpleCharQueueExtent { private org.bukkit.World bukkitWorld; private WorldServer nmsWorld; + @Override + public void enableQueue() { + + } + + @Override + public void disableQueue() { + + } + @Override public synchronized void init(WorldChunkCache cache) { World world = cache.getWorld(); @@ -235,10 +241,10 @@ public class BukkitQueue extends SimpleCharQueueExtent { } @Override - public boolean sendChunk(final int X, final int Z, final int mask) { + public void sendChunk(final int X, final int Z, final int mask) { PlayerChunk playerChunk = getPlayerChunk(X, Z); if (playerChunk == null) { - return false; + return; } // ChunkSection[] sections = nmsChunk.getSections(); // for (int layer = 0; layer < 16; layer++) { @@ -269,9 +275,9 @@ public class BukkitQueue extends SimpleCharQueueExtent { return null; } }); - return true; + return; } - return false; + return; } /* From 21a8899ba8a7036fb1eac61ce36ad33b5d338b25 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Sat, 3 Aug 2019 19:57:29 -0400 Subject: [PATCH 8/9] remove favs --- .../java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java deleted file mode 100644 index e69de29bb..000000000 From 5c6c41a95a7abe452bda6d6749590b90f0a9a533 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Sat, 3 Aug 2019 22:43:29 -0400 Subject: [PATCH 9/9] Docs, command, and formatting changes. --- .../boydti/fawe/bukkit/beta/BukkitQueue.java | 6 +- .../boydti/fawe/beta/ArrayFilterBlock.java | 40 +-- .../com/boydti/fawe/beta/CharFilterBlock.java | 140 ++++---- .../boydti/fawe/beta/ChunkFilterBlock.java | 12 +- .../com/boydti/fawe/beta/ChunkFuture.java | 11 +- .../com/boydti/fawe/beta/DelegateFilter.java | 2 + .../boydti/fawe/beta/DelegateFilterBlock.java | 104 +++--- .../com/boydti/fawe/beta/DirectionMask.java | 1 + .../java/com/boydti/fawe/beta/Filter.java | 36 +- .../com/boydti/fawe/beta/FilterBlock.java | 36 +- .../com/boydti/fawe/beta/FilterBlockMask.java | 5 +- .../main/java/com/boydti/fawe/beta/Flood.java | 20 +- .../java/com/boydti/fawe/beta/IBlocks.java | 3 +- .../java/com/boydti/fawe/beta/IChunk.java | 30 +- .../java/com/boydti/fawe/beta/IChunkGet.java | 3 +- .../java/com/boydti/fawe/beta/IChunkSet.java | 4 +- .../com/boydti/fawe/beta/IDelegateChunk.java | 30 +- .../com/boydti/fawe/beta/IDelegateFilter.java | 2 +- .../fawe/beta/IDelegateQueueExtent.java | 16 +- .../com/boydti/fawe/beta/IQueueExtent.java | 34 +- .../com/boydti/fawe/beta/NorthVector.java | 19 +- .../boydti/fawe/beta/SimpleFilterBlock.java | 1 + .../boydti/fawe/beta/SingleFilterBlock.java | 39 ++- .../java/com/boydti/fawe/beta/Trimable.java | 9 +- .../fawe/beta/filters/ArrayImageMask.java | 5 +- .../boydti/fawe/beta/filters/CountFilter.java | 7 +- .../boydti/fawe/beta/filters/DistrFilter.java | 20 +- .../fawe/beta/filters/ForkedFilter.java | 11 +- .../boydti/fawe/beta/filters/SetFilter.java | 5 +- .../beta/implementation/DelegateChunkSet.java | 7 +- .../beta/implementation/IQueueWrapper.java | 1 + .../implementation/MultiThreadedQueue.java | 90 ++--- .../beta/implementation/QueueHandler.java | 45 +-- .../implementation/SimpleCharQueueExtent.java | 2 +- .../SingleThreadQueueExtent.java | 73 ++-- .../beta/implementation/WorldChunkCache.java | 33 +- .../implementation/blocks/BitSetBlocks.java | 16 +- .../implementation/blocks/CharBlocks.java | 93 +++--- .../implementation/blocks/CharGetBlocks.java | 9 +- .../implementation/blocks/CharSetBlocks.java | 18 +- .../implementation/holder/ChunkHolder.java | 316 +++++++++--------- .../implementation/holder/DelegateChunk.java | 18 +- .../implementation/holder/FinalizedChunk.java | 12 +- .../implementation/holder/ReferenceChunk.java | 18 +- .../beta/implementation/holder/SoftChunk.java | 5 +- .../beta/implementation/holder/WeakChunk.java | 9 +- .../worldedit/command/RegionCommands.java | 5 +- 47 files changed, 763 insertions(+), 658 deletions(-) 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 14a172dbb..a3530e1df 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 @@ -42,6 +42,10 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.locks.Lock; import java.util.function.Supplier; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull; public class BukkitQueue extends SimpleCharQueueExtent { @@ -94,7 +98,7 @@ public class BukkitQueue extends SimpleCharQueueExtent { // }; @Override - public IChunk create(boolean full) { + public IChunk create(boolean isFull) { // if (full) { // //TODO implement // return FULL_CHUNKS.get(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/ArrayFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/ArrayFilterBlock.java index 8e29eecd2..8e72068c7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/ArrayFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/ArrayFilterBlock.java @@ -5,18 +5,19 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; - import javax.annotation.Nullable; public class ArrayFilterBlock extends SimpleFilterBlock { + private final char[] blocks; private final byte[] heights; private final int yOffset; + private final int width, length; private int x, z, index; private char ordinal; - private final int width, length; - public ArrayFilterBlock(Extent extent, char[] blocks, byte[] heights, int width, int length, int yOffset) { + public ArrayFilterBlock(Extent extent, char[] blocks, byte[] heights, int width, int length, + int yOffset) { super(extent); this.blocks = blocks; this.width = width; @@ -34,43 +35,44 @@ public class ArrayFilterBlock extends SimpleFilterBlock { } } - @Override - public void setOrdinal(int ordinal) { - blocks[index] = (char) ordinal; - } - - @Override - public void setBlock(BlockState state) { - blocks[index] = state.getOrdinalChar(); - } - - @Override - public void setFullBlock(BaseBlock block) { - blocks[index] = block.getOrdinalChar(); - } - @Override public int getOrdinal() { return ordinal; } + @Override + public void setOrdinal(int ordinal) { + blocks[index] = (char) ordinal; + } + @Override public BlockState getBlock() { return BlockTypes.states[ordinal]; } + @Override + public void setBlock(BlockState state) { + blocks[index] = state.getOrdinalChar(); + } + @Override public BaseBlock getFullBlock() { return getBlock().toBaseBlock(); } + @Override + public void setFullBlock(BaseBlock block) { + blocks[index] = block.getOrdinalChar(); + } + @Override public CompoundTag getNbtData() { return null; } @Override - public void setNbtData(@Nullable CompoundTag nbtData) {} + public void setNbtData(@Nullable CompoundTag nbtData) { + } @Override public int getX() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java index ea236d5a4..25a037169 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java @@ -12,39 +12,54 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.registry.BlockMaterial; import javax.annotation.Nullable; + public class CharFilterBlock extends ChunkFilterBlock { + + private static final SetDelegate FULL = new SetDelegate() { + @Override + public final void set(CharFilterBlock block, char value) { + block.setArr[block.index] = value; + } + }; + private static final SetDelegate NULL = new SetDelegate() { + @Override + public void set(CharFilterBlock block, char value) { + block.initSet().set(block, value); + } + }; private CharGetBlocks get; private IChunkSet set; - private char[] getArr; - private @Nullable char[] setArr; + private @Nullable + char[] setArr; private SetDelegate delegate; - // local - private int layer, index, x, y, z, xx, yy, zz, X, Z; + private int layer, index, x, y, z, xx, yy, zz, chunkX, chunkZ; public CharFilterBlock(IQueueExtent queueExtent) { super(queueExtent); } @Override - public final ChunkFilterBlock init(final int chunkX, final int chunkZ, final IChunkGet chunk) { + public final ChunkFilterBlock init(int chunkX, int chunkZ, IChunkGet chunk) { this.get = (CharGetBlocks) chunk; - this.X = chunkX; - this.Z = chunkZ; + this.chunkX = chunkX; + this.chunkZ = chunkZ; this.xx = chunkX << 4; this.zz = chunkZ << 4; return this; } - public void flood(final IChunkGet iget, final IChunkSet iset, final int layer, Flood flood, FilterBlockMask mask) { + @Override + public void flood(IChunkGet iget, IChunkSet iset, int layer, Flood flood, + FilterBlockMask mask) { final int maxDepth = flood.getMaxDepth(); final boolean checkDepth = maxDepth < Character.MAX_VALUE; if (init(iget, iset, layer) != null) { while ((index = flood.poll()) != -1) { x = index & 15; - z = (index >> 4) & 15; - y = (index >> 8) & 15; + z = index >> 4 & 15; + y = index >> 8 & 15; if (mask.applyBlock(this)) { int depth = index >> 12; @@ -60,10 +75,13 @@ public class CharFilterBlock extends ChunkFilterBlock { } @Override - public final ChunkFilterBlock init(final IChunkGet iget, final IChunkSet iset, final int layer) { + public final ChunkFilterBlock init(IChunkGet iget, IChunkSet iset, + int layer) { this.layer = layer; final CharGetBlocks get = (CharGetBlocks) iget; - if (!get.hasSection(layer)) return null; + if (!get.hasSection(layer)) { + return null; + } this.set = iset; getArr = get.sections[layer].get(get, layer); if (set.hasSection(layer)) { @@ -82,13 +100,13 @@ public class CharFilterBlock extends ChunkFilterBlock { this.x = x; this.y = y; this.z = z; - this.index = x | (z << 4) | (y << 8); + this.index = x | z << 4 | y << 8; filter.applyBlock(this); } @Override public void filter(Filter filter, int yStart, int yEnd) { - for (y = yStart, index = (yStart << 8); y < yEnd; y++) { + for (y = yStart, index = yStart << 8; y < yEnd; y++) { for (z = 0; z < 16; z++) { for (x = 0; x < 16; x++, index++) { filter.applyBlock(this); @@ -99,8 +117,8 @@ public class CharFilterBlock extends ChunkFilterBlock { @Override public void filter(Filter filter, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) { - int yis = (minY << 8); - int zis = (minZ << 4); + int yis = minY << 8; + int zis = minZ << 4; for (y = minY, index = yis; y <= maxY; y++) { for (z = minZ, index += zis; z <= maxZ; z++) { for (x = minX, index += minX; x <= maxX; x++, index++) { @@ -111,7 +129,7 @@ public class CharFilterBlock extends ChunkFilterBlock { } @Override - public final void filter(final Filter filter, final Region region) { + public final void filter(Filter filter, Region region) { for (y = 0, index = 0; y < 16; y++) { int absY = yy + y; for (z = 0; z < 16; z++) { @@ -127,7 +145,7 @@ public class CharFilterBlock extends ChunkFilterBlock { } @Override - public final void filter(final Filter filter) { + public final void filter(Filter filter) { for (y = 0, index = 0; y < 16; y++) { for (z = 0; z < 16; z++) { for (x = 0; x < 16; x++, index++) { @@ -142,25 +160,6 @@ public class CharFilterBlock extends ChunkFilterBlock { set.setBiome(x, y, z, biome); } - @Override - public void setOrdinal(final int ordinal) { - delegate.set(this, (char) ordinal); - } - - @Override - public void setBlock(final BlockState state) { - delegate.set(this, state.getOrdinalChar()); - } - - @Override - public void setFullBlock(final BaseBlock block) { - delegate.set(this, block.getOrdinalChar()); - final CompoundTag nbt = block.getNbtData(); - if (nbt != null) { // TODO optimize check via ImmutableBaseBlock - set.setTile(x, yy + y, z, nbt); - } - } - @Override public final int getX() { return xx + x; @@ -193,12 +192,12 @@ public class CharFilterBlock extends ChunkFilterBlock { @Override public final int getChunkX() { - return X; + return chunkX; } @Override public final int getChunkZ() { - return Z; + return chunkZ; } public final char getOrdinalChar() { @@ -210,12 +209,22 @@ public class CharFilterBlock extends ChunkFilterBlock { return getArr[index]; } + @Override + public void setOrdinal(int ordinal) { + delegate.set(this, (char) ordinal); + } + @Override public final BlockState getBlock() { final int ordinal = getArr[index]; return BlockTypes.states[ordinal]; } + @Override + public void setBlock(BlockState state) { + delegate.set(this, state.getOrdinalChar()); + } + @Override public final BaseBlock getFullBlock() { final BlockState state = getBlock(); @@ -227,10 +236,25 @@ public class CharFilterBlock extends ChunkFilterBlock { return state.toBaseBlock(); } + @Override + public void setFullBlock(BaseBlock block) { + delegate.set(this, block.getOrdinalChar()); + final CompoundTag nbt = block.getNbtData(); + if (nbt != null) { // TODO optimize check via ImmutableBaseBlock + set.setTile(x, yy + y, z, nbt); + } + } + @Override public final CompoundTag getNbtData() { return get.getTag(x, y + (layer << 4), z); } + /* + NORTH(Vector3.at(0, 0, -1), Flag.CARDINAL, 3, 1), + EAST(Vector3.at(1, 0, 0), Flag.CARDINAL, 0, 2), + SOUTH(Vector3.at(0, 0, 1), Flag.CARDINAL, 1, 3), + WEST(Vector3.at(-1, 0, 0), Flag.CARDINAL, 2, 0), + */ @Override public void setNbtData(CompoundTag tag) { @@ -245,19 +269,13 @@ public class CharFilterBlock extends ChunkFilterBlock { final BlockMaterial material = state.getMaterial(); return material.hasContainer(); } - /* - NORTH(Vector3.at(0, 0, -1), Flag.CARDINAL, 3, 1), - EAST(Vector3.at(1, 0, 0), Flag.CARDINAL, 0, 2), - SOUTH(Vector3.at(0, 0, 1), Flag.CARDINAL, 1, 3), - WEST(Vector3.at(-1, 0, 0), Flag.CARDINAL, 2, 0), - */ @Override public final BlockState getBlockNorth() { if (z > 0) { return states[getArr[index - 16]]; } - return getExtent().getBlock(getX(), getY(), getZ() - 1); + return getExtent().getBlock(getX(), getY(), getZ() - 1); } @Override @@ -265,7 +283,7 @@ public class CharFilterBlock extends ChunkFilterBlock { if (x < 15) { return states[getArr[index + 1]]; } - return getExtent().getBlock(getX() + 1, getY(), getZ()); + return getExtent().getBlock(getX() + 1, getY(), getZ()); } @Override @@ -273,7 +291,7 @@ public class CharFilterBlock extends ChunkFilterBlock { if (z < 15) { return states[getArr[index + 16]]; } - return getExtent().getBlock(getX(), getY(), getZ() + 1); + return getExtent().getBlock(getX(), getY(), getZ() + 1); } @Override @@ -281,7 +299,7 @@ public class CharFilterBlock extends ChunkFilterBlock { if (x > 0) { return states[getArr[index - 1]]; } - return getExtent().getBlock(getX() - 1, getY(), getZ()); + return getExtent().getBlock(getX() - 1, getY(), getZ()); } @Override @@ -311,7 +329,7 @@ public class CharFilterBlock extends ChunkFilterBlock { } @Override - public final BlockState getBlockRelativeY(final int y) { + public final BlockState getBlockRelativeY(int y) { final int newY = this.y + y; final int layerAdd = newY >> 4; switch (layerAdd) { @@ -353,14 +371,13 @@ public class CharFilterBlock extends ChunkFilterBlock { case -12: case -13: case -14: - case -15: { + case -15: final int newLayer = layer + layerAdd; if (newLayer >= 0) { final int index = this.index + ((y & 15) << 8); return states[get.sections[newLayer].get(get, newLayer, index)]; } break; - } } return BlockTypes.__RESERVED__.getDefaultState(); } @@ -383,7 +400,7 @@ public class CharFilterBlock extends ChunkFilterBlock { @Override public BiomeType getBiomeType(int x, int z) { - if ((x >> 4) == X && (z >> 4) == Z) { + if (x >> 4 == chunkX && z >> 4 == chunkZ) { return get.getBiomeType(x & 15, z & 15); } return getExtent().getBiomeType(x, z); @@ -391,27 +408,14 @@ public class CharFilterBlock extends ChunkFilterBlock { @Override public boolean setBiome(int x, int y, int z, BiomeType biome) { - if ((x >> 4) == X && (z >> 4) == Z) { + if (x >> 4 == chunkX && z >> 4 == chunkZ) { return set.setBiome(x & 15, y, z & 15, biome); } return getExtent().setBiome(x, y, z, biome); } private interface SetDelegate { + void set(CharFilterBlock block, char value); } - - private static final SetDelegate NULL = new SetDelegate() { - @Override - public void set(final CharFilterBlock block, final char value) { - block.initSet().set(block, value); - } - }; - - private static final SetDelegate FULL = new SetDelegate() { - @Override - public final void set(final CharFilterBlock block, final char value) { - block.setArr[block.index] = value; - } - }; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java index 2e0de38c4..d87a536f5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java @@ -4,24 +4,28 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.regions.Region; public abstract class ChunkFilterBlock extends SimpleFilterBlock { + public ChunkFilterBlock(Extent extent) { super(extent); } public abstract ChunkFilterBlock init(int chunkX, int chunkZ, IChunkGet chunk); - public abstract ChunkFilterBlock init(final IChunkGet iget, final IChunkSet iset, final int layer); + public abstract ChunkFilterBlock init(IChunkGet iget, IChunkSet iset, + int layer); - public abstract void flood(final IChunkGet iget, final IChunkSet iset, final int layer, Flood flood, FilterBlockMask mask); + public abstract void flood(IChunkGet iget, IChunkSet iset, int layer, + Flood flood, FilterBlockMask mask); public abstract void filter(Filter filter, int x, int y, int z); - public abstract void filter(Filter filter, int minX, int minY, int minZ, int maxX, int maxY, int maxZ); + public abstract void filter(Filter filter, int minX, int minY, int minZ, int maxX, int maxY, + int maxZ); public abstract void filter(Filter filter); public abstract void filter(Filter filter, int yStart, int yEnd); - public abstract void filter(final Filter filter, final Region region); + public abstract void filter(Filter filter, Region region); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFuture.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFuture.java index 264eb4509..38fecb9c9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFuture.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFuture.java @@ -6,11 +6,12 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; public class ChunkFuture implements Future { + private final IChunk chunk; private volatile boolean cancelled; private volatile boolean done; - public ChunkFuture(final IChunk chunk) { + public ChunkFuture(IChunk chunk) { this.chunk = chunk; } @@ -19,10 +20,9 @@ public class ChunkFuture implements Future { } @Override - public boolean cancel(final boolean mayInterruptIfRunning) { + public boolean cancel(boolean mayInterruptIfRunning) { cancelled = true; - if (done) return false; - return true; + return !done; } @Override @@ -46,7 +46,8 @@ public class ChunkFuture implements Future { } @Override - public Void get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + public Void get(long timeout, TimeUnit unit) + throws InterruptedException, ExecutionException, TimeoutException { synchronized (chunk) { if (!done) { this.wait(unit.toMillis(timeout)); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilter.java index bbbe85f61..c71da676a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilter.java @@ -1,11 +1,13 @@ package com.boydti.fawe.beta; public class DelegateFilter implements IDelegateFilter { + private final Filter parent; public DelegateFilter(T parent) { this.parent = parent; } + @Override public T getParent() { return (T) parent; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java index 4cb06ff5e..8aa790db2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java @@ -24,43 +24,35 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; - -import javax.annotation.Nullable; import java.util.Comparator; import java.util.List; +import javax.annotation.Nullable; public class DelegateFilterBlock extends FilterBlock { + private final FilterBlock parent; public DelegateFilterBlock(FilterBlock parent) { this.parent = parent; } + public static BlockVector3 at(double x, double y, double z) { + return BlockVector3.at(x, y, z); + } + + public static BlockVector3 at(int x, int y, int z) { + return BlockVector3.at(x, y, z); + } + + public static Comparator sortByCoordsYzx() { + return BlockVector3.sortByCoordsYzx(); + } + @Override public Extent getExtent() { return parent.getExtent(); } - @Override - public void setOrdinal(int ordinal) { - parent.setOrdinal(ordinal); - } - - @Override - public void setBlock(BlockState state) { - parent.setBlock(state); - } - - @Override - public void setFullBlock(BaseBlock block) { - parent.setFullBlock(block); - } - - @Override - public void setNbtData(@Nullable CompoundTag nbtData) { - parent.setNbtData(nbtData); - } - @Override public boolean hasNbtData() { return parent.hasNbtData(); @@ -76,21 +68,41 @@ public class DelegateFilterBlock extends FilterBlock { return parent.getOrdinal(); } + @Override + public void setOrdinal(int ordinal) { + parent.setOrdinal(ordinal); + } + @Override public BlockState getBlock() { return parent.getBlock(); } + @Override + public void setBlock(BlockState state) { + parent.setBlock(state); + } + @Override public BaseBlock getFullBlock() { return parent.getFullBlock(); } + @Override + public void setFullBlock(BaseBlock block) { + parent.setFullBlock(block); + } + @Override public CompoundTag getNbtData() { return parent.getNbtData(); } + @Override + public void setNbtData(@Nullable CompoundTag nbtData) { + parent.setNbtData(nbtData); + } + @Override public BlockVector3 getMinimumPoint() { return parent.getMinimumPoint(); @@ -241,18 +253,6 @@ public class DelegateFilterBlock extends FilterBlock { return parent.getStateRelativeY(orDefault, y); } - public static BlockVector3 at(double x, double y, double z) { - return BlockVector3.at(x, y, z); - } - - public static BlockVector3 at(int x, int y, int z) { - return BlockVector3.at(x, y, z); - } - - public static Comparator sortByCoordsYzx() { - return BlockVector3.sortByCoordsYzx(); - } - @Override public MutableBlockVector3 setComponents(double x, double y, double z) { return parent.setComponents(x, y, z); @@ -479,7 +479,8 @@ public class DelegateFilterBlock extends FilterBlock { } @Override - public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) { + public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, + double translateZ) { return parent.transform2D(angle, aboutX, aboutZ, translateX, translateZ); } @@ -560,7 +561,8 @@ public class DelegateFilterBlock extends FilterBlock { } @Override - public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) { + public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, + boolean ignoreAir) { return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir); } @@ -570,18 +572,23 @@ public class DelegateFilterBlock extends FilterBlock { } @Override - public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) { + public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, + int failedMax) { return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax); } @Override - public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) { - return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask); + public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, + int failedMax, Mask mask) { + return parent + .getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask); } @Override - public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) { - return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir); + public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, + int failedMax, boolean ignoreAir) { + return parent + .getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir); } @Override @@ -595,12 +602,14 @@ public class DelegateFilterBlock extends FilterBlock { } @Override - public void addSchems(Region region, Mask mask, List clipboards, int rarity, boolean rotate) throws WorldEditException { + public void addSchems(Region region, Mask mask, List clipboards, int rarity, + boolean rotate) throws WorldEditException { parent.addSchems(region, mask, clipboards, rarity, rotate); } @Override - public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException { + public void spawnResource(Region region, Resource gen, int rarity, int frequency) + throws WorldEditException { parent.spawnResource(region, gen, rarity, frequency); } @@ -610,7 +619,8 @@ public class DelegateFilterBlock extends FilterBlock { } @Override - public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException { + public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, + int rarity, int minY, int maxY) throws WorldEditException { parent.addOre(region, mask, material, size, frequency, rarity, minY, maxY); } @@ -671,12 +681,14 @@ public class DelegateFilterBlock extends FilterBlock { } @Override - public > boolean setBlock(BlockVector3 position, T block) throws WorldEditException { + public > boolean setBlock(BlockVector3 position, T block) + throws WorldEditException { return parent.setBlock(position, block); } @Override - public > boolean setBlock(int x, int y, int z, T block) throws WorldEditException { + public > boolean setBlock(int x, int y, int z, T block) + throws WorldEditException { return parent.setBlock(x, y, z, block); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/DirectionMask.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/DirectionMask.java index 4efce15ec..a6ff0e687 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/DirectionMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/DirectionMask.java @@ -1,5 +1,6 @@ package com.boydti.fawe.beta; public interface DirectionMask { + boolean apply(int fromX, int fromY, int fromZ, int toX, int toY, int toZ); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java index bb4da31f7..a459a751c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java @@ -2,31 +2,33 @@ package com.boydti.fawe.beta; import com.sk89q.worldedit.regions.Region; import javax.annotation.Nullable; +import org.jetbrains.annotations.Range; /** - * A filter is an interface used for setting blocks + * A filter is an interface used for setting blocks. */ -public interface Filter { +public interface Filter { + /** * Checks whether a chunk should be read. * - * @param chunkX - * @param chunkZ + * @param chunkX the x coordinate in the chunk + * @param chunkZ the z coordinate in the chunk * @return */ - default boolean appliesChunk(final int chunkX, final int chunkZ) { + default boolean appliesChunk(@Range(from = 0, to = 15) int chunkX, + @Range(from = 0, to = 15) int chunkZ) { return true; } /** - * Do something with the IChunk
- * - Return null if you don't want to filter blocks
- * - Return the chunk if you do want to filter blocks
+ * Do something with the IChunk
- Return null if you don't want to filter blocks
- + * Return the chunk if you do want to filter blocks
* * @param chunk * @return */ - default IChunk applyChunk(final IChunk chunk, @Nullable Region region) { + default IChunk applyChunk(IChunk chunk, @Nullable Region region) { return chunk; } @@ -35,27 +37,27 @@ public interface Filter { } /** - * Make changes to the block here
- * - e.g. block.setId(...)
- * - Note: Performance is critical here
+ * Make changes to the block here
- e.g. block.setId(...)
- Note: Performance is + * critical here
* * @param block */ - default void applyBlock(final FilterBlock block) { + default void applyBlock(FilterBlock block) { } /** - * Do something with the IChunk after block filtering
+ * Do something with the IChunk after block filtering. * * @param chunk * @return */ - default void finishChunk(final IChunk chunk) { + default void finishChunk(IChunk chunk) { } /** - * Fork this for use by another thread - * - Typically filters are simple and don't need to create another copy to be thread safe here + * Fork this for use by another thread - Typically filters are simple and don't need to create + * another copy to be thread safe here + * * @return this */ default Filter fork() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java index ed2a84be4..f0ed63fd2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java @@ -7,34 +7,35 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; - import javax.annotation.Nullable; -import static com.sk89q.worldedit.world.block.BlockTypes.states; - public abstract class FilterBlock extends BlockVector3 implements Extent, TileEntityBlock { + public abstract Extent getExtent(); - public abstract void setOrdinal(int ordinal); - - public abstract void setBlock(BlockState state); - - public abstract void setFullBlock(BaseBlock block); - public void setBiome(BiomeType biome) { setBiome(getX(), getY(), getZ(), biome); } public abstract int getOrdinal(); + public abstract void setOrdinal(int ordinal); + public abstract BlockState getBlock(); + public abstract void setBlock(BlockState state); + public abstract BaseBlock getFullBlock(); + public abstract void setFullBlock(BaseBlock block); + + @Override public abstract CompoundTag getNbtData(); + @Override public abstract void setNbtData(@Nullable CompoundTag nbtData); + @Override public boolean hasNbtData() { return getNbtData() != null; } @@ -83,8 +84,8 @@ public abstract class FilterBlock extends BlockVector3 implements Extent, TileEn return getBlock(getX() - 1, getY(), getZ()); } - public BlockState getBlockRelativeY(final int y) { - return getBlock(getX(), getY() + y , getZ()); + public BlockState getBlockRelativeY(int y) { + return getBlock(getX(), getY() + y, getZ()); } @Override @@ -119,51 +120,62 @@ public abstract class FilterBlock extends BlockVector3 implements Extent, TileEn /* Extent */ + @Override public boolean setOrdinal(Extent orDefault, int ordinal) { setOrdinal(ordinal); return true; } + @Override public boolean setBlock(Extent orDefault, BlockState state) { setBlock(state); return true; } + @Override public boolean setFullBlock(Extent orDefault, BaseBlock block) { setFullBlock(block); return true; } + @Override public boolean setBiome(Extent orDefault, BiomeType biome) { setBiome(biome); return true; } + @Override public int getOrdinal(Extent orDefault) { return getOrdinal(); } + @Override public BlockState getBlock(Extent orDefault) { return getBlock(); } + @Override public BaseBlock getFullBlock(Extent orDefault) { return getFullBlock(); } + @Override public CompoundTag getNbtData(Extent orDefault) { return getNbtData(); } + @Override public BlockState getOrdinalBelow(Extent orDefault) { return getBlockBelow(); } + @Override public BlockState getStateAbove(Extent orDefault) { return getBlockAbove(); } - public BlockState getStateRelativeY(Extent orDefault, final int y) { + @Override + public BlockState getStateRelativeY(Extent orDefault, int y) { return getBlockRelativeY(y); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlockMask.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlockMask.java index e7728435c..7ad53d554 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlockMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlockMask.java @@ -1,5 +1,6 @@ package com.boydti.fawe.beta; public interface FilterBlockMask { - boolean applyBlock(final FilterBlock block); -} \ No newline at end of file + + boolean applyBlock(FilterBlock block); +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java index 377edfa34..961dfba08 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java @@ -6,27 +6,23 @@ import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.world.World; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; - import java.util.concurrent.ConcurrentLinkedQueue; public class Flood { + private final int maxBranch; private final int maxDepth; private final Direction[] directions; - + private final Long2ObjectLinkedOpenHashMap chunkVisits; + private final Long2ObjectLinkedOpenHashMap chunkQueues; private int[] queue; private long[] visit; - private int[][] queues; private long[][] visits; - private int chunkX; private int chunkYLayer; private int chunkZ; - private ConcurrentLinkedQueue queuePool = new ConcurrentLinkedQueue<>(); - private final Long2ObjectLinkedOpenHashMap chunkVisits; - private final Long2ObjectLinkedOpenHashMap chunkQueues; public Flood(int maxBranch, int maxDepth, Direction[] directions) { this.maxBranch = maxBranch; @@ -68,7 +64,7 @@ public class Flood { long pair = MathMan.pairInt(chunkX, chunkZ); int layer = y >> 4; int[] section = getOrCreateQueue(pair, layer); - int val = (x & 15) + ((z & 15) << 4) + ((y & 15) << 8) + (depth << 12); + int val = (x & 15) + ((z & 15) << 4) + ((y & 15) << 8) + (depth << 12); push(section, val); } @@ -171,12 +167,12 @@ public class Flood { } public void set(long[] bits, int i) { - bits[i >> 6] |= (1L << (i & 0x3F)); + bits[i >> 6] |= 1L << (i & 0x3F); } public final boolean getAndSet(long[] bits, int i) { int index = i >> 6; - long offset = (1L << (i & 0x3F)); + long offset = 1L << (i & 0x3F); long val = bits[index]; if ((val & offset) != 0) { return true; @@ -186,7 +182,7 @@ public class Flood { } } - public boolean get(long[] bits, final int i) { - return (bits[i >> 6] & (1L << (i & 0x3F))) != 0; + public boolean get(long[] bits, int i) { + return (bits[i >> 6] & 1L << (i & 0x3F)) != 0; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java index a66d38157..7dafab979 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java @@ -4,7 +4,8 @@ package com.boydti.fawe.beta; * Shared interface for IGetBlocks and ISetBlocks */ public interface IBlocks extends Trimable { + boolean hasSection(int layer); IBlocks reset(); -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java index 2a643d6fe..0d6f4e211 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java @@ -12,12 +12,14 @@ import java.util.concurrent.Future; import javax.annotation.Nullable; /** - * Represents a chunk in the queue {@link IQueueExtent} - * Used for getting and setting blocks / biomes / entities + * Represents a chunk in the queue {@link IQueueExtent} Used for getting and setting blocks / biomes + * / entities */ public interface IChunk> extends Trimable, Callable, IChunkGet { + /** * Initialize at the location + * * @param extent * @param x * @param z @@ -31,7 +33,8 @@ public interface IChunk> extends Trimable, Callable, IChu int getZ(); /** - * If the chunk is a delegate, returns it's paren'ts root + * If the chunk is a delegate, returns it's parent's root + * * @return root IChunk */ default IChunk getRoot() { @@ -39,20 +42,25 @@ public interface IChunk> extends Trimable, Callable, IChu } /** + * Checks if there are any queued changes for this chunk. + * * @return true if no changes are queued for this chunk */ boolean isEmpty(); /** - * Apply the queued changes to the world
- * The future returned may return another future
- * To ensure completion keep calling {@link Future#get()} on each result + * Apply the queued changes to the world containing this chunk. + *

The future returned may return another future. To ensure completion keep calling {@link + * Future#get()} on each result.

+ * * @return Futures */ + @Override T call(); /** * Call and join + * * @throws ExecutionException * @throws InterruptedException */ @@ -66,11 +74,10 @@ public interface IChunk> extends Trimable, Callable, IChu /** * Filter + * * @param filter the filter - * @param block The filter block + * @param block The filter block * @param region The region allowed to filter (may be null) - * @param unitialized a mutable block vector (buffer) - * @param unitialized2 a mutable block vector (buffer) */ void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region); @@ -81,13 +88,16 @@ public interface IChunk> extends Trimable, Callable, IChu boolean setBlock(int x, int y, int z, BlockStateHolder block); - /* get - from the world */ + @Override BiomeType getBiomeType(int x, int z); + @Override BlockState getBlock(int x, int y, int z); + @Override BaseBlock getFullBlock(int x, int y, int z); + @Override CompoundTag getTag(int x, int y, int z); @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkGet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkGet.java index a76894912..c59d4d09d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkGet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkGet.java @@ -7,9 +7,10 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; /** - * Interface for getting blocks + * An interface for getting blocks. */ public interface IChunkGet extends IBlocks, Trimable, InputExtent { + @Override BaseBlock getFullBlock(int x, int y, int z); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java index 9e34c4d4d..5513708a5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java @@ -6,16 +6,16 @@ import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; - -import javax.annotation.Nullable; import java.util.Map; import java.util.Set; import java.util.UUID; +import javax.annotation.Nullable; /** * Interface for setting blocks */ public interface IChunkSet extends IBlocks, OutputExtent { + @Override boolean setBiome(int x, int y, int z, BiomeType biome); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java index d88896ee8..1750c9e42 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java @@ -6,18 +6,20 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; - -import javax.annotation.Nullable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import javax.annotation.Nullable; /** * Delegate for IChunk + * * @param parent class */ public interface IDelegateChunk extends IChunk { + U getParent(); + @Override default IChunk getRoot() { IChunk root = getParent(); while (root instanceof IDelegateChunk) { @@ -48,32 +50,32 @@ public interface IDelegateChunk extends IChunk { } @Override - default boolean setBiome(final int x, final int y, final int z, final BiomeType biome) { + default boolean setBiome(int x, int y, int z, BiomeType biome) { return getParent().setBiome(x, y, z, biome); } @Override - default boolean setBlock(final int x, final int y, final int z, final BlockStateHolder holder) { + default boolean setBlock(int x, int y, int z, BlockStateHolder holder) { return getParent().setBlock(x, y, z, holder); } @Override - default BiomeType getBiomeType(final int x, final int z) { + default BiomeType getBiomeType(int x, int z) { return getParent().getBiomeType(x, z); } @Override - default BlockState getBlock(final int x, final int y, final int z) { + default BlockState getBlock(int x, int y, int z) { return getParent().getBlock(x, y, z); } @Override - default BaseBlock getFullBlock(final int x, final int y, final int z) { + default BaseBlock getFullBlock(int x, int y, int z) { return getParent().getFullBlock(x, y, z); } @Override - default void init(final IQueueExtent extent, final int chunkX, final int chunkZ) { + default void init(IQueueExtent extent, int chunkX, int chunkZ) { getParent().init(extent, chunkX, chunkZ); } @@ -89,7 +91,7 @@ public interface IDelegateChunk extends IChunk { @Override - default boolean trim(final boolean aggressive) { + default boolean trim(boolean aggressive) { return getParent().trim(aggressive); } @@ -113,12 +115,16 @@ public interface IDelegateChunk extends IChunk { return getParent().isEmpty(); } - default T findParent(final Class clazz) { + default T findParent(Class clazz) { IChunk root = getParent(); - if (clazz.isAssignableFrom(root.getClass())) return (T) root; + if (clazz.isAssignableFrom(root.getClass())) { + return (T) root; + } while (root instanceof IDelegateChunk) { root = ((IDelegateChunk) root).getParent(); - if (clazz.isAssignableFrom(root.getClass())) return (T) root; + if (clazz.isAssignableFrom(root.getClass())) { + return (T) root; + } } return null; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java index 5736290e7..a354d7ab7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java @@ -1,10 +1,10 @@ package com.boydti.fawe.beta; import com.sk89q.worldedit.regions.Region; - import javax.annotation.Nullable; public interface IDelegateFilter extends Filter { + Filter getParent(); @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java index ea890c85e..240ab76b9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java @@ -1,37 +1,37 @@ package com.boydti.fawe.beta; import com.boydti.fawe.beta.implementation.WorldChunkCache; - import java.util.concurrent.Future; /** * Delegate for IQueueExtent */ public interface IDelegateQueueExtent extends IQueueExtent { + IQueueExtent getParent(); @Override - default void init(final WorldChunkCache cache) { + default void init(WorldChunkCache cache) { getParent().init(cache); } @Override - default IChunk getCachedChunk(final int x, final int z) { + default IChunk getCachedChunk(int x, int z) { return getParent().getCachedChunk(x, z); } @Override - default Future submit(final IChunk chunk) { + default Future submit(IChunk chunk) { return getParent().submit(chunk); } @Override - default IChunk create(final boolean full) { - return getParent().create(full); + default IChunk create(boolean isFull) { + return getParent().create(isFull); } @Override - default IChunk wrap(final IChunk root) { + default IChunk wrap(IChunk root) { return getParent().wrap(root); } @@ -41,7 +41,7 @@ public interface IDelegateQueueExtent extends IQueueExtent { } @Override - default boolean trim(final boolean aggressive) { + default boolean trim(boolean aggressive) { return getParent().trim(aggressive); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java index 1c24abddb..38392ef74 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java @@ -8,14 +8,13 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; - import java.io.Flushable; import java.util.concurrent.Future; import java.util.function.Supplier; /** - * TODO: implement Extent (need to refactor Extent first) - * Interface for a queue based extent which uses chunks + * TODO: implement Extent (need to refactor Extent first) Interface for a queue based extent which + * uses chunks */ public interface IQueueExtent extends Flushable, Trimable, Extent { @@ -40,12 +39,14 @@ public interface IQueueExtent extends Flushable, Trimable, Extent { /** * Get the {@link WorldChunkCache} + * * @return */ IChunkGet getCachedGet(int x, int z, Supplier supplier); /** * Get the IChunk at a position (and cache it if it's not already) + * * @param x * @param z * @return IChunk @@ -54,24 +55,26 @@ public interface IQueueExtent extends Flushable, Trimable, Extent { /** * Submit the chunk so that it's changes are applied to the world + * * @param chunk * @return result */ > T submit(IChunk chunk); @Override - default boolean setBlock(final int x, final int y, final int z, final BlockStateHolder state) { + default boolean setBlock(int x, int y, int z, BlockStateHolder state) { final IChunk chunk = getCachedChunk(x >> 4, z >> 4); return chunk.setBlock(x & 15, y, z & 15, state); } @Override - default boolean setBiome(final int x, final int y, final int z, final BiomeType biome) { + default boolean setBiome(int x, int y, int z, BiomeType biome) { final IChunk chunk = getCachedChunk(x >> 4, z >> 4); return chunk.setBiome(x & 15, y, z & 15, biome); } - default BlockState getBlock(final int x, final int y, final int z) { + @Override + default BlockState getBlock(int x, int y, int z) { final IChunk chunk = getCachedChunk(x >> 4, z >> 4); return chunk.getBlock(x & 15, y, z & 15); } @@ -82,7 +85,7 @@ public interface IQueueExtent extends Flushable, Trimable, Extent { return chunk.getFullBlock(x & 15, y, z & 15); } - default BiomeType getBiome(final int x, final int z) { + default BiomeType getBiome(int x, int z) { final IChunk chunk = getCachedChunk(x >> 4, z >> 4); return chunk.getBiomeType(x & 15, z & 15); } @@ -98,26 +101,27 @@ public interface IQueueExtent extends Flushable, Trimable, Extent { } /** - * Create a new root IChunk object
- * - Full chunks will be reused, so a more optimized chunk can be returned in that case
- * - Don't wrap the chunk, that should be done in {@link #wrap(IChunk)} - * @param full + * Create a new root IChunk object
- Full chunks will be reused, so a more optimized chunk + * can be returned in that case
- Don't wrap the chunk, that should be done in {@link + * #wrap(IChunk)} + * + * @param isFull true if a more optimized chunk should be returned * @return */ - IChunk create(boolean full); + IChunk create(boolean isFull); /** * Wrap the chunk object (i.e. for region restrictions / limits etc.) + * * @param root * @return wrapped chunk */ - default IChunk wrap(final IChunk root) { + default IChunk wrap(IChunk root) { return root; } /** - * Flush all changes to the world - * - Best to call this async so it doesn't hang the server + * Flush all changes to the world - Best to call this async so it doesn't hang the server */ @Override void flush(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/NorthVector.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/NorthVector.java index 94279a6aa..a3ab572a1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/NorthVector.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/NorthVector.java @@ -8,6 +8,7 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; public class NorthVector extends BlockVector3 { + private final BlockVector3 parent; public NorthVector(BlockVector3 parent) { @@ -34,55 +35,67 @@ public class NorthVector extends BlockVector3 { return parent.getZ(); } + @Override public boolean setOrdinal(Extent orDefault, int ordinal) { return orDefault.setBlock(this, BlockState.getFromOrdinal(ordinal)); } + @Override public boolean setBlock(Extent orDefault, BlockState state) { return orDefault.setBlock(this, state); } + @Override public boolean setFullBlock(Extent orDefault, BaseBlock block) { - return orDefault.setBlock(this, block); + return orDefault.setBlock(this, block); } + @Override public boolean setBiome(Extent orDefault, BiomeType biome) { return orDefault.setBiome(getX(), getY(), getZ(), biome); } + @Override public int getOrdinal(Extent orDefault) { return getBlock(orDefault).getOrdinal(); } + @Override public char getOrdinalChar(Extent orDefault) { return (char) getOrdinal(orDefault); } + @Override public BlockState getBlock(Extent orDefault) { return orDefault.getBlock(this); } + @Override public BaseBlock getFullBlock(Extent orDefault) { return orDefault.getFullBlock(this); } + @Override public CompoundTag getNbtData(Extent orDefault) { return orDefault.getFullBlock(getX(), getY(), getZ()).getNbtData(); } + @Override public BlockState getOrdinalBelow(Extent orDefault) { return getStateRelative(orDefault, 0, -1, 0); } + @Override public BlockState getStateAbove(Extent orDefault) { return getStateRelative(orDefault, 0, 1, 0); } - public BlockState getStateRelativeY(Extent orDefault, final int y) { + @Override + public BlockState getStateRelativeY(Extent orDefault, int y) { return getStateRelative(orDefault, 0, y, 0); } - public BlockState getStateRelative(Extent orDefault, final int x, final int y, final int z) { + public BlockState getStateRelative(Extent orDefault, int x, int y, int z) { return getFullBlockRelative(orDefault, x, y, z).toBlockState(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/SimpleFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/SimpleFilterBlock.java index b8d865aec..27cc60afd 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/SimpleFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/SimpleFilterBlock.java @@ -3,6 +3,7 @@ package com.boydti.fawe.beta; import com.sk89q.worldedit.extent.Extent; public abstract class SimpleFilterBlock extends FilterBlock { + private final Extent extent; public SimpleFilterBlock(Extent extent) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java index 39a2c04a0..ec4bf5b73 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java @@ -5,7 +5,6 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; - import javax.annotation.Nullable; public class SingleFilterBlock extends FilterBlock { @@ -26,29 +25,29 @@ public class SingleFilterBlock extends FilterBlock { return this; } + @Override + public int getOrdinal() { + return block.getOrdinal(); + } + @Override public void setOrdinal(int ordinal) { setBlock(BlockState.getFromOrdinal(ordinal)); } + @Override + public BlockState getBlock() { + return block.toBlockState(); + } + @Override public void setBlock(BlockState state) { setFullBlock(state.toBaseBlock(block.getNbtData())); } @Override - public void setFullBlock(BaseBlock block) { - this.block = block; - } - - @Override - public void setNbtData(@Nullable CompoundTag nbtData) { - block = block.toBaseBlock(nbtData); - } - - @Override - public int getOrdinal() { - return block.getOrdinal(); + public BaseBlock getFullBlock() { + return block; } // @Override @@ -57,13 +56,8 @@ public class SingleFilterBlock extends FilterBlock { // } @Override - public BlockState getBlock() { - return block.toBlockState(); - } - - @Override - public BaseBlock getFullBlock() { - return block; + public void setFullBlock(BaseBlock block) { + this.block = block; } @Override @@ -71,6 +65,11 @@ public class SingleFilterBlock extends FilterBlock { return block.getNbtData(); } + @Override + public void setNbtData(@Nullable CompoundTag nbtData) { + block = block.toBaseBlock(nbtData); + } + @Override public int getX() { return x; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/Trimable.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/Trimable.java index 34efe59ae..cfbc8480b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/Trimable.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/Trimable.java @@ -1,13 +1,16 @@ package com.boydti.fawe.beta; /** - * Interface for objects that can be trimmed (memory related)
- * - Trimming will reduce it's memory footprint + * Interface for objects that can be trimmed (memory related)
- Trimming will reduce it's memory + * footprint */ public interface Trimable { + /** * Trim the object, reducing it's memory footprint - * @param aggressive if trimming should be aggressive e.g. Not return early when the first element cannot be trimmed + * + * @param aggressive if trimming should be aggressive e.g. Not return early when the first + * element cannot be trimmed * @return if this object is empty at the end of the trim, and can therefore be deleted */ boolean trim(boolean aggressive); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ArrayImageMask.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ArrayImageMask.java index 26c2e4e98..bc8bb0f46 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ArrayImageMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ArrayImageMask.java @@ -2,11 +2,11 @@ package com.boydti.fawe.beta.filters; import com.boydti.fawe.beta.FilterBlock; import com.boydti.fawe.beta.FilterBlockMask; - import java.awt.image.BufferedImage; import java.util.concurrent.ThreadLocalRandom; public class ArrayImageMask implements FilterBlockMask { + private final ThreadLocalRandom random; private final boolean white; private final BufferedImage image; @@ -16,9 +16,10 @@ public class ArrayImageMask implements FilterBlockMask { this.white = white; this.random = ThreadLocalRandom.current(); } + @Override public boolean applyBlock(FilterBlock block) { int height = image.getRGB(block.getX(), block.getZ()) & 0xFF; - return ((height == 255 || height > 0 && !white && random.nextInt(256) <= height)); + return height == 255 || height > 0 && !white && random.nextInt(256) <= height; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/CountFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/CountFilter.java index 8dda75900..111502781 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/CountFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/CountFilter.java @@ -3,6 +3,7 @@ package com.boydti.fawe.beta.filters; import com.boydti.fawe.beta.FilterBlock; public class CountFilter extends ForkedFilter { + private int total; public CountFilter() { @@ -23,12 +24,8 @@ public class CountFilter extends ForkedFilter { this.total += filter.getTotal(); } - /* - Implementation - */ - @Override - public final void applyBlock(final FilterBlock block) { + public final void applyBlock(FilterBlock block) { total++; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java index 31d3eeb6c..91ddf73e2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java @@ -8,10 +8,12 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; public class DistrFilter extends ForkedFilter { + private final int[] counter = new int[BlockTypes.states.length]; public DistrFilter() { @@ -34,12 +36,8 @@ public class DistrFilter extends ForkedFilter { } } - /* - Implementation - */ - @Override - public final void applyBlock(final FilterBlock block) { + public final void applyBlock(FilterBlock block) { counter[block.getOrdinal()]++; } @@ -55,9 +53,7 @@ public class DistrFilter extends ForkedFilter { } public int getTotal() { - int total = 0; - for (int value : counter) total += value; - return total; + return Arrays.stream(counter).sum(); } public List> getDistribution() { @@ -92,13 +88,13 @@ public class DistrFilter extends ForkedFilter { return distribution; } - public void print(final Actor actor, final long size) { + public void print(Actor actor, long size) { for (Countable c : getDistribution()) { final String name = c.getID().toString(); final String str = String.format("%-7s (%.3f%%) %s", - String.valueOf(c.getAmount()), - c.getAmount() / (double) size * 100, - name); + String.valueOf(c.getAmount()), + c.getAmount() / (double) size * 100, + name); actor.print(str); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ForkedFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ForkedFilter.java index 6118c4dea..64827ffd0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ForkedFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ForkedFilter.java @@ -1,20 +1,11 @@ package com.boydti.fawe.beta.filters; import com.boydti.fawe.beta.Filter; -import com.boydti.fawe.beta.FilterBlock; -import com.boydti.fawe.config.BBC; -import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.util.Countable; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockTypes; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public abstract class ForkedFilter> implements Filter { + protected final Map children; public ForkedFilter(T root) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/SetFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/SetFilter.java index 841defd43..0ba970ea5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/SetFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/SetFilter.java @@ -5,14 +5,15 @@ import com.boydti.fawe.beta.FilterBlock; import com.sk89q.worldedit.world.block.BlockState; public class SetFilter implements Filter { + private final BlockState state; - public SetFilter(final BlockState state) { + public SetFilter(BlockState state) { this.state = state; } @Override - public void applyBlock(final FilterBlock block) { + public void applyBlock(FilterBlock block) { block.setBlock(state); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/DelegateChunkSet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/DelegateChunkSet.java index 6b224de56..b53e12861 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/DelegateChunkSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/DelegateChunkSet.java @@ -9,13 +9,13 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; - -import javax.annotation.Nullable; import java.util.Map; import java.util.Set; import java.util.UUID; +import javax.annotation.Nullable; public interface DelegateChunkSet extends IChunkSet { + IChunkSet getParent(); @Override @@ -102,7 +102,8 @@ public interface DelegateChunkSet extends IChunkSet { } @Override - default > boolean setBlock(BlockVector3 position, T block) throws WorldEditException { + default > boolean setBlock(BlockVector3 position, T block) + throws WorldEditException { return getParent().setBlock(position, block); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IQueueWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IQueueWrapper.java index 8c4957ce2..c7b47634d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IQueueWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IQueueWrapper.java @@ -3,6 +3,7 @@ package com.boydti.fawe.beta.implementation; import com.boydti.fawe.beta.IQueueExtent; public interface IQueueWrapper { + default IQueueExtent wrapQueue(IQueueExtent queue) { return queue; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/MultiThreadedQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/MultiThreadedQueue.java index e571306ac..5b64ed33c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/MultiThreadedQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/MultiThreadedQueue.java @@ -19,13 +19,14 @@ import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; - import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.concurrent.ForkJoinTask; +import java.util.stream.IntStream; public class MultiThreadedQueue extends AbstractDelegateExtent implements IQueueWrapper { + private final World world; private final QueueHandler handler; @@ -39,56 +40,53 @@ public class MultiThreadedQueue extends AbstractDelegateExtent implements IQueue return handler.getQueue(this.world); } - public T apply(final Region region, final T filter) { + public T apply(Region region, T filter) { // The chunks positions to iterate over final Set chunks = region.getChunks(); final Iterator chunksIter = chunks.iterator(); // Get a pool, to operate on the chunks in parallel final int size = Math.min(chunks.size(), Settings.IMP.QUEUE.PARALLEL_THREADS); - final ForkJoinTask[] tasks = new ForkJoinTask[size]; - for (int i = 0; i < size; i++) { - tasks[i] = handler.submit(new Runnable() { - @Override - public void run() { - final Filter newFilter = filter.fork(); - // Create a chunk that we will reuse/reset for each operation - final IQueueExtent queue = wrapQueue(getQueue()); - synchronized (queue) { - ChunkFilterBlock block = null; + final ForkJoinTask[] tasks = IntStream.range(0, size).mapToObj(i -> handler.submit(() -> { + final Filter newFilter = filter.fork(); + // Create a chunk that we will reuse/reset for each operation + final IQueueExtent queue = wrapQueue(getQueue()); + synchronized (queue) { + ChunkFilterBlock block = null; - while (true) { - // Get the next chunk posWeakChunk - final int X, Z; - synchronized (chunksIter) { - if (!chunksIter.hasNext()) break; - final BlockVector2 pos = chunksIter.next(); - X = pos.getX(); - Z = pos.getZ(); - } - if (!newFilter.appliesChunk(X, Z)) { - continue; - } - IChunk chunk = queue.getCachedChunk(X, Z); - // Initialize - chunk.init(queue, X, Z); - - IChunk newChunk = newFilter.applyChunk(chunk, region); - if (newChunk != null) { - chunk = newChunk; - if (block == null) block = queue.initFilterBlock(); - chunk.filterBlocks(newFilter, block, region); - } - queue.submit(chunk); + while (true) { + // Get the next chunk posWeakChunk + final int X, Z; + synchronized (chunksIter) { + if (!chunksIter.hasNext()) { + break; } - queue.flush(); + final BlockVector2 pos = chunksIter.next(); + X = pos.getX(); + Z = pos.getZ(); } + if (!newFilter.appliesChunk(X, Z)) { + continue; + } + IChunk chunk = queue.getCachedChunk(X, Z); + // Initialize + chunk.init(queue, X, Z); + + IChunk newChunk = newFilter.applyChunk(chunk, region); + if (newChunk != null) { + chunk = newChunk; + if (block == null) { + block = queue.initFilterBlock(); + } + chunk.filterBlocks(newFilter, block, region); + } + queue.submit(chunk); } - }); - } + queue.flush(); + } + })).toArray(ForkJoinTask[]::new); // Join filters - for (int i = 0; i < tasks.length; i++) { - final ForkJoinTask task = tasks[i]; + for (ForkJoinTask task : tasks) { if (task != null) { task.quietlyJoin(); } @@ -102,17 +100,18 @@ public class MultiThreadedQueue extends AbstractDelegateExtent implements IQueue } @Override - public int countBlocks(final Region region, final Mask searchMask) { + public int countBlocks(Region region, Mask searchMask) { return - // Apply a filter over a region - apply(region, searchMask + // Apply a filter over a region + apply(region, searchMask .toFilter(new CountFilter())) // Adapt the mask to a filter which counts .getParent() // Get the counter of this mask .getTotal(); // Get the total from the counter } @Override - public > int setBlocks(Region region, B block) throws MaxChangedBlocksException { + public > int setBlocks(Region region, B block) + throws MaxChangedBlocksException { apply(region, block); return getChanges(); } @@ -135,7 +134,8 @@ public class MultiThreadedQueue extends AbstractDelegateExtent implements IQueue } @Override - public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException { + public int replaceBlocks(Region region, Mask mask, Pattern pattern) + throws MaxChangedBlocksException { apply(region, mask.toFilter(pattern)); return getChanges(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java index 374018e26..b4da68e89 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java @@ -12,7 +12,6 @@ import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.wrappers.WorldWrapper; import com.google.common.util.concurrent.Futures; import com.sk89q.worldedit.world.World; - import java.lang.ref.WeakReference; import java.util.HashMap; import java.util.Iterator; @@ -31,6 +30,7 @@ import java.util.function.Supplier; * Class which handles all the queues {@link IQueueExtent} */ public abstract class QueueHandler implements Trimable, Runnable { + private ForkJoinPool forkJoinPoolPrimary = new ForkJoinPool(); private ForkJoinPool forkJoinPoolSecondary = new ForkJoinPool(); private ThreadPoolExecutor blockingExecutor = FaweCache.newBlockingExecutor(); @@ -43,17 +43,16 @@ public abstract class QueueHandler implements Trimable, Runnable { return create(); } }; - - public QueueHandler() { - TaskManager.IMP.repeat(this, 1); - } - /** - * Used to calculate elapsed time in milliseconds and ensure block placement doesn't lag the server + * Used to calculate elapsed time in milliseconds and ensure block placement doesn't lag the + * server */ private long last; private long allocate = 50; private double targetTPS = 18; + public QueueHandler() { + TaskManager.IMP.repeat(this, 1); + } @Override public void run() { @@ -63,7 +62,7 @@ public abstract class QueueHandler implements Trimable, Runnable { if (!syncTasks.isEmpty()) { long now = System.currentTimeMillis(); targetTPS = 18 - Math.max(Settings.IMP.QUEUE.EXTRA_TIME_MS * 0.05, 0); - long diff = (50 + this.last) - (this.last = now); + long diff = 50 + this.last - (this.last = now); long absDiff = Math.abs(diff); if (diff == 0) { allocate = Math.min(50, allocate + 1); @@ -105,7 +104,9 @@ public abstract class QueueHandler implements Trimable, Runnable { } while (!syncTasks.isEmpty()) { final FutureTask task = syncTasks.poll(); - if (task != null) task.run(); + if (task != null) { + task.run(); + } } } @@ -119,23 +120,23 @@ public abstract class QueueHandler implements Trimable, Runnable { } } - public Future async(final Runnable run, final T value) { + public Future async(Runnable run, T value) { return forkJoinPoolSecondary.submit(run, value); } - public Future async(final Runnable run) { + public Future async(Runnable run) { return forkJoinPoolSecondary.submit(run); } - public Future async(final Callable call) { + public Future async(Callable call) { return forkJoinPoolSecondary.submit(call); } - public ForkJoinTask submit(final Runnable call) { + public ForkJoinTask submit(Runnable call) { return forkJoinPoolPrimary.submit(call); } - public Future sync(final Runnable run, final T value) { + public Future sync(Runnable run, T value) { if (Fawe.isMainThread()) { run.run(); return Futures.immediateFuture(value); @@ -146,7 +147,7 @@ public abstract class QueueHandler implements Trimable, Runnable { return result; } - public Future sync(final Runnable run) { + public Future sync(Runnable run) { if (Fawe.isMainThread()) { run.run(); return Futures.immediateCancelledFuture(); @@ -157,7 +158,7 @@ public abstract class QueueHandler implements Trimable, Runnable { return result; } - public Future sync(final Callable call) throws Exception { + public Future sync(Callable call) throws Exception { if (Fawe.isMainThread()) { return Futures.immediateFuture(call.call()); } @@ -167,7 +168,7 @@ public abstract class QueueHandler implements Trimable, Runnable { return result; } - public Future sync(final Supplier call) { + public Future sync(Supplier call) { if (Fawe.isMainThread()) { return Futures.immediateFuture(call.get()); } @@ -183,7 +184,7 @@ public abstract class QueueHandler implements Trimable, Runnable { } } - public > T submit(final IChunk chunk) { + public > T submit(IChunk chunk) { // if (MemUtil.isMemoryFree()) { TODO NOT IMPLEMENTED - optimize this // return (T) forkJoinPoolSecondary.submit(chunk); // } @@ -192,6 +193,7 @@ public abstract class QueueHandler implements Trimable, Runnable { /** * Get or create the WorldChunkCache for a world + * * @param world * @return */ @@ -218,17 +220,18 @@ public abstract class QueueHandler implements Trimable, Runnable { public abstract void endSet(boolean parallel); - public IQueueExtent getQueue(final World world) { + public IQueueExtent getQueue(World world) { final IQueueExtent queue = queuePool.get(); queue.init(getOrCreate(world)); return queue; } @Override - public boolean trim(final boolean aggressive) { + public boolean trim(boolean aggressive) { boolean result = true; synchronized (chunkCache) { - final Iterator>> iter = chunkCache.entrySet().iterator(); + final Iterator>> iter = chunkCache + .entrySet().iterator(); while (iter.hasNext()) { final Map.Entry> entry = iter.next(); final WeakReference value = entry.getValue(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SimpleCharQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SimpleCharQueueExtent.java index b341c7021..4112521a7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SimpleCharQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SimpleCharQueueExtent.java @@ -2,9 +2,9 @@ package com.boydti.fawe.beta.implementation; import com.boydti.fawe.beta.CharFilterBlock; import com.boydti.fawe.beta.ChunkFilterBlock; -import com.boydti.fawe.beta.FilterBlock; public abstract class SimpleCharQueueExtent extends SingleThreadQueueExtent { + @Override public ChunkFilterBlock initFilterBlock() { return new CharFilterBlock(this); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java index d8cebe622..31d2946b4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java @@ -18,23 +18,32 @@ import java.util.concurrent.Future; import java.util.function.Supplier; /** - * Single threaded implementation for IQueueExtent (still abstract) - * - Does not implement creation of chunks (that has to implemented by the platform e.g. Bukkit) - * - * This queue is reusable {@link #init(WorldChunkCache)} + * Single threaded implementation for IQueueExtent (still abstract) - Does not implement creation of + * chunks (that has to implemented by the platform e.g. Bukkit) + *

+ * This queue is reusable {@link #init(WorldChunkCache)} */ public abstract class SingleThreadQueueExtent implements IQueueExtent { + + // Pool discarded chunks for reuse (can safely be cleared by another thread) + private static final ConcurrentLinkedQueue CHUNK_POOL = new ConcurrentLinkedQueue<>(); + // Chunks currently being queued / worked on + private final Long2ObjectLinkedOpenHashMap chunks = new Long2ObjectLinkedOpenHashMap<>(); private WorldChunkCache cache; private Thread currentThread; private ConcurrentLinkedQueue submissions = new ConcurrentLinkedQueue<>(); + // Last access pointers + private IChunk lastChunk; + private long lastPair = Long.MAX_VALUE; /** - * Safety check to ensure that the thread being used matches the one being initialized on. - * - Can be removed later + * Safety check to ensure that the thread being used matches the one being initialized on. - Can + * be removed later */ private void checkThread() { if (Thread.currentThread() != currentThread && currentThread != null) { - throw new UnsupportedOperationException("This class must be used from a single thread. Use multiple queues for concurrent operations"); + throw new UnsupportedOperationException( + "This class must be used from a single thread. Use multiple queues for concurrent operations"); } } @@ -60,10 +69,11 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { /** * Initialize the queue + * * @param cache */ @Override - public synchronized void init(final WorldChunkCache cache) { + public synchronized void init(WorldChunkCache cache) { if (this.cache != null) { reset(); } @@ -72,15 +82,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { this.cache = cache; } - // Last access pointers - private IChunk lastChunk; - private long lastPair = Long.MAX_VALUE; - // Chunks currently being queued / worked on - private final Long2ObjectLinkedOpenHashMap chunks = new Long2ObjectLinkedOpenHashMap<>(); - // Pool discarded chunks for reuse (can safely be cleared by another thread) - private static final ConcurrentLinkedQueue CHUNK_POOL = new ConcurrentLinkedQueue<>(); - - public void returnToPool(final IChunk chunk) { + public void returnToPool(IChunk chunk) { CHUNK_POOL.add(chunk); } @@ -95,7 +97,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { } @Override - public > T submit(final IChunk chunk) { + public > T submit(IChunk chunk) { if (lastChunk == chunk) { lastPair = Long.MAX_VALUE; lastChunk = null; @@ -107,11 +109,12 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { /** * Submit without first checking that it has been removed from the chunk map + * * @param chunk * @param * @return */ - private > T submitUnchecked(final IChunk chunk) { + private > T submitUnchecked(IChunk chunk) { if (chunk.isEmpty()) { CHUNK_POOL.add(chunk); return (T) (Future) Futures.immediateFuture(null); @@ -125,7 +128,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { } @Override - public synchronized boolean trim(final boolean aggressive) { + public synchronized boolean trim(boolean aggressive) { // TODO trim individial chunk sections CHUNK_POOL.clear(); if (Thread.currentThread() == currentThread) { @@ -146,13 +149,14 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { } /** - * Get a new IChunk from either the pool, or create a new one
- * + Initialize it at the coordinates + * Get a new IChunk from either the pool, or create a new one
+ Initialize it at the + * coordinates + * * @param X * @param Z * @return IChunk */ - private IChunk poolOrCreate(final int X, final int Z) { + private IChunk poolOrCreate(int X, int Z) { IChunk next = CHUNK_POOL.poll(); if (next == null) { next = create(false); @@ -162,21 +166,23 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { } @Override - public final IChunk getCachedChunk(final int x, final int z) { - final long pair = (((long) x) << 32) | (z & 0xffffffffL); + public final IChunk getCachedChunk(int x, int z) { + final long pair = (long) x << 32 | z & 0xffffffffL; if (pair == lastPair) { return lastChunk; } IChunk chunk = chunks.get(pair); if (chunk instanceof ReferenceChunk) { - chunk = ((ReferenceChunk) (chunk)).getParent(); + chunk = ((ReferenceChunk) chunk).getParent(); } if (chunk != null) { lastPair = pair; lastChunk = chunk; } - if (chunk != null) return chunk; + if (chunk != null) { + return chunk; + } checkThread(); final int size = chunks.size(); @@ -205,14 +211,15 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { return chunk; } - private void pollSubmissions(final int targetSize, final boolean aggressive) { + private void pollSubmissions(int targetSize, boolean aggressive) { final int overflow = submissions.size() - targetSize; if (aggressive) { for (int i = 0; i < overflow; i++) { Future first = submissions.poll(); try { - while ((first = (Future) first.get()) != null) ; - } catch (final InterruptedException | ExecutionException e) { + while ((first = (Future) first.get()) != null) { + } + } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } } @@ -223,7 +230,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { if (next.isDone()) { try { next = (Future) next.get(); - } catch (final InterruptedException | ExecutionException e) { + } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } } else { @@ -240,7 +247,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { checkThread(); if (!chunks.isEmpty()) { if (MemUtil.isMemoryLimited()) { - for (final IChunk chunk : chunks.values()) { + for (IChunk chunk : chunks.values()) { final Future future = submitUnchecked(chunk); if (future != null && !future.isDone()) { pollSubmissions(Settings.IMP.QUEUE.PARALLEL_THREADS, true); @@ -248,7 +255,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { } } } else { - for (final IChunk chunk : chunks.values()) { + for (IChunk chunk : chunks.values()) { final Future future = submitUnchecked(chunk); if (future != null && !future.isDone()) { submissions.add(future); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/WorldChunkCache.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/WorldChunkCache.java index 243bc23c5..08c3e050e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/WorldChunkCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/WorldChunkCache.java @@ -6,19 +6,19 @@ import com.sk89q.worldedit.world.World; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.objects.ObjectIterator; - import java.lang.ref.WeakReference; import java.util.function.Supplier; /** - * IGetBlocks may be cached by the WorldChunkCache so that it can be used between multiple IQueueExtents - * - avoids conversion between palette and raw data on every block get + * IGetBlocks may be cached by the WorldChunkCache so that it can be used between multiple + * IQueueExtents - avoids conversion between palette and raw data on every block get */ public class WorldChunkCache implements Trimable { + protected final Long2ObjectLinkedOpenHashMap> getCache; private final World world; - protected WorldChunkCache(final World world) { + protected WorldChunkCache(World world) { this.world = world; this.getCache = new Long2ObjectLinkedOpenHashMap<>(); } @@ -33,15 +33,18 @@ public class WorldChunkCache implements Trimable { /** * Get or create the IGetBlocks - * @param index chunk index {@link com.boydti.fawe.util.MathMan#pairInt(int, int)} + * + * @param index chunk index {@link com.boydti.fawe.util.MathMan#pairInt(int, int)} * @param provider used to create if it isn't already cached * @return cached IGetBlocks */ - public synchronized IChunkGet get(final long index, final Supplier provider) { + public synchronized IChunkGet get(long index, Supplier provider) { final WeakReference ref = getCache.get(index); if (ref != null) { final IChunkGet blocks = ref.get(); - if (blocks != null) return blocks; + if (blocks != null) { + return blocks; + } } final IChunkGet blocks = provider.get(); getCache.put(index, new WeakReference<>(blocks)); @@ -49,18 +52,22 @@ public class WorldChunkCache implements Trimable { } @Override - public synchronized boolean trim(final boolean aggressive) { + public synchronized boolean trim(boolean aggressive) { boolean result = true; if (!getCache.isEmpty()) { - final ObjectIterator>> iter = getCache.long2ObjectEntrySet().fastIterator(); + final ObjectIterator>> iter = getCache + .long2ObjectEntrySet().fastIterator(); while (iter.hasNext()) { final Long2ObjectMap.Entry> entry = iter.next(); final WeakReference value = entry.getValue(); final IChunkGet igb = value.get(); - if (igb == null) iter.remove(); - else { + if (igb == null) { + iter.remove(); + } else { result = false; - if (!aggressive) return result; + if (!aggressive) { + return result; + } synchronized (igb) { igb.trim(aggressive); } @@ -69,4 +76,4 @@ public class WorldChunkCache implements Trimable { } return result; } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java index cba3e70bc..9303b4a44 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java @@ -1,22 +1,17 @@ package com.boydti.fawe.beta.implementation.blocks; -import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IChunkSet; -import com.boydti.fawe.object.collection.BitArray4096; -import com.boydti.fawe.object.collection.BlockSet; import com.boydti.fawe.object.collection.MemBlockSet; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.world.biome.BiomeType; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; - -import java.util.Arrays; import java.util.Map; import java.util.Set; import java.util.UUID; public class BitSetBlocks implements IChunkSet { + private final MemBlockSet.RowZ row; private final BlockState blockState; @@ -43,13 +38,16 @@ public class BitSetBlocks implements IChunkSet { } @Override - public void setTile(int x, int y, int z, CompoundTag tile) {} + public void setTile(int x, int y, int z, CompoundTag tile) { + } @Override - public void setEntity(CompoundTag tag) {} + public void setEntity(CompoundTag tag) { + } @Override - public void removeEntity(UUID uuid) {} + public void removeEntity(UUID uuid) { + } @Override public BlockState getBlock(int x, int y, int z) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java index 371f51081..60cb7e6f7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java @@ -4,6 +4,26 @@ import com.boydti.fawe.beta.IBlocks; import com.boydti.fawe.beta.IChunkSet; public class CharBlocks implements IBlocks { + + public static final Section FULL = new Section() { + @Override + public final char[] get(CharBlocks blocks, int layer) { + return blocks.blocks[layer]; + } + }; + public static final Section EMPTY = new Section() { + @Override + public final char[] get(CharBlocks blocks, int layer) { + blocks.sections[layer] = FULL; + char[] arr = blocks.blocks[layer]; + if (arr == null) { + arr = blocks.blocks[layer] = blocks.load(layer); + } else { + blocks.blocks[layer] = blocks.load(layer, arr); + } + return arr; + } + }; public final char[][] blocks; public final Section[] sections; @@ -15,11 +35,13 @@ public class CharBlocks implements IBlocks { public CharBlocks() { blocks = new char[16][]; sections = new Section[16]; - for (int i = 0; i < 16; i++) sections[i] = EMPTY; + for (int i = 0; i < 16; i++) { + sections[i] = EMPTY; + } } @Override - public boolean trim(final boolean aggressive) { + public boolean trim(boolean aggressive) { boolean result = true; for (int i = 0; i < 16; i++) { if (sections[i] == EMPTY) { @@ -33,82 +55,67 @@ public class CharBlocks implements IBlocks { @Override public IChunkSet reset() { - for (int i = 0; i < 16; i++) sections[i] = EMPTY; + for (int i = 0; i < 16; i++) { + sections[i] = EMPTY; + } return null; } - public void reset(final int layer) { + public void reset(int layer) { sections[layer] = EMPTY; } - public char[] load(final int layer) { + public char[] load(int layer) { return new char[4096]; } - public char[] load(final int layer, final char[] data) { - for (int i = 0; i < 4096; i++) data[i] = 0; + public char[] load(int layer, char[] data) { + for (int i = 0; i < 4096; i++) { + data[i] = 0; + } return data; } @Override - public boolean hasSection(final int layer) { + public boolean hasSection(int layer) { return sections[layer] == FULL; } - public char get(final int x, final int y, final int z) { + public char get(int x, int y, int z) { final int layer = y >> 4; - final int index = ((y & 15) << 8) | (z << 4) | (x); + final int index = (y & 15) << 8 | z << 4 | x; return sections[layer].get(this, layer, index); } - public void set(final int x, final int y, final int z, final char value) { + public void set(int x, int y, int z, char value) { final int layer = y >> 4; - final int index = ((y & 15) << 8) | (z << 4) | (x); + final int index = (y & 15) << 8 | z << 4 | x; set(layer, index, value); } - public final char get(final int layer, final int index) { - return sections[layer].get(this, layer, index); - } - - public final void set(final int layer, final int index, final char value) { - sections[layer].set(this, layer, index, value); - } - /* Section */ + public final char get(int layer, int index) { + return sections[layer].get(this, layer, index); + } + + public final void set(int layer, int index, char value) { + sections[layer].set(this, layer, index, value); + } + public static abstract class Section { + public abstract char[] get(CharBlocks blocks, int layer); - public final char get(final CharBlocks blocks, final int layer, final int index) { + public final char get(CharBlocks blocks, int layer, int index) { return get(blocks, layer)[index]; } - public final void set(final CharBlocks blocks, final int layer, final int index, final char value) { + public final void set(CharBlocks blocks, int layer, int index, + char value) { get(blocks, layer)[index] = value; } } - - public static final Section EMPTY = new Section() { - @Override - public final char[] get(final CharBlocks blocks, final int layer) { - blocks.sections[layer] = FULL; - char[] arr = blocks.blocks[layer]; - if (arr == null) { - arr = blocks.blocks[layer] = blocks.load(layer); - } else { - blocks.blocks[layer] = blocks.load(layer, arr); - } - return arr; - } - }; - - public static final Section FULL = new Section() { - @Override - public final char[] get(final CharBlocks blocks, final int layer) { - return blocks.blocks[layer]; - } - }; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java index 7c5dcf613..84b857470 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java @@ -7,18 +7,19 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; public abstract class CharGetBlocks extends CharBlocks implements IChunkGet { + @Override - public BaseBlock getFullBlock(final int x, final int y, final int z) { + public BaseBlock getFullBlock(int x, int y, int z) { return BlockTypes.states[get(x, y, z)].toBaseBlock(); } @Override - public BlockState getBlock(final int x, final int y, final int z) { + public BlockState getBlock(int x, int y, int z) { return BlockTypes.states[get(x, y, z)]; } @Override - public boolean trim(final boolean aggressive) { + public boolean trim(boolean aggressive) { for (int i = 0; i < 16; i++) { sections[i] = EMPTY; blocks[i] = null; @@ -31,4 +32,4 @@ public abstract class CharGetBlocks extends CharBlocks implements IChunkGet { super.reset(); return null; } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharSetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharSetBlocks.java index 23db45a27..02ff245a2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharSetBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharSetBlocks.java @@ -7,7 +7,6 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; - import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -15,6 +14,7 @@ import java.util.Set; import java.util.UUID; public class CharSetBlocks extends CharBlocks implements IChunkSet { + public BiomeType[] biomes; public HashMap tiles; public HashSet entities; @@ -57,7 +57,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { } @Override - public boolean setBiome(final int x, final int y, final int z, final BiomeType biome) { + public boolean setBiome(int x, int y, int z, BiomeType biome) { if (biomes == null) { biomes = new BiomeType[256]; } @@ -71,13 +71,13 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { } @Override - public boolean setBlock(final int x, final int y, final int z, final BlockStateHolder holder) { + public boolean setBlock(int x, int y, int z, BlockStateHolder holder) { set(x, y, z, holder.getOrdinalChar()); return true; } @Override - public void setTile(final int x, final int y, final int z, final CompoundTag tile) { + public void setTile(int x, int y, int z, CompoundTag tile) { if (tiles == null) { tiles = new HashMap<>(); } @@ -86,7 +86,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { } @Override - public void setEntity(final CompoundTag tag) { + public void setEntity(CompoundTag tag) { if (entities == null) { entities = new HashSet<>(); } @@ -94,7 +94,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { } @Override - public void removeEntity(final UUID uuid) { + public void removeEntity(UUID uuid) { if (entityRemoves == null) { entityRemoves = new HashSet<>(); } @@ -103,7 +103,9 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { @Override public boolean isEmpty() { - if (biomes != null) return false; + if (biomes != null) { + return false; + } for (int i = 0; i < 16; i++) { if (hasSection(i)) { return false; @@ -121,4 +123,4 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { super.reset(); return null; } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java index 2e8c320cb..c966df483 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java @@ -16,14 +16,150 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; - -import javax.annotation.Nullable; import java.util.function.Supplier; +import javax.annotation.Nullable; /** - * Abstract IChunk class that implements basic get/set blocks + * An abstract {@link IChunk} class that implements basic get/set blocks */ public abstract class ChunkHolder implements IChunk, Supplier { + + public static final IBlockDelegate BOTH = new IBlockDelegate() { + @Override + public boolean setBiome(ChunkHolder chunk, int x, int y, int z, + BiomeType biome) { + return chunk.set.setBiome(x, y, z, biome); + } + + @Override + public boolean setBlock(ChunkHolder chunk, int x, int y, int z, + BlockStateHolder block) { + return chunk.set.setBlock(x, y, z, block); + } + + @Override + public BiomeType getBiome(ChunkHolder chunk, int x, int z) { + return chunk.get.getBiomeType(x, z); + } + + @Override + public BlockState getBlock(ChunkHolder chunk, int x, int y, int z) { + return chunk.get.getBlock(x, y, z); + } + + @Override + public BaseBlock getFullBlock(ChunkHolder chunk, int x, int y, + int z) { + return chunk.get.getFullBlock(x, y, z); + } + }; + public static final IBlockDelegate GET = new IBlockDelegate() { + @Override + public boolean setBiome(ChunkHolder chunk, int x, int y, int z, + BiomeType biome) { + chunk.getOrCreateSet(); + chunk.delegate = BOTH; + return chunk.setBiome(x, y, z, biome); + } + + @Override + public boolean setBlock(ChunkHolder chunk, int x, int y, int z, + BlockStateHolder block) { + chunk.getOrCreateSet(); + chunk.delegate = BOTH; + return chunk.setBlock(x, y, z, block); + } + + @Override + public BiomeType getBiome(ChunkHolder chunk, int x, int z) { + return chunk.get.getBiomeType(x, z); + } + + @Override + public BlockState getBlock(ChunkHolder chunk, int x, int y, int z) { + return chunk.get.getBlock(x, y, z); + } + + @Override + public BaseBlock getFullBlock(ChunkHolder chunk, int x, int y, + int z) { + return chunk.get.getFullBlock(x, y, z); + } + }; + public static final IBlockDelegate SET = new IBlockDelegate() { + @Override + public boolean setBiome(ChunkHolder chunk, int x, int y, int z, + BiomeType biome) { + return chunk.set.setBiome(x, y, z, biome); + } + + @Override + public boolean setBlock(ChunkHolder chunk, int x, int y, int z, + BlockStateHolder block) { + return chunk.set.setBlock(x, y, z, block); + } + + @Override + public BiomeType getBiome(ChunkHolder chunk, int x, int z) { + chunk.getOrCreateGet(); + chunk.delegate = BOTH; + return chunk.getBiomeType(x, z); + } + + @Override + public BlockState getBlock(ChunkHolder chunk, int x, int y, int z) { + chunk.getOrCreateGet(); + chunk.delegate = BOTH; + return chunk.getBlock(x, y, z); + } + + @Override + public BaseBlock getFullBlock(ChunkHolder chunk, int x, int y, + int z) { + chunk.getOrCreateGet(); + chunk.delegate = BOTH; + return chunk.getFullBlock(x, y, z); + } + }; + public static final IBlockDelegate NULL = new IBlockDelegate() { + @Override + public boolean setBiome(ChunkHolder chunk, int x, int y, int z, + BiomeType biome) { + chunk.getOrCreateSet(); + chunk.delegate = SET; + return chunk.setBiome(x, y, z, biome); + } + + @Override + public boolean setBlock(ChunkHolder chunk, int x, int y, int z, + BlockStateHolder block) { + chunk.getOrCreateSet(); + chunk.delegate = SET; + return chunk.setBlock(x, y, z, block); + } + + @Override + public BiomeType getBiome(ChunkHolder chunk, int x, int z) { + chunk.getOrCreateGet(); + chunk.delegate = GET; + return chunk.getBiomeType(x, z); + } + + @Override + public BlockState getBlock(ChunkHolder chunk, int x, int y, int z) { + chunk.getOrCreateGet(); + chunk.delegate = GET; + return chunk.getBlock(x, y, z); + } + + @Override + public BaseBlock getFullBlock(ChunkHolder chunk, int x, int y, + int z) { + chunk.getOrCreateGet(); + chunk.delegate = GET; + return chunk.getFullBlock(x, y, z); + } + }; private IChunkGet get; private IChunkSet set; private IBlockDelegate delegate; @@ -35,7 +171,7 @@ public abstract class ChunkHolder implements IChunk, Supplier { this.delegate = NULL; } - public ChunkHolder(final IBlockDelegate delegate) { + public ChunkHolder(IBlockDelegate delegate) { this.delegate = delegate; } @@ -46,7 +182,8 @@ public abstract class ChunkHolder implements IChunk, Supplier { @Override public CompoundTag getTag(int x, int y, int z) { - return delegate.getFullBlock(this, x, y, z).getNbtData(); // TODO NOT IMPLEMENTED (add getTag delegate) + return delegate.getFullBlock(this, x, y, z) + .getNbtData(); // TODO NOT IMPLEMENTED (add getTag delegate) } @Override @@ -55,7 +192,7 @@ public abstract class ChunkHolder implements IChunk, Supplier { } @Override - public void filterBlocks(final Filter filter, ChunkFilterBlock block, @Nullable Region region) { + public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region) { final IChunkGet get = getOrCreateGet(); final IChunkSet set = getOrCreateSet(); try { @@ -64,7 +201,9 @@ public abstract class ChunkHolder implements IChunk, Supplier { } else { block = block.init(chunkX, chunkZ, get); for (int layer = 0; layer < 16; layer++) { - if (!get.hasSection(layer) || !filter.appliesLayer(this, layer)) continue; + if (!get.hasSection(layer) || !filter.appliesLayer(this, layer)) { + continue; + } block.init(get, set, layer); block.filter(filter); } @@ -75,7 +214,7 @@ public abstract class ChunkHolder implements IChunk, Supplier { } @Override - public boolean trim(final boolean aggressive) { + public boolean trim(boolean aggressive) { if (set != null) { final boolean result = set.trim(aggressive); if (result) { @@ -104,12 +243,16 @@ public abstract class ChunkHolder implements IChunk, Supplier { } public final IChunkGet getOrCreateGet() { - if (get == null) get = newGet(); + if (get == null) { + get = newGet(); + } return get; } public final IChunkSet getOrCreateSet() { - if (set == null) set = set(); + if (set == null) { + set = set(); + } return set; } @@ -128,7 +271,7 @@ public abstract class ChunkHolder implements IChunk, Supplier { } @Override - public void init(final IQueueExtent extent, final int chunkX, final int chunkZ) { + public void init(IQueueExtent extent, int chunkX, int chunkZ) { this.extent = extent; this.chunkX = chunkX; this.chunkZ = chunkZ; @@ -156,167 +299,42 @@ public abstract class ChunkHolder implements IChunk, Supplier { } @Override - public boolean setBiome(final int x, final int y, final int z, final BiomeType biome) { + public boolean setBiome(int x, int y, int z, BiomeType biome) { return delegate.setBiome(this, x, y, z, biome); } @Override - public boolean setBlock(final int x, final int y, final int z, final BlockStateHolder block) { + public boolean setBlock(int x, int y, int z, BlockStateHolder block) { return delegate.setBlock(this, x, y, z, block); } @Override - public BiomeType getBiomeType(final int x, final int z) { + public BiomeType getBiomeType(int x, int z) { return delegate.getBiome(this, x, z); } @Override - public BlockState getBlock(final int x, final int y, final int z) { + public BlockState getBlock(int x, int y, int z) { return delegate.getBlock(this, x, y, z); } @Override - public BaseBlock getFullBlock(final int x, final int y, final int z) { + public BaseBlock getFullBlock(int x, int y, int z) { return delegate.getFullBlock(this, x, y, z); } public interface IBlockDelegate { - boolean setBiome(final ChunkHolder chunk, final int x, final int y, final int z, final BiomeType biome); - boolean setBlock(final ChunkHolder chunk, final int x, final int y, final int z, final BlockStateHolder holder); + boolean setBiome(ChunkHolder chunk, int x, int y, int z, + BiomeType biome); - BiomeType getBiome(final ChunkHolder chunk, final int x, final int z); + boolean setBlock(ChunkHolder chunk, int x, int y, int z, + BlockStateHolder holder); - BlockState getBlock(final ChunkHolder chunk, final int x, final int y, final int z); + BiomeType getBiome(ChunkHolder chunk, int x, int z); - BaseBlock getFullBlock(final ChunkHolder chunk, final int x, final int y, final int z); + BlockState getBlock(ChunkHolder chunk, int x, int y, int z); + + BaseBlock getFullBlock(ChunkHolder chunk, int x, int y, int z); } - - public static final IBlockDelegate NULL = new IBlockDelegate() { - @Override - public boolean setBiome(final ChunkHolder chunk, final int x, final int y, final int z, final BiomeType biome) { - chunk.getOrCreateSet(); - chunk.delegate = SET; - return chunk.setBiome(x, y, z, biome); - } - - @Override - public boolean setBlock(final ChunkHolder chunk, final int x, final int y, final int z, final BlockStateHolder block) { - chunk.getOrCreateSet(); - chunk.delegate = SET; - return chunk.setBlock(x, y, z, block); - } - - @Override - public BiomeType getBiome(final ChunkHolder chunk, final int x, final int z) { - chunk.getOrCreateGet(); - chunk.delegate = GET; - return chunk.getBiomeType(x, z); - } - - @Override - public BlockState getBlock(final ChunkHolder chunk, final int x, final int y, final int z) { - chunk.getOrCreateGet(); - chunk.delegate = GET; - return chunk.getBlock(x, y, z); - } - - @Override - public BaseBlock getFullBlock(final ChunkHolder chunk, final int x, final int y, final int z) { - chunk.getOrCreateGet(); - chunk.delegate = GET; - return chunk.getFullBlock(x, y, z); - } - }; - - public static final IBlockDelegate GET = new IBlockDelegate() { - @Override - public boolean setBiome(final ChunkHolder chunk, final int x, final int y, final int z, final BiomeType biome) { - chunk.getOrCreateSet(); - chunk.delegate = BOTH; - return chunk.setBiome(x, y, z, biome); - } - - @Override - public boolean setBlock(final ChunkHolder chunk, final int x, final int y, final int z, final BlockStateHolder block) { - chunk.getOrCreateSet(); - chunk.delegate = BOTH; - return chunk.setBlock(x, y, z, block); - } - - @Override - public BiomeType getBiome(final ChunkHolder chunk, final int x, final int z) { - return chunk.get.getBiomeType(x, z); - } - - @Override - public BlockState getBlock(final ChunkHolder chunk, final int x, final int y, final int z) { - return chunk.get.getBlock(x, y, z); - } - - @Override - public BaseBlock getFullBlock(final ChunkHolder chunk, final int x, final int y, final int z) { - return chunk.get.getFullBlock(x, y, z); - } - }; - - public static final IBlockDelegate SET = new IBlockDelegate() { - @Override - public boolean setBiome(final ChunkHolder chunk, final int x, final int y, final int z, final BiomeType biome) { - return chunk.set.setBiome(x, y, z, biome); - } - - @Override - public boolean setBlock(final ChunkHolder chunk, final int x, final int y, final int z, final BlockStateHolder block) { - return chunk.set.setBlock(x, y, z, block); - } - - @Override - public BiomeType getBiome(final ChunkHolder chunk, final int x, final int z) { - chunk.getOrCreateGet(); - chunk.delegate = BOTH; - return chunk.getBiomeType(x, z); - } - - @Override - public BlockState getBlock(final ChunkHolder chunk, final int x, final int y, final int z) { - chunk.getOrCreateGet(); - chunk.delegate = BOTH; - return chunk.getBlock(x, y, z); - } - - @Override - public BaseBlock getFullBlock(final ChunkHolder chunk, final int x, final int y, final int z) { - chunk.getOrCreateGet(); - chunk.delegate = BOTH; - return chunk.getFullBlock(x, y, z); - } - }; - - public static final IBlockDelegate BOTH = new IBlockDelegate() { - @Override - public boolean setBiome(final ChunkHolder chunk, final int x, final int y, final int z, final BiomeType biome) { - return chunk.set.setBiome(x, y, z, biome); - } - - @Override - public boolean setBlock(final ChunkHolder chunk, final int x, final int y, final int z, final BlockStateHolder block) { - return chunk.set.setBlock(x, y, z, block); - } - - @Override - public BiomeType getBiome(final ChunkHolder chunk, final int x, final int z) { - return chunk.get.getBiomeType(x, z); - } - - @Override - public BlockState getBlock(final ChunkHolder chunk, final int x, final int y, final int z) { - return chunk.get.getBlock(x, y, z); - } - - @Override - public BaseBlock getFullBlock(final ChunkHolder chunk, final int x, final int y, final int z) { - return chunk.get.getFullBlock(x, y, z); - } - }; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java index 88c6269db..6c285b320 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java @@ -1,33 +1,27 @@ package com.boydti.fawe.beta.implementation.holder; -import com.boydti.fawe.beta.ChunkFilterBlock; -import com.boydti.fawe.beta.Filter; -import com.boydti.fawe.beta.FilterBlock; -import com.boydti.fawe.beta.FilterBlockMask; -import com.boydti.fawe.beta.Flood; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IDelegateChunk; -import com.sk89q.worldedit.math.MutableBlockVector3; -import com.sk89q.worldedit.regions.Region; - -import javax.annotation.Nullable; /** * Implementation of IDelegateChunk + * * @param */ public class DelegateChunk implements IDelegateChunk { + private T parent; - public DelegateChunk(final T parent) { + public DelegateChunk(T parent) { this.parent = parent; } + @Override public final T getParent() { return parent; } - public final void setParent(final T parent) { + public final void setParent(T parent) { this.parent = parent; } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/FinalizedChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/FinalizedChunk.java index ca599ae94..cc0d59fdb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/FinalizedChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/FinalizedChunk.java @@ -1,22 +1,24 @@ package com.boydti.fawe.beta.implementation.holder; -import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.IChunk; +import com.boydti.fawe.beta.IQueueExtent; /** - * Used by {@link ReferenceChunk} to allow the chunk to be garbage collected - * - When the object is finalized, add it to the queue + * Used by {@link ReferenceChunk} to allow the chunk to be garbage collected. - When the object is + * finalized, add it to the queue */ public class FinalizedChunk extends DelegateChunk { + private final IQueueExtent queueExtent; - public FinalizedChunk(final IChunk parent, final IQueueExtent queueExtent) { + public FinalizedChunk(IChunk parent, IQueueExtent queueExtent) { super(parent); this.queueExtent = queueExtent; } /** * Submit the chunk to the queue + * * @throws Throwable */ @Override @@ -28,4 +30,4 @@ public class FinalizedChunk extends DelegateChunk { } super.finalize(); } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ReferenceChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ReferenceChunk.java index cb88a839e..4e5c799c8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ReferenceChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ReferenceChunk.java @@ -3,26 +3,26 @@ package com.boydti.fawe.beta.implementation.holder; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IDelegateChunk; import com.boydti.fawe.beta.IQueueExtent; - import java.lang.ref.Reference; /** - * An IChunk may be wrapped by a ReferenceChunk if there is low memory
- * A reference chunk stores a reference (for garbage collection purposes)
- * - If it is garbage collected, the {@link FinalizedChunk} logic is run + * An {@link IChunk} may be wrapped by a ReferenceChunk if there is low memory. This class stores a + * reference for garbage collection purposes. If it cleaned by garbage collection, the {@link + * FinalizedChunk} logic is run. */ public abstract class ReferenceChunk implements IDelegateChunk { - private final Reference ref; - public ReferenceChunk(final IChunk parent, final IQueueExtent queueExtent) { - this.ref = toRef(new FinalizedChunk(parent, queueExtent)); + private final Reference reference; + + public ReferenceChunk(IChunk parent, IQueueExtent queueExtent) { + this.reference = toReference(new FinalizedChunk(parent, queueExtent)); } - protected abstract Reference toRef(FinalizedChunk parent); + protected abstract Reference toReference(FinalizedChunk parent); @Override public IChunk getParent() { - final FinalizedChunk finalized = ref.get(); + final FinalizedChunk finalized = reference.get(); return finalized != null ? finalized.getParent() : null; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/SoftChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/SoftChunk.java index 361b7083d..29ea78386 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/SoftChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/SoftChunk.java @@ -2,7 +2,6 @@ package com.boydti.fawe.beta.implementation.holder; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IQueueExtent; - import java.lang.ref.Reference; import java.lang.ref.SoftReference; @@ -11,12 +10,12 @@ import java.lang.ref.SoftReference; */ public class SoftChunk extends ReferenceChunk { - public SoftChunk(final IChunk parent, final IQueueExtent queueExtent) { + public SoftChunk(IChunk parent, IQueueExtent queueExtent) { super(parent, queueExtent); } @Override - protected Reference toRef(final FinalizedChunk parent) { + protected Reference toReference(FinalizedChunk parent) { return new SoftReference<>(parent); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/WeakChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/WeakChunk.java index 46b5fa8f6..12394302d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/WeakChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/WeakChunk.java @@ -2,21 +2,20 @@ package com.boydti.fawe.beta.implementation.holder; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IQueueExtent; -import com.sk89q.jnbt.CompoundTag; - import java.lang.ref.Reference; import java.lang.ref.WeakReference; /** - * Weak reference implementation of {@link ReferenceChunk} + * A {@link ReferenceChunk} using {@link WeakReference} to hold the chunk. */ public class WeakChunk extends ReferenceChunk { - public WeakChunk(final IChunk parent, final IQueueExtent queueExtent) { + + public WeakChunk(IChunk parent, IQueueExtent queueExtent) { super(parent, queueExtent); } @Override - protected Reference toRef(final FinalizedChunk parent) { + protected Reference toReference(FinalizedChunk parent) { return new WeakReference<>(parent); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 623bfc4d3..bb548648e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -80,6 +80,7 @@ import java.util.List; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; +import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.annotation.param.Switch; import org.enginehub.piston.inject.InjectedValueAccess; @@ -547,7 +548,7 @@ public class RegionCommands { boolean skipEntities, @Switch(name = 'a', desc = "Ignore air blocks") boolean ignoreAirBlocks, - @ArgFlag(name = "m", desc = "Source mask") + @ArgFlag(name = 'm', desc = "Source mask") Mask sourceMask, InjectedValueAccess context) throws WorldEditException { player.checkConfirmationStack(() -> { @@ -677,7 +678,7 @@ public class RegionCommands { int thickness, @Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air") Pattern pattern, - @ArgFlag(name = "m", desc = "Mask to hollow with") Mask mask, + @ArgFlag(name = 'm', desc = "Mask to hollow with") Mask mask, InjectedValueAccess context) throws WorldEditException { checkCommandArgument(thickness >= 0, "Thickness must be >= 0"); Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;