geforkt von Mirrors/FastAsyncWorldEdit
Work on CLI and I forget what else
Dieser Commit ist enthalten in:
Ursprung
8aaed49fa6
Commit
ca54f8c371
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<Player> {
|
||||
|
||||
private static ConsoleCommandSender console;
|
||||
@ -39,26 +36,6 @@ public class BukkitPlayer extends FawePlayer<Player> {
|
||||
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.<FaweBukkit>imp().getVault() == null || Fawe.<FaweBukkit>imp().getVault().permission == null) {
|
||||
this.parent.addAttachment(Fawe.<FaweBukkit>imp().getPlugin()).setPermission(perm, flag);
|
||||
} else if (flag) {
|
||||
if (!Fawe.<FaweBukkit>imp().getVault().permission.playerAdd(this.parent, perm)) {
|
||||
this.parent.addAttachment(Fawe.<FaweBukkit>imp().getPlugin()).setPermission(perm, flag);
|
||||
}
|
||||
} else {
|
||||
if (!Fawe.<FaweBukkit>imp().getVault().permission.playerRemove(this.parent, perm)) {
|
||||
this.parent.addAttachment(Fawe.<FaweBukkit>imp().getPlugin()).setPermission(perm, flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void resetTitle() {
|
||||
parent.resetTitle();
|
||||
@ -77,7 +54,7 @@ public class BukkitPlayer extends FawePlayer<Player> {
|
||||
|
||||
@Override
|
||||
public void sendMessage(final String message) {
|
||||
this.parent.sendMessage(BBC.color(message));
|
||||
this.parent.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override public void printError(String msg) {
|
||||
|
@ -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<FaweMaskManager> 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 '<internal.freebuild>' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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<Player> 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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<Player> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<Player> 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;
|
||||
}
|
||||
|
@ -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<Player> 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;
|
||||
}
|
||||
|
@ -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<RegisteredListener> 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>)player).parent.getWorld() && type == MaskType.MEMBER;
|
||||
return bukkitWorld == BukkitAdapter.adapt(player.toWorldEditPlayer().getWorld()) && type == MaskType.MEMBER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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<Player> 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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<Player> fp, MaskType type) {
|
||||
final Player player = fp.parent;
|
||||
public FaweMask getMask(FawePlayer<Player> fp, MaskType type) {
|
||||
final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
|
||||
final Location location = player.getLocation();
|
||||
final List<Field> 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"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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) {
|
||||
@ -34,12 +38,15 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
||||
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<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
public FaweMask getMask(FawePlayer<Player> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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<Player> 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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<Player> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
@ -42,15 +42,15 @@ public interface IQueueExtent extends Flushable, Trimable, Extent {
|
||||
* Get the {@link WorldChunkCache}
|
||||
* @return
|
||||
*/
|
||||
IChunkGet getCachedGet(int X, int Z, Supplier<IChunkGet> supplier);
|
||||
IChunkGet getCachedGet(int x, int z, Supplier<IChunkGet> 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
|
||||
|
@ -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<DistrFilter> {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkGet getCachedGet(int X, int Z, Supplier<IChunkGet> supplier) {
|
||||
return cache.get(MathMan.pairInt(X, Z), supplier);
|
||||
public IChunkGet getCachedGet(int x, int z, Supplier<IChunkGet> 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);
|
||||
|
@ -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<String, String> 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<String, Object> obj, String color, Map<String, Boolean> properties) {
|
||||
Object[] style = new Object[] { color, properties };
|
||||
for (Map.Entry<String, Object> 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<String, Object> 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<Map<String, Object>> list = (List<Map<String, Object>>) entry.getValue();
|
||||
for (Map<String, Object> elem : list) {
|
||||
elem.putIfAbsent("color", obj.get("color"));
|
||||
for (Map.Entry<String, Object> 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<String, Object> obj = gson.fromJson(text, new TypeToken<Map<String, Object>>() {}.getType());
|
||||
HashMap<String, Boolean> 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<String, String, Boolean> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public abstract class FawePlayer<T> 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<T> 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 = "<unspecified>";
|
||||
@ -181,8 +181,8 @@ public abstract class FawePlayer<T> 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<T> 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<T> extends Metadatable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this player (delets all metadata etc)
|
||||
* Unregister this player (deletes all metadata etc)
|
||||
* - Usually called on logout
|
||||
*/
|
||||
public void unregister() {
|
||||
|
@ -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)
|
||||
|
@ -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++) {
|
||||
|
@ -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();
|
||||
|
@ -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<Vector3> 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);
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -78,10 +78,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
protected final DifferentialArray<int[]> main;
|
||||
protected DifferentialArray<int[]> 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,7 +428,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
// Process table
|
||||
table.processSummedAreaTable();
|
||||
{ // Copy from table
|
||||
// Copy from table
|
||||
int localIndex = 0;
|
||||
int zIndex = (minZ * getWidth());
|
||||
for (int z = minZ, localZ = 0; z <= maxZ; z++, localZ++, zIndex += getWidth()) {
|
||||
@ -441,7 +441,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final void setLayerHeight(int index, int height) {
|
||||
int blockHeight = (height) >> 3;
|
||||
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -121,6 +121,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
initFiles(folder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
// Fawe.debug("Deleting history: " + getWorld().getName() + "/" + uuid + "/" + index);
|
||||
deleteFiles();
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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<Change> getIterator(final boolean dir) {
|
||||
close();
|
||||
try {
|
||||
|
@ -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
|
||||
|
@ -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<Change> iter = getIterator(true);
|
||||
Iterator<Change> 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;
|
||||
|
@ -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
|
||||
// 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));
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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<String> getInformationLines() {
|
||||
final List<String> 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
|
||||
|
@ -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;
|
||||
|
||||
if (fill) {
|
||||
g2.setColor(colorTop);
|
||||
if (fill) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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() {
|
||||
|
@ -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("\\.");
|
||||
|
@ -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<String, String> replacements) {
|
||||
final StringBuilder sb = new StringBuilder(string);
|
||||
int size = string.length();
|
||||
for (Entry<String, String> 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());
|
||||
}
|
||||
}
|
||||
|
@ -99,9 +99,9 @@ public class WEManager {
|
||||
synchronized (masks) {
|
||||
boolean removed = false;
|
||||
if (!masks.isEmpty()) {
|
||||
Iterator<FaweMask> iter = masks.iterator();
|
||||
while (iter.hasNext()) {
|
||||
FaweMask mask = iter.next();
|
||||
Iterator<FaweMask> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<Boolean>() {
|
||||
@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<Boolean>() {
|
||||
@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<Location>() {
|
||||
@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<Location>() {
|
||||
@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<Location>() {
|
||||
@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);
|
||||
|
@ -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,
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
/**
|
||||
* Raised when a world is missing but is required.
|
||||
*/
|
||||
public class MissingWorldException extends WorldEditException {
|
||||
|
||||
}
|
@ -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) {
|
||||
|
@ -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<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||
Set<BlockVector2> 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<BlockVector2> 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"))));
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<ClipboardHolder> {
|
||||
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<Void> {
|
||||
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;
|
||||
|
@ -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<BlockVector3> 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<BlockVector3> 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<Integer> limit = ActorSelectorLimits.forActor(player).getPolygonVertexLimit();
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.format(integer)));
|
||||
actor.print(BBC.SEL_2D_POLYGON.s());
|
||||
Optional<Integer> 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<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit();
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.format(integer)));
|
||||
actor.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
|
||||
Optional<Integer> 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<Integer> 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<Integer> 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[=<mask>]", "Select all connected blocks (magic wand)", "//sel fuzzy[=<mask>]");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
|
||||
List<Snapshot> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<File> 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<File> 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<File> forEachFile) {
|
||||
Consumer<File> rootFunction = forEachFile;
|
||||
|
@ -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()) {
|
||||
try {
|
||||
Platform platform = pm.queryCapability(capability);
|
||||
actor.printDebug(String.format("%s: %s", capability.name(), platform != null ? platform.getPlatformName() : "NONE"));
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()}.</p>
|
||||
*/
|
||||
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.
|
||||
*
|
||||
|
@ -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.
|
||||
|
@ -198,7 +198,7 @@ public class DefaultMaskParser extends FaweParser<Mask> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public class DefaultPatternParser extends FaweParser<Pattern> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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) {
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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();
|
||||
|
||||
}
|
@ -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(),
|
||||
|
@ -232,7 +232,7 @@ public class BlockMaskBuilder {
|
||||
private void suggest(String input, String property, Collection<BlockType> finalTypes) throws InputParseException {
|
||||
throw new SuggestInputParseException(input + " does not have: " + property, input, () -> {
|
||||
Set<PropertyKey> 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))
|
||||
|
@ -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<Map.Entry<Mask, Mask>, Mask> pairingFunction() {
|
||||
public Function<Entry<Mask, Mask>, 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<Map.Entry<Mask, Mask>, Mask> pairing, Set<Map.Entry<Mask, Mask>> failedCombines) {
|
||||
private boolean combineMasks(Function<Entry<Mask, Mask>, Mask> pairing, Set<Map.Entry<Mask, Mask>> failedCombines) {
|
||||
boolean hasOptimized = false;
|
||||
while (true) {
|
||||
Mask[] result = null;
|
||||
|
@ -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<Map.Entry<Mask, Mask>, Mask> pairingFunction() {
|
||||
public Function<Entry<Mask, Mask>, Mask> pairingFunction() {
|
||||
return input -> input.getKey().tryOr(input.getValue());
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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<BlockVector3> 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<BlockVector3>() {
|
||||
@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<long[][]> visits;
|
||||
private final Long2ObjectOpenHashMap<char[][]> 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) {
|
||||
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<String> getSuggestions(String arguments, CommandLocals locals) throws CommandException {
|
||||
Platform platform = platformManager.queryCapability(Capability.USER_COMMANDS);
|
||||
if (platform instanceof MultiUserPlatform) {
|
||||
List<String> suggestions = new ArrayList<>();
|
||||
Collection<Actor> 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
|
@ -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.
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren