mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-22 07:56:52 +00:00
Work on CLI and I forget what else
This commit is contained in:
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user