Simplifications to VoxelSniper

Signed-off-by: MattBDev <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
MattBDev 2019-06-05 15:52:47 -04:00
parent 6c94cca15e
commit e6f2e17bdf
16 changed files with 102 additions and 133 deletions

View File

@ -281,8 +281,8 @@ public class RangeBlockHelper {
this.range = range;
this.step = step;
this.length = 0.0D;
this.rotX = (double)((this.playerLoc.getYaw() + 90.0F) % 360.0F);
this.rotY = (double)(this.playerLoc.getPitch() * -1.0F);
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));

View File

@ -1,4 +1,4 @@
/**
/*
This file is part of VoxelSniper, licensed under the MIT License (MIT).
Copyright (c) The VoxelBox <http://thevoxelbox.com>
@ -71,7 +71,6 @@ import java.util.Map;
import java.util.UUID;
public class Sniper {
private VoxelSniper plugin;
private final UUID player;
private boolean enabled = true;
// private LinkedList<FaweChangeSet> undoList = new LinkedList<>();
@ -80,7 +79,6 @@ public class Sniper {
public Sniper(VoxelSniper plugin, Player player) {
Preconditions.checkNotNull(plugin);
Preconditions.checkNotNull(player);
this.plugin = plugin;
this.player = player.getUniqueId();
SniperTool sniperTool = new SniperTool(this);
sniperTool.assignAction(SnipeAction.ARROW, Material.ARROW);
@ -89,7 +87,7 @@ public class Sniper {
}
public String getCurrentToolId() {
return getToolId((getPlayer().getInventory().getItemInMainHand() != null) ? getPlayer().getInventory().getItemInMainHand().getType() : null);
return getToolId(getPlayer().getInventory().getItemInMainHand().getType());
}
public String getToolId(Material itemInHand) {
@ -397,14 +395,12 @@ public class Sniper {
} else {
changeQueue.flush();
}
if (changeSet != null) {
if (Settings.IMP.HISTORY.COMBINE_STAGES) {
changeSet.closeAsync();
} else {
changeSet.close();
}
session.remember(changeSet.toEditSession(fp));
if (Settings.IMP.HISTORY.COMBINE_STAGES) {
changeSet.closeAsync();
} else {
changeSet.close();
}
session.remember(changeSet.toEditSession(fp));
return true;
}
return false;

View File

@ -9,6 +9,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
/**
* Bukkit extension point.
@ -55,15 +56,10 @@ public class VoxelSniper extends JavaPlugin {
}
@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, String commandLabel, @NotNull String[] args) {
if (sender instanceof Player) {
String[] arguments = args;
if (arguments == null) {
arguments = new String[0];
}
return voxelSniperListener.onCommand((Player) sender, arguments, command.getName());
return voxelSniperListener.onCommand((Player) sender, args, command.getName());
}
getLogger().info("Only players can execute VoxelSniper commands.");
@ -90,7 +86,7 @@ public class VoxelSniper extends JavaPlugin {
Player player = (Player) fp.parent;
return onCommand(player, new Command("p") {
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, @NotNull String[] args) {
return false;
}
}, null, args);
@ -103,7 +99,7 @@ public class VoxelSniper extends JavaPlugin {
Player player = (Player) fp.parent;
return onCommand(player, new Command("d") {
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, @NotNull String[] args) {
return false;
}
}, null, args);

View File

@ -15,21 +15,25 @@ public class BlockResetBrush extends Brush {
static {
BlockResetBrush.DENIED_UPDATES.add(Material.SIGN);
BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_SIGN_POST);
BlockResetBrush.DENIED_UPDATES.add(Material.WALL_SIGN);
BlockResetBrush.DENIED_UPDATES.add(Material.CHEST);
BlockResetBrush.DENIED_UPDATES.add(Material.FURNACE);
BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_BURNING_FURNACE);
BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_REDSTONE_TORCH_OFF);
BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_REDSTONE_TORCH_ON);
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.LEGACY_DIODE_BLOCK_OFF);
BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_DIODE_BLOCK_ON);
BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_WOODEN_DOOR);
BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_WOOD_DOOR);
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.LEGACY_IRON_DOOR_BLOCK);
BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_FENCE_GATE);
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);
}
/**
@ -39,7 +43,6 @@ public class BlockResetBrush extends Brush {
this.setName("Block Reset Brush");
}
@SuppressWarnings("deprecation")
private void applyBrush(final SnipeData v) {
for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) {
for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) {

View File

@ -84,7 +84,7 @@ public class HeatRayBrush extends Brush {
if (currentLocation.toVector().isInSphere(targetLocation, v.getBrushSize())) {
currentBlock = currentLocation.getBlock();
if (currentBlock == null || currentBlock.getType() == Material.CHEST) {
if (currentBlock.getType() == Material.CHEST) {
continue;
}
@ -168,13 +168,13 @@ public class HeatRayBrush extends Brush {
v.sendMessage(ChatColor.AQUA + "/b hr freq[float] -- Frequency parameter for the noise generator.");
}
if (parameter.startsWith("oct")) {
this.octaves = Integer.valueOf(parameter.replace("oct", ""));
this.octaves = Integer.parseInt(parameter.replace("oct", ""));
v.getVoxelMessage().custom(ChatColor.GREEN + "Octaves: " + this.octaves);
} else if (parameter.startsWith("amp")) {
this.amplitude = Double.valueOf(parameter.replace("amp", ""));
this.amplitude = Double.parseDouble(parameter.replace("amp", ""));
v.getVoxelMessage().custom(ChatColor.GREEN + "Amplitude: " + this.amplitude);
} else if (parameter.startsWith("freq")) {
this.frequency = Double.valueOf(parameter.replace("freq", ""));
this.frequency = Double.parseDouble(parameter.replace("freq", ""));
v.getVoxelMessage().custom(ChatColor.GREEN + "Frequency: " + this.frequency);
}
}

View File

@ -151,13 +151,13 @@ public class MoveBrush extends Brush {
v.getVoxelMessage().custom(ChatColor.AQUA + "Z direction set to: " + this.moveDirections[2]);
}
if (par[i].toLowerCase().startsWith("x")) {
this.moveDirections[0] = Integer.valueOf(par[i].substring(1));
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.valueOf(par[i].substring(1));
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.valueOf(par[i].substring(1));
this.moveDirections[2] = Integer.parseInt(par[i].substring(1));
v.getVoxelMessage().custom(ChatColor.AQUA + "Z direction set to: " + this.moveDirections[2]);
}
}
@ -200,12 +200,12 @@ public class MoveBrush extends Brush {
public boolean calculateRegion() throws Exception {
if (this.location1 != null && this.location2 != null) {
if (this.location1.getWorld().equals(this.location2.getWorld())) {
final int lowX = ((this.location1.getBlockX() <= this.location2.getBlockX()) ? this.location1.getBlockX() : this.location2.getBlockX());
final int lowY = (this.location1.getBlockY() <= this.location2.getBlockY()) ? this.location1.getBlockY() : this.location2.getBlockY();
final int lowZ = (this.location1.getBlockZ() <= this.location2.getBlockZ()) ? this.location1.getBlockZ() : this.location2.getBlockZ();
final int highX = (this.location1.getBlockX() >= this.location2.getBlockX()) ? this.location1.getBlockX() : this.location2.getBlockX();
final int highY = (this.location1.getBlockY() >= this.location2.getBlockY()) ? this.location1.getBlockY() : this.location2.getBlockY();
final int highZ = (this.location1.getBlockZ() >= this.location2.getBlockZ()) ? this.location1.getBlockZ() : this.location2.getBlockZ();
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, please use a smaller selection.");
}

View File

@ -39,10 +39,6 @@ public class OceanBrush extends Brush {
return 0;
}
/**
* @param v
* @param undo
*/
protected final void oceanator(final SnipeData v, final Undo undo) {
final AsyncWorld world = this.getWorld();
@ -55,7 +51,7 @@ public class OceanBrush extends Brush {
for (int z = minZ; z <= maxZ; z++) {
final int currentHeight = getHeight(x, z);
final int wLevelDiff = currentHeight - (this.waterLevel - 1);
final int newSeaFloorLevel = ((this.waterLevel - wLevelDiff) >= LOW_CUT_LEVEL) ? this.waterLevel - wLevelDiff : LOW_CUT_LEVEL;
final int newSeaFloorLevel = Math.max((this.waterLevel - wLevelDiff), LOW_CUT_LEVEL);
final int highestY = this.getWorld().getHighestBlockYAt(x, z);

View File

@ -29,10 +29,8 @@ public class ScannerBrush extends Brush {
private int clamp(final int value, final int min, final int max) {
if (value < min) {
return min;
} else if (value > max) {
return max;
} else {
return value;
return Math.min(value, max);
}
}

View File

@ -32,12 +32,12 @@ public class SetBrush extends PerformBrush {
this.block = null;
return true;
}
final int lowX = (this.block.getX() <= bl.getX()) ? this.block.getX() : bl.getX();
final int lowY = (this.block.getY() <= bl.getY()) ? this.block.getY() : bl.getY();
final int lowZ = (this.block.getZ() <= bl.getZ()) ? this.block.getZ() : bl.getZ();
final int highX = (this.block.getX() >= bl.getX()) ? this.block.getX() : bl.getX();
final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY();
final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ();
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, please use a smaller selection.");

View File

@ -29,12 +29,12 @@ public class SetRedstoneFlipBrush extends Brush {
return true;
} else {
this.undo = new Undo();
final int lowX = (this.block.getX() <= bl.getX()) ? this.block.getX() : bl.getX();
final int lowY = (this.block.getY() <= bl.getY()) ? this.block.getY() : bl.getY();
final int lowZ = (this.block.getZ() <= bl.getZ()) ? this.block.getZ() : bl.getZ();
final int highX = (this.block.getX() >= bl.getX()) ? this.block.getX() : bl.getX();
final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY();
final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ();
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++) {

View File

@ -28,12 +28,12 @@ public class SetRedstoneRotateBrush extends Brush {
return true;
} else {
this.undo = new Undo();
final int lowX = (this.block.getX() <= bl.getX()) ? this.block.getX() : bl.getX();
final int lowY = (this.block.getY() <= bl.getY()) ? this.block.getY() : bl.getY();
final int lowZ = (this.block.getZ() <= bl.getZ()) ? this.block.getZ() : bl.getZ();
final int highX = (this.block.getX() >= bl.getX()) ? this.block.getX() : bl.getX();
final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY();
final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ();
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++) {

View File

@ -37,18 +37,18 @@ public class ShellSetBrush extends Brush {
return true;
}
final int lowX = (this.block.getX() <= bl.getX()) ? this.block.getX() : bl.getX();
final int lowY = (this.block.getY() <= bl.getY()) ? this.block.getY() : bl.getY();
final int lowZ = (this.block.getZ() <= bl.getZ()) ? this.block.getZ() : bl.getZ();
final int highX = (this.block.getX() >= bl.getX()) ? this.block.getX() : bl.getX();
final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY();
final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ();
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) > MAX_SIZE) {
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, please use a smaller selection.");
} else {
final ArrayList<AsyncBlock> blocks = new ArrayList<>(
((Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY)) / 2));
final ArrayList<AsyncBlock> 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++) {

View File

@ -8,6 +8,7 @@ import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import java.io.*;
import java.util.Arrays;
/**
* Overwrites signs. (Wiki:
@ -240,7 +241,7 @@ public class SignOverwriteBrush extends Brush {
return i;
}
String newText = "";
StringBuilder newText = new StringBuilder();
// go through the array until the next top level parameter is found
for (i++; i < params.length; i++) {
@ -250,16 +251,16 @@ public class SignOverwriteBrush extends Brush {
i--;
break;
} else {
newText += currentParameter + " ";
newText.append(currentParameter).append(" ");
}
}
newText = ChatColor.translateAlternateColorCodes('&', newText);
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.isEmpty() && newText.endsWith(" ")) {
newText = newText.substring(0, newText.length() - 1);
} else if (newText.isEmpty()) {
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;
}
@ -269,10 +270,10 @@ public class SignOverwriteBrush extends Brush {
// 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 = newText.substring(0, MAX_SIGN_LINE_LENGTH);
newText = new StringBuilder(newText.substring(0, MAX_SIGN_LINE_LENGTH));
}
this.signTextLines[lineIndex] = newText;
this.signTextLines[lineIndex] = newText.toString();
return i;
}
@ -298,17 +299,13 @@ public class SignOverwriteBrush extends Brush {
try {
store.createNewFile();
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");
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");
}
}
outStream.close();
outFile.close();
v.sendMessage(ChatColor.BLUE + "File saved successfully.");
} catch (IOException exception) {
v.sendMessage(ChatColor.RED + "Failed to save file. " + exception.getMessage());
@ -330,17 +327,12 @@ public class SignOverwriteBrush extends Brush {
return;
}
try {
FileReader inFile = new FileReader(store);
BufferedReader inStream = new BufferedReader(inFile);
try (FileReader inFile = new FileReader(store); BufferedReader inStream = new BufferedReader(inFile)) {
for (int i = 0; i < this.signTextLines.length; i++) {
this.signLinesEnabled[i] = Boolean.valueOf(inStream.readLine());
this.signTextLines[i] = inStream.readLine();
}
inStream.close();
inFile.close();
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) {
@ -353,18 +345,14 @@ public class SignOverwriteBrush extends Brush {
* Clears the internal text buffer. (Sets it to empty strings)
*/
private void clearBuffer() {
for (int i = 0; i < this.signTextLines.length; i++) {
this.signTextLines[i] = "";
}
Arrays.fill(this.signTextLines, "");
}
/**
* Resets line enabled states to enabled.
*/
private void resetStates() {
for (int i = 0; i < this.signLinesEnabled.length; i++) {
this.signLinesEnabled[i] = true;
}
Arrays.fill(this.signLinesEnabled, true);
}
@Override

View File

@ -203,7 +203,7 @@ public class StencilBrush extends Brush {
}
}
@SuppressWarnings("deprecation")
@SuppressWarnings("UnstableApiUsage")
private void stencilSave(final SnipeData v) {
final File file = new File("plugins/VoxelSniper/stencils/" + this.filename + ".vstencil");
@ -223,9 +223,9 @@ public class StencilBrush extends Brush {
Files.createParentDirs(file);
file.createNewFile();
final FaweOutputStream out = new FaweOutputStream(new DataOutputStream(new PGZIPOutputStream(new BufferedOutputStream(new FileOutputStream(file)))));
int blockPositionX = (this.firstPoint[0] > this.secondPoint[0]) ? this.secondPoint[0] : this.firstPoint[0];
int blockPositionZ = (this.firstPoint[1] > this.secondPoint[1]) ? this.secondPoint[1] : this.firstPoint[1];
int blockPositionY = (this.firstPoint[2] > this.secondPoint[2]) ? this.secondPoint[2] : this.firstPoint[2];
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);

View File

@ -62,10 +62,10 @@ public class TriangleBrush extends PerformBrush {
}
private void triangleP(final SnipeData v) {
double lengthOne = 0;
double lengthTwo = 0;
double lengthThree = 0;
double heronBig = 0;
double lengthOne;
double lengthTwo;
double lengthThree;
double heronBig;
// Calculate slope vectors
for (int i = 0; i < 3; i++) {
@ -85,7 +85,7 @@ public class TriangleBrush extends PerformBrush {
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((lengthOne > lengthTwo) ? lengthOne : lengthTwo);
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];

View File

@ -31,11 +31,7 @@ public class VoxelBrushToolCommand extends VoxelCommand {
}
if (args.length == 3 && args[2] != null && !args[2].isEmpty()) {
Material itemInHand = (player.getItemInHand() != null) ? player.getItemInHand().getType() : null;
if (itemInHand == null) {
player.sendMessage("/btool assign <arrow|powder> <toolid>");
return true;
}
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 {
@ -48,11 +44,7 @@ public class VoxelBrushToolCommand extends VoxelCommand {
sniper.removeTool(args[1]);
return true;
} else {
Material itemInHand = (player.getItemInHand() != null) ? player.getItemInHand().getType() : null;
if (itemInHand == null) {
player.sendMessage("Can't unassign empty hands.");
return true;
}
Material itemInHand = player.getItemInHand().getType();
if (sniper.getCurrentToolId() == null) {
player.sendMessage("Can't unassign default tool.");
return true;