Work on CLI and I forget what else

This commit is contained in:
MattBDev
2019-07-29 10:57:28 -04:00
parent 8aaed49fa6
commit ca54f8c371
92 changed files with 1111 additions and 1107 deletions

View File

@@ -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) {

View File

@@ -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 {

View File

@@ -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.");
}
}
}