From ca54f8c37117b4326831e14f74d7d37a8a641694 Mon Sep 17 00:00:00 2001
From: MattBDev <4009945+MattBDev@users.noreply.github.com>
Date: Mon, 29 Jul 2019 10:57:28 -0400
Subject: [PATCH] Work on CLI and I forget what else
---
.../voxelsniper/RangeBlockHelper.java | 19 +-
.../thevoxelbox/voxelsniper/VoxelSniper.java | 5 +-
.../voxelsniper/brush/JaggedLineBrush.java | 21 +-
.../voxelsniper/brush/RingBrush.java | 21 +-
.../voxelsniper/brush/ScannerBrush.java | 62 +++--
.../com/boydti/fawe/bukkit/BukkitPlayer.java | 27 +--
.../com/boydti/fawe/bukkit/FaweBukkit.java | 33 ++-
.../boydti/fawe/bukkit/beta/BukkitQueue.java | 1 +
.../fawe/bukkit/regions/ASkyBlockHook.java | 18 +-
.../fawe/bukkit/regions/FactionsFeature.java | 16 +-
.../bukkit/regions/FactionsOneFeature.java | 15 +-
.../bukkit/regions/FactionsUUIDFeature.java | 9 +-
.../fawe/bukkit/regions/FreeBuildRegion.java | 14 +-
.../regions/GriefPreventionFeature.java | 20 +-
.../bukkit/regions/PreciousStonesFeature.java | 17 +-
.../fawe/bukkit/regions/ResidenceFeature.java | 6 +-
.../fawe/bukkit/regions/TownyFeature.java | 48 ++--
.../fawe/bukkit/regions/Worldguard.java | 34 ++-
.../fawe/bukkit/regions/WorldguardFlag.java | 24 +-
.../bukkit/BukkitBlockCommandSender.java | 168 +++++++++++++
.../worldedit/bukkit/BukkitCommandSender.java | 18 +-
.../sk89q/worldedit/bukkit/BukkitPlayer.java | 11 +-
.../sk89q/worldedit/bukkit/BukkitWorld.java | 5 +
.../worldedit/bukkit/WorldEditPlugin.java | 2 +
.../src/main/java/com/boydti/fawe/Fawe.java | 6 +-
.../fawe/beta/IDelegateQueueExtent.java | 4 +-
.../com/boydti/fawe/beta/IQueueExtent.java | 8 +-
.../boydti/fawe/beta/filters/DistrFilter.java | 6 +-
.../SingleThreadQueueExtent.java | 10 +-
.../main/java/com/boydti/fawe/config/BBC.java | 226 +-----------------
.../com/boydti/fawe/object/FawePlayer.java | 16 +-
.../fawe/object/brush/CopyPastaBrush.java | 11 +-
.../fawe/object/brush/FallingSphere.java | 2 -
.../fawe/object/brush/InspectBrush.java | 5 +-
.../boydti/fawe/object/brush/SplineBrush.java | 6 +-
.../fawe/object/brush/SurfaceSpline.java | 4 +-
.../cfi/HeightMapMCAGenerator.java | 131 +++++-----
.../fawe/object/changeset/AnvilHistory.java | 5 +-
.../fawe/object/changeset/CFIChangeSet.java | 2 +-
.../object/changeset/DiskStorageHistory.java | 1 +
.../fawe/object/changeset/FaweChangeSet.java | 14 +-
.../object/changeset/FaweStreamChangeSet.java | 6 +
.../changeset/MemoryOptimizedHistory.java | 3 +-
.../clipboard/ResizableClipboardBuilder.java | 9 +-
.../clipboard/remap/ClipboardRemapper.java | 11 +-
.../fawe/object/collection/LongHashSet.java | 2 +-
.../fawe/object/collection/MemBlockSet.java | 31 ++-
.../object/collection/SummedAreaTable.java | 8 +-
.../object/io/BufferedRandomAccessFile.java | 5 +-
.../object/io/RandomFileOutputStream.java | 2 +-
.../object/progress/ChatProgressTracker.java | 3 +-
.../regions/selector/FuzzyRegionSelector.java | 9 +-
.../fawe/object/schematic/PNGWriter.java | 32 ++-
.../java/com/boydti/fawe/util/MainUtil.java | 6 +-
.../java/com/boydti/fawe/util/MemUtil.java | 3 +-
.../java/com/boydti/fawe/util/Permission.java | 8 +-
.../java/com/boydti/fawe/util/StringMan.java | 29 +--
.../java/com/boydti/fawe/util/WEManager.java | 8 +-
.../boydti/fawe/wrappers/PlayerWrapper.java | 14 +-
.../java/com/sk89q/jnbt/NBTConstants.java | 7 +-
.../main/java/com/sk89q/util/StringUtil.java | 2 +-
.../com/sk89q/worldedit/LocalSession.java | 52 ++--
.../worldedit/MissingWorldException.java | 27 +++
.../java/com/sk89q/worldedit/WorldEdit.java | 24 +-
.../worldedit/command/ChunkCommands.java | 26 +-
.../worldedit/command/ClipboardCommands.java | 26 +-
.../worldedit/command/GenerationCommands.java | 22 +-
.../worldedit/command/HistoryCommands.java | 2 +-
.../sk89q/worldedit/command/ListFilters.java | 3 +-
.../worldedit/command/RegionCommands.java | 4 +-
.../worldedit/command/SchematicCommands.java | 44 ++--
.../worldedit/command/SelectionCommands.java | 144 +++++------
.../worldedit/command/SnapshotCommands.java | 32 +--
.../command/SnapshotUtilCommands.java | 32 +--
.../worldedit/command/UtilityCommands.java | 8 +-
.../worldedit/command/WorldEditCommands.java | 20 +-
.../com/sk89q/worldedit/entity/Entity.java | 27 +--
.../com/sk89q/worldedit/entity/Player.java | 6 +-
.../parser/mask/DefaultMaskParser.java | 2 +-
.../parser/pattern/DefaultPatternParser.java | 2 +-
.../platform/AbstractNonPlayerActor.java | 51 ++++
.../platform/AbstractPlayerActor.java | 162 ++++++++-----
.../extension/platform/Locatable.java | 69 ++++++
.../platform/PlatformCommandManager.java | 5 -
.../function/mask/BlockMaskBuilder.java | 2 +-
.../function/mask/MaskIntersection.java | 17 +-
.../worldedit/function/mask/MaskUnion.java | 8 +-
.../worldedit/function/mask/RegionMask.java | 2 +
.../worldedit/function/visitor/ScanChunk.java | 44 ++--
.../command/UserCommandCompleter.java | 72 ------
.../WorldEditExceptionConverter.java | 11 +-
.../java/com/sk89q/worldedit/world/World.java | 3 +-
92 files changed, 1111 insertions(+), 1107 deletions(-)
create mode 100644 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java
create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/MissingWorldException.java
create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java
create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Locatable.java
delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/UserCommandCompleter.java
diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java
index ad5bea3e0..4dd725463 100644
--- a/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java
+++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java
@@ -26,8 +26,6 @@ package com.thevoxelbox.voxelsniper;
import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.boydti.fawe.bukkit.wrapper.AsyncWorld;
-import com.sk89q.worldedit.bukkit.BukkitAdapter;
-import com.sk89q.worldedit.world.registry.LegacyMapper;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@@ -41,7 +39,6 @@ public class RangeBlockHelper {
private Location playerLoc;
private double rotX;
private double rotY;
- private double viewHeight;
private double rotXSin;
private double rotXCos;
private double rotYSin;
@@ -70,14 +67,14 @@ public class RangeBlockHelper {
public RangeBlockHelper(Location location, int range, double step) {
this.world = (AsyncWorld) location.getWorld();
- this.init(location, (double)range, step, 0.0D);
+ this.init(location, range, step, 0.0D);
}
public RangeBlockHelper(Player player, int range, double step) {
if (player != null) {
this.world = VoxelSniper.getInstance().getSniperManager().getSniperForPlayer(player).getWorld();
}
- this.init(player.getLocation(), (double)range, step, 1.65D);
+ this.init(player.getLocation(), range, step, 1.65D);
}
public RangeBlockHelper(Player player, AsyncWorld world) {
@@ -163,7 +160,6 @@ public class RangeBlockHelper {
public final AsyncBlock getFaceBlock() {
while(this.getNextBlock() != null && isAir(this.getCurBlock().getType())) {
- ;
}
if(this.getCurBlock() != null) {
@@ -205,7 +201,6 @@ public class RangeBlockHelper {
this.fromOffworld();
while(this.getNextBlock() != null && isAir(this.getCurBlock().getType())) {
- ;
}
return this.getCurBlock();
@@ -229,26 +224,26 @@ public class RangeBlockHelper {
AsyncBlock block = world.getBlockAt(this.targetX, this.targetY, this.targetZ);
Material type = block.getType();
- return !isAir(type) ? block : (this.length <= this.range && this.targetY <= 255 && this.targetY >= 0?this.getRange():this.world.getBlockAt(this.lastX, this.lastY, this.lastZ));
+ return !isAir(type) ? block :
+ this.length <= this.range && this.targetY <= 255 && this.targetY >= 0?this.getRange():this.world.getBlockAt(this.lastX, this.lastY, this.lastZ);
}
private void init(Location location, double range, double step, double viewHeight) {
this.playerLoc = location;
- this.viewHeight = viewHeight;
this.playerX = this.playerLoc.getX();
- this.playerY = this.playerLoc.getY() + this.viewHeight;
+ this.playerY = this.playerLoc.getY() + viewHeight;
this.playerZ = this.playerLoc.getZ();
this.range = range;
this.step = step;
this.length = 0.0D;
this.rotX = (this.playerLoc.getYaw() + 90.0F) % 360.0F;
- this.rotY = this.playerLoc.getPitch() * -1.0F;
+ this.rotY = this.playerLoc.getPitch() * -1.0f;
this.rotYCos = Math.cos(Math.toRadians(this.rotY));
this.rotYSin = Math.sin(Math.toRadians(this.rotY));
this.rotXCos = Math.cos(Math.toRadians(this.rotX));
this.rotXSin = Math.sin(Math.toRadians(this.rotX));
this.targetX = (int)Math.floor(this.playerLoc.getX());
- this.targetY = (int)Math.floor(this.playerLoc.getY() + this.viewHeight);
+ this.targetY = (int)Math.floor(this.playerLoc.getY() + viewHeight);
this.targetZ = (int)Math.floor(this.playerLoc.getZ());
this.lastX = this.targetX;
this.lastY = this.targetY;
diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java
index 1af02afad..bbed59499 100644
--- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java
+++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java
@@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.BukkitCommand;
import com.boydti.fawe.object.FaweCommand;
import com.boydti.fawe.object.FawePlayer;
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.thevoxelbox.voxelsniper.brush.*;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
@@ -127,7 +128,7 @@ public class VoxelSniper extends JavaPlugin {
setupCommand("/p", new FaweCommand("voxelsniper.sniper") {
@Override
public boolean execute(FawePlayer fp, String... args) {
- Player player = (Player) fp.parent;
+ Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
return onCommand(player, new Command("p") {
@Override
public boolean execute(@NotNull CommandSender sender, String commandLabel, @NotNull String[] args) {
@@ -140,7 +141,7 @@ public class VoxelSniper extends JavaPlugin {
setupCommand("/d", new FaweCommand("voxelsniper.sniper") {
@Override
public boolean execute(FawePlayer fp, String... args) {
- Player player = (Player) fp.parent;
+ Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
return onCommand(player, new Command("d") {
@Override
public boolean execute(@NotNull CommandSender sender, String commandLabel, @NotNull String[] args) {
diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java
index 19951eec8..231217225 100644
--- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java
+++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java
@@ -18,9 +18,8 @@ public class JaggedLineBrush extends PerformBrush {
private static final int RECURSION_DEFAULT = 3;
private static final int RECURSION_MAX = 10;
private static final int SPREAD_DEFAULT = 3;
- private static int timesUsed = 0;
private Random random = new Random();
- private Vector originCoords = null;
+ private Vector originCoords;
private Vector targetCoords = new Vector();
private int recursion = RECURSION_DEFAULT;
private int spread = SPREAD_DEFAULT;
@@ -29,7 +28,7 @@ public class JaggedLineBrush extends PerformBrush {
this.setName("Jagged Line");
}
- private void jaggedP(final SnipeData v) {
+ private void jaggedP(SnipeData v) {
final Vector originClone = this.originCoords.clone().add(JaggedLineBrush.HALF_BLOCK_OFFSET);
final Vector targetClone = this.targetCoords.clone().add(JaggedLineBrush.HALF_BLOCK_OFFSET);
@@ -51,7 +50,7 @@ public class JaggedLineBrush extends PerformBrush {
}
@Override
- public final void arrow(final SnipeData v) {
+ public final void arrow(SnipeData v) {
if (originCoords == null) {
originCoords = new Vector();
}
@@ -60,7 +59,7 @@ public class JaggedLineBrush extends PerformBrush {
}
@Override
- public final void powder(final SnipeData v) {
+ public final void powder(SnipeData v) {
if (originCoords == null) {
v.sendMessage(ChatColor.RED + "Warning: You did not select a first coordinate with the arrow");
} else {
@@ -71,15 +70,15 @@ public class JaggedLineBrush extends PerformBrush {
}
@Override
- public final void info(final Message vm) {
+ public final void info(Message vm) {
vm.brushName(this.getName());
vm.custom(ChatColor.GRAY + String.format("Recursion set to: %d", this.recursion));
vm.custom(ChatColor.GRAY + String.format("Spread set to: %d", this.spread));
}
@Override
- public final void parameters(final String[] par, final SnipeData v) {
- for (final String parameter : par) {
+ public final void parameters(String[] par, SnipeData v) {
+ for (String parameter : par) {
try {
if (parameter.equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Jagged Line Brush instructions: Right click first point with the arrow. Right click with powder to draw a jagged line to set the second point.");
@@ -97,9 +96,9 @@ public class JaggedLineBrush extends PerformBrush {
}
return;
- } else if (parameter.startsWith("s")) {
- final int temp = Integer.parseInt(parameter.substring(1));
- this.spread = temp;
+ }
+ if (parameter.startsWith("s")) {
+ this.spread = Integer.parseInt(parameter.substring(1));
v.sendMessage(ChatColor.GREEN + "Spread set to: " + this.spread);
}
} catch (Exception exception) {
diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java
index 9208276d9..c0c5ff7b9 100644
--- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java
+++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java
@@ -8,14 +8,14 @@ import org.bukkit.ChatColor;
public class RingBrush extends PerformBrush {
- private double trueCircle = 0;
- private double innerSize = 0;
+ private double trueCircle;
+ private double innerSize;
public RingBrush() {
this.setName("Ring");
}
- private void ring(final SnipeData v, AsyncBlock targetBlock) {
+ private void ring(SnipeData v, AsyncBlock targetBlock) {
final int brushSize = v.getBrushSize();
final double outerSquared = Math.pow(brushSize + this.trueCircle, 2);
final double innerSquared = Math.pow(this.innerSize, 2);
@@ -24,7 +24,7 @@ public class RingBrush extends PerformBrush {
final double xSquared = Math.pow(x, 2);
for (int z = brushSize; z >= 0; z--) {
final double ySquared = Math.pow(z, 2);
- if ((xSquared + ySquared) <= outerSquared && (xSquared + ySquared) >= innerSquared) {
+ if (xSquared + ySquared <= outerSquared && xSquared + ySquared >= innerSquared) {
current.perform(targetBlock.getRelative(x, 0, z));
current.perform(targetBlock.getRelative(x, 0, -z));
current.perform(targetBlock.getRelative(-x, 0, z));
@@ -37,24 +37,24 @@ public class RingBrush extends PerformBrush {
}
@Override
- protected final void arrow(final SnipeData v) {
+ protected final void arrow(SnipeData v) {
this.ring(v, this.getTargetBlock());
}
@Override
- protected final void powder(final SnipeData v) {
+ protected final void powder(SnipeData v) {
this.ring(v, this.getLastBlock());
}
@Override
- public final void info(final Message vm) {
+ public final void info(Message vm) {
vm.brushName(this.getName());
vm.size();
vm.custom(ChatColor.AQUA + "The inner radius is " + ChatColor.RED + this.innerSize);
}
@Override
- public final void parameters(final String[] par, final SnipeData v) {
+ public final void parameters(String[] par, SnipeData v) {
for (int i = 1; i < par.length; i++) {
if (par[i].equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Ring Brush Parameters:");
@@ -69,10 +69,9 @@ public class RingBrush extends PerformBrush {
v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
} else if (par[i].startsWith("ir")) {
try {
- final double d = Double.parseDouble(par[i].replace("ir", ""));
- this.innerSize = d;
+ this.innerSize = Double.parseDouble(par[i].replace("ir", ""));
v.sendMessage(ChatColor.AQUA + "The inner radius has been set to " + ChatColor.RED + this.innerSize);
- } catch (final Exception exception) {
+ } catch (Exception exception) {
v.sendMessage(ChatColor.RED + "The parameters included are invalid.");
}
} else {
diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java
index 2761adf64..4920a10d3 100644
--- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java
+++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java
@@ -9,6 +9,7 @@ import org.bukkit.Material;
import org.bukkit.block.BlockFace;
public class ScannerBrush extends Brush {
+
private static final int DEPTH_MIN = 1;
private static final int DEPTH_DEFAULT = 24;
private static final int DEPTH_MAX = 64;
@@ -20,7 +21,7 @@ public class ScannerBrush extends Brush {
this.setName("Scanner");
}
- private int clamp(final int value, final int min, final int max) {
+ private int clamp(int value, int min, int max) {
if (value < min) {
return min;
} else {
@@ -28,7 +29,7 @@ public class ScannerBrush extends Brush {
}
}
- private void scan(final SnipeData v, final BlockFace bf) {
+ private void scan(SnipeData v, BlockFace bf) {
if (bf == null) {
return;
}
@@ -37,8 +38,10 @@ public class ScannerBrush extends Brush {
case NORTH:
// Scan south
for (int i = 1; i < this.depth + 1; i++) {
- if (this.clampY(this.getTargetBlock().getX() + i, this.getTargetBlock().getY(), this.getTargetBlock().getZ()).getType() == this.checkFor) {
- v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
+ if (this.clampY(this.getTargetBlock().getX() + i, this.getTargetBlock().getY(),
+ this.getTargetBlock().getZ()).getType() == this.checkFor) {
+ v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i
+ + " blocks.");
return;
}
}
@@ -48,8 +51,10 @@ public class ScannerBrush extends Brush {
case SOUTH:
// Scan north
for (int i = 1; i < this.depth + 1; i++) {
- if (this.clampY(this.getTargetBlock().getX() - i, this.getTargetBlock().getY(), this.getTargetBlock().getZ()).getType() == this.checkFor) {
- v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
+ if (this.clampY(this.getTargetBlock().getX() - i, this.getTargetBlock().getY(),
+ this.getTargetBlock().getZ()).getType() == this.checkFor) {
+ v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i
+ + " blocks.");
return;
}
}
@@ -59,8 +64,10 @@ public class ScannerBrush extends Brush {
case EAST:
// Scan west
for (int i = 1; i < this.depth + 1; i++) {
- if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ() + i).getType() == this.checkFor) {
- v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
+ if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(),
+ this.getTargetBlock().getZ() + i).getType() == this.checkFor) {
+ v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i
+ + " blocks.");
return;
}
}
@@ -70,8 +77,10 @@ public class ScannerBrush extends Brush {
case WEST:
// Scan east
for (int i = 1; i < this.depth + 1; i++) {
- if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ() - i).getType() == this.checkFor) {
- v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
+ if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(),
+ this.getTargetBlock().getZ() - i).getType() == this.checkFor) {
+ v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i
+ + " blocks.");
return;
}
}
@@ -81,11 +90,13 @@ public class ScannerBrush extends Brush {
case UP:
// Scan down
for (int i = 1; i < this.depth + 1; i++) {
- if ((this.getTargetBlock().getY() - i) <= 0) {
+ if (this.getTargetBlock().getY() - i <= 0) {
break;
}
- if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() - i, this.getTargetBlock().getZ()).getType() == this.checkFor) {
- v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
+ if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() - i,
+ this.getTargetBlock().getZ()).getType() == this.checkFor) {
+ v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i
+ + " blocks.");
return;
}
}
@@ -95,11 +106,13 @@ public class ScannerBrush extends Brush {
case DOWN:
// Scan up
for (int i = 1; i < this.depth + 1; i++) {
- if ((this.getTargetBlock().getY() + i) >= v.getWorld().getMaxHeight()) {
+ if (this.getTargetBlock().getY() + i >= v.getWorld().getMaxHeight()) {
break;
}
- if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() + i, this.getTargetBlock().getZ()).getType() == this.checkFor) {
- v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
+ if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() + i,
+ this.getTargetBlock().getZ()).getType() == this.checkFor) {
+ v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i
+ + " blocks.");
return;
}
}
@@ -113,38 +126,41 @@ public class ScannerBrush extends Brush {
@SuppressWarnings("deprecation")
@Override
- protected final void arrow(final SnipeData v) {
+ protected final void arrow(SnipeData v) {
this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId()));
this.scan(v, this.getTargetBlock().getFace(this.getLastBlock()));
}
@SuppressWarnings("deprecation")
@Override
- protected final void powder(final SnipeData v) {
+ protected final void powder(SnipeData v) {
this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId()));
this.scan(v, this.getTargetBlock().getFace(this.getLastBlock()));
}
@Override
- public final void info(final Message vm) {
+ public final void info(Message vm) {
vm.brushName(this.getName());
vm.custom(ChatColor.GREEN + "Scanner depth set to " + this.depth);
vm.custom(ChatColor.GREEN + "Scanner scans for " + this.checkFor + " (change with /v #)");
}
@Override
- public final void parameters(final String[] par, final SnipeData v) {
+ public final void parameters(String[] par, SnipeData v) {
for (int i = 1; i < par.length; i++) {
if (par[i].equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Scanner brush Parameters:");
- v.sendMessage(ChatColor.AQUA + "/b sc d# -- will set the search depth to #. Clamps to 1 - 64.");
+ v.sendMessage(ChatColor.AQUA
+ + "/b sc d# -- will set the search depth to #. Clamps to 1 - 64.");
return;
}
if (par[i].startsWith("d")) {
- this.depth = this.clamp(Integer.parseInt(par[i].substring(1)), DEPTH_MIN, DEPTH_MAX);
+ this.depth = this
+ .clamp(Integer.parseInt(par[i].substring(1)), DEPTH_MIN, DEPTH_MAX);
v.sendMessage(ChatColor.AQUA + "Scanner depth set to " + this.depth);
} else {
- v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info.");
+ v.sendMessage(ChatColor.RED
+ + "Invalid brush parameters! Use the info parameter to display parameter info.");
}
}
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java
index 7fe7f7a9e..2c811f70c 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java
@@ -1,16 +1,13 @@
package com.boydti.fawe.bukkit;
-import com.boydti.fawe.Fawe;
-import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
+import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
-import java.util.UUID;
-
public class BukkitPlayer extends FawePlayer {
private static ConsoleCommandSender console;
@@ -39,26 +36,6 @@ public class BukkitPlayer extends FawePlayer {
return parent.isSneaking();
}
- @Override
- public void setPermission(final String perm, final boolean flag) {
- /*
- * Permissions are used to managing WorldEdit region restrictions
- * - The `/wea` command will give/remove the required bypass permission
- */
- if (Fawe.imp().getVault() == null || Fawe.imp().getVault().permission == null) {
- this.parent.addAttachment(Fawe.imp().getPlugin()).setPermission(perm, flag);
- } else if (flag) {
- if (!Fawe.imp().getVault().permission.playerAdd(this.parent, perm)) {
- this.parent.addAttachment(Fawe.imp().getPlugin()).setPermission(perm, flag);
- }
- } else {
- if (!Fawe.imp().getVault().permission.playerRemove(this.parent, perm)) {
- this.parent.addAttachment(Fawe.imp().getPlugin()).setPermission(perm, flag);
- }
- }
- }
-
-
@Override
public void resetTitle() {
parent.resetTitle();
@@ -77,7 +54,7 @@ public class BukkitPlayer extends FawePlayer {
@Override
public void sendMessage(final String message) {
- this.parent.sendMessage(BBC.color(message));
+ this.parent.sendMessage(message);
}
@Override public void printError(String msg) {
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java
index e37f7b888..061f04902 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java
@@ -3,11 +3,9 @@ package com.boydti.fawe.bukkit;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.IFawe;
import com.boydti.fawe.beta.implementation.QueueHandler;
-import com.boydti.fawe.bukkit.beta.BukkitQueue;
import com.boydti.fawe.bukkit.beta.BukkitQueueHandler;
import com.boydti.fawe.bukkit.listener.BrushListener;
import com.boydti.fawe.bukkit.listener.BukkitImageListener;
-import com.boydti.fawe.bukkit.listener.CFIPacketListener;
import com.boydti.fawe.bukkit.listener.RenderListener;
import com.boydti.fawe.bukkit.regions.*;
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
@@ -21,7 +19,6 @@ import com.boydti.fawe.bukkit.v0.ChunkListener_8;
import com.boydti.fawe.bukkit.v0.ChunkListener_9;
import com.boydti.fawe.bukkit.v1_13.BukkitQueue_1_13;
import com.boydti.fawe.bukkit.v1_14.BukkitQueue_1_14;
-import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweCommand;
import com.boydti.fawe.object.FawePlayer;
@@ -32,10 +29,10 @@ import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.image.ImageViewer;
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.World;
import org.bstats.bukkit.MetricsLite;
import org.bukkit.Bukkit;
-import org.bukkit.Chunk;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
@@ -43,11 +40,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
-import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
-import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.FileOutputStream;
@@ -155,7 +150,7 @@ public class FaweBukkit implements IFawe, Listener {
fos.write(jarData);
}
}
- BukkitImageViewer viewer = new BukkitImageViewer((Player) fp.parent);
+ BukkitImageViewer viewer = new BukkitImageViewer(BukkitAdapter.adapt(fp.toWorldEditPlayer()));
if (imageListener == null) {
this.imageListener = new BukkitImageListener(plugin);
}
@@ -184,7 +179,7 @@ public class FaweBukkit implements IFawe, Listener {
@Override
public void debug(final String message) {
ConsoleCommandSender console = Bukkit.getConsoleSender();
- console.sendMessage(BBC.color(message));
+ console.sendMessage(message);
}
@Override
@@ -398,19 +393,19 @@ public class FaweBukkit implements IFawe, Listener {
final ArrayList managers = new ArrayList<>();
if (worldguardPlugin != null && worldguardPlugin.isEnabled()) {
try {
- managers.add(new Worldguard(worldguardPlugin, this));
- managers.add(new WorldguardFlag(worldguardPlugin, this));
+ managers.add(new Worldguard(worldguardPlugin));
+ managers.add(new WorldguardFlag(worldguardPlugin));
Fawe.debug("Plugin 'WorldGuard' found. Using it now.");
- } catch (final Throwable e) {
+ } catch (Throwable e) {
e.printStackTrace();
}
}
final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny");
if (townyPlugin != null && townyPlugin.isEnabled()) {
try {
- managers.add(new TownyFeature(townyPlugin, this));
+ managers.add(new TownyFeature(townyPlugin));
Fawe.debug("Plugin 'Towny' found. Using it now.");
- } catch (final Throwable e) {
+ } catch (Throwable e) {
e.printStackTrace();
}
}
@@ -419,7 +414,7 @@ public class FaweBukkit implements IFawe, Listener {
try {
managers.add(new FactionsFeature(factionsPlugin));
Fawe.debug("Plugin 'Factions' found. Using it now.");
- } catch (final Throwable e) {
+ } catch (Throwable e) {
try {
managers.add(new FactionsUUIDFeature(factionsPlugin, this));
Fawe.debug("Plugin 'FactionsUUID' found. Using it now.");
@@ -439,7 +434,7 @@ public class FaweBukkit implements IFawe, Listener {
try {
managers.add(new ResidenceFeature(residencePlugin, this));
Fawe.debug("Plugin 'Residence' found. Using it now.");
- } catch (final Throwable e) {
+ } catch (Throwable e) {
e.printStackTrace();
}
}
@@ -448,7 +443,7 @@ public class FaweBukkit implements IFawe, Listener {
try {
managers.add(new GriefPreventionFeature(griefpreventionPlugin));
Fawe.debug("Plugin 'GriefPrevention' found. Using it now.");
- } catch (final Throwable e) {
+ } catch (Throwable e) {
e.printStackTrace();
}
}
@@ -457,7 +452,7 @@ public class FaweBukkit implements IFawe, Listener {
try {
managers.add(new PreciousStonesFeature(preciousStonesPlugin, this));
Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
- } catch (final Throwable e) {
+ } catch (Throwable e) {
e.printStackTrace();
}
}
@@ -468,7 +463,7 @@ public class FaweBukkit implements IFawe, Listener {
try {
managers.add(new ASkyBlockHook(aSkyBlock));
Fawe.debug("Plugin 'ASkyBlock' found. Using it now.");
- } catch (final Throwable e) {
+ } catch (Throwable e) {
e.printStackTrace();
}
}
@@ -476,7 +471,7 @@ public class FaweBukkit implements IFawe, Listener {
try {
managers.add(new FreeBuildRegion());
Fawe.debug("Plugin '' found. Using it now.");
- } catch (final Throwable e) {
+ } catch (Throwable e) {
e.printStackTrace();
}
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java
index e23c09c0f..c0b0fb4ef 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java
@@ -234,6 +234,7 @@ public class BukkitQueue extends SimpleCharQueueExtent {
return playerChunk;
}
+ @Override
public boolean sendChunk(final int X, final int Z, final int mask) {
PlayerChunk playerChunk = getPlayerChunk(X, Z);
if (playerChunk == null) {
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java
index 2c1a58fcd..664734cd9 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java
@@ -3,10 +3,11 @@ package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.MutableBlockVector3;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import com.wasteofplastic.askyblock.Island;
import org.bukkit.Location;
-import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
@@ -24,22 +25,21 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener {
@Override
public FaweMask getMask(final FawePlayer fp, MaskType type) {
- final Player player = fp.parent;
+ final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Location location = player.getLocation();
Island island = ASkyBlockAPI.getInstance().getIslandAt(location);
if (island != null && isAllowed(player, island, type)) {
- World world = location.getWorld();
- Location center = island.getCenter();
- Location pos1 = new Location(world, island.getMinProtectedX(), 0, island.getMinProtectedZ());
- Location pos2 = center.add(center.subtract(pos1));
- pos2.setY(255);
+ Location center1 = island.getCenter();
+ MutableBlockVector3 center = MutableBlockVector3.at(center1.getX(), center1.getY(), center1.getZ());
+ BlockVector3 pos1 = BlockVector3.at(island.getMinProtectedX(), 0, island.getMinProtectedZ());
+ MutableBlockVector3 pos2 = center.add(center.subtract(pos1)).mutY(255);
- return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) {
+ return new FaweMask(pos1, pos2) {
@Override
public boolean isValid(FawePlayer player, MaskType type) {
- return isAllowed((Player) player.parent, island, type);
+ return isAllowed(BukkitAdapter.adapt(player.toWorldEditPlayer()), island, type);
}
};
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java
index 723a6a838..2b1fa2b62 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java
@@ -7,6 +7,7 @@ import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.ps.PS;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldedit.math.BlockVector3;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -21,7 +22,7 @@ public class FactionsFeature extends BukkitMaskManager implements Listener {
@Override
public FaweMask getMask(final FawePlayer fp, MaskType type) {
- final Player player = fp.parent;
+ final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Location loc = player.getLocation();
final PS ps = PS.valueOf(loc);
final Faction fac = BoardColl.get().getFactionAt(ps);
@@ -30,16 +31,17 @@ public class FactionsFeature extends BukkitMaskManager implements Listener {
MPlayer leader = fac.getLeader();
if (leader != null && fp.getUUID().equals(leader.getUuid())) {
final Chunk chunk = loc.getChunk();
- final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16);
- final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
- return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint());
+ final BlockVector3 pos1 = BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16);
+ final BlockVector3 pos2 = BlockVector3
+ .at((chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
+ return new FaweMask(pos1, pos2);
}
} else if (fac.getOnlinePlayers().contains(player)) {
if (!fac.getComparisonName().equals("wilderness")) {
final Chunk chunk = loc.getChunk();
- final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16);
- final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
- return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint());
+ final BlockVector3 pos1 = BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16);
+ final BlockVector3 pos2 = BlockVector3.at((chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
+ return new FaweMask(pos1, pos2);
}
}
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java
index e1ec86f25..656ebacf0 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java
@@ -6,16 +6,15 @@ import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.util.Permission;
import com.massivecraft.factions.FLocation;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldedit.math.BlockVector3;
+import java.lang.reflect.Method;
+import java.util.List;
import org.bukkit.Chunk;
-import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
-import java.lang.reflect.Method;
-import java.util.List;
-
public class FactionsOneFeature extends BukkitMaskManager implements Listener {
private final Method methodGetFactionAt;
@@ -28,7 +27,7 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener {
@Override
public FaweMask getMask(final FawePlayer fp, MaskType type) {
- final Player player = fp.parent;
+ final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Chunk chunk = player.getLocation().getChunk();
final boolean perm = Permission
.hasPermission(fp.toWorldEditPlayer(), "fawe.factions.wilderness");
@@ -75,9 +74,9 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener {
}
}
- final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4);
- final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4));
- return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint());
+ final BlockVector3 pos1 = BlockVector3.at(locs.minX << 4, 1, locs.minZ << 4);
+ final BlockVector3 pos2 = BlockVector3.at(15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4));
+ return new FaweMask(pos1, pos2);
}
return null;
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java
index c6f9e3bb2..cccb32804 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java
@@ -9,6 +9,7 @@ import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldedit.math.BlockVector3;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
@@ -26,7 +27,7 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
@Override
public FaweMask getMask(final FawePlayer fp, MaskType type) {
- final Player player = fp.parent;
+ final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Chunk chunk = player.getLocation().getChunk();
final boolean perm = Permission
.hasPermission(fp.toWorldEditPlayer(), "fawe.factions.wilderness");
@@ -73,9 +74,9 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
}
}
- final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4);
- final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4));
- return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint());
+ final BlockVector3 pos1 = BlockVector3.at(locs.minX << 4, 1, locs.minZ << 4);
+ final BlockVector3 pos2 = BlockVector3.at(15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4));
+ return new FaweMask(pos1,pos2);
}
return null;
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java
index 6e9b47a9d..3a4c1268d 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java
@@ -10,6 +10,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BlockTypes;
+import jdk.nashorn.internal.ir.Block;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@@ -20,6 +21,7 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.plugin.RegisteredListener;
import java.util.ArrayList;
+import org.bukkit.util.BlockVector;
public class FreeBuildRegion extends BukkitMaskManager {
private final ArrayList listeners;
@@ -52,20 +54,20 @@ public class FreeBuildRegion extends BukkitMaskManager {
if (currRegList.isEmpty()) return null;
RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[0]);
- World bukkitWorld = player.parent.getWorld();
+ World bukkitWorld = BukkitAdapter.adapt(player.toWorldEditPlayer().getWorld());
AsyncWorld asyncWorld = AsyncWorld.wrap(bukkitWorld);
- Location pos1 = BukkitAdapter.adapt(bukkitWorld, BlockVector3.ZERO);
- Location pos2 = BukkitAdapter.adapt(bukkitWorld, BlockVector3.ZERO);
+ BlockVector3 pos1 = BlockVector3.ZERO;
+ BlockVector3 pos2 = BlockVector3.ZERO;
AsyncBlock block = new AsyncBlock(asyncWorld, new NullFaweQueue(asyncWorld.getWorldName(), BlockTypes.STONE.getDefaultState()), 0, 0, 0);
- BlockBreakEvent event = new BlockBreakEvent(block, player.parent);
+ BlockBreakEvent event = new BlockBreakEvent(block, BukkitAdapter.adapt(player.toWorldEditPlayer()));
- return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) {
+ return new FaweMask(pos1, pos2) {
@Override
public boolean isValid(FawePlayer player, MaskType type) {
- return bukkitWorld == ((FawePlayer)player).parent.getWorld() && type == MaskType.MEMBER;
+ return bukkitWorld == BukkitAdapter.adapt(player.toWorldEditPlayer().getWorld()) && type == MaskType.MEMBER;
}
@Override
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java
index 6b987df14..15a22d1fe 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java
@@ -5,10 +5,10 @@ import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.general.RegionFilter;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldedit.math.BlockVector3;
import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import org.bukkit.Bukkit;
-import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
@@ -21,24 +21,24 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene
}
public boolean isAllowed(Player player, Claim claim, MaskType type) {
- return claim != null && (claim.getOwnerName().equalsIgnoreCase(player.getName()) || claim.getOwnerName().equals(player.getUniqueId()) || (type == MaskType.MEMBER && (claim.allowBuild(player, Material.AIR) == null)));
+ return claim != null && (claim.getOwnerName().equalsIgnoreCase(player.getName()) || claim.getOwnerName().equals(player.getUniqueId()) ||
+ type == MaskType.MEMBER && claim.allowBuild(player, Material.AIR) == null);
}
@Override
public FaweMask getMask(final FawePlayer fp, MaskType type) {
- final Player player = fp.parent;
- final Location location = player.getLocation();
- final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, true, null);
+ final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
+ final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(BukkitAdapter.adapt(fp.getLocation()), true, null);
if (claim != null) {
if (isAllowed(player, claim, type)) {
claim.getGreaterBoundaryCorner().getBlockX();
- final Location pos1 = new Location(location.getWorld(), claim.getLesserBoundaryCorner().getBlockX(), 0, claim.getLesserBoundaryCorner().getBlockZ());
- final Location pos2 = new Location(location.getWorld(), claim.getGreaterBoundaryCorner().getBlockX(), 256, claim.getGreaterBoundaryCorner().getBlockZ());
- return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) {
+ final BlockVector3 pos1 = BlockVector3.at(claim.getLesserBoundaryCorner().getBlockX(), 0, claim.getLesserBoundaryCorner().getBlockZ());
+ final BlockVector3 pos2 = BlockVector3.at(claim.getGreaterBoundaryCorner().getBlockX(), 256, claim.getGreaterBoundaryCorner().getBlockZ());
+ return new FaweMask(pos1, pos2) {
@Override
- public boolean isValid(FawePlayer player, MaskType type) {
- return isAllowed((Player) player.parent, claim, type);
+ public boolean isValid(FawePlayer fp, MaskType type) {
+ return isAllowed(player, claim, type);
}
};
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java
index d67f9a919..a94b4a7f2 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java
@@ -3,6 +3,7 @@ package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask;
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import java.util.List;
@@ -15,23 +16,19 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
public class PreciousStonesFeature extends BukkitMaskManager implements Listener {
- FaweBukkit plugin;
- Plugin preciousstones;
- public PreciousStonesFeature(final Plugin preciousstonesPlugin, final FaweBukkit p3) {
+ public PreciousStonesFeature(Plugin preciousstonesPlugin, FaweBukkit p3) {
super(preciousstonesPlugin.getName());
- this.preciousstones = preciousstonesPlugin;
- this.plugin = p3;
}
public boolean isAllowed(Player player, Field field, MaskType type, boolean allowMember) {
- return field != null && (field.isOwner(player.getName()) || (type == MaskType.MEMBER && allowMember && field.getAllAllowed().contains(player.getName())));
+ return field != null && (field.isOwner(player.getName()) || type == MaskType.MEMBER && allowMember && field.getAllAllowed().contains(player.getName()));
}
@Override
- public FaweMask getMask(final FawePlayer fp, MaskType type) {
- final Player player = fp.parent;
+ public FaweMask getMask(FawePlayer fp, MaskType type) {
+ final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Location location = player.getLocation();
final List fields = PreciousStones.API().getFieldsProtectingArea(FieldFlag.ALL, location);
if (fields.isEmpty()) {
@@ -39,14 +36,14 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener
}
String name = player.getName();
boolean member = fp.hasPermission("fawe.preciousstones.member");
- for (final Field myField : fields) {
+ for (Field myField : fields) {
if (isAllowed(player, myField, type, member)) {
BlockVector3 pos1 = BlockVector3.at(myField.getMinx(), myField.getMiny(), myField.getMinz());
BlockVector3 pos2 = BlockVector3.at(myField.getMaxx(), myField.getMaxy(), myField.getMaxz());
return new FaweMask(pos1, pos2) {
@Override
public boolean isValid(FawePlayer player, MaskType type) {
- return isAllowed((Player) player.parent, myField, type, fp.hasPermission("fawe.preciousstones.member"));
+ return isAllowed((Player) BukkitAdapter.adapt(player.toWorldEditPlayer()), myField, type, fp.hasPermission("fawe.preciousstones.member"));
}
};
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java
index 398be6d63..3217ab4e1 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java
@@ -29,7 +29,7 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
@Override
public FaweMask getMask(final FawePlayer fp, final MaskType type) {
- final Player player = fp.parent;
+ final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Location location = player.getLocation();
ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location);
if (residence != null) {
@@ -42,10 +42,10 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
final Location pos1 = area.getLowLoc();
final Location pos2 = area.getHighLoc();
final ClaimedResidence finalResidence = residence;
- return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) {
+ return new FaweMask(BukkitAdapter.asBlockVector(pos1), BukkitAdapter.asBlockVector(pos2)) {
@Override
public boolean isValid(FawePlayer player, MaskType type) {
- return isAllowed((Player) player.parent, finalResidence, type);
+ return isAllowed((Player) BukkitAdapter.adapt(player.toWorldEditPlayer()), finalResidence, type);
}
};
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java
index 06a4476d1..f7cc9dc27 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java
@@ -1,12 +1,17 @@
package com.boydti.fawe.bukkit.regions;
-import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
-import com.palmergames.bukkit.towny.object.*;
+import com.palmergames.bukkit.towny.object.PlayerCache;
+import com.palmergames.bukkit.towny.object.Resident;
+import com.palmergames.bukkit.towny.object.Town;
+import com.palmergames.bukkit.towny.object.TownBlock;
+import com.palmergames.bukkit.towny.object.TownyUniverse;
+import com.palmergames.bukkit.towny.object.WorldCoord;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldedit.math.BlockVector3;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -14,13 +19,12 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
public class TownyFeature extends BukkitMaskManager implements Listener {
- FaweBukkit plugin;
- Plugin towny;
- public TownyFeature(final Plugin townyPlugin, final FaweBukkit p3) {
+ private Plugin towny;
+
+ public TownyFeature(Plugin townyPlugin) {
super(townyPlugin.getName());
this.towny = townyPlugin;
- this.plugin = p3;
}
public boolean isAllowed(Player player, TownBlock block) {
@@ -30,16 +34,19 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
Resident resident;
try {
resident = TownyUniverse.getDataSource().getResident(player.getName());
- try {
- if (block.getResident().equals(resident)) {
- return true;
+ try {
+ if (block.getResident().equals(resident)) {
+ return true;
+ }
+ } catch (NotRegisteredException ignore) {
}
- } catch (NotRegisteredException ignore) {}
Town town = block.getTown();
if (town.isMayor(resident)) {
return true;
}
- if (!town.hasResident(resident)) return false;
+ if (!town.hasResident(resident)) {
+ return false;
+ }
if (player.hasPermission("fawe.towny.*")) {
return true;
}
@@ -55,8 +62,8 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
}
@Override
- public FaweMask getMask(final FawePlayer fp) {
- final Player player = fp.parent;
+ public FaweMask getMask(FawePlayer fp) {
+ final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Location location = player.getLocation();
try {
final PlayerCache cache = ((Towny) this.towny).getCache(player);
@@ -71,18 +78,23 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
boolean isMember = isAllowed(player, myplot);
if (isMember) {
final Chunk chunk = location.getChunk();
- final Location pos1 = new Location(location.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16);
- final Location pos2 = new Location(location.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
- return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) {
+ final BlockVector3 pos1 = BlockVector3
+ .at(chunk.getX() * 16, 0, chunk.getZ() * 16);
+ final BlockVector3 pos2 = BlockVector3.at(
+ chunk.getX() * 16 + 15, 156, chunk.getZ() * 16
+ + 15);
+ return new FaweMask(pos1, pos2) {
@Override
public boolean isValid(FawePlayer player, MaskType type) {
- return isAllowed((Player) player.parent, myplot);
+ return isAllowed(BukkitAdapter.adapt(player.toWorldEditPlayer()),
+ myplot);
}
};
}
}
}
- } catch (final Exception e) {}
+ } catch (Exception ignored) {
+ }
return null;
}
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java
index 887c47a01..f9125bc0e 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java
@@ -1,6 +1,5 @@
package com.boydti.fawe.bukkit.regions;
-import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.bukkit.filter.WorldGuardFilter;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper;
@@ -30,7 +29,6 @@ import org.bukkit.plugin.Plugin;
public class Worldguard extends BukkitMaskManager implements Listener {
private WorldGuardPlugin worldguard;
- FaweBukkit plugin;
private WorldGuardPlugin getWorldGuard() {
final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard");
@@ -43,13 +41,12 @@ public class Worldguard extends BukkitMaskManager implements Listener {
return (WorldGuardPlugin) plugin;
}
- public Worldguard(final Plugin p2, final FaweBukkit p3) {
+ public Worldguard(Plugin p2) {
super(p2.getName());
this.worldguard = this.getWorldGuard();
- this.plugin = p3;
}
- public ProtectedRegion getRegion(final LocalPlayer player, final Location location) {
+ public ProtectedRegion getRegion(LocalPlayer player, Location location) {
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
if (container == null) {
System.out.println("Region capability is not enabled for WorldGuard.");
@@ -65,7 +62,7 @@ public class Worldguard extends BukkitMaskManager implements Listener {
return global;
}
final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(location.getX(), location.getY(), location.getZ()));
- for (final ProtectedRegion region : regions) {
+ for (ProtectedRegion region : regions) {
if (isAllowed(player, region)) {
return region;
}
@@ -86,43 +83,42 @@ public class Worldguard extends BukkitMaskManager implements Listener {
if (localplayer.hasPermission("fawe.worldguard.member")) {
if (region.isMember(localplayer) || region.isMember(localplayer.getName())) {
return true;
- } else if (region.isMember("*")) {
- return true;
- }
+ } else
+ return region.isMember("*");
}
return false;
}
@Override
public FaweMask getMask(FawePlayer fp, MaskType type) {
- final Player player = fp.parent;
+ final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
final Location location = player.getLocation();
final ProtectedRegion myregion = this.getRegion(localplayer, location);
if (myregion != null) {
- final Location pos1;
- final Location pos2;
+ final BlockVector3 pos1;
+ final BlockVector3 pos2;
if (myregion.getId().equals("__global__")) {
- pos1 = new Location(location.getWorld(), Integer.MIN_VALUE, 0, Integer.MIN_VALUE);
- pos2 = new Location(location.getWorld(), Integer.MAX_VALUE, 255, Integer.MAX_VALUE);
+ pos1 = BlockVector3.at(Integer.MIN_VALUE, 0, Integer.MIN_VALUE);
+ pos2 = BlockVector3.at(Integer.MAX_VALUE, 255, Integer.MAX_VALUE);
} else {
if (myregion instanceof ProtectedCuboidRegion) {
- pos1 = new Location(location.getWorld(), myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ());
- pos2 = new Location(location.getWorld(), myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ());
+ pos1 = BlockVector3.at(myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ());
+ pos2 = BlockVector3.at(myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ());
} else {
return new FaweMask(adapt(myregion)) {
@Override
public boolean isValid(FawePlayer player, MaskType type) {
- return isAllowed(worldguard.wrapPlayer((Player) player.parent), myregion);
+ return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player.toWorldEditPlayer())), myregion);
}
};
}
}
- return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) {
+ return new FaweMask(pos1, pos2) {
@Override
public boolean isValid(FawePlayer player, MaskType type) {
- return isAllowed(worldguard.wrapPlayer((Player) player.parent), myregion);
+ return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player.toWorldEditPlayer())), myregion);
}
};
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java
index 4e5d5e7ed..7992f769f 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java
@@ -1,10 +1,10 @@
package com.boydti.fawe.bukkit.regions;
-import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.bukkit.filter.WorldGuardFilter;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.general.RegionFilter;
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.AbstractRegion;
import com.sk89q.worldguard.LocalPlayer;
@@ -12,29 +12,29 @@ import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.managers.RegionManager;
-import com.sk89q.worldguard.protection.regions.*;
+import com.sk89q.worldguard.protection.regions.ProtectedRegion;
+import com.sk89q.worldguard.protection.regions.RegionContainer;
+import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
-import java.util.Map;
-
public class WorldguardFlag extends BukkitMaskManager implements Listener {
- private WorldGuardPlugin worldguard;
- private FaweBukkit plugin;
- public WorldguardFlag(Plugin p2, FaweBukkit p3) {
+ private WorldGuardPlugin worldguard;
+
+ public WorldguardFlag(Plugin p2) {
super("worldguardflag");
this.worldguard = (WorldGuardPlugin) p2; // this.getWorldGuard();
- this.plugin = p3;
}
@Override
public FaweMask getMask(FawePlayer fp, MaskType type) {
- final Player player = fp.parent;
+ final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
- final RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
+ final RegionContainer container = WorldGuard.getInstance().getPlatform()
+ .getRegionContainer();
final RegionManager manager = container.get(fp.getWorld());
return new FaweMask(new ManagerRegion(manager, localplayer)) {
@@ -55,6 +55,7 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener {
* ManagerRegion wraps a RegionManager and will provide results based upon the regions enclosed
*/
private static class ManagerRegion extends AbstractRegion {
+
private final RegionManager manager;
private final LocalPlayer localplayer;
@@ -105,7 +106,8 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener {
@Override
public boolean contains(BlockVector3 position) {
// Make sure that all these flags are not denied. Denies override allows. WorldGuardExtraFlags can add Flags.WORLDEDIT
- return manager.getApplicableRegions(position).testState(localplayer, Flags.BUILD, Flags.BLOCK_PLACE, Flags.BLOCK_BREAK);
+ return manager.getApplicableRegions(position)
+ .testState(localplayer, Flags.BUILD, Flags.BLOCK_PLACE, Flags.BLOCK_BREAK);
}
}
diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java
new file mode 100644
index 000000000..21053ba35
--- /dev/null
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java
@@ -0,0 +1,168 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.bukkit;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor;
+import com.sk89q.worldedit.extension.platform.Locatable;
+import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.session.SessionKey;
+import com.sk89q.worldedit.util.Location;
+import com.sk89q.worldedit.util.auth.AuthorizationException;
+import com.sk89q.worldedit.util.formatting.text.Component;
+import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
+import org.bukkit.Material;
+import org.bukkit.command.BlockCommandSender;
+
+import java.util.UUID;
+
+import javax.annotation.Nullable;
+
+public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements Locatable {
+
+ private final BlockCommandSender sender;
+ private final WorldEditPlugin plugin;
+ private final Location location;
+ private final UUID uuid;
+
+ public BukkitBlockCommandSender(WorldEditPlugin plugin, BlockCommandSender sender) {
+ checkNotNull(plugin);
+ checkNotNull(sender);
+
+ this.plugin = plugin;
+ this.sender = sender;
+ this.location = BukkitAdapter.adapt(sender.getBlock().getLocation());
+ this.uuid = new UUID(location.toVector().toBlockPoint().hashCode(), location.getExtent().hashCode());
+ }
+
+ @Override
+ public String getName() {
+ return sender.getName();
+ }
+
+ @Override
+ public void printRaw(String msg) {
+ for (String part : msg.split("\n")) {
+ sender.sendMessage(part);
+ }
+ }
+
+ @Override
+ public void print(String msg) {
+ for (String part : msg.split("\n")) {
+ sender.sendMessage("\u00A7d" + part);
+ }
+ }
+
+ @Override
+ public void printDebug(String msg) {
+ for (String part : msg.split("\n")) {
+ sender.sendMessage("\u00A77" + part);
+ }
+ }
+
+ @Override
+ public void printError(String msg) {
+ for (String part : msg.split("\n")) {
+ sender.sendMessage("\u00A7c" + part);
+ }
+ }
+
+ @Override
+ public void print(Component component) {
+ TextAdapter.sendComponent(sender, component);
+ }
+
+ @Override
+ public Location getLocation() {
+ return this.location;
+ }
+
+ @Override
+ public boolean setLocation(Location location) {
+ return false;
+ }
+
+ @Override
+ public Extent getExtent() {
+ return this.location.getExtent();
+ }
+
+ @Override
+ public UUID getUniqueId() {
+ return uuid;
+ }
+
+ @Override
+ public String[] getGroups() {
+ return new String[0];
+ }
+
+ @Override
+ public void checkPermission(String permission) throws AuthorizationException {
+ if (!hasPermission(permission)) {
+ throw new AuthorizationException();
+ }
+ }
+
+ @Override
+ public boolean hasPermission(String permission) {
+ return sender.hasPermission(permission);
+ }
+
+ @Override
+ public boolean togglePermission(String permission) {
+ return true;
+ }
+
+ @Override
+ public void setPermission(String permission, boolean value) {
+
+ }
+
+ @Override
+ public SessionKey getSessionKey() {
+ return new SessionKey() {
+ @Nullable
+ @Override
+ public String getName() {
+ return sender.getName();
+ }
+
+ @Override
+ public boolean isActive() {
+ return sender.getBlock().getType() == Material.COMMAND_BLOCK
+ || sender.getBlock().getType() == Material.CHAIN_COMMAND_BLOCK
+ || sender.getBlock().getType() == Material.REPEATING_COMMAND_BLOCK;
+ }
+
+ @Override
+ public boolean isPersistent() {
+ return false;
+ }
+
+ @Override
+ public UUID getUniqueId() {
+ return uuid;
+ }
+ };
+ }
+}
diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java
index 36f7d248d..455fdc47f 100644
--- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java
@@ -22,21 +22,19 @@ package com.sk89q.worldedit.bukkit;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.extension.platform.Actor;
+import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor;
import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
+import java.io.File;
+import java.util.UUID;
+import javax.annotation.Nullable;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import java.io.File;
-import java.util.UUID;
-
-import javax.annotation.Nullable;
-
-public class BukkitCommandSender implements Actor {
+public class BukkitCommandSender extends AbstractNonPlayerActor {
/**
* One time generated ID.
@@ -149,17 +147,17 @@ public class BukkitCommandSender implements Actor {
@Nullable
@Override
public String getName() {
- return null;
+ return sender.getName();
}
@Override
public boolean isActive() {
- return false;
+ return true;
}
@Override
public boolean isPersistent() {
- return false;
+ return true;
}
@Override
diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java
index 3dee53bf9..cfcf9f44f 100644
--- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java
@@ -255,14 +255,13 @@ public class BukkitPlayer extends AbstractPlayerActor {
}
@Override
- public void floatAt(int x, int y, int z, boolean alwaysGlass) {
- if (alwaysGlass || !player.getAllowFlight()) {
- super.floatAt(x, y, z, alwaysGlass);
- return;
+ public boolean isAllowedToFly() {
+ return player.getAllowFlight();
}
- setPosition(Vector3.at(x + 0.5, y, z + 0.5));
- player.setFlying(true);
+ @Override
+ public void setFlying(boolean flying) {
+ player.setFlying(flying);
}
@Override
diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
index b22974a4f..3c4888d41 100644
--- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
@@ -45,6 +45,7 @@ import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import javax.annotation.Nullable;
import org.bukkit.Effect;
@@ -156,6 +157,10 @@ public class BukkitWorld extends AbstractWorld {
return getWorld().getName();
}
+ @Override
+ public String getId() {
+ return getWorld().getName().replace(" ", "_").toLowerCase(Locale.ROOT);
+ }
@Override
public Path getStoragePath() {
return getWorld().getWorldFolder().toPath();
diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java
index dcc606800..eb2b96707 100644
--- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java
@@ -527,6 +527,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
public Actor wrapCommandSender(CommandSender sender) {
if (sender instanceof Player) {
return wrapPlayer((Player) sender);
+ } else if (sender instanceof BlockCommandSender) {
+ return new BukkitBlockCommandSender(this, (BlockCommandSender) sender);
}
return new BukkitCommandSender(this, sender);
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java
index fe772decd..7b3795a59 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java
@@ -133,7 +133,7 @@ public class Fawe {
if (INSTANCE != null) {
INSTANCE.IMP.debug(s);
} else {
- System.out.println(BBC.stripColor(BBC.color(s)));
+ System.out.println(s);
}
}
@@ -145,10 +145,10 @@ public class Fawe {
public static void debug(Object s) {
Actor actor = Request.request().getActor();
if (actor != null && actor.isPlayer()) {
- actor.print(BBC.color(BBC.PREFIX.original() + " " + s));
+ actor.print((String)s);
return;
}
- debugPlain(BBC.PREFIX.original() + " " + s);
+ debugPlain((String) s);
}
/**
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java
index f05a1b2e5..ea890c85e 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java
@@ -16,8 +16,8 @@ public interface IDelegateQueueExtent extends IQueueExtent {
}
@Override
- default IChunk getCachedChunk(final int X, final int Z) {
- return getParent().getCachedChunk(X, Z);
+ default IChunk getCachedChunk(final int x, final int z) {
+ return getParent().getCachedChunk(x, z);
}
@Override
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java
index 66d7dcfda..1c24abddb 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java
@@ -42,15 +42,15 @@ public interface IQueueExtent extends Flushable, Trimable, Extent {
* Get the {@link WorldChunkCache}
* @return
*/
- IChunkGet getCachedGet(int X, int Z, Supplier supplier);
+ IChunkGet getCachedGet(int x, int z, Supplier supplier);
/**
* Get the IChunk at a position (and cache it if it's not already)
- * @param X
- * @param Z
+ * @param x
+ * @param z
* @return IChunk
*/
- IChunk getCachedChunk(int X, int Z);
+ IChunk getCachedChunk(int x, int z);
/**
* Submit the chunk so that it's changes are applied to the world
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java
index bde69e284..31d3eeb6c 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java
@@ -1,14 +1,12 @@
package com.boydti.fawe.beta.filters;
import com.boydti.fawe.beta.FilterBlock;
-import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.function.mask.ABlockMask;
import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -95,13 +93,13 @@ public class DistrFilter extends ForkedFilter {
}
public void print(final Actor actor, final long size) {
- for (final Countable c : getDistribution()) {
+ for (Countable c : getDistribution()) {
final String name = c.getID().toString();
final String str = String.format("%-7s (%.3f%%) %s",
String.valueOf(c.getAmount()),
c.getAmount() / (double) size * 100,
name);
- actor.print(BBC.getPrefix() + str);
+ actor.print(str);
}
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java
index 814cd1146..d8cebe622 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java
@@ -39,8 +39,8 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
}
@Override
- public IChunkGet getCachedGet(int X, int Z, Supplier supplier) {
- return cache.get(MathMan.pairInt(X, Z), supplier);
+ public IChunkGet getCachedGet(int x, int z, Supplier supplier) {
+ return cache.get(MathMan.pairInt(x, z), supplier);
}
/**
@@ -162,8 +162,8 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
}
@Override
- public final IChunk getCachedChunk(final int X, final int Z) {
- final long pair = (((long) X) << 32) | (Z & 0xffffffffL);
+ public final IChunk getCachedChunk(final int x, final int z) {
+ final long pair = (((long) x) << 32) | (z & 0xffffffffL);
if (pair == lastPair) {
return lastChunk;
}
@@ -195,7 +195,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
submissions.add(future);
}
}
- chunk = poolOrCreate(X, Z);
+ chunk = poolOrCreate(x, z);
chunk = wrap(chunk);
chunks.put(pair, chunk);
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java b/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java
index 374005175..a536d14aa 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java
@@ -4,21 +4,13 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.configuration.MemorySection;
import com.boydti.fawe.configuration.file.YamlConfiguration;
import com.boydti.fawe.object.FawePlayer;
-import com.boydti.fawe.object.RunnableVal3;
-import com.boydti.fawe.util.StringMan;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.extension.platform.Actor;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.EnumSet;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Locale;
-import java.util.Map;
-import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
@@ -28,10 +20,9 @@ public enum BBC {
* Things to note about this class:
* Can use multiple arguments %s, %s1, %s2, %s3 etc
*/
- PREFIX("(FAWE)", "Info"),
FILE_DELETED("%s0 has been deleted.", "Info"),
SCHEMATIC_PASTING("&7The schematic is pasting. This cannot be undone.", "Info"),
- LIGHTING_PROPOGATE_SELECTION("Lighting has been propogated in %s0 chunks. (Note: To remove light use //removelight)", "Info"),
+ LIGHTING_PROPAGATE_SELECTION("Lighting has been propogated in %s0 chunks. (Note: To remove light use //removelight)", "Info"),
UPDATED_LIGHTING_SELECTION("Lighting has been updated in %s0 chunks. (It may take a second for the packets to send)", "Info"),
SET_REGION("Selection set to your current allowed region", "Info"),
WORLDEDIT_COMMAND_LIMIT("Please wait until your current action completes", "Info"),
@@ -304,7 +295,7 @@ public enum BBC {
SEL_CUBOID("Cuboid: left click for point 1, right click for point 2", "Selection"),
SEL_CUBOID_EXTEND("Cuboid: left click for a starting point, right click to extend", "Selection"),
SEL_2D_POLYGON("2D polygon selector: Left/right click to add a point.", "Selection"),
- SEL_ELLIPSIOD("Ellipsoid selector: left click=center, right click to extend", "Selection"),
+ SAL_ELLIPSOID("Ellipsoid selector: left click=center, right click to extend", "Selection"),
SEL_SPHERE("Sphere selector: left click=center, right click to set radius", "Selection"),
SEL_CYLINDRICAL("Cylindrical selector: Left click=center, right click to extend.", "Selection"),
SEL_MAX("%s0 points maximum.", "Selection"),
@@ -365,16 +356,6 @@ public enum BBC {
TIP_BIOME_PATTERN("Tip: The #biome[forest] pattern can be used in any command", "Tips"),
TIP_BIOME_MASK("Tip: Restrict to a biome with the `$jungle` mask", "Tips"),;
-
- private static final HashMap replacements = new HashMap<>();
- static {
- for (char letter : "1234567890abcdefklmnor".toCharArray()) {
- replacements.put("&" + letter, "\u00a7" + letter);
- }
- replacements.put("\\\\n", "\n");
- replacements.put("\\n", "\n");
- replacements.put("&-", "\n");
- }
/**
* Translated
*/
@@ -460,7 +441,6 @@ public enum BBC {
changed = true;
yml.set(caption.category + "." + caption.name().toLowerCase(Locale.ROOT), caption.defaultMessage);
}
- caption.translatedMessage = StringMan.replaceFromMap(caption.translatedMessage, replacements);
}
if (changed) {
yml.save(file);
@@ -483,15 +463,6 @@ public enum BBC {
return toString().length();
}
- public static String color(String string) {
- return StringMan.replaceFromMap(string, replacements);
- }
-
- public static String stripColor(String string) {
-
- return StringMan.removeFromSet(string, replacements.values());
- }
-
public String s() {
return this.translatedMessage;
}
@@ -519,17 +490,13 @@ public enum BBC {
try {
Method method = actor.getClass().getMethod("print", String.class);
method.setAccessible(true);
- method.invoke(actor, (PREFIX.isEmpty() ? "" : PREFIX.s() + " ") + this.format(args));
+ method.invoke(actor, this.format(args));
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
}
}
- public static String getPrefix() {
- return PREFIX.isEmpty() ? "" : PREFIX.s() + " ";
- }
-
public void send(FawePlayer> player, Object... args) {
if (isEmpty()) {
return;
@@ -537,7 +504,7 @@ public enum BBC {
if (player == null) {
Fawe.debug(this.format(args));
} else {
- player.sendMessage((PREFIX.isEmpty() ? "" : PREFIX.s() + " ") + this.format(args));
+ player.sendMessage(this.format(args));
}
}
public void send(Actor player, Object... args) {
@@ -551,189 +518,4 @@ public enum BBC {
}
}
- public static char getCode(String name) {
- switch (name) {
- case "BLACK":
- return '0';
- case "DARK_BLUE":
- return '1';
- case "DARK_GREEN":
- return '2';
- case "DARK_AQUA":
- return '3';
- case "DARK_RED":
- return '4';
- case "DARK_PURPLE":
- return '5';
- case "GOLD":
- return '6';
- case "GRAY":
- return '7';
- case "DARK_GRAY":
- return '8';
- case "BLUE":
- return '9';
- case "GREEN":
- return 'a';
- case "AQUA":
- return 'b';
- case "RED":
- return 'c';
- case "LIGHT_PURPLE":
- return 'd';
- case "YELLOW":
- return 'e';
- case "WHITE":
- return 'f';
- case "OBFUSCATED":
- return 'k';
- case "BOLD":
- return 'l';
- case "STRIKETHROUGH":
- return 'm';
- case "UNDERLINE":
- return 'n';
- case "ITALIC":
- return 'o';
- default:
- case "RESET":
- return 'r';
- }
- }
-
- public static String getColorName(char code) {
- switch (code) {
- case '0':
- return "BLACK";
- case '1':
- return "DARK_BLUE";
- case '2':
- return "DARK_GREEN";
- case '3':
- return "DARK_AQUA";
- case '4':
- return "DARK_RED";
- case '5':
- return "DARK_PURPLE";
- case '6':
- return "GOLD";
- case '7':
- return "GRAY";
- case '8':
- return "DARK_GRAY";
- case '9':
- return "BLUE";
- case 'a':
- return "GREEN";
- case 'b':
- return "AQUA";
- case 'c':
- return "RED";
- case 'd':
- return "LIGHT_PURPLE";
- case 'e':
- return "YELLOW";
- case 'f':
- return "WHITE";
- case 'k':
- return "OBFUSCATED";
- case 'l':
- return "BOLD";
- case 'm':
- return "STRIKETHROUGH";
- case 'n':
- return "UNDERLINE";
- case 'o':
- return "ITALIC";
- case 'r':
- return "RESET";
- default:
- return "GRAY";
- }
- }
-
- private static Object[] append(StringBuilder builder, Map obj, String color, Map properties) {
- Object[] style = new Object[] { color, properties };
- for (Map.Entry entry : obj.entrySet()) {
- switch (entry.getKey()) {
- case "text":
- String text = (String) entry.getValue();
- String newColor = (String) obj.get("color");
- String newBold = (String) obj.get("bold");
- int index = builder.length();
- if (!Objects.equals(color, newColor)) {
- style[0] = newColor;
- char code = BBC.getCode(newColor.toUpperCase(Locale.ROOT));
- builder.append('\u00A7').append(code);
- }
- for (Map.Entry entry2 : obj.entrySet()) {
- if (StringMan.isEqualIgnoreCaseToAny(entry2.getKey(), "bold", "italic", "underlined", "strikethrough", "obfuscated")) {
- boolean newValue = Boolean.parseBoolean((String) entry2.getValue());
- if (properties.put(entry2.getKey(), newValue) != newValue) {
- if (newValue) {
- char code = BBC.getCode(entry2.getKey().toUpperCase(Locale.ROOT));
- builder.append('\u00A7').append(code);
- } else {
- builder.insert(index, '\u00A7').append('r');
- if (Objects.equals(color, newColor) && newColor != null) {
- builder.append('\u00A7').append(BBC.getCode(newColor.toUpperCase(Locale.ROOT)));
- }
- }
- }
- }
- }
- builder.append(text);
- break;
- case "extra":
- List
*/
-public interface Entity extends Faceted {
+public interface Entity extends Faceted, Locatable {
/**
* Get a copy of the entity's state.
@@ -48,33 +47,11 @@ public interface Entity extends Faceted {
@Nullable
BaseEntity getState();
- /**
- * Get the location of this entity.
- *
- * @return the location of the entity
- */
- Location getLocation();
-
- /**
- * Sets the location of this entity.
- *
- * @param location the new location of the entity
- * @return if the teleport worked
- */
- boolean setLocation(Location location);
-
default EntityType getType() {
BaseEntity state = getState();
return state != null ? state.getType() : null;
}
- /**
- * Get the extent that this entity is on.
- *
- * @return the extent
- */
- Extent getExtent();
-
/**
* Remove this entity from it container.
*
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java
index 3673d8842..624bdbc6b 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java
@@ -191,8 +191,12 @@ public interface Player extends Entity, Actor {
* Get the point of the block that is being stood in.
*
* @return point
+ * @deprecated Use Locatable#getBlockLocation
*/
- Location getBlockIn();
+ @Deprecated
+ default Location getBlockIn() {
+ return getBlockLocation();
+ }
/**
* Get the point of the block that is being stood upon.
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java
index b9d7990be..87eb1e579 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java
@@ -198,7 +198,7 @@ public class DefaultMaskParser extends FaweParser {
String suggestion = suggestions.get(i);
if (suggestion.indexOf(' ') != 0) {
String[] split = suggestion.split(" ");
- suggestion = BBC.color("[" + StringMan.join(split, "][") + "]");
+ suggestion = "[" + StringMan.join(split, "][") + "]";
suggestions.set(i, suggestion);
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/DefaultPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/DefaultPatternParser.java
index 738cbea35..7b027ebf9 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/DefaultPatternParser.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/DefaultPatternParser.java
@@ -161,7 +161,7 @@ public class DefaultPatternParser extends FaweParser {
String suggestion = suggestions.get(i);
if (suggestion.indexOf(' ') != 0) {
String[] split = suggestion.split(" ");
- suggestion = BBC.color("[" + StringMan.join(split, "][") + "]");
+ suggestion = "[" + StringMan.join(split, "][") + "]";
suggestions.set(i, suggestion);
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java
new file mode 100644
index 000000000..8262d0696
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java
@@ -0,0 +1,51 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.extension.platform;
+
+import com.sk89q.worldedit.internal.cui.CUIEvent;
+
+import java.io.File;
+
+public abstract class AbstractNonPlayerActor implements Actor {
+
+ @Override
+ public boolean canDestroyBedrock() {
+ return true;
+ }
+
+ @Override
+ public boolean isPlayer() {
+ return false;
+ }
+
+ @Override
+ public File openFileOpenDialog(String[] extensions) {
+ return null;
+ }
+
+ @Override
+ public File openFileSaveDialog(String[] extensions) {
+ return null;
+ }
+
+ @Override
+ public void dispatchCUIEvent(CUIEvent event) {
+ }
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java
index f8b5971b9..cc8c89cb8 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java
@@ -19,7 +19,10 @@
package com.sk89q.worldedit.extension.platform;
+import com.sk89q.worldedit.EditSession;
+import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.NotABlockException;
+import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent;
@@ -33,6 +36,7 @@ import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TargetBlock;
import com.sk89q.worldedit.util.auth.AuthorizationException;
+import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@@ -44,13 +48,13 @@ import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial;
-
import java.io.File;
import javax.annotation.Nullable;
/**
- * An abstract implementation of both a {@link Actor} and a {@link Player} that is intended for
- * implementations of WorldEdit to use to wrap players that make use of WorldEdit.
+ * An abstract implementation of both a {@link Actor} and a {@link Player}
+ * that is intended for implementations of WorldEdit to use to wrap
+ * players that make use of WorldEdit.
*/
public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@@ -151,12 +155,12 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public void findFreePosition() {
- findFreePosition(getBlockIn());
+ findFreePosition(getBlockLocation());
}
@Override
public boolean ascendLevel() {
- final Location pos = getBlockIn();
+ final Location pos = getBlockLocation();
final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY());
final int z = pos.getBlockZ();
@@ -214,7 +218,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public boolean descendLevel() {
- final Location pos = getBlockIn();
+ final Location pos = getBlockLocation();
final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY());
final int z = pos.getBlockZ();
@@ -277,7 +281,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public boolean ascendToCeiling(int clearance, boolean alwaysGlass) {
- Location pos = getBlockIn();
+ Location pos = getBlockLocation();
int x = pos.getBlockX();
int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 2);
@@ -294,6 +298,13 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial()
.isMovementBlocker()) {
int platformY = Math.max(initialY, y - 3 - clearance);
+ if (platformY < initialY) { // if ==, they already have the given clearance, if <, clearance is too large
+ printError("Not enough space above you!");
+ return false;
+ } else if (platformY == initialY) {
+ printError("You're already at the ceiling.");
+ return false;
+ }
floatAt(x, platformY + 1, z, alwaysGlass);
return true;
}
@@ -311,7 +322,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public boolean ascendUpwards(int distance, boolean alwaysGlass) {
- final Location pos = getBlockIn();
+ final Location pos = getBlockLocation();
final int x = pos.getBlockX();
final int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 1);
@@ -338,27 +349,41 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
- try {
+ if (alwaysGlass || !isAllowedToFly()) {
BlockVector3 spot = BlockVector3.at(x, y - 1, z);
- if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial()
- .isMovementBlocker()) {
- getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState());
+ final World world = getWorld();
+ if (!world.getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) {
+ try (EditSession session = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 1, this)) {
+ session.setBlock(spot, BlockTypes.GLASS.getDefaultState());
+ } catch (MaxChangedBlocksException ignored) {
}
- } catch (WorldEditException e) {
- e.printStackTrace();
+ }
+ } else {
+ setFlying(true);
}
setPosition(Vector3.at(x + 0.5, y, z + 0.5));
}
- @Override
- public Location getBlockIn() {
- return getLocation().setPosition(getLocation().toVector().floor());
+ /**
+ * Check whether the player is allowed to fly.
+ *
+ * @return true if allowed flight
+ */
+ protected boolean isAllowedToFly() {
+ return false;
+ }
+
+ /**
+ * Set whether the player is currently flying.
+ *
+ * @param flying true to fly
+ */
+ protected void setFlying(boolean flying) {
}
@Override
public Location getBlockOn() {
- return getLocation()
- .setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor());
+ return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor());
}
@Override
@@ -407,15 +432,16 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public Direction getCardinalDirection(int yawOffset) {
- if (getLocation().getPitch() > 67.5) {
+ final Location location = getLocation();
+ if (location.getPitch() > 67.5) {
return Direction.DOWN;
}
- if (getLocation().getPitch() < -67.5) {
+ if (location.getPitch() < -67.5) {
return Direction.UP;
}
// From hey0's code
- double rot = (getLocation().getYaw() + yawOffset) % 360; //let's use real yaw now
+ double rot = (location.getYaw() + yawOffset) % 360; //let's use real yaw now
if (rot < 0) {
rot += 360.0;
}
@@ -432,56 +458,66 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
}
}
+ private boolean canPassThroughBlock(Location curBlock) {
+ BlockVector3 blockPos = curBlock.toVector().toBlockPoint();
+ BlockState block = curBlock.getExtent().getBlock(blockPos);
+ return !block.getBlockType().getMaterial().isMovementBlocker();
+ }
+
/**
- * Get the player's view yaw.
- *
- * @return yaw
+ * Advances the block target block until the current block is a wall
+ * @return true if a wall is found
*/
-
- @Override
- public boolean passThroughForwardWall(int range) {
- int searchDist = 0;
- TargetBlock hitBlox = new TargetBlock(this, range, 0.2);
- Extent world = getLocation().getExtent();
- Location block;
- boolean firstBlock = true;
- int freeToFind = 2;
- boolean inFree = false;
-
- while ((block = hitBlox.getNextBlock()) != null) {
- boolean free = !world.getBlock(block.toVector().toBlockPoint()).getBlockType()
- .getMaterial().isMovementBlocker();
-
- if (firstBlock) {
- firstBlock = false;
-
- if (!free) {
- --freeToFind;
- continue;
- }
- }
-
- ++searchDist;
- if (searchDist > 20) {
- return false;
- }
-
- if (inFree != free) {
- if (free) {
- --freeToFind;
- }
- }
-
- if (freeToFind == 0) {
- setOnGround(block);
+ private boolean advanceToWall(TargetBlock hitBlox) {
+ Location curBlock;
+ while ((curBlock = hitBlox.getCurrentBlock()) != null) {
+ if (!canPassThroughBlock(curBlock)) {
return true;
}
- inFree = free;
+ hitBlox.getNextBlock();
}
return false;
}
+ /**
+ * Advances the block target block until the current block is a free
+ * @return true if a free spot is found
+ */
+ private boolean advanceToFree(TargetBlock hitBlox) {
+ Location curBlock;
+ while ((curBlock = hitBlox.getCurrentBlock()) != null) {
+ if (canPassThroughBlock(curBlock)) {
+ return true;
+ }
+
+ hitBlox.getNextBlock();
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean passThroughForwardWall(int range) {
+ TargetBlock hitBlox = new TargetBlock(this, range, 0.2);
+
+ if (!advanceToWall(hitBlox)) {
+ return false;
+ }
+
+ if (!advanceToFree(hitBlox)) {
+ return false;
+ }
+
+ Location foundBlock = hitBlox.getCurrentBlock();
+ if (foundBlock != null) {
+ setOnGround(foundBlock);
+ return true;
+ }
+
+
+ return false;
+ }
@Override
public void setPosition(Vector3 pos) {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Locatable.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Locatable.java
new file mode 100644
index 000000000..cc25ab5c7
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Locatable.java
@@ -0,0 +1,69 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.extension.platform;
+
+import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.math.Vector3;
+import com.sk89q.worldedit.util.Location;
+
+public interface Locatable {
+
+ /**
+ * Get the location of this actor.
+ *
+ * @return the location of the actor
+ */
+ Location getLocation();
+
+ /**
+ * Get the location of this actor in block coordinates.
+ *
+ * @return the block location of the actor
+ */
+ default Location getBlockLocation() {
+ Location location = getLocation();
+ return location.setPosition(location.toVector().floor());
+ }
+
+ /**
+ * Sets the location of this actor.
+ *
+ * @param location the new location of the actor
+ * @return if the teleport succeeded
+ */
+ boolean setLocation(Location location);
+
+ /**
+ * Sets the position of this actor.
+ *
+ * @param pos where to move them
+ */
+ default void setPosition(Vector3 pos) {
+ setLocation(new Location(getExtent(), pos));
+ }
+
+ /**
+ * Get the extent that this actor is in.
+ *
+ * @return the extent
+ */
+ Extent getExtent();
+
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java
index 270ddb3cd..6cdfaf54d 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java
@@ -411,11 +411,6 @@ public final class PlatformCommandManager {
GenerationCommandsRegistration.builder(),
new GenerationCommands(worldEdit)
);
- this.registration.register(
- new CFICommand(commandManager),
- CFICommandsRegistration.builder(),
- new CFICommands(worldEdit)
- );
this.registration.register(
commandManager,
HistoryCommandsRegistration.builder(),
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java
index 54ee24e23..3d77e7b6d 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java
@@ -232,7 +232,7 @@ public class BlockMaskBuilder {
private void suggest(String input, String property, Collection finalTypes) throws InputParseException {
throw new SuggestInputParseException(input + " does not have: " + property, input, () -> {
Set keys = new HashSet<>();
- finalTypes.forEach(t -> t.getProperties().stream().forEach(p -> keys.add(p.getKey())));
+ finalTypes.forEach(t -> t.getProperties().forEach(p -> keys.add(p.getKey())));
return keys.stream().map(PropertyKey::getId)
.filter(p -> StringMan.blockStateMatches(property, p))
.sorted(StringMan.blockStateComparator(property))
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java
index f71639485..8dea4f786 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java
@@ -22,20 +22,20 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe;
-import com.google.common.base.Function;
-
import com.sk89q.worldedit.math.BlockVector3;
-
-import javax.annotation.Nullable;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
+import java.util.function.Function;
+import javax.annotation.Nullable;
/**
@@ -100,7 +100,7 @@ public class MaskIntersection extends AbstractMask {
}
}
- public Function, Mask> pairingFunction() {
+ public Function, Mask> pairingFunction() {
return input -> input.getKey().tryCombine(input.getValue());
}
@@ -120,12 +120,11 @@ public class MaskIntersection extends AbstractMask {
}
if (changed) {
masks.clear();
- for (Mask mask : masksArray) masks.add(mask);
+ Collections.addAll(masks, masksArray);
}
// Optimize this
boolean formArray = false;
- for (int i = 0; i < masksArray.length; i++) {
- Mask mask = masksArray[i];
+ for (Mask mask : masksArray) {
if (mask.getClass() == this.getClass()) {
this.masks.remove(mask);
this.masks.addAll(((MaskIntersection) mask).getMasks());
@@ -162,7 +161,7 @@ public class MaskIntersection extends AbstractMask {
return changed ? this : null;
}
- private boolean combineMasks(Function, Mask> pairing, Set> failedCombines) {
+ private boolean combineMasks(Function, Mask> pairing, Set> failedCombines) {
boolean hasOptimized = false;
while (true) {
Mask[] result = null;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java
index 690f14361..6151a6c15 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java
@@ -19,16 +19,14 @@
package com.sk89q.worldedit.function.mask;
-import com.google.common.base.Function;
import com.sk89q.worldedit.math.BlockVector3;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
-
-import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
+import java.util.function.Function;
import javax.annotation.Nullable;
/**
@@ -81,7 +79,7 @@ public class MaskUnion extends MaskIntersection {
}
@Override
- public Function, Mask> pairingFunction() {
+ public Function, Mask> pairingFunction() {
return input -> input.getKey().tryOr(input.getValue());
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java
index 45a1343eb..ca1da29b5 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java
@@ -20,8 +20,10 @@
package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull;
+
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
+import javax.annotation.Nullable;
/**
* A mask that tests whether given positions are contained within a region.
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/ScanChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/ScanChunk.java
index 96ce3ca37..7e8b00667 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/ScanChunk.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/ScanChunk.java
@@ -1,17 +1,10 @@
package com.sk89q.worldedit.function.visitor;
-import com.boydti.fawe.beta.IChunk;
-import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.math.BlockVector3;
-import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongArraySet;
-import it.unimi.dsi.fastutil.objects.ObjectIterator;
-
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -24,12 +17,12 @@ public class ScanChunk {
public static final BlockVector3[] DIAGONAL_DIRECTIONS;
static {
- DEFAULT_DIRECTIONS[0] = (BlockVector3.at(0, -1, 0));
- DEFAULT_DIRECTIONS[1] = (BlockVector3.at(0, 1, 0));
- DEFAULT_DIRECTIONS[2] = (BlockVector3.at(-1, 0, 0));
- DEFAULT_DIRECTIONS[3] = (BlockVector3.at(1, 0, 0));
- DEFAULT_DIRECTIONS[4] = (BlockVector3.at(0, 0, -1));
- DEFAULT_DIRECTIONS[5] = (BlockVector3.at(0, 0, 1));
+ DEFAULT_DIRECTIONS[0] = BlockVector3.at(0, -1, 0);
+ DEFAULT_DIRECTIONS[1] = BlockVector3.at(0, 1, 0);
+ DEFAULT_DIRECTIONS[2] = BlockVector3.at(-1, 0, 0);
+ DEFAULT_DIRECTIONS[3] = BlockVector3.at(1, 0, 0);
+ DEFAULT_DIRECTIONS[4] = BlockVector3.at(0, 0, -1);
+ DEFAULT_DIRECTIONS[5] = BlockVector3.at(0, 0, 1);
List list = new ArrayList<>();
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
@@ -43,13 +36,8 @@ public class ScanChunk {
}
}
}
- Collections.sort(list, new Comparator() {
- @Override
- public int compare(BlockVector3 o1, BlockVector3 o2) {
- return (int) Math.signum(o1.lengthSq() - o2.lengthSq());
- }
- });
- DIAGONAL_DIRECTIONS = list.toArray(new BlockVector3[list.size()]);
+ list.sort((o1, o2) -> (int) Math.signum(o1.lengthSq() - o2.lengthSq()));
+ DIAGONAL_DIRECTIONS = list.toArray(new BlockVector3[0]);
}
private final RegionFunction function;
@@ -57,7 +45,7 @@ public class ScanChunk {
private final Long2ObjectOpenHashMap visits;
private final Long2ObjectOpenHashMap queues;
- public ScanChunk(final RegionFunction function) {
+ public ScanChunk(RegionFunction function) {
this.function = function;
this.directions = DEFAULT_DIRECTIONS;
@@ -65,8 +53,8 @@ public class ScanChunk {
this.visits = new Long2ObjectOpenHashMap<>();
}
- public static final long pairInt(int x, int y) {
- return (((long) x) << 32) | (y & 0xffffffffL);
+ public static long pairInt(int x, int y) {
+ return (long) x << 32 | y & 0xffffffffL;
}
public boolean isVisited(int x, int y, int z) {
@@ -180,7 +168,7 @@ public class ScanChunk {
char triple = queue[index];
int x = index & 15;
- int z = (index >> 4) & 15;
+ int z = index >> 4 & 15;
int y = index >> 8;
int absX = xx + x;
@@ -249,7 +237,7 @@ public class ScanChunk {
char triple = queue[index];
int x = index & 15;
- int z = (index >> 4) & 15;
+ int z = index >> 4 & 15;
int y = index >> 8;
}
queuePool.add(queue);
@@ -327,11 +315,11 @@ public class ScanChunk {
}
public void set(long[] bits, int i) {
- bits[i >> 6] |= (1L << (i & 0x3F));
+ bits[i >> 6] |= 1L << (i & 0x3F);
}
- public boolean get(long[] bits, final int i) {
- return (bits[i >> 6] & (1L << (i & 0x3F))) != 0;
+ public boolean get(long[] bits, int i) {
+ return (bits[i >> 6] & 1L << (i & 0x3F)) != 0;
}
public char getLocalIndex(int x, int y, int z) {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/UserCommandCompleter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/UserCommandCompleter.java
deleted file mode 100644
index a93363295..000000000
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/UserCommandCompleter.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * WorldEdit, a Minecraft world manipulation toolkit
- * Copyright (C) sk89q
- * Copyright (C) WorldEdit team and contributors
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package com.sk89q.worldedit.internal.command;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.sk89q.minecraft.util.commands.CommandException;
-import com.sk89q.minecraft.util.commands.CommandLocals;
-import com.sk89q.worldedit.extension.platform.Actor;
-import com.sk89q.worldedit.extension.platform.Capability;
-import com.sk89q.worldedit.extension.platform.MultiUserPlatform;
-import com.sk89q.worldedit.extension.platform.Platform;
-import com.sk89q.worldedit.extension.platform.PlatformManager;
-import com.sk89q.worldedit.util.command.CommandCompleter;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Provides the names of connected users as suggestions.
- */
-public class UserCommandCompleter implements CommandCompleter {
-
- private final PlatformManager platformManager;
-
- /**
- * Create a new instance.
- *
- * @param platformManager the platform manager
- */
- public UserCommandCompleter(PlatformManager platformManager) {
- checkNotNull(platformManager);
- this.platformManager = platformManager;
- }
-
- @Override
- public List getSuggestions(String arguments, CommandLocals locals) throws CommandException {
- Platform platform = platformManager.queryCapability(Capability.USER_COMMANDS);
- if (platform instanceof MultiUserPlatform) {
- List suggestions = new ArrayList<>();
- Collection users = ((MultiUserPlatform) platform).getConnectedUsers();
- for (Actor user : users) {
- if (user.getName().toLowerCase().startsWith(arguments.toLowerCase().trim())) {
- suggestions.add(user.getName());
- }
- }
- return suggestions;
- } else {
- return Collections.emptyList();
- }
- }
-
-}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/exception/WorldEditExceptionConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/exception/WorldEditExceptionConverter.java
index 94d628128..f9b68cbb6 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/exception/WorldEditExceptionConverter.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/exception/WorldEditExceptionConverter.java
@@ -20,6 +20,7 @@
package com.sk89q.worldedit.internal.command.exception;
import static com.google.common.base.Preconditions.checkNotNull;
+
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.DisallowedItemException;
import com.sk89q.worldedit.EmptyClipboardException;
@@ -40,11 +41,11 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
import com.sk89q.worldedit.util.io.file.InvalidFilenameException;
-import org.enginehub.piston.exception.CommandException;
-import org.enginehub.piston.exception.UsageException;
-
+import com.sk89q.worldedit.world.storage.MissingWorldException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.enginehub.piston.exception.CommandException;
+import org.enginehub.piston.exception.UsageException;
/**
* converts WorldEdit exceptions and converts them into {@link CommandException}s.
@@ -80,6 +81,10 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
throw newCommandException("Make a region selection first.", e);
}
+ @ExceptionMatch
+ public void convert(MissingWorldException e) throws CommandException {
+ throw newCommandException("You need to provide a world (Try //world)", e);
+ }
@ExceptionMatch
public void convert(UnknownItemException e) throws CommandException {
throw newCommandException("Block name '" + e.getID() + "' was not recognized.", e);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java
index a6e061d01..055c8e294 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java
@@ -32,6 +32,7 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.Region;
+import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.block.BlockState;
@@ -45,7 +46,7 @@ import java.nio.file.Path;
/**
* Represents a world (dimension).
*/
-public interface World extends Extent {
+public interface World extends Extent, Keyed {
/**
* Get the name of the world.