Work on CLI and I forget what else

Dieser Commit ist enthalten in:
MattBDev 2019-07-29 10:57:28 -04:00
Ursprung 8aaed49fa6
Commit ca54f8c371
92 geänderte Dateien mit 1111 neuen und 1107 gelöschten Zeilen

Datei anzeigen

@ -26,8 +26,6 @@ package com.thevoxelbox.voxelsniper;
import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.boydti.fawe.bukkit.wrapper.AsyncWorld; 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.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -41,7 +39,6 @@ public class RangeBlockHelper {
private Location playerLoc; private Location playerLoc;
private double rotX; private double rotX;
private double rotY; private double rotY;
private double viewHeight;
private double rotXSin; private double rotXSin;
private double rotXCos; private double rotXCos;
private double rotYSin; private double rotYSin;
@ -70,14 +67,14 @@ public class RangeBlockHelper {
public RangeBlockHelper(Location location, int range, double step) { public RangeBlockHelper(Location location, int range, double step) {
this.world = (AsyncWorld) location.getWorld(); 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) { public RangeBlockHelper(Player player, int range, double step) {
if (player != null) { if (player != null) {
this.world = VoxelSniper.getInstance().getSniperManager().getSniperForPlayer(player).getWorld(); 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) { public RangeBlockHelper(Player player, AsyncWorld world) {
@ -163,7 +160,6 @@ public class RangeBlockHelper {
public final AsyncBlock getFaceBlock() { public final AsyncBlock getFaceBlock() {
while(this.getNextBlock() != null && isAir(this.getCurBlock().getType())) { while(this.getNextBlock() != null && isAir(this.getCurBlock().getType())) {
;
} }
if(this.getCurBlock() != null) { if(this.getCurBlock() != null) {
@ -205,7 +201,6 @@ public class RangeBlockHelper {
this.fromOffworld(); this.fromOffworld();
while(this.getNextBlock() != null && isAir(this.getCurBlock().getType())) { while(this.getNextBlock() != null && isAir(this.getCurBlock().getType())) {
;
} }
return this.getCurBlock(); return this.getCurBlock();
@ -229,26 +224,26 @@ public class RangeBlockHelper {
AsyncBlock block = world.getBlockAt(this.targetX, this.targetY, this.targetZ); AsyncBlock block = world.getBlockAt(this.targetX, this.targetY, this.targetZ);
Material type = block.getType(); 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) { private void init(Location location, double range, double step, double viewHeight) {
this.playerLoc = location; this.playerLoc = location;
this.viewHeight = viewHeight;
this.playerX = this.playerLoc.getX(); this.playerX = this.playerLoc.getX();
this.playerY = this.playerLoc.getY() + this.viewHeight; this.playerY = this.playerLoc.getY() + viewHeight;
this.playerZ = this.playerLoc.getZ(); this.playerZ = this.playerLoc.getZ();
this.range = range; this.range = range;
this.step = step; this.step = step;
this.length = 0.0D; this.length = 0.0D;
this.rotX = (this.playerLoc.getYaw() + 90.0F) % 360.0F; 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.rotYCos = Math.cos(Math.toRadians(this.rotY));
this.rotYSin = Math.sin(Math.toRadians(this.rotY)); this.rotYSin = Math.sin(Math.toRadians(this.rotY));
this.rotXCos = Math.cos(Math.toRadians(this.rotX)); this.rotXCos = Math.cos(Math.toRadians(this.rotX));
this.rotXSin = Math.sin(Math.toRadians(this.rotX)); this.rotXSin = Math.sin(Math.toRadians(this.rotX));
this.targetX = (int)Math.floor(this.playerLoc.getX()); 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.targetZ = (int)Math.floor(this.playerLoc.getZ());
this.lastX = this.targetX; this.lastX = this.targetX;
this.lastY = this.targetY; this.lastY = this.targetY;

Datei anzeigen

@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.BukkitCommand; import com.boydti.fawe.bukkit.BukkitCommand;
import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.FaweCommand;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.thevoxelbox.voxelsniper.brush.*; import com.thevoxelbox.voxelsniper.brush.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -127,7 +128,7 @@ public class VoxelSniper extends JavaPlugin {
setupCommand("/p", new FaweCommand("voxelsniper.sniper") { setupCommand("/p", new FaweCommand("voxelsniper.sniper") {
@Override @Override
public boolean execute(FawePlayer fp, String... args) { public boolean execute(FawePlayer fp, String... args) {
Player player = (Player) fp.parent; Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
return onCommand(player, new Command("p") { return onCommand(player, new Command("p") {
@Override @Override
public boolean execute(@NotNull CommandSender sender, String commandLabel, @NotNull String[] args) { 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") { setupCommand("/d", new FaweCommand("voxelsniper.sniper") {
@Override @Override
public boolean execute(FawePlayer fp, String... args) { public boolean execute(FawePlayer fp, String... args) {
Player player = (Player) fp.parent; Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
return onCommand(player, new Command("d") { return onCommand(player, new Command("d") {
@Override @Override
public boolean execute(@NotNull CommandSender sender, String commandLabel, @NotNull String[] args) { public boolean execute(@NotNull CommandSender sender, String commandLabel, @NotNull String[] args) {

Datei anzeigen

@ -18,9 +18,8 @@ public class JaggedLineBrush extends PerformBrush {
private static final int RECURSION_DEFAULT = 3; private static final int RECURSION_DEFAULT = 3;
private static final int RECURSION_MAX = 10; private static final int RECURSION_MAX = 10;
private static final int SPREAD_DEFAULT = 3; private static final int SPREAD_DEFAULT = 3;
private static int timesUsed = 0;
private Random random = new Random(); private Random random = new Random();
private Vector originCoords = null; private Vector originCoords;
private Vector targetCoords = new Vector(); private Vector targetCoords = new Vector();
private int recursion = RECURSION_DEFAULT; private int recursion = RECURSION_DEFAULT;
private int spread = SPREAD_DEFAULT; private int spread = SPREAD_DEFAULT;
@ -29,7 +28,7 @@ public class JaggedLineBrush extends PerformBrush {
this.setName("Jagged Line"); 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 originClone = this.originCoords.clone().add(JaggedLineBrush.HALF_BLOCK_OFFSET);
final Vector targetClone = this.targetCoords.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 @Override
public final void arrow(final SnipeData v) { public final void arrow(SnipeData v) {
if (originCoords == null) { if (originCoords == null) {
originCoords = new Vector(); originCoords = new Vector();
} }
@ -60,7 +59,7 @@ public class JaggedLineBrush extends PerformBrush {
} }
@Override @Override
public final void powder(final SnipeData v) { public final void powder(SnipeData v) {
if (originCoords == null) { if (originCoords == null) {
v.sendMessage(ChatColor.RED + "Warning: You did not select a first coordinate with the arrow"); v.sendMessage(ChatColor.RED + "Warning: You did not select a first coordinate with the arrow");
} else { } else {
@ -71,15 +70,15 @@ public class JaggedLineBrush extends PerformBrush {
} }
@Override @Override
public final void info(final Message vm) { public final void info(Message vm) {
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom(ChatColor.GRAY + String.format("Recursion set to: %d", this.recursion)); vm.custom(ChatColor.GRAY + String.format("Recursion set to: %d", this.recursion));
vm.custom(ChatColor.GRAY + String.format("Spread set to: %d", this.spread)); vm.custom(ChatColor.GRAY + String.format("Spread set to: %d", this.spread));
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) { public final void parameters(String[] par, SnipeData v) {
for (final String parameter : par) { for (String parameter : par) {
try { try {
if (parameter.equalsIgnoreCase("info")) { 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."); 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; return;
} else if (parameter.startsWith("s")) { }
final int temp = Integer.parseInt(parameter.substring(1)); if (parameter.startsWith("s")) {
this.spread = temp; this.spread = Integer.parseInt(parameter.substring(1));
v.sendMessage(ChatColor.GREEN + "Spread set to: " + this.spread); v.sendMessage(ChatColor.GREEN + "Spread set to: " + this.spread);
} }
} catch (Exception exception) { } catch (Exception exception) {

Datei anzeigen

@ -8,14 +8,14 @@ import org.bukkit.ChatColor;
public class RingBrush extends PerformBrush { public class RingBrush extends PerformBrush {
private double trueCircle = 0; private double trueCircle;
private double innerSize = 0; private double innerSize;
public RingBrush() { public RingBrush() {
this.setName("Ring"); this.setName("Ring");
} }
private void ring(final SnipeData v, AsyncBlock targetBlock) { private void ring(SnipeData v, AsyncBlock targetBlock) {
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final double outerSquared = Math.pow(brushSize + this.trueCircle, 2); final double outerSquared = Math.pow(brushSize + this.trueCircle, 2);
final double innerSquared = Math.pow(this.innerSize, 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); final double xSquared = Math.pow(x, 2);
for (int z = brushSize; z >= 0; z--) { for (int z = brushSize; z >= 0; z--) {
final double ySquared = Math.pow(z, 2); 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)); 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 @Override
protected final void arrow(final SnipeData v) { protected final void arrow(SnipeData v) {
this.ring(v, this.getTargetBlock()); this.ring(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) { protected final void powder(SnipeData v) {
this.ring(v, this.getLastBlock()); this.ring(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) { public final void info(Message vm) {
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
vm.custom(ChatColor.AQUA + "The inner radius is " + ChatColor.RED + this.innerSize); vm.custom(ChatColor.AQUA + "The inner radius is " + ChatColor.RED + this.innerSize);
} }
@Override @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++) { for (int i = 1; i < par.length; i++) {
if (par[i].equalsIgnoreCase("info")) { if (par[i].equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Ring Brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Ring Brush Parameters:");
@ -69,10 +69,9 @@ public class RingBrush extends PerformBrush {
v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
} else if (par[i].startsWith("ir")) { } else if (par[i].startsWith("ir")) {
try { try {
final double d = Double.parseDouble(par[i].replace("ir", "")); this.innerSize = Double.parseDouble(par[i].replace("ir", ""));
this.innerSize = d;
v.sendMessage(ChatColor.AQUA + "The inner radius has been set to " + ChatColor.RED + this.innerSize); 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."); v.sendMessage(ChatColor.RED + "The parameters included are invalid.");
} }
} else { } else {

Datei anzeigen

@ -9,6 +9,7 @@ import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
public class ScannerBrush extends Brush { public class ScannerBrush extends Brush {
private static final int DEPTH_MIN = 1; private static final int DEPTH_MIN = 1;
private static final int DEPTH_DEFAULT = 24; private static final int DEPTH_DEFAULT = 24;
private static final int DEPTH_MAX = 64; private static final int DEPTH_MAX = 64;
@ -20,7 +21,7 @@ public class ScannerBrush extends Brush {
this.setName("Scanner"); 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) { if (value < min) {
return min; return min;
} else { } 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) { if (bf == null) {
return; return;
} }
@ -37,8 +38,10 @@ public class ScannerBrush extends Brush {
case NORTH: case NORTH:
// Scan south // Scan south
for (int i = 1; i < this.depth + 1; i++) { 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) { if (this.clampY(this.getTargetBlock().getX() + i, this.getTargetBlock().getY(),
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); this.getTargetBlock().getZ()).getType() == this.checkFor) {
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i
+ " blocks.");
return; return;
} }
} }
@ -48,8 +51,10 @@ public class ScannerBrush extends Brush {
case SOUTH: case SOUTH:
// Scan north // Scan north
for (int i = 1; i < this.depth + 1; i++) { 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) { if (this.clampY(this.getTargetBlock().getX() - i, this.getTargetBlock().getY(),
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); this.getTargetBlock().getZ()).getType() == this.checkFor) {
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i
+ " blocks.");
return; return;
} }
} }
@ -59,8 +64,10 @@ public class ScannerBrush extends Brush {
case EAST: case EAST:
// Scan west // Scan west
for (int i = 1; i < this.depth + 1; i++) { 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) { if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(),
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); this.getTargetBlock().getZ() + i).getType() == this.checkFor) {
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i
+ " blocks.");
return; return;
} }
} }
@ -70,8 +77,10 @@ public class ScannerBrush extends Brush {
case WEST: case WEST:
// Scan east // Scan east
for (int i = 1; i < this.depth + 1; i++) { 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) { if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(),
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); this.getTargetBlock().getZ() - i).getType() == this.checkFor) {
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i
+ " blocks.");
return; return;
} }
} }
@ -81,11 +90,13 @@ public class ScannerBrush extends Brush {
case UP: case UP:
// Scan down // Scan down
for (int i = 1; i < this.depth + 1; i++) { for (int i = 1; i < this.depth + 1; i++) {
if ((this.getTargetBlock().getY() - i) <= 0) { if (this.getTargetBlock().getY() - i <= 0) {
break; break;
} }
if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() - i, this.getTargetBlock().getZ()).getType() == this.checkFor) { if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() - i,
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); this.getTargetBlock().getZ()).getType() == this.checkFor) {
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i
+ " blocks.");
return; return;
} }
} }
@ -95,11 +106,13 @@ public class ScannerBrush extends Brush {
case DOWN: case DOWN:
// Scan up // Scan up
for (int i = 1; i < this.depth + 1; i++) { 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; break;
} }
if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() + i, this.getTargetBlock().getZ()).getType() == this.checkFor) { if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() + i,
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); this.getTargetBlock().getZ()).getType() == this.checkFor) {
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i
+ " blocks.");
return; return;
} }
} }
@ -113,38 +126,41 @@ public class ScannerBrush extends Brush {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected final void arrow(final SnipeData v) { protected final void arrow(SnipeData v) {
this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId())); this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId()));
this.scan(v, this.getTargetBlock().getFace(this.getLastBlock())); this.scan(v, this.getTargetBlock().getFace(this.getLastBlock()));
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected final void powder(final SnipeData v) { protected final void powder(SnipeData v) {
this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId())); this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId()));
this.scan(v, this.getTargetBlock().getFace(this.getLastBlock())); this.scan(v, this.getTargetBlock().getFace(this.getLastBlock()));
} }
@Override @Override
public final void info(final Message vm) { public final void info(Message vm) {
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom(ChatColor.GREEN + "Scanner depth set to " + this.depth); vm.custom(ChatColor.GREEN + "Scanner depth set to " + this.depth);
vm.custom(ChatColor.GREEN + "Scanner scans for " + this.checkFor + " (change with /v #)"); vm.custom(ChatColor.GREEN + "Scanner scans for " + this.checkFor + " (change with /v #)");
} }
@Override @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++) { for (int i = 1; i < par.length; i++) {
if (par[i].equalsIgnoreCase("info")) { if (par[i].equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Scanner brush Parameters:"); 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; return;
} }
if (par[i].startsWith("d")) { 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); v.sendMessage(ChatColor.AQUA + "Scanner depth set to " + this.depth);
} else { } 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.");
} }
} }
} }

Datei anzeigen

@ -1,16 +1,13 @@
package com.boydti.fawe.bukkit; package com.boydti.fawe.bukkit;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.UUID;
public class BukkitPlayer extends FawePlayer<Player> { public class BukkitPlayer extends FawePlayer<Player> {
private static ConsoleCommandSender console; private static ConsoleCommandSender console;
@ -39,26 +36,6 @@ public class BukkitPlayer extends FawePlayer<Player> {
return parent.isSneaking(); return parent.isSneaking();
} }
@Override
public void setPermission(final String perm, final boolean flag) {
/*
* Permissions are used to managing WorldEdit region restrictions
* - The `/wea` command will give/remove the required bypass permission
*/
if (Fawe.<FaweBukkit>imp().getVault() == null || Fawe.<FaweBukkit>imp().getVault().permission == null) {
this.parent.addAttachment(Fawe.<FaweBukkit>imp().getPlugin()).setPermission(perm, flag);
} else if (flag) {
if (!Fawe.<FaweBukkit>imp().getVault().permission.playerAdd(this.parent, perm)) {
this.parent.addAttachment(Fawe.<FaweBukkit>imp().getPlugin()).setPermission(perm, flag);
}
} else {
if (!Fawe.<FaweBukkit>imp().getVault().permission.playerRemove(this.parent, perm)) {
this.parent.addAttachment(Fawe.<FaweBukkit>imp().getPlugin()).setPermission(perm, flag);
}
}
}
@Override @Override
public void resetTitle() { public void resetTitle() {
parent.resetTitle(); parent.resetTitle();
@ -77,7 +54,7 @@ public class BukkitPlayer extends FawePlayer<Player> {
@Override @Override
public void sendMessage(final String message) { public void sendMessage(final String message) {
this.parent.sendMessage(BBC.color(message)); this.parent.sendMessage(message);
} }
@Override public void printError(String msg) { @Override public void printError(String msg) {

Datei anzeigen

@ -3,11 +3,9 @@ package com.boydti.fawe.bukkit;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.IFawe; import com.boydti.fawe.IFawe;
import com.boydti.fawe.beta.implementation.QueueHandler; 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.beta.BukkitQueueHandler;
import com.boydti.fawe.bukkit.listener.BrushListener; import com.boydti.fawe.bukkit.listener.BrushListener;
import com.boydti.fawe.bukkit.listener.BukkitImageListener; 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.listener.RenderListener;
import com.boydti.fawe.bukkit.regions.*; import com.boydti.fawe.bukkit.regions.*;
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils; 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.v0.ChunkListener_9;
import com.boydti.fawe.bukkit.v1_13.BukkitQueue_1_13; import com.boydti.fawe.bukkit.v1_13.BukkitQueue_1_13;
import com.boydti.fawe.bukkit.v1_14.BukkitQueue_1_14; 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.config.Settings;
import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.FaweCommand;
import com.boydti.fawe.object.FawePlayer; 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.TaskManager;
import com.boydti.fawe.util.image.ImageViewer; import com.boydti.fawe.util.image.ImageViewer;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import org.bstats.bukkit.MetricsLite; import org.bstats.bukkit.MetricsLite;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -43,11 +40,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -155,7 +150,7 @@ public class FaweBukkit implements IFawe, Listener {
fos.write(jarData); fos.write(jarData);
} }
} }
BukkitImageViewer viewer = new BukkitImageViewer((Player) fp.parent); BukkitImageViewer viewer = new BukkitImageViewer(BukkitAdapter.adapt(fp.toWorldEditPlayer()));
if (imageListener == null) { if (imageListener == null) {
this.imageListener = new BukkitImageListener(plugin); this.imageListener = new BukkitImageListener(plugin);
} }
@ -184,7 +179,7 @@ public class FaweBukkit implements IFawe, Listener {
@Override @Override
public void debug(final String message) { public void debug(final String message) {
ConsoleCommandSender console = Bukkit.getConsoleSender(); ConsoleCommandSender console = Bukkit.getConsoleSender();
console.sendMessage(BBC.color(message)); console.sendMessage(message);
} }
@Override @Override
@ -398,19 +393,19 @@ public class FaweBukkit implements IFawe, Listener {
final ArrayList<FaweMaskManager> managers = new ArrayList<>(); final ArrayList<FaweMaskManager> managers = new ArrayList<>();
if (worldguardPlugin != null && worldguardPlugin.isEnabled()) { if (worldguardPlugin != null && worldguardPlugin.isEnabled()) {
try { try {
managers.add(new Worldguard(worldguardPlugin, this)); managers.add(new Worldguard(worldguardPlugin));
managers.add(new WorldguardFlag(worldguardPlugin, this)); managers.add(new WorldguardFlag(worldguardPlugin));
Fawe.debug("Plugin 'WorldGuard' found. Using it now."); Fawe.debug("Plugin 'WorldGuard' found. Using it now.");
} catch (final Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny"); final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny");
if (townyPlugin != null && townyPlugin.isEnabled()) { if (townyPlugin != null && townyPlugin.isEnabled()) {
try { try {
managers.add(new TownyFeature(townyPlugin, this)); managers.add(new TownyFeature(townyPlugin));
Fawe.debug("Plugin 'Towny' found. Using it now."); Fawe.debug("Plugin 'Towny' found. Using it now.");
} catch (final Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -419,7 +414,7 @@ public class FaweBukkit implements IFawe, Listener {
try { try {
managers.add(new FactionsFeature(factionsPlugin)); managers.add(new FactionsFeature(factionsPlugin));
Fawe.debug("Plugin 'Factions' found. Using it now."); Fawe.debug("Plugin 'Factions' found. Using it now.");
} catch (final Throwable e) { } catch (Throwable e) {
try { try {
managers.add(new FactionsUUIDFeature(factionsPlugin, this)); managers.add(new FactionsUUIDFeature(factionsPlugin, this));
Fawe.debug("Plugin 'FactionsUUID' found. Using it now."); Fawe.debug("Plugin 'FactionsUUID' found. Using it now.");
@ -439,7 +434,7 @@ public class FaweBukkit implements IFawe, Listener {
try { try {
managers.add(new ResidenceFeature(residencePlugin, this)); managers.add(new ResidenceFeature(residencePlugin, this));
Fawe.debug("Plugin 'Residence' found. Using it now."); Fawe.debug("Plugin 'Residence' found. Using it now.");
} catch (final Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -448,7 +443,7 @@ public class FaweBukkit implements IFawe, Listener {
try { try {
managers.add(new GriefPreventionFeature(griefpreventionPlugin)); managers.add(new GriefPreventionFeature(griefpreventionPlugin));
Fawe.debug("Plugin 'GriefPrevention' found. Using it now."); Fawe.debug("Plugin 'GriefPrevention' found. Using it now.");
} catch (final Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -457,7 +452,7 @@ public class FaweBukkit implements IFawe, Listener {
try { try {
managers.add(new PreciousStonesFeature(preciousStonesPlugin, this)); managers.add(new PreciousStonesFeature(preciousStonesPlugin, this));
Fawe.debug("Plugin 'PreciousStones' found. Using it now."); Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
} catch (final Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -468,7 +463,7 @@ public class FaweBukkit implements IFawe, Listener {
try { try {
managers.add(new ASkyBlockHook(aSkyBlock)); managers.add(new ASkyBlockHook(aSkyBlock));
Fawe.debug("Plugin 'ASkyBlock' found. Using it now."); Fawe.debug("Plugin 'ASkyBlock' found. Using it now.");
} catch (final Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -476,7 +471,7 @@ public class FaweBukkit implements IFawe, Listener {
try { try {
managers.add(new FreeBuildRegion()); managers.add(new FreeBuildRegion());
Fawe.debug("Plugin '<internal.freebuild>' found. Using it now."); Fawe.debug("Plugin '<internal.freebuild>' found. Using it now.");
} catch (final Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

Datei anzeigen

@ -234,6 +234,7 @@ public class BukkitQueue extends SimpleCharQueueExtent {
return playerChunk; return playerChunk;
} }
@Override
public boolean sendChunk(final int X, final int Z, final int mask) { public boolean sendChunk(final int X, final int Z, final int mask) {
PlayerChunk playerChunk = getPlayerChunk(X, Z); PlayerChunk playerChunk = getPlayerChunk(X, Z);
if (playerChunk == null) { if (playerChunk == null) {

Datei anzeigen

@ -3,10 +3,11 @@ package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.sk89q.worldedit.bukkit.BukkitAdapter; 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.ASkyBlockAPI;
import com.wasteofplastic.askyblock.Island; import com.wasteofplastic.askyblock.Island;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -24,22 +25,21 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener {
@Override @Override
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) {
final Player player = fp.parent; final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Location location = player.getLocation(); final Location location = player.getLocation();
Island island = ASkyBlockAPI.getInstance().getIslandAt(location); Island island = ASkyBlockAPI.getInstance().getIslandAt(location);
if (island != null && isAllowed(player, island, type)) { if (island != null && isAllowed(player, island, type)) {
World world = location.getWorld(); Location center1 = island.getCenter();
Location center = island.getCenter(); MutableBlockVector3 center = MutableBlockVector3.at(center1.getX(), center1.getY(), center1.getZ());
Location pos1 = new Location(world, island.getMinProtectedX(), 0, island.getMinProtectedZ()); BlockVector3 pos1 = BlockVector3.at(island.getMinProtectedX(), 0, island.getMinProtectedZ());
Location pos2 = center.add(center.subtract(pos1)); MutableBlockVector3 pos2 = center.add(center.subtract(pos1)).mutY(255);
pos2.setY(255);
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { return new FaweMask(pos1, pos2) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(FawePlayer player, MaskType type) {
return isAllowed((Player) player.parent, island, type); return isAllowed(BukkitAdapter.adapt(player.toWorldEditPlayer()), island, type);
} }
}; };
} }

Datei anzeigen

@ -7,6 +7,7 @@ import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,7 +22,7 @@ public class FactionsFeature extends BukkitMaskManager implements Listener {
@Override @Override
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) {
final Player player = fp.parent; final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Location loc = player.getLocation(); final Location loc = player.getLocation();
final PS ps = PS.valueOf(loc); final PS ps = PS.valueOf(loc);
final Faction fac = BoardColl.get().getFactionAt(ps); final Faction fac = BoardColl.get().getFactionAt(ps);
@ -30,16 +31,17 @@ public class FactionsFeature extends BukkitMaskManager implements Listener {
MPlayer leader = fac.getLeader(); MPlayer leader = fac.getLeader();
if (leader != null && fp.getUUID().equals(leader.getUuid())) { if (leader != null && fp.getUUID().equals(leader.getUuid())) {
final Chunk chunk = loc.getChunk(); final Chunk chunk = loc.getChunk();
final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); final BlockVector3 pos1 = BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16);
final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); final BlockVector3 pos2 = BlockVector3
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); .at((chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
return new FaweMask(pos1, pos2);
} }
} else if (fac.getOnlinePlayers().contains(player)) { } else if (fac.getOnlinePlayers().contains(player)) {
if (!fac.getComparisonName().equals("wilderness")) { if (!fac.getComparisonName().equals("wilderness")) {
final Chunk chunk = loc.getChunk(); final Chunk chunk = loc.getChunk();
final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); final BlockVector3 pos1 = BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16);
final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); final BlockVector3 pos2 = BlockVector3.at((chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); return new FaweMask(pos1, pos2);
} }
} }
} }

Datei anzeigen

@ -6,16 +6,15 @@ import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.util.Permission; import com.boydti.fawe.util.Permission;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.sk89q.worldedit.bukkit.BukkitAdapter; 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.Chunk;
import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.lang.reflect.Method;
import java.util.List;
public class FactionsOneFeature extends BukkitMaskManager implements Listener { public class FactionsOneFeature extends BukkitMaskManager implements Listener {
private final Method methodGetFactionAt; private final Method methodGetFactionAt;
@ -28,7 +27,7 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener {
@Override @Override
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) {
final Player player = fp.parent; final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Chunk chunk = player.getLocation().getChunk(); final Chunk chunk = player.getLocation().getChunk();
final boolean perm = Permission final boolean perm = Permission
.hasPermission(fp.toWorldEditPlayer(), "fawe.factions.wilderness"); .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 BlockVector3 pos1 = BlockVector3.at(locs.minX << 4, 1, locs.minZ << 4);
final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4)); final BlockVector3 pos2 = BlockVector3.at(15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4));
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); return new FaweMask(pos1, pos2);
} }
return null; return null;
} }

Datei anzeigen

@ -9,6 +9,7 @@ import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -26,7 +27,7 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
@Override @Override
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) {
final Player player = fp.parent; final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Chunk chunk = player.getLocation().getChunk(); final Chunk chunk = player.getLocation().getChunk();
final boolean perm = Permission final boolean perm = Permission
.hasPermission(fp.toWorldEditPlayer(), "fawe.factions.wilderness"); .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 BlockVector3 pos1 = BlockVector3.at(locs.minX << 4, 1, locs.minZ << 4);
final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4)); final BlockVector3 pos2 = BlockVector3.at(15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4));
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); return new FaweMask(pos1,pos2);
} }
return null; return null;
} }

Datei anzeigen

@ -10,6 +10,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import jdk.nashorn.internal.ir.Block;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -20,6 +21,7 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.plugin.RegisteredListener; import org.bukkit.plugin.RegisteredListener;
import java.util.ArrayList; import java.util.ArrayList;
import org.bukkit.util.BlockVector;
public class FreeBuildRegion extends BukkitMaskManager { public class FreeBuildRegion extends BukkitMaskManager {
private final ArrayList<RegisteredListener> listeners; private final ArrayList<RegisteredListener> listeners;
@ -52,20 +54,20 @@ public class FreeBuildRegion extends BukkitMaskManager {
if (currRegList.isEmpty()) return null; if (currRegList.isEmpty()) return null;
RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[0]); RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[0]);
World bukkitWorld = player.parent.getWorld(); World bukkitWorld = BukkitAdapter.adapt(player.toWorldEditPlayer().getWorld());
AsyncWorld asyncWorld = AsyncWorld.wrap(bukkitWorld); AsyncWorld asyncWorld = AsyncWorld.wrap(bukkitWorld);
Location pos1 = BukkitAdapter.adapt(bukkitWorld, BlockVector3.ZERO); BlockVector3 pos1 = BlockVector3.ZERO;
Location pos2 = BukkitAdapter.adapt(bukkitWorld, BlockVector3.ZERO); BlockVector3 pos2 = BlockVector3.ZERO;
AsyncBlock block = new AsyncBlock(asyncWorld, new NullFaweQueue(asyncWorld.getWorldName(), BlockTypes.STONE.getDefaultState()), 0, 0, 0); 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 @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(FawePlayer player, MaskType type) {
return bukkitWorld == ((FawePlayer<Player>)player).parent.getWorld() && type == MaskType.MEMBER; return bukkitWorld == BukkitAdapter.adapt(player.toWorldEditPlayer().getWorld()) && type == MaskType.MEMBER;
} }
@Override @Override

Datei anzeigen

@ -5,10 +5,10 @@ import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.general.RegionFilter; import com.boydti.fawe.regions.general.RegionFilter;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.GriefPrevention; import me.ryanhamshire.GriefPrevention.GriefPrevention;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; 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) { 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 @Override
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) {
final Player player = fp.parent; final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Location location = player.getLocation(); final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(BukkitAdapter.adapt(fp.getLocation()), true, null);
final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, true, null);
if (claim != null) { if (claim != null) {
if (isAllowed(player, claim, type)) { if (isAllowed(player, claim, type)) {
claim.getGreaterBoundaryCorner().getBlockX(); claim.getGreaterBoundaryCorner().getBlockX();
final Location pos1 = new Location(location.getWorld(), claim.getLesserBoundaryCorner().getBlockX(), 0, claim.getLesserBoundaryCorner().getBlockZ()); final BlockVector3 pos1 = BlockVector3.at(claim.getLesserBoundaryCorner().getBlockX(), 0, claim.getLesserBoundaryCorner().getBlockZ());
final Location pos2 = new Location(location.getWorld(), claim.getGreaterBoundaryCorner().getBlockX(), 256, claim.getGreaterBoundaryCorner().getBlockZ()); final BlockVector3 pos2 = BlockVector3.at(claim.getGreaterBoundaryCorner().getBlockX(), 256, claim.getGreaterBoundaryCorner().getBlockZ());
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { return new FaweMask(pos1, pos2) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(FawePlayer fp, MaskType type) {
return isAllowed((Player) player.parent, claim, type); return isAllowed(player, claim, type);
} }
}; };
} }

Datei anzeigen

@ -3,6 +3,7 @@ package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import java.util.List; import java.util.List;
@ -15,23 +16,19 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public class PreciousStonesFeature extends BukkitMaskManager implements Listener { 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()); super(preciousstonesPlugin.getName());
this.preciousstones = preciousstonesPlugin;
this.plugin = p3;
} }
public boolean isAllowed(Player player, Field field, MaskType type, boolean allowMember) { 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 @Override
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(FawePlayer<Player> fp, MaskType type) {
final Player player = fp.parent; final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Location location = player.getLocation(); final Location location = player.getLocation();
final List<Field> fields = PreciousStones.API().getFieldsProtectingArea(FieldFlag.ALL, location); final List<Field> fields = PreciousStones.API().getFieldsProtectingArea(FieldFlag.ALL, location);
if (fields.isEmpty()) { if (fields.isEmpty()) {
@ -39,14 +36,14 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener
} }
String name = player.getName(); String name = player.getName();
boolean member = fp.hasPermission("fawe.preciousstones.member"); boolean member = fp.hasPermission("fawe.preciousstones.member");
for (final Field myField : fields) { for (Field myField : fields) {
if (isAllowed(player, myField, type, member)) { if (isAllowed(player, myField, type, member)) {
BlockVector3 pos1 = BlockVector3.at(myField.getMinx(), myField.getMiny(), myField.getMinz()); BlockVector3 pos1 = BlockVector3.at(myField.getMinx(), myField.getMiny(), myField.getMinz());
BlockVector3 pos2 = BlockVector3.at(myField.getMaxx(), myField.getMaxy(), myField.getMaxz()); BlockVector3 pos2 = BlockVector3.at(myField.getMaxx(), myField.getMaxy(), myField.getMaxz());
return new FaweMask(pos1, pos2) { return new FaweMask(pos1, pos2) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { 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"));
} }
}; };
} }

Datei anzeigen

@ -29,7 +29,7 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
@Override @Override
public FaweMask getMask(final FawePlayer<Player> fp, final MaskType type) { public FaweMask getMask(final FawePlayer<Player> fp, final MaskType type) {
final Player player = fp.parent; final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Location location = player.getLocation(); final Location location = player.getLocation();
ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location); ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location);
if (residence != null) { if (residence != null) {
@ -42,10 +42,10 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
final Location pos1 = area.getLowLoc(); final Location pos1 = area.getLowLoc();
final Location pos2 = area.getHighLoc(); final Location pos2 = area.getHighLoc();
final ClaimedResidence finalResidence = residence; 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 @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(FawePlayer player, MaskType type) {
return isAllowed((Player) player.parent, finalResidence, type); return isAllowed((Player) BukkitAdapter.adapt(player.toWorldEditPlayer()), finalResidence, type);
} }
}; };
} }

Datei anzeigen

@ -1,12 +1,17 @@
package com.boydti.fawe.bukkit.regions; package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.palmergames.bukkit.towny.Towny; import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; 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.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -14,13 +19,12 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public class TownyFeature extends BukkitMaskManager implements Listener { 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()); super(townyPlugin.getName());
this.towny = townyPlugin; this.towny = townyPlugin;
this.plugin = p3;
} }
public boolean isAllowed(Player player, TownBlock block) { public boolean isAllowed(Player player, TownBlock block) {
@ -30,16 +34,19 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
Resident resident; Resident resident;
try { try {
resident = TownyUniverse.getDataSource().getResident(player.getName()); resident = TownyUniverse.getDataSource().getResident(player.getName());
try { try {
if (block.getResident().equals(resident)) { if (block.getResident().equals(resident)) {
return true; return true;
}
} catch (NotRegisteredException ignore) {
} }
} catch (NotRegisteredException ignore) {}
Town town = block.getTown(); Town town = block.getTown();
if (town.isMayor(resident)) { if (town.isMayor(resident)) {
return true; return true;
} }
if (!town.hasResident(resident)) return false; if (!town.hasResident(resident)) {
return false;
}
if (player.hasPermission("fawe.towny.*")) { if (player.hasPermission("fawe.towny.*")) {
return true; return true;
} }
@ -55,8 +62,8 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
} }
@Override @Override
public FaweMask getMask(final FawePlayer<Player> fp) { public FaweMask getMask(FawePlayer<Player> fp) {
final Player player = fp.parent; final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final Location location = player.getLocation(); final Location location = player.getLocation();
try { try {
final PlayerCache cache = ((Towny) this.towny).getCache(player); final PlayerCache cache = ((Towny) this.towny).getCache(player);
@ -71,18 +78,23 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
boolean isMember = isAllowed(player, myplot); boolean isMember = isAllowed(player, myplot);
if (isMember) { if (isMember) {
final Chunk chunk = location.getChunk(); final Chunk chunk = location.getChunk();
final Location pos1 = new Location(location.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); final BlockVector3 pos1 = BlockVector3
final Location pos2 = new Location(location.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); .at(chunk.getX() * 16, 0, chunk.getZ() * 16);
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { final BlockVector3 pos2 = BlockVector3.at(
chunk.getX() * 16 + 15, 156, chunk.getZ() * 16
+ 15);
return new FaweMask(pos1, pos2) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { 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; return null;
} }
} }

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.bukkit.regions; package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.bukkit.filter.WorldGuardFilter; import com.boydti.fawe.bukkit.filter.WorldGuardFilter;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
@ -30,7 +29,6 @@ import org.bukkit.plugin.Plugin;
public class Worldguard extends BukkitMaskManager implements Listener { public class Worldguard extends BukkitMaskManager implements Listener {
private WorldGuardPlugin worldguard; private WorldGuardPlugin worldguard;
FaweBukkit plugin;
private WorldGuardPlugin getWorldGuard() { private WorldGuardPlugin getWorldGuard() {
final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard"); final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard");
@ -43,13 +41,12 @@ public class Worldguard extends BukkitMaskManager implements Listener {
return (WorldGuardPlugin) plugin; return (WorldGuardPlugin) plugin;
} }
public Worldguard(final Plugin p2, final FaweBukkit p3) { public Worldguard(Plugin p2) {
super(p2.getName()); super(p2.getName());
this.worldguard = this.getWorldGuard(); 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(); RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
if (container == null) { if (container == null) {
System.out.println("Region capability is not enabled for WorldGuard."); System.out.println("Region capability is not enabled for WorldGuard.");
@ -65,7 +62,7 @@ public class Worldguard extends BukkitMaskManager implements Listener {
return global; return global;
} }
final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(location.getX(), location.getY(), location.getZ())); 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)) { if (isAllowed(player, region)) {
return region; return region;
} }
@ -86,43 +83,42 @@ public class Worldguard extends BukkitMaskManager implements Listener {
if (localplayer.hasPermission("fawe.worldguard.member")) { if (localplayer.hasPermission("fawe.worldguard.member")) {
if (region.isMember(localplayer) || region.isMember(localplayer.getName())) { if (region.isMember(localplayer) || region.isMember(localplayer.getName())) {
return true; return true;
} else if (region.isMember("*")) { } else
return true; return region.isMember("*");
}
} }
return false; return false;
} }
@Override @Override
public FaweMask getMask(FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(FawePlayer<Player> fp, MaskType type) {
final Player player = fp.parent; final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final LocalPlayer localplayer = this.worldguard.wrapPlayer(player); final LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
final Location location = player.getLocation(); final Location location = player.getLocation();
final ProtectedRegion myregion = this.getRegion(localplayer, location); final ProtectedRegion myregion = this.getRegion(localplayer, location);
if (myregion != null) { if (myregion != null) {
final Location pos1; final BlockVector3 pos1;
final Location pos2; final BlockVector3 pos2;
if (myregion.getId().equals("__global__")) { if (myregion.getId().equals("__global__")) {
pos1 = new Location(location.getWorld(), Integer.MIN_VALUE, 0, Integer.MIN_VALUE); pos1 = BlockVector3.at(Integer.MIN_VALUE, 0, Integer.MIN_VALUE);
pos2 = new Location(location.getWorld(), Integer.MAX_VALUE, 255, Integer.MAX_VALUE); pos2 = BlockVector3.at(Integer.MAX_VALUE, 255, Integer.MAX_VALUE);
} else { } else {
if (myregion instanceof ProtectedCuboidRegion) { if (myregion instanceof ProtectedCuboidRegion) {
pos1 = new Location(location.getWorld(), myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ()); pos1 = BlockVector3.at(myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ());
pos2 = new Location(location.getWorld(), myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ()); pos2 = BlockVector3.at(myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ());
} else { } else {
return new FaweMask(adapt(myregion)) { return new FaweMask(adapt(myregion)) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { 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 @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(FawePlayer player, MaskType type) {
return isAllowed(worldguard.wrapPlayer((Player) player.parent), myregion); return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player.toWorldEditPlayer())), myregion);
} }
}; };
} }

Datei anzeigen

@ -1,10 +1,10 @@
package com.boydti.fawe.bukkit.regions; package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.bukkit.filter.WorldGuardFilter; import com.boydti.fawe.bukkit.filter.WorldGuardFilter;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.general.RegionFilter; import com.boydti.fawe.regions.general.RegionFilter;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.AbstractRegion;
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
@ -12,29 +12,29 @@ import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flags; import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.managers.RegionManager; 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.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.util.Map;
public class WorldguardFlag extends BukkitMaskManager implements Listener { 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"); super("worldguardflag");
this.worldguard = (WorldGuardPlugin) p2; // this.getWorldGuard(); this.worldguard = (WorldGuardPlugin) p2; // this.getWorldGuard();
this.plugin = p3;
} }
@Override @Override
public FaweMask getMask(FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(FawePlayer<Player> fp, MaskType type) {
final Player player = fp.parent; final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer());
final LocalPlayer localplayer = this.worldguard.wrapPlayer(player); final 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()); final RegionManager manager = container.get(fp.getWorld());
return new FaweMask(new ManagerRegion(manager, localplayer)) { 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 * ManagerRegion wraps a RegionManager and will provide results based upon the regions enclosed
*/ */
private static class ManagerRegion extends AbstractRegion { private static class ManagerRegion extends AbstractRegion {
private final RegionManager manager; private final RegionManager manager;
private final LocalPlayer localplayer; private final LocalPlayer localplayer;
@ -105,7 +106,8 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener {
@Override @Override
public boolean contains(BlockVector3 position) { public boolean contains(BlockVector3 position) {
// Make sure that all these flags are not denied. Denies override allows. WorldGuardExtraFlags can add Flags.WORLDEDIT // 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);
} }
} }

Datei anzeigen

@ -0,0 +1,168 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.bukkit;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor;
import com.sk89q.worldedit.extension.platform.Locatable;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import org.bukkit.Material;
import org.bukkit.command.BlockCommandSender;
import java.util.UUID;
import javax.annotation.Nullable;
public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements Locatable {
private final BlockCommandSender sender;
private final WorldEditPlugin plugin;
private final Location location;
private final UUID uuid;
public BukkitBlockCommandSender(WorldEditPlugin plugin, BlockCommandSender sender) {
checkNotNull(plugin);
checkNotNull(sender);
this.plugin = plugin;
this.sender = sender;
this.location = BukkitAdapter.adapt(sender.getBlock().getLocation());
this.uuid = new UUID(location.toVector().toBlockPoint().hashCode(), location.getExtent().hashCode());
}
@Override
public String getName() {
return sender.getName();
}
@Override
public void printRaw(String msg) {
for (String part : msg.split("\n")) {
sender.sendMessage(part);
}
}
@Override
public void print(String msg) {
for (String part : msg.split("\n")) {
sender.sendMessage("\u00A7d" + part);
}
}
@Override
public void printDebug(String msg) {
for (String part : msg.split("\n")) {
sender.sendMessage("\u00A77" + part);
}
}
@Override
public void printError(String msg) {
for (String part : msg.split("\n")) {
sender.sendMessage("\u00A7c" + part);
}
}
@Override
public void print(Component component) {
TextAdapter.sendComponent(sender, component);
}
@Override
public Location getLocation() {
return this.location;
}
@Override
public boolean setLocation(Location location) {
return false;
}
@Override
public Extent getExtent() {
return this.location.getExtent();
}
@Override
public UUID getUniqueId() {
return uuid;
}
@Override
public String[] getGroups() {
return new String[0];
}
@Override
public void checkPermission(String permission) throws AuthorizationException {
if (!hasPermission(permission)) {
throw new AuthorizationException();
}
}
@Override
public boolean hasPermission(String permission) {
return sender.hasPermission(permission);
}
@Override
public boolean togglePermission(String permission) {
return true;
}
@Override
public void setPermission(String permission, boolean value) {
}
@Override
public SessionKey getSessionKey() {
return new SessionKey() {
@Nullable
@Override
public String getName() {
return sender.getName();
}
@Override
public boolean isActive() {
return sender.getBlock().getType() == Material.COMMAND_BLOCK
|| sender.getBlock().getType() == Material.CHAIN_COMMAND_BLOCK
|| sender.getBlock().getType() == Material.REPEATING_COMMAND_BLOCK;
}
@Override
public boolean isPersistent() {
return false;
}
@Override
public UUID getUniqueId() {
return uuid;
}
};
}
}

Datei anzeigen

@ -22,21 +22,19 @@ package com.sk89q.worldedit.bukkit;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; 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.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.auth.AuthorizationException; import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter; 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.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.File; public class BukkitCommandSender extends AbstractNonPlayerActor {
import java.util.UUID;
import javax.annotation.Nullable;
public class BukkitCommandSender implements Actor {
/** /**
* One time generated ID. * One time generated ID.
@ -149,17 +147,17 @@ public class BukkitCommandSender implements Actor {
@Nullable @Nullable
@Override @Override
public String getName() { public String getName() {
return null; return sender.getName();
} }
@Override @Override
public boolean isActive() { public boolean isActive() {
return false; return true;
} }
@Override @Override
public boolean isPersistent() { public boolean isPersistent() {
return false; return true;
} }
@Override @Override

Datei anzeigen

@ -255,14 +255,13 @@ public class BukkitPlayer extends AbstractPlayerActor {
} }
@Override @Override
public void floatAt(int x, int y, int z, boolean alwaysGlass) { public boolean isAllowedToFly() {
if (alwaysGlass || !player.getAllowFlight()) { return player.getAllowFlight();
super.floatAt(x, y, z, alwaysGlass);
return;
} }
setPosition(Vector3.at(x + 0.5, y, z + 0.5)); @Override
player.setFlying(true); public void setFlying(boolean flying) {
player.setFlying(flying);
} }
@Override @Override

Datei anzeigen

@ -45,6 +45,7 @@ import java.util.ArrayList;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.bukkit.Effect; import org.bukkit.Effect;
@ -156,6 +157,10 @@ public class BukkitWorld extends AbstractWorld {
return getWorld().getName(); return getWorld().getName();
} }
@Override
public String getId() {
return getWorld().getName().replace(" ", "_").toLowerCase(Locale.ROOT);
}
@Override @Override
public Path getStoragePath() { public Path getStoragePath() {
return getWorld().getWorldFolder().toPath(); return getWorld().getWorldFolder().toPath();

Datei anzeigen

@ -527,6 +527,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
public Actor wrapCommandSender(CommandSender sender) { public Actor wrapCommandSender(CommandSender sender) {
if (sender instanceof Player) { if (sender instanceof Player) {
return wrapPlayer((Player) sender); return wrapPlayer((Player) sender);
} else if (sender instanceof BlockCommandSender) {
return new BukkitBlockCommandSender(this, (BlockCommandSender) sender);
} }
return new BukkitCommandSender(this, sender); return new BukkitCommandSender(this, sender);

Datei anzeigen

@ -133,7 +133,7 @@ public class Fawe {
if (INSTANCE != null) { if (INSTANCE != null) {
INSTANCE.IMP.debug(s); INSTANCE.IMP.debug(s);
} else { } 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) { public static void debug(Object s) {
Actor actor = Request.request().getActor(); Actor actor = Request.request().getActor();
if (actor != null && actor.isPlayer()) { if (actor != null && actor.isPlayer()) {
actor.print(BBC.color(BBC.PREFIX.original() + " " + s)); actor.print((String)s);
return; return;
} }
debugPlain(BBC.PREFIX.original() + " " + s); debugPlain((String) s);
} }
/** /**

Datei anzeigen

@ -16,8 +16,8 @@ public interface IDelegateQueueExtent extends IQueueExtent {
} }
@Override @Override
default IChunk getCachedChunk(final int X, final int Z) { default IChunk getCachedChunk(final int x, final int z) {
return getParent().getCachedChunk(X, Z); return getParent().getCachedChunk(x, z);
} }
@Override @Override

Datei anzeigen

@ -42,15 +42,15 @@ public interface IQueueExtent extends Flushable, Trimable, Extent {
* Get the {@link WorldChunkCache} * Get the {@link WorldChunkCache}
* @return * @return
*/ */
IChunkGet getCachedGet(int X, int Z, Supplier<IChunkGet> supplier); IChunkGet getCachedGet(int x, int z, Supplier<IChunkGet> supplier);
/** /**
* Get the IChunk at a position (and cache it if it's not already) * Get the IChunk at a position (and cache it if it's not already)
* @param X * @param x
* @param Z * @param z
* @return IChunk * @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 * Submit the chunk so that it's changes are applied to the world

Datei anzeigen

@ -1,14 +1,12 @@
package com.boydti.fawe.beta.filters; package com.boydti.fawe.beta.filters;
import com.boydti.fawe.beta.FilterBlock; import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.function.mask.ABlockMask; import com.sk89q.worldedit.function.mask.ABlockMask;
import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -95,13 +93,13 @@ public class DistrFilter extends ForkedFilter<DistrFilter> {
} }
public void print(final Actor actor, final long size) { 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 name = c.getID().toString();
final String str = String.format("%-7s (%.3f%%) %s", final String str = String.format("%-7s (%.3f%%) %s",
String.valueOf(c.getAmount()), String.valueOf(c.getAmount()),
c.getAmount() / (double) size * 100, c.getAmount() / (double) size * 100,
name); name);
actor.print(BBC.getPrefix() + str); actor.print(str);
} }
} }
} }

Datei anzeigen

@ -39,8 +39,8 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
} }
@Override @Override
public IChunkGet getCachedGet(int X, int Z, Supplier<IChunkGet> supplier) { public IChunkGet getCachedGet(int x, int z, Supplier<IChunkGet> supplier) {
return cache.get(MathMan.pairInt(X, Z), supplier); return cache.get(MathMan.pairInt(x, z), supplier);
} }
/** /**
@ -162,8 +162,8 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
} }
@Override @Override
public final IChunk getCachedChunk(final int X, final int Z) { public final IChunk getCachedChunk(final int x, final int z) {
final long pair = (((long) X) << 32) | (Z & 0xffffffffL); final long pair = (((long) x) << 32) | (z & 0xffffffffL);
if (pair == lastPair) { if (pair == lastPair) {
return lastChunk; return lastChunk;
} }
@ -195,7 +195,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
submissions.add(future); submissions.add(future);
} }
} }
chunk = poolOrCreate(X, Z); chunk = poolOrCreate(x, z);
chunk = wrap(chunk); chunk = wrap(chunk);
chunks.put(pair, chunk); chunks.put(pair, chunk);

Datei anzeigen

@ -4,21 +4,13 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.configuration.MemorySection; import com.boydti.fawe.configuration.MemorySection;
import com.boydti.fawe.configuration.file.YamlConfiguration; import com.boydti.fawe.configuration.file.YamlConfiguration;
import com.boydti.fawe.object.FawePlayer; 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 com.sk89q.worldedit.extension.platform.Actor;
import java.io.File; import java.io.File;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -28,10 +20,9 @@ public enum BBC {
* Things to note about this class: * Things to note about this class:
* Can use multiple arguments %s, %s1, %s2, %s3 etc * Can use multiple arguments %s, %s1, %s2, %s3 etc
*/ */
PREFIX("(FAWE)", "Info"),
FILE_DELETED("%s0 has been deleted.", "Info"), FILE_DELETED("%s0 has been deleted.", "Info"),
SCHEMATIC_PASTING("&7The schematic is pasting. This cannot be undone.", "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"), 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"), SET_REGION("Selection set to your current allowed region", "Info"),
WORLDEDIT_COMMAND_LIMIT("Please wait until your current action completes", "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("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_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_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_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_CYLINDRICAL("Cylindrical selector: Left click=center, right click to extend.", "Selection"),
SEL_MAX("%s0 points maximum.", "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_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"),; TIP_BIOME_MASK("Tip: Restrict to a biome with the `$jungle` mask", "Tips"),;
private static final HashMap<String, String> replacements = new HashMap<>();
static {
for (char letter : "1234567890abcdefklmnor".toCharArray()) {
replacements.put("&" + letter, "\u00a7" + letter);
}
replacements.put("\\\\n", "\n");
replacements.put("\\n", "\n");
replacements.put("&-", "\n");
}
/** /**
* Translated * Translated
*/ */
@ -460,7 +441,6 @@ public enum BBC {
changed = true; changed = true;
yml.set(caption.category + "." + caption.name().toLowerCase(Locale.ROOT), caption.defaultMessage); yml.set(caption.category + "." + caption.name().toLowerCase(Locale.ROOT), caption.defaultMessage);
} }
caption.translatedMessage = StringMan.replaceFromMap(caption.translatedMessage, replacements);
} }
if (changed) { if (changed) {
yml.save(file); yml.save(file);
@ -483,15 +463,6 @@ public enum BBC {
return toString().length(); 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() { public String s() {
return this.translatedMessage; return this.translatedMessage;
} }
@ -519,17 +490,13 @@ public enum BBC {
try { try {
Method method = actor.getClass().getMethod("print", String.class); Method method = actor.getClass().getMethod("print", String.class);
method.setAccessible(true); method.setAccessible(true);
method.invoke(actor, (PREFIX.isEmpty() ? "" : PREFIX.s() + " ") + this.format(args)); method.invoke(actor, this.format(args));
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
public static String getPrefix() {
return PREFIX.isEmpty() ? "" : PREFIX.s() + " ";
}
public void send(FawePlayer<?> player, Object... args) { public void send(FawePlayer<?> player, Object... args) {
if (isEmpty()) { if (isEmpty()) {
return; return;
@ -537,7 +504,7 @@ public enum BBC {
if (player == null) { if (player == null) {
Fawe.debug(this.format(args)); Fawe.debug(this.format(args));
} else { } else {
player.sendMessage((PREFIX.isEmpty() ? "" : PREFIX.s() + " ") + this.format(args)); player.sendMessage(this.format(args));
} }
} }
public void send(Actor player, Object... args) { public void send(Actor player, Object... args) {
@ -551,189 +518,4 @@ public enum BBC {
} }
} }
public static char getCode(String name) {
switch (name) {
case "BLACK":
return '0';
case "DARK_BLUE":
return '1';
case "DARK_GREEN":
return '2';
case "DARK_AQUA":
return '3';
case "DARK_RED":
return '4';
case "DARK_PURPLE":
return '5';
case "GOLD":
return '6';
case "GRAY":
return '7';
case "DARK_GRAY":
return '8';
case "BLUE":
return '9';
case "GREEN":
return 'a';
case "AQUA":
return 'b';
case "RED":
return 'c';
case "LIGHT_PURPLE":
return 'd';
case "YELLOW":
return 'e';
case "WHITE":
return 'f';
case "OBFUSCATED":
return 'k';
case "BOLD":
return 'l';
case "STRIKETHROUGH":
return 'm';
case "UNDERLINE":
return 'n';
case "ITALIC":
return 'o';
default:
case "RESET":
return 'r';
}
}
public static String getColorName(char code) {
switch (code) {
case '0':
return "BLACK";
case '1':
return "DARK_BLUE";
case '2':
return "DARK_GREEN";
case '3':
return "DARK_AQUA";
case '4':
return "DARK_RED";
case '5':
return "DARK_PURPLE";
case '6':
return "GOLD";
case '7':
return "GRAY";
case '8':
return "DARK_GRAY";
case '9':
return "BLUE";
case 'a':
return "GREEN";
case 'b':
return "AQUA";
case 'c':
return "RED";
case 'd':
return "LIGHT_PURPLE";
case 'e':
return "YELLOW";
case 'f':
return "WHITE";
case 'k':
return "OBFUSCATED";
case 'l':
return "BOLD";
case 'm':
return "STRIKETHROUGH";
case 'n':
return "UNDERLINE";
case 'o':
return "ITALIC";
case 'r':
return "RESET";
default:
return "GRAY";
}
}
private static Object[] append(StringBuilder builder, Map<String, Object> obj, String color, Map<String, Boolean> properties) {
Object[] style = new Object[] { color, properties };
for (Map.Entry<String, Object> entry : obj.entrySet()) {
switch (entry.getKey()) {
case "text":
String text = (String) entry.getValue();
String newColor = (String) obj.get("color");
String newBold = (String) obj.get("bold");
int index = builder.length();
if (!Objects.equals(color, newColor)) {
style[0] = newColor;
char code = BBC.getCode(newColor.toUpperCase(Locale.ROOT));
builder.append('\u00A7').append(code);
}
for (Map.Entry<String, Object> entry2 : obj.entrySet()) {
if (StringMan.isEqualIgnoreCaseToAny(entry2.getKey(), "bold", "italic", "underlined", "strikethrough", "obfuscated")) {
boolean newValue = Boolean.parseBoolean((String) entry2.getValue());
if (properties.put(entry2.getKey(), newValue) != newValue) {
if (newValue) {
char code = BBC.getCode(entry2.getKey().toUpperCase(Locale.ROOT));
builder.append('\u00A7').append(code);
} else {
builder.insert(index, '\u00A7').append('r');
if (Objects.equals(color, newColor) && newColor != null) {
builder.append('\u00A7').append(BBC.getCode(newColor.toUpperCase(Locale.ROOT)));
}
}
}
}
}
builder.append(text);
break;
case "extra":
List<Map<String, Object>> list = (List<Map<String, Object>>) entry.getValue();
for (Map<String, Object> elem : list) {
elem.putIfAbsent("color", obj.get("color"));
for (Map.Entry<String, Object> entry2 : obj.entrySet()) {
if (StringMan.isEqualIgnoreCaseToAny(entry2.getKey(), "bold", "italic", "underlined", "strikethrough", "obfuscated")) {
elem.putIfAbsent(entry2.getKey(), entry2.getValue());
}
}
style = append(builder, elem, (String) style[0], (Map) style[1]);
}
}
}
return style;
}
public static String jsonToString(String text) {
Gson gson = new Gson();
StringBuilder builder = new StringBuilder();
Map<String, Object> obj = gson.fromJson(text, new TypeToken<Map<String, Object>>() {}.getType());
HashMap<String, Boolean> properties = new HashMap<>();
properties.put("bold", false);
properties.put("italic", false);
properties.put("underlined", false);
properties.put("strikethrough", false);
properties.put("obfuscated", false);
append(builder, obj, null, properties);
return builder.toString();
}
/**
* @param m
* @param runPart Part, Color, NewLine
*/
public static void splitMessage(String m, RunnableVal3<String, String, Boolean> runPart) {
m = color(m);
String color = "GRAY";
boolean newline = false;
for (String line : m.split("\n")) {
boolean hasColor = line.charAt(0) == '\u00A7';
String[] splitColor = line.split("\u00A7");
for (String part : splitColor) {
if (hasColor) {
color = getColorName(part.charAt(0));
part = part.substring(1);
}
runPart.run(part, color, newline);
hasColor = true;
}
newline = true;
}
}
} }

Datei anzeigen

@ -145,7 +145,7 @@ public abstract class FawePlayer<T> extends Metadatable {
return cancelled; return cancelled;
} }
private void setConfirmTask(@NotNull Runnable task, InjectedValueAccess context, String command) { private void setConfirmTask(@NotNull Runnable task, InjectedValueAccess context, @NotNull String command) {
CommandEvent event = new CommandEvent(getPlayer(), command); CommandEvent event = new CommandEvent(getPlayer(), command);
Runnable newTask = () -> PlatformCommandManager.getInstance().handleCommandTask(() -> { Runnable newTask = () -> PlatformCommandManager.getInstance().handleCommandTask(() -> {
task.run(); task.run();
@ -154,8 +154,8 @@ public abstract class FawePlayer<T> extends Metadatable {
setMeta("cmdConfirm", newTask); setMeta("cmdConfirm", newTask);
} }
public void checkConfirmation(@NotNull Runnable task, String command, int times, int limit, InjectedValueAccess context) throws RegionOperationException { public void checkConfirmation(@NotNull Runnable task, @NotNull String command, int times, int limit, InjectedValueAccess context) throws RegionOperationException {
if (command != null && !getMeta("cmdConfirmRunning", false)) { if (!getMeta("cmdConfirmRunning", false)) {
if (times > limit) { if (times > limit) {
setConfirmTask(task, context, command); setConfirmTask(task, context, command);
String volume = "<unspecified>"; String volume = "<unspecified>";
@ -181,8 +181,8 @@ public abstract class FawePlayer<T> extends Metadatable {
task.run(); task.run();
} }
public void checkConfirmationStack(@NotNull Runnable task, String command, Region region, int times, InjectedValueAccess context) throws RegionOperationException { public void checkConfirmationStack(@NotNull Runnable task, @NotNull String command, Region region, int times, InjectedValueAccess context) throws RegionOperationException {
if (command != null && !getMeta("cmdConfirmRunning", false)) { if (!getMeta("cmdConfirmRunning", false)) {
if (region != null) { if (region != null) {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
@ -199,8 +199,8 @@ public abstract class FawePlayer<T> extends Metadatable {
task.run(); task.run();
} }
public void checkConfirmationRegion(@NotNull Runnable task, String command, Region region, InjectedValueAccess context) throws RegionOperationException { public void checkConfirmationRegion(@NotNull Runnable task, @NotNull String command, Region region, InjectedValueAccess context) throws RegionOperationException {
if (command != null && !getMeta("cmdConfirmRunning", false)) { if (!getMeta("cmdConfirmRunning", false)) {
if (region != null) { if (region != null) {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
@ -576,7 +576,7 @@ public abstract class FawePlayer<T> extends Metadatable {
} }
/** /**
* Unregister this player (delets all metadata etc) * Unregister this player (deletes all metadata etc)
* - Usually called on logout * - Usually called on logout
*/ */
public void unregister() { public void unregister() {

Datei anzeigen

@ -9,7 +9,6 @@ import com.boydti.fawe.object.function.mask.AbstractDelegateMask;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
@ -21,11 +20,10 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
public class CopyPastaBrush implements Brush, ResettableTool { public class CopyPastaBrush implements Brush, ResettableTool {
@ -62,7 +60,6 @@ public class CopyPastaBrush implements Brush, ResettableTool {
mask = Masks.alwaysTrue(); mask = Masks.alwaysTrue();
} }
final ResizableClipboardBuilder builder = new ResizableClipboardBuilder(editSession.getWorld()); final ResizableClipboardBuilder builder = new ResizableClipboardBuilder(editSession.getWorld());
final int size2 = (int) (size * size);
final int minY = position.getBlockY(); final int minY = position.getBlockY();
mask = new AbstractDelegateMask(mask) { mask = new AbstractDelegateMask(mask) {
@Override @Override
@ -93,13 +90,13 @@ public class CopyPastaBrush implements Brush, ResettableTool {
} else { } else {
AffineTransform transform = null; AffineTransform transform = null;
if (randomRotate) { if (randomRotate) {
if (transform == null) transform = new AffineTransform(); transform = new AffineTransform();
int rotate = 90 * ThreadLocalRandom.current().nextInt(4); int rotate = 90 * ThreadLocalRandom.current().nextInt(4);
transform = transform.rotateY(rotate); transform = transform.rotateY(rotate);
} }
if (autoRotate) { if (autoRotate) {
if (transform == null) transform = new AffineTransform(); if (transform == null) transform = new AffineTransform();
Location loc = editSession.getPlayer().getPlayer().getLocation(); Location loc = editSession.getPlayer().toWorldEditPlayer().getLocation();
float yaw = loc.getYaw(); float yaw = loc.getYaw();
float pitch = loc.getPitch(); float pitch = loc.getPitch();
transform = transform.rotateY((-yaw) % 360); transform = transform.rotateY((-yaw) % 360);
@ -108,8 +105,6 @@ public class CopyPastaBrush implements Brush, ResettableTool {
if (transform != null && !transform.isIdentity()) { if (transform != null && !transform.isIdentity()) {
clipboard.setTransform(transform); clipboard.setTransform(transform);
} }
Clipboard faweClip = clipboard.getClipboard();
Region region = faweClip.getRegion();
Operation operation = clipboard Operation operation = clipboard
.createPaste(editSession) .createPaste(editSession)

Datei anzeigen

@ -15,8 +15,6 @@ public class FallingSphere implements Brush {
int pz = position.getBlockZ(); int pz = position.getBlockZ();
int maxY = editSession.getMaxY(); int maxY = editSession.getMaxY();
int lastY = py;
int radius = (int) Math.round(size); int radius = (int) Math.round(size);
int radiusSqr = (int) Math.round(size * size); int radiusSqr = (int) Math.round(size * size);
for (int z = -radius; z <= radius; z++) { for (int z = -radius; z <= radius; z++) {

Datei anzeigen

@ -60,12 +60,11 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
public boolean perform(final Player player, LocalSession session, boolean rightClick) { public boolean perform(final Player player, LocalSession session, boolean rightClick) {
if (!session.isToolControlEnabled() || !player.hasPermission("worldedit.tool.inspect")) { if (!session.isToolControlEnabled() || !player.hasPermission("worldedit.tool.inspect")) {
player.print(BBC.getPrefix() + BBC.NO_PERM.format("worldedit.tool.inspect")); player.print(BBC.NO_PERM.format("worldedit.tool.inspect"));
return false; return false;
} }
if (!Settings.IMP.HISTORY.USE_DATABASE) { if (!Settings.IMP.HISTORY.USE_DATABASE) {
player.print(BBC.getPrefix() + BBC.SETTING_DISABLE player.print(BBC.SETTING_DISABLE.format("history.use-database (Import with /frb #import )"));
.format("history.use-database (Import with /frb #import )"));
return false; return false;
} }
BlockVector3 target = getTarget(player, rightClick).toBlockPoint(); BlockVector3 target = getTarget(player, rightClick).toBlockPoint();

Datei anzeigen

@ -95,13 +95,13 @@ public class SplineBrush implements Brush, ResettableTool {
points.add(position); points.add(position);
} }
this.positionSets.add(points); this.positionSets.add(points);
player.print(BBC.getPrefix() + BBC.BRUSH_SPLINE_PRIMARY_2.s()); player.print(BBC.BRUSH_SPLINE_PRIMARY_2.s());
if (!visualization) { if (!visualization) {
return; return;
} }
} }
if (positionSets.size() < 2) { if (positionSets.size() < 2) {
player.print(BBC.getPrefix() + BBC.BRUSH_SPLINE_SECONDARY_ERROR.s()); player.print(BBC.BRUSH_SPLINE_SECONDARY_ERROR.s());
return; return;
} }
List<Vector3> centroids = new ArrayList<>(); List<Vector3> centroids = new ArrayList<>();
@ -133,7 +133,7 @@ public class SplineBrush implements Brush, ResettableTool {
} }
editSession.drawSpline(pattern, currentSpline, 0, 0, 0, 10, 0, true); editSession.drawSpline(pattern, currentSpline, 0, 0, 0, 10, 0, true);
} }
player.print(BBC.getPrefix() + BBC.BRUSH_SPLINE_SECONDARY.s()); player.print(BBC.BRUSH_SPLINE_SECONDARY.s());
if (visualization) { if (visualization) {
numSplines = originalSize; numSplines = originalSize;
positionSets.remove(positionSets.size() - 1); positionSets.remove(positionSets.size() - 1);

Datei anzeigen

@ -36,7 +36,7 @@ public class SurfaceSpline implements Brush {
if (max == -1) return; if (max == -1) return;
// pos.mutY(max); // pos.mutY(max);
path.add(BlockVector3.at(pos.getBlockX(), max, pos.getBlockZ())); path.add(BlockVector3.at(pos.getBlockX(), max, pos.getBlockZ()));
editSession.getPlayer().sendMessage(BBC.getPrefix() + BBC.BRUSH_SPLINE_PRIMARY_2.s()); editSession.getPlayer().sendMessage(BBC.BRUSH_SPLINE_PRIMARY_2.s());
if (!vis) return; if (!vis) return;
} }
LocalBlockVectorSet vset = new LocalBlockVectorSet(); LocalBlockVectorSet vset = new LocalBlockVectorSet();
@ -90,6 +90,6 @@ public class SurfaceSpline implements Brush {
editSession.setBlocks(newSet, pattern); editSession.setBlocks(newSet, pattern);
if (!vis) path.clear(); if (!vis) path.clear();
} }
editSession.getPlayer().sendMessage(BBC.getPrefix() + BBC.BRUSH_SPLINE_SECONDARY.s()); editSession.getPlayer().sendMessage(BBC.BRUSH_SPLINE_SECONDARY.s());
} }
} }

Datei anzeigen

@ -78,10 +78,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
protected final DifferentialArray<int[]> main; protected final DifferentialArray<int[]> main;
protected DifferentialArray<int[]> overlay; protected DifferentialArray<int[]> overlay;
protected final CFIPrimtives primtives = new CFIPrimtives(); protected final CFIPrimitives primitives = new CFIPrimitives();
private CFIPrimtives oldPrimitives = new CFIPrimtives(); private CFIPrimitives oldPrimitives = new CFIPrimitives();
public final class CFIPrimtives implements Cloneable { public final class CFIPrimitives implements Cloneable {
protected int waterHeight = 0; protected int waterHeight = 0;
protected int floorThickness = 0; protected int floorThickness = 0;
protected int worldThickness = 0; protected int worldThickness = 0;
@ -93,11 +93,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null || !(obj instanceof CFIPrimtives)) { if (obj == null || !(obj instanceof CFIPrimitives)) {
return false; return false;
} }
try { try {
for (Field field : CFIPrimtives.class.getDeclaredFields()) { for (Field field : CFIPrimitives.class.getDeclaredFields()) {
if (field.get(this) != field.get(obj)) return false; if (field.get(this) != field.get(obj)) return false;
} }
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
@ -125,8 +125,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
out.writeBoolean(overlay != null); out.writeBoolean(overlay != null);
if (overlay != null) overlay.flushChanges(out); if (overlay != null) overlay.flushChanges(out);
try { try {
for (Field field : ReflectionUtils.sortFields(CFIPrimtives.class.getDeclaredFields())) { for (Field field : ReflectionUtils.sortFields(CFIPrimitives.class.getDeclaredFields())) {
Object now = field.get(primtives); Object now = field.get(primitives);
Object old = field.get(oldPrimitives); Object old = field.get(oldPrimitives);
boolean diff = old != now; boolean diff = old != now;
out.writeBoolean(diff); out.writeBoolean(diff);
@ -135,7 +135,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
out.writePrimitive(now); out.writePrimitive(now);
} }
} }
resetPrimtives(); resetPrimitives();
} catch (Throwable neverHappens) { } catch (Throwable neverHappens) {
neverHappens.printStackTrace(); neverHappens.printStackTrace();
} }
@ -148,11 +148,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
heights.isModified() || heights.isModified() ||
biomes.isModified() || biomes.isModified() ||
(overlay != null && overlay.isModified()) || (overlay != null && overlay.isModified()) ||
!primtives.equals(oldPrimitives); !primitives.equals(oldPrimitives);
} }
private void resetPrimtives() throws CloneNotSupportedException { private void resetPrimitives() throws CloneNotSupportedException {
oldPrimitives = (CFIPrimtives) primtives.clone(); oldPrimitives = (CFIPrimitives) primitives.clone();
} }
@Override @Override
@ -163,13 +163,13 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
main.undoChanges(in); main.undoChanges(in);
if (in.readBoolean()) overlay.undoChanges(in); if (in.readBoolean()) overlay.undoChanges(in);
try { try {
for (Field field : ReflectionUtils.sortFields(CFIPrimtives.class.getDeclaredFields())) { for (Field field : ReflectionUtils.sortFields(CFIPrimitives.class.getDeclaredFields())) {
if (in.readBoolean()) { if (in.readBoolean()) {
field.set(primtives, in.readPrimitive(field.getType())); // old field.set(primitives, in.readPrimitive(field.getType())); // old
in.readPrimitive(field.getType()); // new in.readPrimitive(field.getType()); // new
} }
} }
resetPrimtives(); resetPrimitives();
} catch (Throwable neverHappens) { } catch (Throwable neverHappens) {
neverHappens.printStackTrace(); neverHappens.printStackTrace();
} }
@ -185,13 +185,13 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (in.readBoolean()) overlay.redoChanges(in); if (in.readBoolean()) overlay.redoChanges(in);
try { try {
for (Field field : ReflectionUtils.sortFields(CFIPrimtives.class.getDeclaredFields())) { for (Field field : ReflectionUtils.sortFields(CFIPrimitives.class.getDeclaredFields())) {
if (in.readBoolean()) { if (in.readBoolean()) {
in.readPrimitive(field.getType()); // old in.readPrimitive(field.getType()); // old
field.set(primtives, in.readPrimitive(field.getType())); // new field.set(primitives, in.readPrimitive(field.getType())); // new
} }
} }
resetPrimtives(); resetPrimitives();
} catch (Throwable neverHappens) { } catch (Throwable neverHappens) {
neverHappens.printStackTrace(); neverHappens.printStackTrace();
} }
@ -332,7 +332,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
textureUtil = Fawe.get().getTextureUtil(); textureUtil = Fawe.get().getTextureUtil();
} }
try { try {
if (primtives.randomVariation) { if (primitives.randomVariation) {
return new RandomTextureUtil(textureUtil); return new RandomTextureUtil(textureUtil);
} else if (textureUtil instanceof CachedTextureUtil) { } else if (textureUtil instanceof CachedTextureUtil) {
return textureUtil; return textureUtil;
@ -346,31 +346,31 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
public void setBedrockId(int bedrockId) { public void setBedrockId(int bedrockId) {
this.primtives.bedrockId = bedrockId; this.primitives.bedrockId = bedrockId;
} }
public void setFloorThickness(int floorThickness) { public void setFloorThickness(int floorThickness) {
this.primtives.floorThickness = floorThickness; this.primitives.floorThickness = floorThickness;
} }
public void setWorldThickness(int height) { public void setWorldThickness(int height) {
this.primtives.worldThickness = height; this.primitives.worldThickness = height;
} }
public void setWaterHeight(int waterHeight) { public void setWaterHeight(int waterHeight) {
this.primtives.waterHeight = waterHeight; this.primitives.waterHeight = waterHeight;
} }
public void setWaterId(int waterId) { public void setWaterId(int waterId) {
this.primtives.waterId = waterId; this.primitives.waterId = waterId;
} }
public void setTextureRandomVariation(boolean randomVariation) { public void setTextureRandomVariation(boolean randomVariation) {
this.primtives.randomVariation = randomVariation; this.primitives.randomVariation = randomVariation;
} }
public boolean getTextureRandomVariation() { public boolean getTextureRandomVariation() {
return this.primtives.randomVariation; return this.primitives.randomVariation;
} }
public void setTextureUtil(TextureUtil textureUtil) { public void setTextureUtil(TextureUtil textureUtil) {
@ -428,16 +428,15 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
// Process table // Process table
table.processSummedAreaTable(); table.processSummedAreaTable();
{ // Copy from table // Copy from table
int localIndex = 0; int localIndex = 0;
int zIndex = (minZ * getWidth()); int zIndex = (minZ * getWidth());
for (int z = minZ, localZ = 0; z <= maxZ; z++, localZ++, zIndex += getWidth()) { for (int z = minZ, localZ = 0; z <= maxZ; z++, localZ++, zIndex += getWidth()) {
int index = zIndex + minX; int index = zIndex + minX;
for (int x = minX, localX = 0; x <= maxX; x++, localX++, index++, localIndex++) { for (int x = minX, localX = 0; x <= maxX; x++, localX++, index++, localIndex++) {
int y = heights[index] & 0xFF; int y = heights[index] & 0xFF;
int newHeight = table.average(localX, localZ, localIndex); int newHeight = table.average(localX, localZ, localIndex);
setLayerHeight(index, newHeight); setLayerHeight(index, newHeight);
}
} }
} }
} }
@ -909,8 +908,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
} }
} }
if (y <= primtives.waterHeight) { if (y <= primitives.waterHeight) {
return primtives.waterId << 4; return primitives.waterId << 4;
} }
return 0; return 0;
} else if (y == height) { } else if (y == height) {
@ -1020,11 +1019,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
public void setBiomePriority(int value) { public void setBiomePriority(int value) {
this.primtives.biomePriority = ((value * 65536) / 100) - 32768; this.primitives.biomePriority = ((value * 65536) / 100) - 32768;
} }
public int getBiomePriority() { public int getBiomePriority() {
return ((primtives.biomePriority + 32768) * 100) / 65536; return ((primitives.biomePriority + 32768) * 100) / 65536;
} }
public void setBlockAndBiomeColor(BufferedImage img, Mask mask, BufferedImage imgMask, boolean whiteOnly) { public void setBlockAndBiomeColor(BufferedImage img, Mask mask, BufferedImage imgMask, boolean whiteOnly) {
@ -1061,7 +1060,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
.current().nextInt(256) > height)) continue; .current().nextInt(256) > height)) continue;
} }
int color = img.getRGB(x, z); int color = img.getRGB(x, z);
if (textureUtil.getIsBlockCloserThanBiome(buffer, color, primtives.biomePriority)) { if (textureUtil.getIsBlockCloserThanBiome(buffer, color, primitives.biomePriority)) {
int combined = buffer[0]; int combined = buffer[0];
mainArr[index] = combined; mainArr[index] = combined;
floorArr[index] = combined; floorArr[index] = combined;
@ -1091,7 +1090,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
boolean yBiome = y > 0 && y < heightIndex; boolean yBiome = y > 0 && y < heightIndex;
for (int x = 0; x < img.getWidth(); x++, index++) { for (int x = 0; x < img.getWidth(); x++, index++) {
int color = img.getRGB(x, y); int color = img.getRGB(x, y);
if (textureUtil.getIsBlockCloserThanBiome(buffer, color, primtives.biomePriority)) { if (textureUtil.getIsBlockCloserThanBiome(buffer, color, primitives.biomePriority)) {
int combined = buffer[0]; int combined = buffer[0];
mainArr[index] = combined; mainArr[index] = combined;
floorArr[index] = combined; floorArr[index] = combined;
@ -1131,7 +1130,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (mask.getWidth() != getWidth() || mask.getHeight() != getLength()) if (mask.getWidth() != getWidth() || mask.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
primtives.modifiedMain = true; primitives.modifiedMain = true;
TextureUtil textureUtil = getTextureUtil(); TextureUtil textureUtil = getTextureUtil();
floor.record(() -> main.record(() -> { floor.record(() -> main.record(() -> {
@ -1160,7 +1159,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
public void setColor(BufferedImage img, Mask mask) { public void setColor(BufferedImage img, Mask mask) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
primtives.modifiedMain = true; primitives.modifiedMain = true;
TextureUtil textureUtil = getTextureUtil(); TextureUtil textureUtil = getTextureUtil();
@ -1193,7 +1192,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
public void setColor(BufferedImage img) { public void setColor(BufferedImage img) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
primtives.modifiedMain = true; primitives.modifiedMain = true;
TextureUtil textureUtil = getTextureUtil(); TextureUtil textureUtil = getTextureUtil();
floor.record(() -> main.record(() -> { floor.record(() -> main.record(() -> {
@ -1296,7 +1295,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} else { } else {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
primtives.modifiedMain = true; primitives.modifiedMain = true;
main.record(() -> { main.record(() -> {
int[] mainArr = main.get(); int[] mainArr = main.get();
@ -1349,7 +1348,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} else { } else {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
primtives.modifiedMain = true; primitives.modifiedMain = true;
main.record(() -> floor.record(() -> { main.record(() -> floor.record(() -> {
int[] floorArr = floor.get(); int[] floorArr = floor.get();
@ -1416,7 +1415,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (pattern instanceof BlockStateHolder) { if (pattern instanceof BlockStateHolder) {
setMain(mask, ((BlockStateHolder) pattern).getInternalId()); setMain(mask, ((BlockStateHolder) pattern).getInternalId());
} else { } else {
primtives.modifiedMain = true; primitives.modifiedMain = true;
int index = 0; int index = 0;
for (int z = 0; z < getLength(); z++) { for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z); mutable.mutZ(z);
@ -1436,7 +1435,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (pattern instanceof BlockStateHolder) { if (pattern instanceof BlockStateHolder) {
setColumn(mask, ((BlockStateHolder) pattern).getInternalId()); setColumn(mask, ((BlockStateHolder) pattern).getInternalId());
} else { } else {
primtives.modifiedMain = true; primitives.modifiedMain = true;
int index = 0; int index = 0;
for (int z = 0; z < getLength(); z++) { for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z); mutable.mutZ(z);
@ -1597,12 +1596,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int layer = 0; layer <= maxLayer; layer++) { for (int layer = 0; layer <= maxLayer; layer++) {
chunk.hasSections[layer] = true; chunk.hasSections[layer] = true;
} }
if (primtives.waterHeight != 0) { if (primitives.waterHeight != 0) {
int maxIndex = (primtives.waterHeight) << 8; int maxIndex = (primitives.waterHeight) << 8;
Arrays.fill(chunk.blocks, 0, maxIndex, primtives.waterId); Arrays.fill(chunk.blocks, 0, maxIndex, primitives.waterId);
} }
if (primtives.modifiedMain) { // If the main block is modified, we can't short circuit this if (primitives.modifiedMain) { // If the main block is modified, we can't short circuit this
for (int z = csz; z <= cez; z++) { for (int z = csz; z <= cez; z++) {
index = (z & 15) << 4; index = (z & 15) << 4;
for (int x = csx; x <= cex; x++, index++) { for (int x = csx; x <= cex; x++, index++) {
@ -1618,9 +1617,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
Arrays.fill(chunk.blocks, 0, maxIndex, BlockID.STONE); Arrays.fill(chunk.blocks, 0, maxIndex, BlockID.STONE);
} }
final boolean hasFloorThickness = primtives.floorThickness != 0 || primtives.worldThickness != 0; final boolean hasFloorThickness = primitives.floorThickness != 0 || primitives.worldThickness != 0;
if (primtives.worldThickness != 0) { if (primitives.worldThickness != 0) {
int endLayer = ((minY - primtives.worldThickness + 1) >> 4); int endLayer = ((minY - primitives.worldThickness + 1) >> 4);
for (int layer = 0; layer < endLayer; layer++) { for (int layer = 0; layer < endLayer; layer++) {
chunk.hasSections[layer] = false; chunk.hasSections[layer] = false;
} }
@ -1645,8 +1644,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
int min = maxMainY; int min = maxMainY;
if (primtives.floorThickness != 0) { if (primitives.floorThickness != 0) {
maxMainY = Math.max(0, maxMainY - (primtives.floorThickness - 1)); maxMainY = Math.max(0, maxMainY - (primitives.floorThickness - 1));
for (int y = maxMainY; y <= height; y++) { for (int y = maxMainY; y <= height; y++) {
chunk.blocks[index + (y << 8)] = floorCombined; chunk.blocks[index + (y << 8)] = floorCombined;
} }
@ -1655,8 +1654,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
chunk.blocks[index + ((height) << 8)] = floorCombined; chunk.blocks[index + ((height) << 8)] = floorCombined;
} }
if (primtives.worldThickness != 0) { if (primitives.worldThickness != 0) {
minMainY = Math.max(minY, min - primtives.worldThickness + 1); minMainY = Math.max(minY, min - primitives.worldThickness + 1);
for (int y = minY; y < minMainY; y++) { for (int y = minY; y < minMainY; y++) {
chunk.blocks[index + (y << 8)] = BlockID.AIR; chunk.blocks[index + (y << 8)] = BlockID.AIR;
} }
@ -1676,8 +1675,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
chunk.blocks[overlayIndex] = overlayCombined; chunk.blocks[overlayIndex] = overlayCombined;
} }
if (primtives.bedrockId != 0) { if (primitives.bedrockId != 0) {
chunk.blocks[index] = primtives.bedrockId; chunk.blocks[index] = primitives.bedrockId;
} }
} }
} }
@ -1775,7 +1774,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
private void setMain(Mask mask, int combined) { private void setMain(Mask mask, int combined) {
primtives.modifiedMain = true; primitives.modifiedMain = true;
int index = 0; int index = 0;
for (int z = 0; z < getLength(); z++) { for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z); mutable.mutZ(z);
@ -1791,7 +1790,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
private void setColumn(Mask mask, int combined) { private void setColumn(Mask mask, int combined) {
primtives.modifiedMain = true; primitives.modifiedMain = true;
int index = 0; int index = 0;
for (int z = 0; z < getLength(); z++) { for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z); mutable.mutZ(z);
@ -1817,7 +1816,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
private void setMain(int value) { private void setMain(int value) {
primtives.modifiedMain = true; primitives.modifiedMain = true;
main.record(() -> Arrays.fill(main.get(), value)); main.record(() -> Arrays.fill(main.get(), value));
} }
@ -1848,7 +1847,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
private void setMain(BufferedImage img, int combined, boolean white) { private void setMain(BufferedImage img, int combined, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
primtives.modifiedMain = true; primitives.modifiedMain = true;
main.record(() -> { main.record(() -> {
int index = 0; int index = 0;
@ -1885,7 +1884,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
private void setColumn(BufferedImage img, int combined, boolean white) { private void setColumn(BufferedImage img, int combined, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
primtives.modifiedMain = true; primitives.modifiedMain = true;
main.record(() -> floor.record(() -> { main.record(() -> floor.record(() -> {
int index = 0; int index = 0;

Datei anzeigen

@ -2,7 +2,6 @@ package com.boydti.fawe.object.changeset;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.jnbt.anvil.history.IAnvilHistory;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Iterators; import com.google.common.collect.Iterators;
@ -20,7 +19,7 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class AnvilHistory extends FaweChangeSet implements IAnvilHistory { public class AnvilHistory extends FaweChangeSet {
private final File folder; private final File folder;
private int size; private int size;
@ -41,7 +40,7 @@ public class AnvilHistory extends FaweChangeSet implements IAnvilHistory {
this.size = 0; this.size = 0;
} }
@Override //@Override
public boolean addFileChange(File originalMCAFile) { public boolean addFileChange(File originalMCAFile) {
try { try {
Files.move(originalMCAFile.toPath(), Paths.get(folder.getPath(), originalMCAFile.getName()), StandardCopyOption.ATOMIC_MOVE); Files.move(originalMCAFile.toPath(), Paths.get(folder.getPath(), originalMCAFile.getName()), StandardCopyOption.ATOMIC_MOVE);

Datei anzeigen

@ -22,7 +22,7 @@ public class CFIChangeSet extends FaweChangeSet {
super(hmmg); super(hmmg);
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + uuid + File.separator + "CFI" + File.separator + hmmg.getWorldName()); File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + uuid + File.separator + "CFI" + File.separator + hmmg.getWorldName());
int max = MainUtil.getMaxFileId(folder); int max = MainUtil.getMaxFileId(folder);
this.file = new File(folder, Integer.toString(max) + ".cfi"); this.file = new File(folder, max + ".cfi");
File parent = this.file.getParentFile(); File parent = this.file.getParentFile();
if (!parent.exists()) this.file.getParentFile().mkdirs(); if (!parent.exists()) this.file.getParentFile().mkdirs();
if (!this.file.exists()) this.file.createNewFile(); if (!this.file.exists()) this.file.createNewFile();

Datei anzeigen

@ -121,6 +121,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
initFiles(folder); initFiles(folder);
} }
@Override
public void delete() { public void delete() {
// Fawe.debug("Deleting history: " + getWorld().getName() + "/" + uuid + "/" + index); // Fawe.debug("Deleting history: " + getWorld().getName() + "/" + uuid + "/" + index);
deleteFiles(); deleteFiles();

Datei anzeigen

@ -20,17 +20,11 @@ import com.sk89q.worldedit.history.change.EntityRemove;
import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.history.changeset.ChangeSet;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.task.LinkedFuture;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockID;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -57,7 +51,7 @@ public abstract class FaweChangeSet implements ChangeSet {
public FaweChangeSet(String world) { public FaweChangeSet(String world) {
this.worldName = world; this.worldName = world;
this.mainThread = (Fawe.get() == null) || Fawe.isMainThread(); this.mainThread = Fawe.get() == null || Fawe.isMainThread();
this.layers = FaweCache.CHUNK_LAYERS; this.layers = FaweCache.CHUNK_LAYERS;
} }
@ -65,7 +59,7 @@ public abstract class FaweChangeSet implements ChangeSet {
this.world = world; this.world = world;
this.worldName = world.getName(); this.worldName = world.getName();
this.mainThread = Fawe.isMainThread(); this.mainThread = Fawe.isMainThread();
this.layers = (this.world.getMaxY() + 1) >> 4; this.layers = this.world.getMaxY() + 1 >> 4;
} }
public String getWorldName() { public String getWorldName() {
@ -177,6 +171,7 @@ public abstract class FaweChangeSet implements ChangeSet {
addEntityRemove(tag); addEntityRemove(tag);
} }
@Override
public void add(Change change) { public void add(Change change) {
if (change.getClass() == BlockChange.class) { if (change.getClass() == BlockChange.class) {
add((BlockChange) change); add((BlockChange) change);
@ -211,11 +206,13 @@ public abstract class FaweChangeSet implements ChangeSet {
try { try {
if (from.hasNbtData()) { if (from.hasNbtData()) {
CompoundTag nbt = from.getNbtData(); CompoundTag nbt = from.getNbtData();
assert nbt != null;
MainUtil.setPosition(nbt, x, y, z); MainUtil.setPosition(nbt, x, y, z);
addTileRemove(nbt); addTileRemove(nbt);
} }
if (to.hasNbtData()) { if (to.hasNbtData()) {
CompoundTag nbt = to.getNbtData(); CompoundTag nbt = to.getNbtData();
assert nbt != null;
MainUtil.setPosition(nbt, x, y, z); MainUtil.setPosition(nbt, x, y, z);
addTileCreate(nbt); addTileCreate(nbt);
} }
@ -236,6 +233,7 @@ public abstract class FaweChangeSet implements ChangeSet {
try { try {
if (to.hasNbtData()) { if (to.hasNbtData()) {
CompoundTag nbt = to.getNbtData(); CompoundTag nbt = to.getNbtData();
assert nbt != null;
MainUtil.setPosition(nbt, x, y, z); MainUtil.setPosition(nbt, x, y, z);
addTileCreate(nbt); addTileCreate(nbt);
} }

Datei anzeigen

@ -312,6 +312,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
return originZ; return originZ;
} }
@Override
public void add(int x, int y, int z, int combinedFrom, int combinedTo) { public void add(int x, int y, int z, int combinedFrom, int combinedTo) {
blockSize++; blockSize++;
try { try {
@ -344,6 +345,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
} }
} }
@Override
public void addTileCreate(CompoundTag tag) { public void addTileCreate(CompoundTag tag) {
if (tag == null) { if (tag == null) {
return; return;
@ -357,6 +359,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
} }
} }
@Override
public void addTileRemove(CompoundTag tag) { public void addTileRemove(CompoundTag tag) {
if (tag == null) { if (tag == null) {
return; return;
@ -370,6 +373,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
} }
} }
@Override
public void addEntityRemove(CompoundTag tag) { public void addEntityRemove(CompoundTag tag) {
if (tag == null) { if (tag == null) {
return; return;
@ -383,6 +387,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
} }
} }
@Override
public void addEntityCreate(CompoundTag tag) { public void addEntityCreate(CompoundTag tag) {
if (tag == null) { if (tag == null) {
return; return;
@ -660,6 +665,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
} }
} }
@Override
public Iterator<Change> getIterator(final boolean dir) { public Iterator<Change> getIterator(final boolean dir) {
close(); close();
try { try {

Datei anzeigen

@ -155,8 +155,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
if (biomes == null) { if (biomes == null) {
return null; return null;
} }
FaweInputStream result = MainUtil.getCompressedIS(new FastByteArraysInputStream(biomes)); return MainUtil.getCompressedIS(new FastByteArraysInputStream(biomes));
return result;
} }
@Override @Override

Datei anzeigen

@ -11,7 +11,6 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.Iterator; import java.util.Iterator;
public class ResizableClipboardBuilder extends MemoryOptimizedHistory { public class ResizableClipboardBuilder extends MemoryOptimizedHistory {
@ -63,13 +62,13 @@ public class ResizableClipboardBuilder extends MemoryOptimizedHistory {
BlockVector3 pos2 = BlockVector3.at(maxX, maxY, maxZ); BlockVector3 pos2 = BlockVector3.at(maxX, maxY, maxZ);
CuboidRegion region = new CuboidRegion(pos1, pos2); CuboidRegion region = new CuboidRegion(pos1, pos2);
BlockArrayClipboard clipboard = new BlockArrayClipboard(region); BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
Iterator<Change> iter = getIterator(true); Iterator<Change> iterator = getIterator(true);
try { try {
while (iter.hasNext()) { while (iterator.hasNext()) {
Change change = iter.next(); Change change = iterator.next();
if (change instanceof MutableBlockChange) { if (change instanceof MutableBlockChange) {
MutableBlockChange blockChange = (MutableBlockChange) change; MutableBlockChange blockChange = (MutableBlockChange) change;
BlockStateHolder block = BlockState.getFromInternalId(blockChange.combinedId); BlockState block = BlockState.getFromInternalId(blockChange.combinedId);
clipboard.setBlock(blockChange.x, blockChange.y, blockChange.z, block); clipboard.setBlock(blockChange.x, blockChange.y, blockChange.z, block);
} else if (change instanceof MutableTileChange) { } else if (change instanceof MutableTileChange) {
MutableTileChange tileChange = (MutableTileChange) change; MutableTileChange tileChange = (MutableTileChange) change;

Datei anzeigen

@ -247,12 +247,11 @@ public class ClipboardRemapper {
mapPEtoPC.put(new BaseBlock(198,-1), new BaseBlock(208,-1)); mapPEtoPC.put(new BaseBlock(198,-1), new BaseBlock(208,-1));
mapPEtoPC.put(new BaseBlock(207,-1), new BaseBlock(212,-1)); mapPEtoPC.put(new BaseBlock(207,-1), new BaseBlock(212,-1));
{ // beetroot // beetroot
mapPEtoPC.put(new BaseBlock(244, 2), new BaseBlock(207, 1)); mapPEtoPC.put(new BaseBlock(244, 2), new BaseBlock(207, 1));
mapPEtoPC.put(new BaseBlock(244, 4), new BaseBlock(207, 2)); mapPEtoPC.put(new BaseBlock(244, 4), new BaseBlock(207, 2));
mapPEtoPC.put(new BaseBlock(244, 7), new BaseBlock(207, 3)); mapPEtoPC.put(new BaseBlock(244, 7), new BaseBlock(207, 3));
for (int data = 3; data < 16; data++) mapPEtoPC.putIfAbsent(new BaseBlock(244, data), new BaseBlock(207, data)); for (int data = 3; data < 16; data++) mapPEtoPC.putIfAbsent(new BaseBlock(244, data), new BaseBlock(207, data));
}
for (int data = 0; data < 16; data++) { for (int data = 0; data < 16; data++) {
mapPEtoPC.put(new BaseBlock(218, data), new BaseBlock(219 + data, -1)); mapPEtoPC.put(new BaseBlock(218, data), new BaseBlock(219 + data, -1));

Datei anzeigen

@ -35,7 +35,7 @@ public class LongHashSet {
} }
public static int lsw(long l) { public static int lsw(long l) {
return (int) (l & 0xFFFFFFFF) + Integer.MIN_VALUE; return (int) l + Integer.MIN_VALUE;
} }
public boolean containsKey(int msw, int lsw) { public boolean containsKey(int msw, int lsw) {

Datei anzeigen

@ -5,13 +5,11 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.math.MutableBlockVector2;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import org.jetbrains.annotations.NotNull;
import java.util.AbstractSet; import java.util.AbstractSet;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import org.jetbrains.annotations.NotNull;
/** /**
* Memory optimized BlockVector3 Set using a sparsely populated bitset and grouped by chunk section * Memory optimized BlockVector3 Set using a sparsely populated bitset and grouped by chunk section
@ -706,25 +704,26 @@ public final class MemBlockSet extends BlockSet {
long total = 0; long total = 0;
long lastBit = 0; long lastBit = 0;
int lastCount = 0; int lastCount = 0;
for (int X = 0; X < rows.length; X++) { for (int x = 0; x < rows.length; x++) {
IRow nullRowX = rows[X]; IRow nullRowX = rows[x];
if (!(nullRowX instanceof RowX)) continue; if (!(nullRowX instanceof RowX)) continue;
RowX rowx = (RowX) nullRowX; RowX rowx = (RowX) nullRowX;
for (int Z = 0; Z < rowx.rows.length; Z++) { for (int z = 0; z < rowx.rows.length; z++) {
IRow nullRowZ = rowx.rows[Z]; IRow nullRowZ = rowx.rows[z];
if (!(nullRowZ instanceof RowZ)) continue; if (!(nullRowZ instanceof RowZ)) continue;
RowZ rowz = (RowZ) nullRowZ; RowZ rowz = (RowZ) nullRowZ;
outer: for (int y = 0; y < 16; y++) {
for (int Y = 0; Y < 16; Y++) { IRow nullRowY = rowz.rows[y];
IRow nullRowY = rowz.rows[Y]; if (!(nullRowY instanceof RowY)) {
if (!(nullRowY instanceof RowY)) continue; continue;
}
RowY rowY = (RowY) nullRowY; RowY rowY = (RowY) nullRowY;
for (long bit : rowY.bits) { for (long bit : rowY.bits) {
if (bit == 0) continue; if (bit == 0) {
else if (bit == -1L) { continue;
} else if (bit == -1L) {
total += 64; total += 64;
} } else if (bit == lastBit) {
else if (bit == lastBit) {
total += lastCount; total += lastCount;
} else { } else {
lastBit = bit; lastBit = bit;

Datei anzeigen

@ -3,6 +3,7 @@ package com.boydti.fawe.object.collection;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
public class SummedAreaTable { public class SummedAreaTable {
private final char[] source; private final char[] source;
private final long[] summed; private final long[] summed;
private final int length; private final int length;
@ -28,10 +29,9 @@ public class SummedAreaTable {
public void processSummedAreaTable() { public void processSummedAreaTable() {
int rowSize = source.length / width; int rowSize = source.length / width;
int colSize = width;
int index = 0; int index = 0;
for (int i = 0; i < rowSize; i++) { for (int i = 0; i < rowSize; i++) {
for (int j = 0; j < colSize; j++, index++) { for (int j = 0; j < width; j++, index++) {
long val = getVal(i, j, index, source[index]); long val = getVal(i, j, index, source[index]);
summed[index] = val; summed[index] = val;
} }
@ -39,7 +39,9 @@ public class SummedAreaTable {
} }
private long getSum(int index) { private long getSum(int index) {
if (index < 0) return 0; if (index < 0) {
return 0;
}
return summed[index]; return summed[index];
} }

Datei anzeigen

@ -344,8 +344,7 @@ public class BufferedRandomAccessFile extends RandomAccessFile {
if (this.curr_ == this.hi_) if (this.curr_ == this.hi_)
return -1; return -1;
} }
byte res = this.buff_[(int) (this.curr_ - this.lo_)]; return this.buff_[(int) (this.curr_ - this.lo_)];
return res;
} }
public void writeCurrent(byte b) throws IOException { public void writeCurrent(byte b) throws IOException {

Datei anzeigen

@ -23,7 +23,7 @@ public class RandomFileOutputStream extends OutputStream {
protected boolean closeParent; protected boolean closeParent;
// ***************************************************************************** // *****************************************************************************
// INSTANCE CONSTRUCTION/INITIALIZATON/FINALIZATION, OPEN/CLOSE // INSTANCE CONSTRUCTION/INITIALIZATION/FINALIZATION, OPEN/CLOSE
// ***************************************************************************** // *****************************************************************************
public RandomFileOutputStream(String fnm) throws IOException { public RandomFileOutputStream(String fnm) throws IOException {

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.progress; package com.boydti.fawe.object.progress;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
public class ChatProgressTracker extends DefaultProgressTracker { public class ChatProgressTracker extends DefaultProgressTracker {
@ -11,6 +10,6 @@ public class ChatProgressTracker extends DefaultProgressTracker {
@Override @Override
public void sendTile(String title, String sub) { public void sendTile(String title, String sub) {
getPlayer().sendMessage(BBC.getPrefix() + title + sub); getPlayer().sendMessage(title + sub);
} }
} }

Datei anzeigen

@ -20,6 +20,8 @@ import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class FuzzyRegionSelector extends AbstractDelegateExtent implements RegionSelector { public class FuzzyRegionSelector extends AbstractDelegateExtent implements RegionSelector {
@ -147,11 +149,8 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio
@Override @Override
public List<String> getInformationLines() { public List<String> getInformationLines() {
final List<String> lines = new ArrayList<>(); return IntStream.range(0, positions.size())
for (int i = 0; i < positions.size(); i++) { .mapToObj(i -> "Position " + i + ": " + positions.get(i)).collect(Collectors.toList());
lines.add("Position " + i + ": " + positions.get(i));
}
return lines;
} }
@Override @Override

Datei anzeigen

@ -38,7 +38,6 @@ public class PNGWriter implements ClipboardWriter {
double d = Math.min((double) imageSize / length, (double) imageSize / width) / 3; double d = Math.min((double) imageSize / length, (double) imageSize / width) / 3;
double d_2 = d / 2; double d_2 = d / 2;
double cx = (double) imageSize / 2; double cx = (double) imageSize / 2;
double cy = (double) imageSize / 2;
int[] poly1X = new int[4]; int[] poly1X = new int[4];
int[] poly1Y = new int[4]; int[] poly1Y = new int[4];
@ -106,50 +105,47 @@ public class PNGWriter implements ClipboardWriter {
continue; continue;
} }
double cpy = cpy2 - dpxi[y - y0]; double cpy = cpy2 - dpxi[y - y0];
poly1X[0] = (int) (cpx); poly1X[0] = (int) cpx;
poly1Y[0] = (int) (cpy); poly1Y[0] = (int) cpy;
poly1X[1] = (int) (cpx - d); poly1X[1] = (int) (cpx - d);
poly1Y[1] = (int) (cpy - d_2); poly1Y[1] = (int) (cpy - d_2);
poly1X[2] = (int) (cpx); poly1X[2] = (int) cpx;
poly1Y[2] = (int) (cpy - d); poly1Y[2] = (int) (cpy - d);
poly1X[3] = (int) (cpx + d); poly1X[3] = (int) (cpx + d);
poly1Y[3] = (int) (cpy - d_2); poly1Y[3] = (int) (cpy - d_2);
poly2X[0] = (int) (cpx); poly2X[0] = (int) cpx;
poly2Y[0] = (int) (cpy); poly2Y[0] = (int) cpy;
poly2X[1] = (int) (cpx + d); poly2X[1] = (int) (cpx + d);
poly2Y[1] = (int) (cpy - d_2); poly2Y[1] = (int) (cpy - d_2);
poly2X[2] = (int) (cpx + d); poly2X[2] = (int) (cpx + d);
poly2Y[2] = (int) (cpy + d_2 + dpxi[0]); poly2Y[2] = (int) (cpy + d_2 + dpxi[0]);
poly2X[3] = (int) (cpx); poly2X[3] = (int) cpx;
poly2Y[3] = (int) (cpy + dpxi[1]); poly2Y[3] = (int) (cpy + dpxi[1]);
poly3X[0] = (int) (cpx); poly3X[0] = (int) cpx;
poly3Y[0] = (int) (cpy); poly3Y[0] = (int) cpy;
poly3X[1] = (int) (cpx - d); poly3X[1] = (int) (cpx - d);
poly3Y[1] = (int) (cpy - d_2); poly3Y[1] = (int) (cpy - d_2);
poly3X[2] = (int) (cpx - d); poly3X[2] = (int) (cpx - d);
poly3Y[2] = (int) (cpy + d_2 + dpxi[0]); poly3Y[2] = (int) (cpy + d_2 + dpxi[0]);
poly3X[3] = (int) (cpx); poly3X[3] = (int) cpx;
poly3Y[3] = (int) (cpy + dpxi[1]); poly3Y[3] = (int) (cpy + dpxi[1]);
Color colorTop = new Color(tu.getColor(block.getBlockType())); Color colorTop = new Color(tu.getColor(block.getBlockType()));
Color colorRight = colorTop;
Color colorLeft = colorTop;
g2.setColor(colorTop);
if (fill) { if (fill) {
g2.setColor(colorTop);
g2.fillPolygon(poly1X, poly1Y, 4); g2.fillPolygon(poly1X, poly1Y, 4);
g2.setColor(colorRight); g2.setColor(colorTop);
g2.fillPolygon(poly2X, poly2Y, 4); g2.fillPolygon(poly2X, poly2Y, 4);
g2.setColor(colorLeft); g2.setColor(colorTop);
g2.fillPolygon(poly3X, poly3Y, 4); g2.fillPolygon(poly3X, poly3Y, 4);
} else { } else {
g2.setColor(colorTop);
g2.drawPolygon(poly1X, poly1Y, 4); g2.drawPolygon(poly1X, poly1Y, 4);
g2.setColor(colorRight); g2.setColor(colorTop);
g2.drawPolygon(poly2X, poly2Y, 4); g2.drawPolygon(poly2X, poly2Y, 4);
g2.setColor(colorLeft); g2.setColor(colorTop);
g2.drawPolygon(poly3X, poly3Y, 4); g2.drawPolygon(poly3X, poly3Y, 4);
} }
} }

Datei anzeigen

@ -93,7 +93,6 @@ public class MainUtil {
* e.g. sending messages * e.g. sending messages
*/ */
public static void sendMessage(final FawePlayer<?> player, String message) { public static void sendMessage(final FawePlayer<?> player, String message) {
message = BBC.color(message);
if (player == null) { if (player == null) {
Fawe.debug(message); Fawe.debug(message);
} else { } else {
@ -631,7 +630,6 @@ public class MainUtil {
boolean reading = false; boolean reading = false;
int index = 1; int index = 1;
int numIndex = 1; int numIndex = 1;
outer:
for (int i = len; i >= 2; i--) { for (int i = len; i >= 2; i--) {
char c = fileName.charAt(i); char c = fileName.charAt(i);
if (!reading) { if (!reading) {
@ -644,7 +642,9 @@ public class MainUtil {
break; break;
case '.': case '.':
res[index--] = val; res[index--] = val;
if (index == -1) return res; if (index == -1) {
return res;
}
val = 0; val = 0;
numIndex = 1; numIndex = 1;
break; break;

Datei anzeigen

@ -28,8 +28,7 @@ public class MemUtil {
} }
public static long getUsedBytes() { public static long getUsedBytes() {
long used = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
return used;
} }
public static long getFreeBytes() { public static long getFreeBytes() {

Datei anzeigen

@ -1,6 +1,7 @@
package com.boydti.fawe.util; package com.boydti.fawe.util;
import com.sk89q.worldedit.util.auth.Subject; import com.sk89q.worldedit.util.auth.Subject;
import org.jetbrains.annotations.NotNull;
public enum Permission { public enum Permission {
/* /*
@ -17,11 +18,8 @@ public enum Permission {
} }
public static boolean hasPermission(Subject player, String permission) { public static boolean hasPermission(@NotNull Subject player, String permission) {
if (player == null || player.hasPermission(ADMIN.permission)) { if (player.hasPermission(ADMIN.permission) || player.hasPermission(permission)) {
return true;
}
if (player.hasPermission(permission)) {
return true; return true;
} }
final String[] nodes = permission.split("\\."); final String[] nodes = permission.split("\\.");

Datei anzeigen

@ -6,33 +6,12 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
public class StringMan { public class StringMan {
public static String replaceFromMap(String string, Map<String, String> replacements) {
final StringBuilder sb = new StringBuilder(string);
int size = string.length();
for (Entry<String, String> entry : replacements.entrySet()) {
if (size == 0) {
break;
}
final String key = entry.getKey();
final String value = entry.getValue();
int start = sb.indexOf(key, 0);
while (start > -1) {
final int end = start + key.length();
final int nextSearchStart = start + value.length();
sb.replace(start, end, value);
size -= end - start;
start = sb.indexOf(key, nextSearchStart);
}
}
return sb.toString();
}
public static boolean containsAny(CharSequence sequence, String any) { public static boolean containsAny(CharSequence sequence, String any) {
return IntStream.range(0, sequence.length()) return IntStream.range(0, sequence.length())
@ -516,10 +495,6 @@ public class StringMan {
} }
public static String repeat(String s, int n) { public static String repeat(String s, int n) {
final StringBuilder sb = new StringBuilder(); return IntStream.range(0, n).mapToObj(i -> s).collect(Collectors.joining());
for (int i = 0; i < n; i++) {
sb.append(s);
}
return sb.toString();
} }
} }

Datei anzeigen

@ -99,9 +99,9 @@ public class WEManager {
synchronized (masks) { synchronized (masks) {
boolean removed = false; boolean removed = false;
if (!masks.isEmpty()) { if (!masks.isEmpty()) {
Iterator<FaweMask> iter = masks.iterator(); Iterator<FaweMask> iterator = masks.iterator();
while (iter.hasNext()) { while (iterator.hasNext()) {
FaweMask mask = iter.next(); FaweMask mask = iterator.next();
if (mask.isValid(player, type)) { if (mask.isValid(player, type)) {
Region region = mask.getRegion(); Region region = mask.getRegion();
if (region.contains(loc.toBlockPoint())) { if (region.contains(loc.toBlockPoint())) {
@ -112,7 +112,7 @@ public class WEManager {
} }
} else { } else {
removed = true; removed = true;
iter.remove(); iterator.remove();
} }
} }
} }

Datei anzeigen

@ -170,7 +170,7 @@ public class PlayerWrapper extends AbstractPlayerActor {
} }
@Override @Override
public void findFreePosition(final Location searchPos) { public void findFreePosition(Location searchPos) {
TaskManager.IMP.sync(new RunnableVal<Boolean>() { TaskManager.IMP.sync(new RunnableVal<Boolean>() {
@Override @Override
public void run(Boolean value) { public void run(Boolean value) {
@ -180,7 +180,7 @@ public class PlayerWrapper extends AbstractPlayerActor {
} }
@Override @Override
public void setOnGround(final Location searchPos) { public void setOnGround(Location searchPos) {
TaskManager.IMP.sync(new RunnableVal<Boolean>() { TaskManager.IMP.sync(new RunnableVal<Boolean>() {
@Override @Override
public void run(Boolean value) { public void run(Boolean value) {
@ -284,7 +284,7 @@ public class PlayerWrapper extends AbstractPlayerActor {
} }
@Override @Override
public void floatAt(final int x, final int y, final int z, final boolean alwaysGlass) { public void floatAt(int x, int y, int z, boolean alwaysGlass) {
RuntimeException caught = null; RuntimeException caught = null;
try { try {
EditSession edit = new EditSessionBuilder(parent.getWorld()).player(FawePlayer.wrap(this)).build(); EditSession edit = new EditSessionBuilder(parent.getWorld()).player(FawePlayer.wrap(this)).build();
@ -309,7 +309,7 @@ public class PlayerWrapper extends AbstractPlayerActor {
} }
@Override @Override
public Location getBlockTrace(final int range, final boolean useLastBlock) { public Location getBlockTrace(int range, boolean useLastBlock) {
return TaskManager.IMP.sync(new RunnableVal<Location>() { return TaskManager.IMP.sync(new RunnableVal<Location>() {
@Override @Override
public void run(Location value) { public void run(Location value) {
@ -320,7 +320,7 @@ public class PlayerWrapper extends AbstractPlayerActor {
} }
@Override @Override
public Location getBlockTraceFace(final int range, final boolean useLastBlock) { public Location getBlockTraceFace(int range, boolean useLastBlock) {
return TaskManager.IMP.sync(new RunnableVal<Location>() { return TaskManager.IMP.sync(new RunnableVal<Location>() {
@Override @Override
public void run(Location value) { public void run(Location value) {
@ -331,7 +331,7 @@ public class PlayerWrapper extends AbstractPlayerActor {
} }
@Override @Override
public Location getSolidBlockTrace(final int range) { public Location getSolidBlockTrace(int range) {
return TaskManager.IMP.sync(new RunnableVal<Location>() { return TaskManager.IMP.sync(new RunnableVal<Location>() {
@Override @Override
public void run(Location value) { public void run(Location value) {
@ -347,7 +347,7 @@ public class PlayerWrapper extends AbstractPlayerActor {
} }
@Override @Override
public boolean passThroughForwardWall(final int range) { public boolean passThroughForwardWall(int range) {
return TaskManager.IMP.sync(() -> { return TaskManager.IMP.sync(() -> {
int searchDist = 0; int searchDist = 0;
TargetBlock hitBlox = new TargetBlock(PlayerWrapper.this, range, 0.2); TargetBlock hitBlox = new TargetBlock(PlayerWrapper.this, range, 0.2);

Datei anzeigen

@ -20,13 +20,14 @@
package com.sk89q.jnbt; package com.sk89q.jnbt;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/** /**
* A class which holds constant values. * A class which holds constant values.
*/ */
public final class NBTConstants { public final class NBTConstants {
public static final Charset CHARSET = Charset.forName("UTF-8"); public static final Charset CHARSET = StandardCharsets.UTF_8;
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2,
TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6, TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6,

Datei anzeigen

@ -135,7 +135,7 @@ public final class StringUtil {
} }
StringBuilder buffer = new StringBuilder(Integer.toString(str[initialIndex])); StringBuilder buffer = new StringBuilder(Integer.toString(str[initialIndex]));
for (int i = initialIndex + 1; i < str.length; ++i) { for (int i = initialIndex + 1; i < str.length; ++i) {
buffer.append(delimiter).append(Integer.toString(str[i])); buffer.append(delimiter).append(str[i]);
} }
return buffer.toString(); return buffer.toString();
} }

Datei anzeigen

@ -56,6 +56,7 @@ import com.sk89q.worldedit.command.tool.SinglePickaxe;
import com.sk89q.worldedit.command.tool.Tool; import com.sk89q.worldedit.command.tool.Tool;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Locatable;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.ChangeSetExecutor; import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
@ -70,7 +71,6 @@ import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.regions.selector.RegionSelectorType; import com.sk89q.worldedit.regions.selector.RegionSelectorType;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
@ -313,10 +313,6 @@ public class LocalSession implements TextureHolder {
return (historyNegativeIndex == null ? historyNegativeIndex = 0 : historyNegativeIndex); return (historyNegativeIndex == null ? historyNegativeIndex = 0 : historyNegativeIndex);
} }
public void setHistoryIndex(int value) {
historyNegativeIndex = history.size() - value - 1;
}
public boolean save() { public boolean save() {
saveHistoryNegativeIndex(uuid, currentWorld); saveHistoryNegativeIndex(uuid, currentWorld);
if (defaultSelector == RegionSelectorType.CUBOID) { if (defaultSelector == RegionSelectorType.CUBOID) {
@ -505,13 +501,14 @@ public class LocalSession implements TextureHolder {
* Performs an undo. * Performs an undo.
* *
* @param newBlockBag a new block bag * @param newBlockBag a new block bag
* @param player the player * @param actor the actor
* @return whether anything was undone * @return whether anything was undone
*/ */
public EditSession undo(@Nullable BlockBag newBlockBag, Player player) { public EditSession undo(@Nullable BlockBag newBlockBag, Actor actor) {
checkNotNull(player); checkNotNull(actor);
FawePlayer fp = FawePlayer.wrap(player); //TODO This method needs to be modified to use actors instead of FAWEPlayer
loadSessionHistoryFromDisk(player.getUniqueId(), fp.getWorldForEditing()); FawePlayer fp = FawePlayer.wrap((Player)actor);
loadSessionHistoryFromDisk(actor.getUniqueId(), fp.getWorldForEditing());
if (getHistoryNegativeIndex() < history.size()) { if (getHistoryNegativeIndex() < history.size()) {
FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex())); FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
try (EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld()) try (EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld())
@ -521,7 +518,7 @@ public class LocalSession implements TextureHolder {
.fastmode(false) .fastmode(false)
.limitUnprocessed(fp) .limitUnprocessed(fp)
.player(fp) .player(fp)
.blockBag(getBlockBag(player)) .blockBag(getBlockBag((Player)actor))
.build()) { .build()) {
newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.UNDO); newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.UNDO);
setDirty(); setDirty();
@ -542,13 +539,14 @@ public class LocalSession implements TextureHolder {
* Performs a redo * Performs a redo
* *
* @param newBlockBag a new block bag * @param newBlockBag a new block bag
* @param player the player * @param actor the actor
* @return whether anything was redone * @return whether anything was redone
*/ */
public EditSession redo(@Nullable BlockBag newBlockBag, Player player) { public EditSession redo(@Nullable BlockBag newBlockBag, Actor actor) {
checkNotNull(player); checkNotNull(actor);
FawePlayer fp = FawePlayer.wrap(player); //TODO This method needs to be modified to use actors instead of FAWEPlayer
loadSessionHistoryFromDisk(player.getUniqueId(), fp.getWorldForEditing()); FawePlayer fp = FawePlayer.wrap((Player)actor);
loadSessionHistoryFromDisk(actor.getUniqueId(), fp.getWorldForEditing());
if (getHistoryNegativeIndex() > 0) { if (getHistoryNegativeIndex() > 0) {
setDirty(); setDirty();
historyNegativeIndex--; historyNegativeIndex--;
@ -560,7 +558,7 @@ public class LocalSession implements TextureHolder {
.fastmode(false) .fastmode(false)
.limitUnprocessed(fp) .limitUnprocessed(fp)
.player(fp) .player(fp)
.blockBag(getBlockBag(player)) .blockBag(getBlockBag((Player)actor))
.build()) { .build()) {
newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.REDO); newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.REDO);
return newEditSession; return newEditSession;
@ -849,14 +847,18 @@ public class LocalSession implements TextureHolder {
* Get the position use for commands that take a center point * Get the position use for commands that take a center point
* (i.e. //forestgen, etc.). * (i.e. //forestgen, etc.).
* *
* @param player the player * @param actor the actor
* @return the position to use * @return the position to use
* @throws IncompleteRegionException thrown if a region is not fully selected * @throws IncompleteRegionException thrown if a region is not fully selected
*/ */
public BlockVector3 getPlacementPosition(Player player) throws IncompleteRegionException { public BlockVector3 getPlacementPosition(Actor actor) throws IncompleteRegionException {
checkNotNull(player); checkNotNull(actor);
if (!placeAtPos1) { if (!placeAtPos1) {
return player.getBlockIn().toVector().toBlockPoint(); if (actor instanceof Locatable) {
return ((Locatable) actor).getBlockLocation().toVector().toBlockPoint();
} else {
throw new IncompleteRegionException();
}
} }
return selector.getPrimaryPosition(); return selector.getPrimaryPosition();
@ -1093,9 +1095,9 @@ public class LocalSession implements TextureHolder {
/** /**
* Tell the player the WorldEdit version. * Tell the player the WorldEdit version.
* *
* @param player the player * @param actor the actor
*/ */
public void tellVersion(Actor player) { public void tellVersion(Actor actor) {
} }
public boolean shouldUseServerCUI() { public boolean shouldUseServerCUI() {
@ -1325,7 +1327,7 @@ public class LocalSession implements TextureHolder {
/** /**
* Construct a new edit session. * Construct a new edit session.
* *
* @param player the player * @param player the actor
* @return an edit session * @return an edit session
*/ */
public EditSession createEditSession(Player player) { public EditSession createEditSession(Player player) {
@ -1334,12 +1336,12 @@ public class LocalSession implements TextureHolder {
BlockBag blockBag = getBlockBag(player); BlockBag blockBag = getBlockBag(player);
World world = player.getWorld(); World world = player.getWorld();
boolean isPlayer = player.isPlayer();
EditSessionBuilder builder = new EditSessionBuilder(world); EditSessionBuilder builder = new EditSessionBuilder(world);
if (player.isPlayer()) builder.player(FawePlayer.wrap(player)); if (player.isPlayer()) builder.player(FawePlayer.wrap(player));
builder.blockBag(blockBag); builder.blockBag(blockBag);
builder.fastmode(fastMode); builder.fastmode(fastMode);
// Create an edit session
EditSession editSession = builder.build(); EditSession editSession = builder.build();
if (mask != null) { if (mask != null) {

Datei anzeigen

@ -0,0 +1,27 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
/**
* Raised when a world is missing but is required.
*/
public class MissingWorldException extends WorldEditException {
}

Datei anzeigen

@ -109,7 +109,7 @@ public final class WorldEdit {
private final PlatformManager platformManager = new PlatformManager(this); private final PlatformManager platformManager = new PlatformManager(this);
private final EditSessionFactory editSessionFactory = new EditSessionFactory.EditSessionFactoryImpl(eventBus); private final EditSessionFactory editSessionFactory = new EditSessionFactory.EditSessionFactoryImpl(eventBus);
private final SessionManager sessions = new SessionManager(this); private final SessionManager sessions = new SessionManager(this);
private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20)); private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20));;
private final Supervisor supervisor = new SimpleSupervisor(); private final Supervisor supervisor = new SimpleSupervisor();
private final BlockFactory blockFactory = new BlockFactory(this); private final BlockFactory blockFactory = new BlockFactory(this);
@ -232,7 +232,7 @@ public final class WorldEdit {
* traversal exploits by checking the root directory and the file directory. * traversal exploits by checking the root directory and the file directory.
* On success, a {@code java.io.File} object will be returned. * On success, a {@code java.io.File} object will be returned.
* *
* @param player the player * @param actor the actor
* @param dir sub-directory to look in * @param dir sub-directory to look in
* @param filename filename (user-submitted) * @param filename filename (user-submitted)
* @param defaultExt append an extension if missing one, null to not use * @param defaultExt append an extension if missing one, null to not use
@ -240,8 +240,8 @@ public final class WorldEdit {
* @return a file * @return a file
* @throws FilenameException thrown if the filename is invalid * @throws FilenameException thrown if the filename is invalid
*/ */
public File getSafeSaveFile(Player player, File dir, String filename, String defaultExt, String... extensions) throws FilenameException { public File getSafeSaveFile(Actor actor, File dir, String filename, String defaultExt, String... extensions) throws FilenameException {
return getSafeFile(player, dir, filename, defaultExt, extensions, true); return getSafeFile(actor, dir, filename, defaultExt, extensions, true);
} }
/** /**
@ -250,7 +250,7 @@ public final class WorldEdit {
* traversal exploits by checking the root directory and the file directory. * traversal exploits by checking the root directory and the file directory.
* On success, a {@code java.io.File} object will be returned. * On success, a {@code java.io.File} object will be returned.
* *
* @param player the player * @param actor the actor
* @param dir sub-directory to look in * @param dir sub-directory to look in
* @param filename filename (user-submitted) * @param filename filename (user-submitted)
* @param defaultExt append an extension if missing one, null to not use * @param defaultExt append an extension if missing one, null to not use
@ -258,14 +258,14 @@ public final class WorldEdit {
* @return a file * @return a file
* @throws FilenameException thrown if the filename is invalid * @throws FilenameException thrown if the filename is invalid
*/ */
public File getSafeOpenFile(Player player, File dir, String filename, String defaultExt, String... extensions) throws FilenameException { public File getSafeOpenFile(Actor actor, File dir, String filename, String defaultExt, String... extensions) throws FilenameException {
return getSafeFile(player, dir, filename, defaultExt, extensions, false); return getSafeFile(actor, dir, filename, defaultExt, extensions, false);
} }
/** /**
* Get a safe path to a file. * Get a safe path to a file.
* *
* @param player the player * @param actor the actor
* @param dir sub-directory to look in * @param dir sub-directory to look in
* @param filename filename (user-submitted) * @param filename filename (user-submitted)
* @param defaultExt append an extension if missing one, null to not use * @param defaultExt append an extension if missing one, null to not use
@ -274,16 +274,16 @@ public final class WorldEdit {
* @return a file * @return a file
* @throws FilenameException thrown if the filename is invalid * @throws FilenameException thrown if the filename is invalid
*/ */
private File getSafeFile(@Nullable Player player, File dir, String filename, String defaultExt, String[] extensions, boolean isSave) throws FilenameException { private File getSafeFile(@Nullable Actor actor, File dir, String filename, String defaultExt, String[] extensions, boolean isSave) throws FilenameException {
if (extensions != null && (extensions.length == 1 && extensions[0] == null)) extensions = null; if (extensions != null && (extensions.length == 1 && extensions[0] == null)) extensions = null;
File f; File f;
if (filename.equals("#") && player != null) { if (filename.equals("#") && actor != null) {
if (isSave) { if (isSave) {
f = player.openFileSaveDialog(extensions); f = actor.openFileSaveDialog(extensions);
} else { } else {
f = player.openFileOpenDialog(extensions); f = actor.openFileOpenDialog(extensions);
} }
if (f == null) { if (f == null) {

Datei anzeigen

@ -31,6 +31,7 @@ import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.internal.anvil.ChunkDeleter; import com.sk89q.worldedit.internal.anvil.ChunkDeleter;
import com.sk89q.worldedit.internal.anvil.ChunkDeletionInfo; import com.sk89q.worldedit.internal.anvil.ChunkDeletionInfo;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
@ -41,6 +42,7 @@ import com.sk89q.worldedit.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.storage.LegacyChunkStore; import com.sk89q.worldedit.world.storage.LegacyChunkStore;
import com.sk89q.worldedit.world.storage.McRegionChunkStore; import com.sk89q.worldedit.world.storage.McRegionChunkStore;
import java.io.File; import java.io.File;
@ -75,7 +77,7 @@ public class ChunkCommands {
) )
@CommandPermissions("worldedit.chunkinfo") @CommandPermissions("worldedit.chunkinfo")
public void chunkInfo(Player player) { public void chunkInfo(Player player) {
Location pos = player.getBlockIn(); Location pos = player.getBlockLocation();
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0); int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0); int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
@ -90,13 +92,13 @@ public class ChunkCommands {
desc = "List chunks that your selection includes" desc = "List chunks that your selection includes"
) )
@CommandPermissions("worldedit.listchunks") @CommandPermissions("worldedit.listchunks")
public void listChunks(Player player, LocalSession session, public void listChunks(Actor actor, World world, LocalSession session,
@ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException { @ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException {
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks(); Set<BlockVector2> chunks = session.getSelection(world).getChunks();
PaginationBox paginationBox = PaginationBox.fromStrings("Selected Chunks", "/listchunks -p %page%", PaginationBox paginationBox = PaginationBox.fromStrings("Selected Chunks", "/listchunks -p %page%",
chunks.stream().map(BlockVector2::toString).collect(Collectors.toList())); chunks.stream().map(BlockVector2::toString).collect(Collectors.toList()));
player.print(paginationBox.create(page)); actor.print(paginationBox.create(page));
} }
@Command( @Command(
@ -105,10 +107,10 @@ public class ChunkCommands {
) )
@CommandPermissions("worldedit.delchunks") @CommandPermissions("worldedit.delchunks")
@Logging(REGION) @Logging(REGION)
public void deleteChunks(Player player, LocalSession session, public void deleteChunks(Actor actor, World world, LocalSession session,
@ArgFlag(name = 'o', desc = "Only delete chunks older than the specified time.", def = "") @ArgFlag(name = 'o', desc = "Only delete chunks older than the specified time.", def = "")
ZonedDateTime beforeTime) throws WorldEditException { ZonedDateTime beforeTime) throws WorldEditException {
Path worldDir = player.getWorld().getStoragePath(); Path worldDir = world.getStoragePath();
if (worldDir == null) { if (worldDir == null) {
throw new StopExecutionException(TextComponent.of("Couldn't find world folder for this world.")); throw new StopExecutionException(TextComponent.of("Couldn't find world folder for this world."));
} }
@ -131,10 +133,10 @@ public class ChunkCommands {
ChunkDeletionInfo.ChunkBatch newBatch = new ChunkDeletionInfo.ChunkBatch(); ChunkDeletionInfo.ChunkBatch newBatch = new ChunkDeletionInfo.ChunkBatch();
newBatch.worldPath = worldDir.toAbsolutePath().normalize().toString(); newBatch.worldPath = worldDir.toAbsolutePath().normalize().toString();
newBatch.backup = true; newBatch.backup = true;
final Region selection = session.getSelection(player.getWorld()); final Region selection = session.getSelection(world);
if (selection instanceof CuboidRegion) { if (selection instanceof CuboidRegion) {
newBatch.minChunk = BlockVector2.at(selection.getMinimumPoint().getBlockX() >> 4, selection.getMinimumPoint().getBlockZ() >> 4); newBatch.minChunk = selection.getMinimumPoint().shr(4).toBlockVector2();
newBatch.maxChunk = BlockVector2.at(selection.getMaximumPoint().getBlockX() >> 4, selection.getMaximumPoint().getBlockZ() >> 4); newBatch.maxChunk = selection.getMaximumPoint().shr(4).toBlockVector2();
} else { } else {
// this has a possibility to OOM for very large selections still // this has a possibility to OOM for very large selections still
Set<BlockVector2> chunks = selection.getChunks(); Set<BlockVector2> chunks = selection.getChunks();
@ -156,13 +158,13 @@ public class ChunkCommands {
throw new StopExecutionException(TextComponent.of("Failed to write chunk list: " + e.getMessage())); throw new StopExecutionException(TextComponent.of("Failed to write chunk list: " + e.getMessage()));
} }
player.print(String.format("%d chunk(s) have been marked for deletion the next time the server starts.", actor.print(String.format("%d chunk(s) have been marked for deletion the next time the server starts.",
newBatch.getChunkCount())); newBatch.getChunkCount()));
if (currentInfo.batches.size() > 1) { if (currentInfo.batches.size() > 1) {
player.printDebug(String.format("%d chunks total marked for deletion. (May have overlaps).", actor.printDebug(String.format("%d chunks total marked for deletion. (May have overlaps).",
currentInfo.batches.stream().mapToInt(ChunkDeletionInfo.ChunkBatch::getChunkCount).sum())); currentInfo.batches.stream().mapToInt(ChunkDeletionInfo.ChunkBatch::getChunkCount).sum()));
} }
player.print(TextComponent.of("You can mark more chunks for deletion, or to stop now, run: ", TextColor.LIGHT_PURPLE) actor.print(TextComponent.of("You can mark more chunks for deletion, or to stop now, run: ", TextColor.LIGHT_PURPLE)
.append(TextComponent.of("/stop", TextColor.AQUA) .append(TextComponent.of("/stop", TextColor.AQUA)
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/stop")))); .clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/stop"))));
} }

Datei anzeigen

@ -19,6 +19,10 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
@ -35,10 +39,6 @@ import com.boydti.fawe.object.schematic.Schematic;
import com.boydti.fawe.util.ImgurUtility; import com.boydti.fawe.util.ImgurUtility;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MaskTraverser; import com.boydti.fawe.util.MaskTraverser;
import static com.google.common.base.Preconditions.checkNotNull;
import org.enginehub.piston.inject.InjectedValueAccess;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
@ -47,8 +47,6 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.extent.PasteEvent; import com.sk89q.worldedit.event.extent.PasteEvent;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
@ -74,12 +72,6 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -91,6 +83,12 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch;
import org.enginehub.piston.inject.InjectedValueAccess;
/** /**
@ -159,7 +157,7 @@ public class ClipboardCommands {
if (!player.hasPermission("fawe.tips")) { if (!player.hasPermission("fawe.tips")) {
BBC.TIP_PASTE.or(BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(player); BBC.TIP_PASTE.or(BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(player);
} }
}, getArguments(context), region, context); }, "/copy", region, context);
} }
@Command( @Command(
@ -283,7 +281,7 @@ public class ClipboardCommands {
if (!player.hasPermission("fawe.tips")) { if (!player.hasPermission("fawe.tips")) {
BBC.TIP_LAZYCUT.send(player); BBC.TIP_LAZYCUT.send(player);
} }
}, getArguments(context), region, context); }, "cut", region, context);
} }

Datei anzeigen

@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL; import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL;
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT; import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION; import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
@ -105,7 +106,7 @@ public class GenerationCommands {
CavesGen gen = new CavesGen(size, frequency, rarity, minY, maxY, systemFrequency, individualRarity, pocketChance, pocketMin, pocketMax); CavesGen gen = new CavesGen(size, frequency, rarity, minY, maxY, systemFrequency, individualRarity, pocketChance, pocketMin, pocketMax);
editSession.generate(region, gen); editSession.generate(region, gen);
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount()); BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
}, getArguments(context), region, context); }, "/caves", region, context);
} }
@ -119,7 +120,7 @@ public class GenerationCommands {
player.checkConfirmationRegion(() -> { player.checkConfirmationRegion(() -> {
editSession.addOres(region, mask); editSession.addOres(region, mask);
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount()); BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
}, getArguments(context), region, context); }, "/ores", region, context);
} }
@Command( @Command(
@ -173,7 +174,7 @@ public class GenerationCommands {
player.checkConfirmationRegion(() -> { player.checkConfirmationRegion(() -> {
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY); editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount()); BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
}, getArguments(context), region, context); }, "/ore", region, context);
} }
@Command( @Command(
@ -195,7 +196,7 @@ public class GenerationCommands {
fp.checkConfirmationRadius(() -> { fp.checkConfirmationRadius(() -> {
int affected = editSession.makeHollowCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), thickness - 1); int affected = editSession.makeHollowCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), thickness - 1);
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(fp, affected);
}, getArguments(context), (int) max, context); }, "/hcyl", (int) max, context);
} }
@Command( @Command(
@ -218,7 +219,7 @@ public class GenerationCommands {
fp.checkConfirmationRadius(() -> { fp.checkConfirmationRadius(() -> {
int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), !hollow); int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), !hollow);
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(fp, affected);
}, getArguments(context), (int) max, context); }, "/cyl", (int) max, context);
} }
@Command( @Command(
@ -260,7 +261,7 @@ public class GenerationCommands {
int affected = editSession.makeSphere(finalPos, pattern, radii.getX(), radii.getY(), radii.getZ(), !hollow); int affected = editSession.makeSphere(finalPos, pattern, radii.getX(), radii.getY(), radii.getZ(), !hollow);
player.findFreePosition(); player.findFreePosition();
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(fp, affected);
}, getArguments(context), (int) max, context); }, "sphere", (int) max, context);
} }
@Command( @Command(
@ -294,8 +295,9 @@ public class GenerationCommands {
int size, int size,
@Arg(desc = "//TODO", def = "10") @Arg(desc = "//TODO", def = "10")
int apothem, int apothem,
@Range(min = 0, max = 100) @Arg(desc = "//TODO ", def = "0.02") @Arg(desc = "//TODO ", def = "0.02")
double density) throws WorldEditException { double density) throws WorldEditException {
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), apothem, density); int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), apothem, density);
BBC.COMMAND_PUMPKIN.send(player, affected); BBC.COMMAND_PUMPKIN.send(player, affected);
return affected; return affected;
@ -335,7 +337,7 @@ public class GenerationCommands {
int affected = editSession.makePyramid(pos, pattern, size, !hollow); int affected = editSession.makePyramid(pos, pattern, size, !hollow);
player.findFreePosition(); player.findFreePosition();
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(fp, affected);
}, getArguments(context), size, context); }, "/pyramid", size, player, editSession);
} }
@Command( @Command(
@ -399,7 +401,7 @@ public class GenerationCommands {
} catch (ExpressionException e) { } catch (ExpressionException e) {
player.printError(e.getMessage()); player.printError(e.getMessage());
} }
}, getArguments(context), region, context); }, "/generate", region, context);
} }
@Command( @Command(
@ -462,7 +464,7 @@ public class GenerationCommands {
} catch (ExpressionException e) { } catch (ExpressionException e) {
fp.printError(e.getMessage()); fp.printError(e.getMessage());
} }
}, getArguments(context), region, context); }, "/generatebiome", region, context);
} }
} }

Datei anzeigen

@ -256,7 +256,7 @@ public class HistoryCommands {
if (undone == null) { if (undone == null) {
BBC.COMMAND_UNDO_ERROR.send(player); BBC.COMMAND_UNDO_ERROR.send(player);
} }
}, getArguments(context), times, 50, context); }, "undo", times, 50, context);
} }
@Command( @Command(

Datei anzeigen

@ -10,11 +10,10 @@ import java.util.UUID;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException; import java.util.regex.PatternSyntaxException;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.exception.StopExecutionException; import org.enginehub.piston.exception.StopExecutionException;
//TODO This class breaks compilation //TODO This class breaks compilation
@CommandContainer //@CommandContainer
public class ListFilters { public class ListFilters {
public class Filter { public class Filter {
public boolean listPrivate() { public boolean listPrivate() {

Datei anzeigen

@ -135,7 +135,7 @@ public class RegionCommands {
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16)); selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
} }
int count = FaweAPI.fixLighting(player.getWorld(), selection,null); int count = FaweAPI.fixLighting(player.getWorld(), selection,null);
BBC.LIGHTING_PROPOGATE_SELECTION.send(fp, count); BBC.LIGHTING_PROPAGATE_SELECTION.send(fp, count);
} }
@Command( @Command(
@ -721,7 +721,7 @@ public class RegionCommands {
Operations.completeLegacy(visitor); Operations.completeLegacy(visitor);
BBC.COMMAND_FLORA.send(player, ground.getAffected()); BBC.COMMAND_FLORA.send(player, ground.getAffected());
}, getArguments(context), region, context); }, "/flora", region, context);
} }
} }

Datei anzeigen

@ -292,7 +292,7 @@ public class SchematicCommands {
desc = "Save a schematic into your clipboard" desc = "Save a schematic into your clipboard"
) )
@CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save", "worldedit.schematic.save.other"}) @CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save", "worldedit.schematic.save.other"})
public void save(Player player, LocalSession session, public void save(Actor actor, LocalSession session,
@Arg(desc = "File name.") @Arg(desc = "File name.")
String filename, String filename,
@Arg(desc = "Format name.", def = "sponge") @Arg(desc = "Format name.", def = "sponge")
@ -307,20 +307,20 @@ public class SchematicCommands {
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir); File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
if (!global && Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS) { if (!global && Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS) {
dir = new File(dir, player.getUniqueId().toString()); dir = new File(dir, actor.getUniqueId().toString());
} }
ClipboardFormat format = ClipboardFormats.findByAlias(formatName); ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
if (format == null) { if (format == null) {
player.printError("Unknown schematic format: " + formatName); actor.printError("Unknown schematic format: " + formatName);
return; return;
} }
boolean other = false; boolean other = false;
if (filename.contains("../")) { if (filename.contains("../")) {
other = true; other = true;
if (!player.hasPermission("worldedit.schematic.save.other")) { if (!actor.hasPermission("worldedit.schematic.save.other")) {
BBC.NO_PERM.send(player, "worldedit.schematic.save.other"); BBC.NO_PERM.send(actor, "worldedit.schematic.save.other");
return; return;
} }
if (filename.startsWith("../")) { if (filename.startsWith("../")) {
@ -329,21 +329,21 @@ public class SchematicCommands {
} }
} }
File f = worldEdit.getSafeSaveFile(player, dir, filename, format.getPrimaryFileExtension()); File f = worldEdit.getSafeSaveFile(actor, dir, filename, format.getPrimaryFileExtension());
boolean overwrite = f.exists(); boolean overwrite = f.exists();
if (overwrite) { if (overwrite) {
if (!player.hasPermission("worldedit.schematic.delete")) { if (!actor.hasPermission("worldedit.schematic.delete")) {
throw new StopExecutionException(TextComponent.of("That schematic already exists!")); throw new StopExecutionException(TextComponent.of("That schematic already exists!"));
} }
if (other) { if (other) {
if (!player.hasPermission("worldedit.schematic.delete.other")) { if (!actor.hasPermission("worldedit.schematic.delete.other")) {
BBC.NO_PERM.send(player, "worldedit.schematic.delete.other"); BBC.NO_PERM.send(player, "worldedit.schematic.delete.other");
return; return;
} }
} }
if (!allowOverwrite) { if (!allowOverwrite) {
player.printError("That schematic already exists. Use the -f flag to overwrite it."); actor.printError("That schematic already exists. Use the -f flag to overwrite it.");
return; return;
} }
} }
@ -359,8 +359,8 @@ public class SchematicCommands {
ClipboardHolder holder = session.getClipboard(); ClipboardHolder holder = session.getClipboard();
SchematicSaveTask task = new SchematicSaveTask(player, f, format, holder, overwrite); SchematicSaveTask task = new SchematicSaveTask(actor, f, format, holder, overwrite);
AsyncCommandBuilder.wrap(task, player) AsyncCommandBuilder.wrap(task, actor)
.registerWithSupervisor(worldEdit.getSupervisor(), "Saving schematic " + filename) .registerWithSupervisor(worldEdit.getSupervisor(), "Saving schematic " + filename)
.sendMessageAfterDelay("(Please wait... saving schematic.)") .sendMessageAfterDelay("(Please wait... saving schematic.)")
.onSuccess(filename + " saved" + (overwrite ? " (overwriting previous file)." : "."), null) .onSuccess(filename + " saved" + (overwrite ? " (overwriting previous file)." : "."), null)
@ -635,12 +635,12 @@ public class SchematicCommands {
} }
private static class SchematicLoadTask implements Callable<ClipboardHolder> { private static class SchematicLoadTask implements Callable<ClipboardHolder> {
private final Player player; private final Actor actor;
private final File file; private final File file;
private final ClipboardFormat format; private final ClipboardFormat format;
SchematicLoadTask(Player player, File file, ClipboardFormat format) { SchematicLoadTask(Actor actor, File file, ClipboardFormat format) {
this.player = player; this.actor = actor;
this.file = file; this.file = file;
this.format = format; this.format = format;
} }
@ -653,21 +653,21 @@ public class SchematicCommands {
ClipboardReader reader = closer.register(format.getReader(bis)); ClipboardReader reader = closer.register(format.getReader(bis));
Clipboard clipboard = reader.read(); Clipboard clipboard = reader.read();
log.info(player.getName() + " loaded " + file.getCanonicalPath()); log.info(actor.getName() + " loaded " + file.getCanonicalPath());
return new ClipboardHolder(clipboard); return new ClipboardHolder(clipboard);
} }
} }
} }
private static class SchematicSaveTask implements Callable<Void> { private static class SchematicSaveTask implements Callable<Void> {
private final Player player; private final Actor actor;
private final File file; private final File file;
private final ClipboardFormat format; private final ClipboardFormat format;
private final ClipboardHolder holder; private final ClipboardHolder holder;
private final boolean overwrite; private final boolean overwrite;
SchematicSaveTask(Player player, File file, ClipboardFormat format, ClipboardHolder holder, boolean overwrite) { SchematicSaveTask(Actor actor, File file, ClipboardFormat format, ClipboardHolder holder, boolean overwrite) {
this.player = player; this.actor = actor;
this.file = file; this.file = file;
this.format = format; this.format = format;
this.holder = holder; this.holder = holder;
@ -700,14 +700,14 @@ public class SchematicCommands {
} }
if (new PlayerSaveClipboardEvent(player, clipboard, uri, file.toURI()).call()) { if (new PlayerSaveClipboardEvent(player, clipboard, uri, file.toURI()).call()) {
if (writer instanceof MinecraftStructure) { if (writer instanceof MinecraftStructure) {
((MinecraftStructure) writer).write(target, player.getName()); ((MinecraftStructure) writer).write(target, actor.getName());
} else { } else {
writer.write(target); writer.write(target);
} }
log.info(player.getName() + " saved " + file.getCanonicalPath()); log.info(actor.getName() + " saved " + file.getCanonicalPath());
BBC.SCHEMATIC_SAVED.send(player, file.getName()); BBC.SCHEMATIC_SAVED.send(actor, file.getName());
} else { } else {
BBC.WORLDEDIT_CANCEL_REASON_MANUAL.send(player); BBC.WORLDEDIT_CANCEL_REASON_MANUAL.send(actor);
} }
} }
return null; return null;

Datei anzeigen

@ -40,6 +40,8 @@ import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Locatable;
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
@ -61,6 +63,7 @@ import com.sk89q.worldedit.regions.selector.RegionSelectorType;
import com.sk89q.worldedit.regions.selector.SphereRegionSelector; import com.sk89q.worldedit.regions.selector.SphereRegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.component.CommandListBox; import com.sk89q.worldedit.util.formatting.component.CommandListBox;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat; import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer; import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
@ -99,23 +102,26 @@ public class SelectionCommands {
) )
@Logging(POSITION) @Logging(POSITION)
@CommandPermissions("worldedit.selection.pos") @CommandPermissions("worldedit.selection.pos")
public void pos1(Player player, LocalSession session, public void pos1(Actor actor, World world, LocalSession session,
@Arg(desc = "Coordinates to set position 1 to", def = "") @Arg(desc = "Coordinates to set position 1 to", def = "")
BlockVector3 coordinates) throws WorldEditException { BlockVector3 coordinates) throws WorldEditException {
BlockVector3 pos; Location pos;
if (coordinates != null) { if (coordinates != null) {
pos = coordinates; pos = new Location(world, coordinates.toVector3());
} else if (actor instanceof Locatable) {
pos = ((Locatable) actor).getBlockLocation();
} else { } else {
pos = player.getBlockIn().toBlockPoint(); actor.printError("You must provide coordinates as console.");
}
pos = pos.clampY(0, player.getWorld().getMaximumPoint().getBlockY());
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) {
BBC.SELECTOR_ALREADY_SET.send(player);
return; return;
} }
session.getRegionSelector(player.getWorld()) if (!session.getRegionSelector(world).selectPrimary(pos.toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
.explainPrimarySelection(player, session, pos); BBC.SELECTOR_ALREADY_SET.send(actor);
return;
}
session.getRegionSelector(world)
.explainPrimarySelection(actor, session, pos.toBlockPoint());
} }
@Command( @Command(
@ -124,23 +130,25 @@ public class SelectionCommands {
) )
@Logging(POSITION) @Logging(POSITION)
@CommandPermissions("worldedit.selection.pos") @CommandPermissions("worldedit.selection.pos")
public void pos2(Player player, LocalSession session, public void pos2(Actor actor, World world, LocalSession session,
@Arg(desc = "Coordinates to set position 2 to", def = "") @Arg(desc = "Coordinates to set position 2 to", def = "")
BlockVector3 coordinates) throws WorldEditException { BlockVector3 coordinates) throws WorldEditException {
BlockVector3 pos; Location pos;
if (coordinates != null) { if (coordinates != null) {
pos = coordinates; pos = new Location(world, coordinates.toVector3());
} else if (actor instanceof Locatable) {
pos = ((Locatable) actor).getBlockLocation();
} else { } else {
pos = player.getBlockIn().toBlockPoint(); actor.printError("You must provide coordinates as console.");
return;
} }
pos = pos.clampY(0, player.getWorld().getMaximumPoint().getBlockY()); if (!session.getRegionSelector(world).selectSecondary(pos.toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) { BBC.SELECTOR_ALREADY_SET.send(actor);
BBC.SELECTOR_ALREADY_SET.send(player);
return; return;
} }
session.getRegionSelector(player.getWorld()) session.getRegionSelector(world)
.explainSecondarySelection(player, session, pos); .explainSecondarySelection(actor, session, pos.toBlockPoint());
} }
@Command( @Command(
@ -222,7 +230,7 @@ public class SelectionCommands {
: ChunkStore.toChunk(coordinates.toBlockVector3()); : ChunkStore.toChunk(coordinates.toBlockVector3());
} else { } else {
// use player loc // use player loc
min2D = ChunkStore.toChunk(player.getBlockIn().toBlockPoint()); min2D = ChunkStore.toChunk(player.getBlockLocation().toBlockPoint());
} }
min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16); min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
@ -296,7 +304,7 @@ public class SelectionCommands {
) )
@Logging(REGION) @Logging(REGION)
@CommandPermissions("worldedit.selection.contract") @CommandPermissions("worldedit.selection.contract")
public void contract(Player player, LocalSession session, public void contract(Actor actor, World world, LocalSession session,
@Arg(desc = "Amount to contract the selection by") @Arg(desc = "Amount to contract the selection by")
int amount, int amount,
@Arg(desc = "Amount to contract the selection by in the other direction", def = "0") @Arg(desc = "Amount to contract the selection by in the other direction", def = "0")
@ -305,7 +313,7 @@ public class SelectionCommands {
@MultiDirection @MultiDirection
List<BlockVector3> direction) throws WorldEditException { List<BlockVector3> direction) throws WorldEditException {
try { try {
Region region = session.getSelection(player.getWorld()); Region region = session.getSelection(world);
int oldSize = region.getArea(); int oldSize = region.getArea();
if (reverseAmount == 0) { if (reverseAmount == 0) {
for (BlockVector3 dir : direction) { for (BlockVector3 dir : direction) {
@ -316,15 +324,15 @@ public class SelectionCommands {
region.contract(dir.multiply(amount), dir.multiply(-reverseAmount)); region.contract(dir.multiply(amount), dir.multiply(-reverseAmount));
} }
} }
session.getRegionSelector(player.getWorld()).learnChanges(); session.getRegionSelector(world).learnChanges();
int newSize = region.getArea(); int newSize = region.getArea();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); session.getRegionSelector(world).explainRegionAdjust(actor, session);
BBC.SELECTION_CONTRACT.send(player, (oldSize - newSize)); BBC.SELECTION_CONTRACT.send(actor, (oldSize - newSize));
} catch (RegionOperationException e) { } catch (RegionOperationException e) {
player.printError(e.getMessage()); actor.printError(e.getMessage());
} }
} }
@ -334,26 +342,26 @@ public class SelectionCommands {
) )
@Logging(REGION) @Logging(REGION)
@CommandPermissions("worldedit.selection.shift") @CommandPermissions("worldedit.selection.shift")
public void shift(Player player, LocalSession session, public void shift(Actor actor, World world, LocalSession session,
@Arg(desc = "Amount to shift the selection by") @Arg(desc = "Amount to shift the selection by")
int amount, int amount,
@Arg(desc = "Direction to contract", def = Direction.AIM) @Arg(desc = "Direction to contract", def = Direction.AIM)
@MultiDirection @MultiDirection
List<BlockVector3> direction) throws WorldEditException { List<BlockVector3> direction) throws WorldEditException {
try { try {
Region region = session.getSelection(player.getWorld()); Region region = session.getSelection(world);
for (BlockVector3 dir : direction) { for (BlockVector3 dir : direction) {
region.shift(dir.multiply(amount)); region.shift(dir.multiply(amount));
} }
session.getRegionSelector(player.getWorld()).learnChanges(); session.getRegionSelector(world).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); session.getRegionSelector(world).explainRegionAdjust(actor, session);
BBC.SELECTION_SHIFT.send(player); BBC.SELECTION_SHIFT.send(actor);
} catch (RegionOperationException e) { } catch (RegionOperationException e) {
player.printError(e.getMessage()); actor.printError(e.getMessage());
} }
} }
@ -363,18 +371,18 @@ public class SelectionCommands {
) )
@Logging(REGION) @Logging(REGION)
@CommandPermissions("worldedit.selection.outset") @CommandPermissions("worldedit.selection.outset")
public void outset(Player player, LocalSession session, public void outset(Actor actor, World world, LocalSession session,
@Arg(desc = "Amount to expand the selection by in all directions") @Arg(desc = "Amount to expand the selection by in all directions")
int amount, int amount,
@Switch(name = 'h', desc = "Only expand horizontally") @Switch(name = 'h', desc = "Only expand horizontally")
boolean onlyHorizontal, boolean onlyHorizontal,
@Switch(name = 'v', desc = "Only expand vertically") @Switch(name = 'v', desc = "Only expand vertically")
boolean onlyVertical) throws WorldEditException { boolean onlyVertical) throws WorldEditException {
Region region = session.getSelection(player.getWorld()); Region region = session.getSelection(world);
region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical)); region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
session.getRegionSelector(player.getWorld()).learnChanges(); session.getRegionSelector(world).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); session.getRegionSelector(world).explainRegionAdjust(actor, session);
BBC.SELECTION_OUTSET.send(player); BBC.SELECTION_OUTSET.send(actor);
} }
@Command( @Command(
@ -383,18 +391,18 @@ public class SelectionCommands {
) )
@Logging(REGION) @Logging(REGION)
@CommandPermissions("worldedit.selection.inset") @CommandPermissions("worldedit.selection.inset")
public void inset(Player player, LocalSession session, public void inset(Actor actor, World world, LocalSession session,
@Arg(desc = "Amount to contract the selection by in all directions") @Arg(desc = "Amount to contract the selection by in all directions")
int amount, int amount,
@Switch(name = 'h', desc = "Only contract horizontally") @Switch(name = 'h', desc = "Only contract horizontally")
boolean onlyHorizontal, boolean onlyHorizontal,
@Switch(name = 'v', desc = "Only contract vertically") @Switch(name = 'v', desc = "Only contract vertically")
boolean onlyVertical) throws WorldEditException { boolean onlyVertical) throws WorldEditException {
Region region = session.getSelection(player.getWorld()); Region region = session.getSelection(world);
region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical)); region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
session.getRegionSelector(player.getWorld()).learnChanges(); session.getRegionSelector(world).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); session.getRegionSelector(world).explainRegionAdjust(actor, session);
BBC.SELECTION_INSET.send(player); actor.print("Region inset.");
} }
private BlockVector3[] getChangesForEachDir(int amount, boolean onlyHorizontal, boolean onlyVertical) { private BlockVector3[] getChangesForEachDir(int amount, boolean onlyHorizontal, boolean onlyVertical) {
@ -544,17 +552,16 @@ public class SelectionCommands {
aliases = { ";", "/desel", "/deselect" }, aliases = { ";", "/desel", "/deselect" },
desc = "Choose a region selector" desc = "Choose a region selector"
) )
public void select(Player player, LocalSession session, EditSession editSession, public void select(Actor actor, World world, LocalSession session, EditSession editSession,
@Arg(desc = "Selector to switch to", def = "") @Arg(desc = "Selector to switch to", def = "")
SelectorChoice selector, SelectorChoice selector,
@Arg(desc = "Selector mask", def = "") Mask mask, @Arg(desc = "Selector mask", def = "") Mask mask,
@Switch(name = 'd', desc = "Set default selector") @Switch(name = 'd', desc = "Set default selector")
boolean setDefaultSelector) throws WorldEditException { boolean setDefaultSelector) throws WorldEditException {
final World world = player.getWorld();
if (selector == null) { if (selector == null) {
session.getRegionSelector(world).clear(); session.getRegionSelector(world).clear();
session.dispatchCUISelection(player); session.dispatchCUISelection(actor);
BBC.SELECTION_CLEARED.send(player); BBC.SELECTION_CLEARED.send(actor);
return; return;
} }
@ -564,55 +571,56 @@ public class SelectionCommands {
switch (selector) { switch (selector) {
case CUBOID: case CUBOID:
newSelector = new CuboidRegionSelector(oldSelector); newSelector = new CuboidRegionSelector(oldSelector);
player.print(BBC.SEL_CUBOID.s()); actor.print(BBC.SEL_CUBOID.s());
break; break;
case EXTEND: case EXTEND:
newSelector = new ExtendingCuboidRegionSelector(oldSelector); newSelector = new ExtendingCuboidRegionSelector(oldSelector);
player.print(BBC.SEL_CUBOID_EXTEND.s()); actor.print(BBC.SEL_CUBOID_EXTEND.s());
break; break;
case POLY: { case POLY: {
newSelector = new Polygonal2DRegionSelector(oldSelector); newSelector = new Polygonal2DRegionSelector(oldSelector);
player.print(BBC.SEL_2D_POLYGON.s()); actor.print(BBC.SEL_2D_POLYGON.s());
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolygonVertexLimit(); Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolygonVertexLimit();
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.format(integer))); limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer)));
break; break;
} }
case ELLIPSOID: case ELLIPSOID:
newSelector = new EllipsoidRegionSelector(oldSelector); newSelector = new EllipsoidRegionSelector(oldSelector);
player.print(BBC.SEL_ELLIPSIOD.s()); actor.print(BBC.SAL_ELLIPSOID.s());
break; break;
case SPHERE: case SPHERE:
newSelector = new SphereRegionSelector(oldSelector); newSelector = new SphereRegionSelector(oldSelector);
player.print(BBC.SEL_SPHERE.s()); actor.print(BBC.SEL_SPHERE.s());
break; break;
case CYL: case CYL:
newSelector = new CylinderRegionSelector(oldSelector); newSelector = new CylinderRegionSelector(oldSelector);
player.print(BBC.SEL_CYLINDRICAL.s()); actor.print(BBC.SEL_CYLINDRICAL.s());
break; break;
case CONVEX: case CONVEX:
case HULL: case HULL:
case POLYHEDRON: { case POLYHEDRON: {
newSelector = new ConvexPolyhedralRegionSelector(oldSelector); newSelector = new ConvexPolyhedralRegionSelector(oldSelector);
player.print(BBC.SEL_CONVEX_POLYHEDRAL.s()); actor.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit(); Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.format(integer))); limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer)));
break; break;
} }
case POLYHEDRAL: case POLYHEDRAL:
newSelector = new PolyhedralRegionSelector(player.getWorld()); newSelector = new PolyhedralRegionSelector(world);
player.print(BBC.SEL_CONVEX_POLYHEDRAL.s()); actor.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit(); Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.format(integer))); limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer)));
player.print(BBC.SEL_LIST.s()); actor.print(BBC.SEL_LIST.s());
break; break;
case FUZZY: case FUZZY:
case MAGIC: case MAGIC:
if (mask == null) { if (mask == null) {
mask = new IdMask(world); mask = new IdMask(world);
} }
newSelector = new FuzzyRegionSelector(player, editSession, mask); //TODO Make FuzzyRegionSelector accept actors
player.print(BBC.SEL_FUZZY.s()); newSelector = new FuzzyRegionSelector((Player) actor, editSession, mask);
player.print(BBC.SEL_LIST.s()); actor.print(BBC.SEL_FUZZY.s());
actor.print(BBC.SEL_LIST.s());
break; break;
case LIST: case LIST:
default: default:
@ -631,7 +639,7 @@ public class SelectionCommands {
box.appendCommand("polyhedral", "Select a hollow polyhedral", "//sel polyhedral"); box.appendCommand("polyhedral", "Select a hollow polyhedral", "//sel polyhedral");
box.appendCommand("fuzzy[=<mask>]", "Select all connected blocks (magic wand)", "//sel fuzzy[=<mask>]"); box.appendCommand("fuzzy[=<mask>]", "Select all connected blocks (magic wand)", "//sel fuzzy[=<mask>]");
player.print(box.create(1)); actor.print(box.create(1));
return; return;
} }
@ -646,14 +654,14 @@ public class SelectionCommands {
if (found != null) { if (found != null) {
session.setDefaultRegionSelector(found); session.setDefaultRegionSelector(found);
BBC.SELECTOR_SET_DEFAULT.send(player, found.name()); BBC.SELECTOR_SET_DEFAULT.send(actor, found.name());
} else { } else {
throw new RuntimeException("Something unexpected happened. Please report this."); throw new RuntimeException("Something unexpected happened. Please report this.");
} }
} }
session.setRegionSelector(world, newSelector); session.setRegionSelector(world, newSelector);
session.dispatchCUISelection(player); session.dispatchCUISelection(actor);
} }
} }

Datei anzeigen

@ -29,12 +29,14 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.formatting.component.PaginationBox; import com.sk89q.worldedit.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException; import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
import com.sk89q.worldedit.world.snapshot.Snapshot; import com.sk89q.worldedit.world.snapshot.Snapshot;
import com.sk89q.worldedit.world.storage.MissingWorldException; import com.sk89q.worldedit.world.storage.MissingWorldException;
@ -67,24 +69,24 @@ public class SnapshotCommands {
desc = "List snapshots" desc = "List snapshots"
) )
@CommandPermissions("worldedit.snapshots.list") @CommandPermissions("worldedit.snapshots.list")
public void list(Player player, public void list(Actor actor, World world,
@ArgFlag(name = 'p', desc = "Page of results to return", def = "1") @ArgFlag(name = 'p', desc = "Page of results to return", def = "1")
int page) throws WorldEditException { int page) throws WorldEditException {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) { if (config.snapshotRepo == null) {
BBC.SNAPSHOT_NOT_CONFIGURED.send(player); BBC.SNAPSHOT_NOT_CONFIGURED.send(actor);
return; return;
} }
try { try {
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName()); List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, world.getName());
if (!snapshots.isEmpty()) { if (!snapshots.isEmpty()) {
player.print(new SnapshotListBox(player.getWorld().getName(), snapshots).create(page)); actor.print(new SnapshotListBox(world.getName(), snapshots).create(page));
} else { } else {
BBC.SNAPSHOT_NOT_AVAILABLE.send(player); BBC.SNAPSHOT_NOT_AVAILABLE.send(actor);
// Okay, let's toss some debugging information! // Okay, let's toss some debugging information!
File dir = config.snapshotRepo.getDirectory(); File dir = config.snapshotRepo.getDirectory();
@ -99,7 +101,7 @@ public class SnapshotCommands {
} }
} }
} catch (MissingWorldException ex) { } catch (MissingWorldException ex) {
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player); BBC.SNAPSHOT_NOT_FOUND_WORLD.send(actor);
} }
} }
@ -108,37 +110,37 @@ public class SnapshotCommands {
desc = "Choose a snapshot to use" desc = "Choose a snapshot to use"
) )
@CommandPermissions("worldedit.snapshots.restore") @CommandPermissions("worldedit.snapshots.restore")
public void use(Player player, LocalSession session, public void use(Actor actor, World world, LocalSession session,
@Arg(desc = "Snapeshot to use") @Arg(desc = "Snapshot to use")
String name) throws WorldEditException { String name) throws WorldEditException {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) { if (config.snapshotRepo == null) {
BBC.SNAPSHOT_NOT_CONFIGURED.send(player); BBC.SNAPSHOT_NOT_CONFIGURED.send(actor);
return; return;
} }
// Want the latest snapshot? // Want the latest snapshot?
if (name.equalsIgnoreCase("latest")) { if (name.equalsIgnoreCase("latest")) {
try { try {
Snapshot snapshot = config.snapshotRepo.getDefaultSnapshot(player.getWorld().getName()); Snapshot snapshot = config.snapshotRepo.getDefaultSnapshot(world.getName());
if (snapshot != null) { if (snapshot != null) {
session.setSnapshot(null); session.setSnapshot(null);
BBC.SNAPSHOT_NEWEST.send(player); BBC.SNAPSHOT_NEWEST.send(actor);
} else { } else {
BBC.SNAPSHOT_NOT_FOUND.send(player); BBC.SNAPSHOT_NOT_FOUND.send(actor);
} }
} catch (MissingWorldException ex) { } catch (MissingWorldException ex) {
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player); BBC.SNAPSHOT_NOT_FOUND_WORLD.send(actor);
} }
} else { } else {
try { try {
session.setSnapshot(config.snapshotRepo.getSnapshot(name)); session.setSnapshot(config.snapshotRepo.getSnapshot(name));
BBC.SNAPSHOT_SET.send(player, name); BBC.SNAPSHOT_SET.send(actor, name);
} catch (InvalidSnapshotException e) { } catch (InvalidSnapshotException e) {
BBC.SNAPSHOT_NOT_AVAILABLE.send(player); BBC.SNAPSHOT_NOT_AVAILABLE.send(actor);
} }
} }
} }

Datei anzeigen

@ -30,9 +30,10 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException; import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
import com.sk89q.worldedit.world.snapshot.Snapshot; import com.sk89q.worldedit.world.snapshot.Snapshot;
import com.sk89q.worldedit.world.snapshot.SnapshotRestore; import com.sk89q.worldedit.world.snapshot.SnapshotRestore;
@ -60,25 +61,25 @@ public class SnapshotUtilCommands {
) )
@Logging(REGION) @Logging(REGION)
@CommandPermissions("worldedit.snapshots.restore") @CommandPermissions("worldedit.snapshots.restore")
public void restore(Player player, LocalSession session, EditSession editSession, public void restore(Actor actor, World world, LocalSession session, EditSession editSession,
@Arg(name = "snapshot", desc = "The snapshot to restore", def = "") @Arg(name = "snapshot", desc = "The snapshot to restore", def = "")
String snapshotName) throws WorldEditException { String snapshotName) throws WorldEditException {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) { if (config.snapshotRepo == null) {
BBC.SNAPSHOT_NOT_CONFIGURED.send(player); BBC.SNAPSHOT_NOT_CONFIGURED.send(actor);
return; return;
} }
Region region = session.getSelection(player.getWorld()); Region region = session.getSelection(world);
Snapshot snapshot; Snapshot snapshot;
if (snapshotName != null) { if (snapshotName != null) {
try { try {
snapshot = config.snapshotRepo.getSnapshot(snapshotName); snapshot = config.snapshotRepo.getSnapshot(snapshotName);
} catch (InvalidSnapshotException e) { } catch (InvalidSnapshotException e) {
BBC.SNAPSHOT_NOT_AVAILABLE.send(player); BBC.SNAPSHOT_NOT_AVAILABLE.send(actor);
return; return;
} }
} else { } else {
@ -88,10 +89,10 @@ public class SnapshotUtilCommands {
// No snapshot set? // No snapshot set?
if (snapshot == null) { if (snapshot == null) {
try { try {
snapshot = config.snapshotRepo.getDefaultSnapshot(player.getWorld().getName()); snapshot = config.snapshotRepo.getDefaultSnapshot(world.getName());
if (snapshot == null) { if (snapshot == null) {
BBC.SNAPSHOT_NOT_AVAILABLE.send(player); BBC.SNAPSHOT_NOT_AVAILABLE.send(actor);
// Okay, let's toss some debugging information! // Okay, let's toss some debugging information!
File dir = config.snapshotRepo.getDirectory(); File dir = config.snapshotRepo.getDirectory();
@ -108,7 +109,7 @@ public class SnapshotUtilCommands {
return; return;
} }
} catch (MissingWorldException ex) { } catch (MissingWorldException ex) {
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player); BBC.SNAPSHOT_NOT_FOUND_WORLD.send(actor);
return; return;
} }
} }
@ -116,7 +117,7 @@ public class SnapshotUtilCommands {
// Load chunk store // Load chunk store
try (ChunkStore chunkStore = snapshot.getChunkStore()) { try (ChunkStore chunkStore = snapshot.getChunkStore()) {
BBC.SNAPSHOT_LOADED.send(player, snapshot.getName()); BBC.SNAPSHOT_LOADED.send(actor, snapshot.getName());
// Restore snapshot // Restore snapshot
SnapshotRestore restore = new SnapshotRestore(chunkStore, editSession, region); SnapshotRestore restore = new SnapshotRestore(chunkStore, editSession, region);
@ -127,21 +128,20 @@ public class SnapshotUtilCommands {
if (restore.hadTotalFailure()) { if (restore.hadTotalFailure()) {
String error = restore.getLastErrorMessage(); String error = restore.getLastErrorMessage();
if (!restore.getMissingChunks().isEmpty()) { if (!restore.getMissingChunks().isEmpty()) {
BBC.SNAPSHOT_ERROR_RESTORE.send(player); BBC.SNAPSHOT_ERROR_RESTORE.send(actor);
} else if (error != null) { } else if (error != null) {
player.printError("Errors prevented any blocks from being restored."); actor.printError("Errors prevented any blocks from being restored.");
player.printError("Last error: " + error); actor.printError("Last error: " + error);
} else { } else {
BBC.SNAPSHOT_ERROR_RESTORE_CHUNKS.send(player); BBC.SNAPSHOT_ERROR_RESTORE_CHUNKS.send(actor);
} }
} else { } else {
player.print(String.format("Restored; %d " actor.print(String.format("Restored; %d missing chunks and %d other errors.",
+ "missing chunks and %d other errors.",
restore.getMissingChunks().size(), restore.getMissingChunks().size(),
restore.getErrorChunks().size())); restore.getErrorChunks().size()));
} }
} catch (DataException | IOException e) { } catch (DataException | IOException e) {
player.printError("Failed to load snapshot: " + e.getMessage()); actor.printError("Failed to load snapshot: " + e.getMessage());
} }
} }
} }

Datei anzeigen

@ -785,10 +785,10 @@ public class UtilityCommands {
actor.print(m.build()); actor.print(m.build());
} }
public static int getFiles(File root, Actor actor, InjectedValueAccess args, int page, int perPage, String formatName, boolean playerFolder, Consumer<File> forEachFile, ListFilters... filters) { // public static int getFiles(File root, Actor actor, InjectedValueAccess args, int page, int perPage, String formatName, boolean playerFolder, Consumer<File> forEachFile, ListFilters... filters) {
// TODO NOT IMPLEMENTED replace getFiles // // TODO NOT IMPLEMENTED replace getFiles
return page; // return page;
} // }
public static int getFiles(File dir, Actor actor, InjectedValueAccess args, @Range(min = 0) int page, int perPage, String formatName, boolean playerFolder, Consumer<File> forEachFile) { public static int getFiles(File dir, Actor actor, InjectedValueAccess args, @Range(min = 0) int page, int perPage, String formatName, boolean playerFolder, Consumer<File> forEachFile) {
Consumer<File> rootFunction = forEachFile; Consumer<File> rootFunction = forEachFile;

Datei anzeigen

@ -36,6 +36,7 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent; import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.NoCapablePlatformException;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extension.platform.PlatformManager; import com.sk89q.worldedit.extension.platform.PlatformManager;
import java.io.IOException; import java.io.IOException;
@ -98,8 +99,13 @@ public class WorldEditCommands {
actor.printDebug("----------- Capabilities -----------"); actor.printDebug("----------- Capabilities -----------");
for (Capability capability : Capability.values()) { for (Capability capability : Capability.values()) {
Platform platform = pm.queryCapability(capability); try {
actor.printDebug(String.format("%s: %s", capability.name(), platform != null ? platform.getPlatformName() : "NONE")); Platform platform = pm.queryCapability(capability);
actor.printDebug(String.format("%s: %s", capability.name(),
platform != null ? platform.getPlatformName() : "NONE"));
} catch (NoCapablePlatformException e) {
actor.printDebug(String.format("%s: %s", capability.name(), "NONE"));
}
} }
actor.printDebug(""); actor.printDebug("");
actor.printDebug("Wiki: " + "https://github.com/boy0001/FastAsyncWorldedit/wiki"); actor.printDebug("Wiki: " + "https://github.com/boy0001/FastAsyncWorldedit/wiki");
@ -120,7 +126,7 @@ public class WorldEditCommands {
@Command( @Command(
name = "report", name = "report",
aliases = { "debugpaste" }, aliases = { "debugpaste" },
desc = "Writes a report of latest.log, config.yml, message.yml and your commands.yml to https://athion.net/ISPaster/paste" desc = "Writes a report of latest.log, config.yml, message.yml https://athion.net/ISPaster/paste"
) )
@CommandQueued(false) @CommandQueued(false)
@CommandPermissions({"worldedit.report", "worldedit.debugpaste"}) @CommandPermissions({"worldedit.report", "worldedit.debugpaste"})
@ -162,19 +168,19 @@ public class WorldEditCommands {
name = "tz", name = "tz",
desc = "Set your timezone for snapshots" desc = "Set your timezone for snapshots"
) )
public void tz(Player player, LocalSession session, public void tz(Actor actor, LocalSession session,
@Arg(desc = "The timezone to set") @Arg(desc = "The timezone to set")
String timezone) { String timezone) {
try { try {
ZoneId tz = ZoneId.of(timezone); ZoneId tz = ZoneId.of(timezone);
session.setTimezone(tz); session.setTimezone(tz);
BBC.TIMEZONE_SET.send(player, tz.getDisplayName( BBC.TIMEZONE_SET.send(actor, tz.getDisplayName(
TextStyle.FULL, Locale.ENGLISH TextStyle.FULL, Locale.ENGLISH
)); ));
BBC.TIMEZONE_DISPLAY BBC.TIMEZONE_DISPLAY
.send(player, dateFormat.format(ZonedDateTime.now(tz))); .send(actor, dateFormat.format(ZonedDateTime.now(tz)));
} catch (ZoneRulesException e) { } catch (ZoneRulesException e) {
player.printError("Invalid timezone"); actor.printError("Invalid timezone");
} }
} }

Datei anzeigen

@ -19,11 +19,10 @@
package com.sk89q.worldedit.entity; package com.sk89q.worldedit.entity;
import com.sk89q.worldedit.extension.platform.Locatable;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.util.Faceted; import com.sk89q.worldedit.util.Faceted;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityType;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
@ -34,7 +33,7 @@ import javax.annotation.Nullable;
* instance of an entity, but a {@link BaseEntity} can be created from * instance of an entity, but a {@link BaseEntity} can be created from
* this entity by calling {@link #getState()}.</p> * this entity by calling {@link #getState()}.</p>
*/ */
public interface Entity extends Faceted { public interface Entity extends Faceted, Locatable {
/** /**
* Get a copy of the entity's state. * Get a copy of the entity's state.
@ -48,33 +47,11 @@ public interface Entity extends Faceted {
@Nullable @Nullable
BaseEntity getState(); 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() { default EntityType getType() {
BaseEntity state = getState(); BaseEntity state = getState();
return state != null ? state.getType() : null; 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. * Remove this entity from it container.
* *

Datei anzeigen

@ -191,8 +191,12 @@ public interface Player extends Entity, Actor {
* Get the point of the block that is being stood in. * Get the point of the block that is being stood in.
* *
* @return point * @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. * Get the point of the block that is being stood upon.

Datei anzeigen

@ -198,7 +198,7 @@ public class DefaultMaskParser extends FaweParser<Mask> {
String suggestion = suggestions.get(i); String suggestion = suggestions.get(i);
if (suggestion.indexOf(' ') != 0) { if (suggestion.indexOf(' ') != 0) {
String[] split = suggestion.split(" "); String[] split = suggestion.split(" ");
suggestion = BBC.color("[" + StringMan.join(split, "][") + "]"); suggestion = "[" + StringMan.join(split, "][") + "]";
suggestions.set(i, suggestion); suggestions.set(i, suggestion);
} }
} }

Datei anzeigen

@ -161,7 +161,7 @@ public class DefaultPatternParser extends FaweParser<Pattern> {
String suggestion = suggestions.get(i); String suggestion = suggestions.get(i);
if (suggestion.indexOf(' ') != 0) { if (suggestion.indexOf(' ') != 0) {
String[] split = suggestion.split(" "); String[] split = suggestion.split(" ");
suggestion = BBC.color("[" + StringMan.join(split, "][") + "]"); suggestion = "[" + StringMan.join(split, "][") + "]";
suggestions.set(i, suggestion); suggestions.set(i, suggestion);
} }
} }

Datei anzeigen

@ -0,0 +1,51 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extension.platform;
import com.sk89q.worldedit.internal.cui.CUIEvent;
import java.io.File;
public abstract class AbstractNonPlayerActor implements Actor {
@Override
public boolean canDestroyBedrock() {
return true;
}
@Override
public boolean isPlayer() {
return false;
}
@Override
public File openFileOpenDialog(String[] extensions) {
return null;
}
@Override
public File openFileSaveDialog(String[] extensions) {
return null;
}
@Override
public void dispatchCUIEvent(CUIEvent event) {
}
}

Datei anzeigen

@ -19,7 +19,10 @@
package com.sk89q.worldedit.extension.platform; 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.NotABlockException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent; 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.Location;
import com.sk89q.worldedit.util.TargetBlock; import com.sk89q.worldedit.util.TargetBlock;
import com.sk89q.worldedit.util.auth.AuthorizationException; 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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; 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.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
import java.io.File; import java.io.File;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
* An abstract implementation of both a {@link Actor} and a {@link Player} that is intended for * An abstract implementation of both a {@link Actor} and a {@link Player}
* implementations of WorldEdit to use to wrap players that make use of WorldEdit. * 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 { public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@ -151,12 +155,12 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public void findFreePosition() { public void findFreePosition() {
findFreePosition(getBlockIn()); findFreePosition(getBlockLocation());
} }
@Override @Override
public boolean ascendLevel() { public boolean ascendLevel() {
final Location pos = getBlockIn(); final Location pos = getBlockLocation();
final int x = pos.getBlockX(); final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY()); int y = Math.max(0, pos.getBlockY());
final int z = pos.getBlockZ(); final int z = pos.getBlockZ();
@ -214,7 +218,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public boolean descendLevel() { public boolean descendLevel() {
final Location pos = getBlockIn(); final Location pos = getBlockLocation();
final int x = pos.getBlockX(); final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY()); int y = Math.max(0, pos.getBlockY());
final int z = pos.getBlockZ(); final int z = pos.getBlockZ();
@ -277,7 +281,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public boolean ascendToCeiling(int clearance, boolean alwaysGlass) { public boolean ascendToCeiling(int clearance, boolean alwaysGlass) {
Location pos = getBlockIn(); Location pos = getBlockLocation();
int x = pos.getBlockX(); int x = pos.getBlockX();
int initialY = Math.max(0, pos.getBlockY()); int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 2); 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() if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial()
.isMovementBlocker()) { .isMovementBlocker()) {
int platformY = Math.max(initialY, y - 3 - clearance); 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); floatAt(x, platformY + 1, z, alwaysGlass);
return true; return true;
} }
@ -311,7 +322,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public boolean ascendUpwards(int distance, boolean alwaysGlass) { public boolean ascendUpwards(int distance, boolean alwaysGlass) {
final Location pos = getBlockIn(); final Location pos = getBlockLocation();
final int x = pos.getBlockX(); final int x = pos.getBlockX();
final int initialY = Math.max(0, pos.getBlockY()); final int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 1); int y = Math.max(0, pos.getBlockY() + 1);
@ -338,27 +349,41 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public void floatAt(int x, int y, int z, boolean alwaysGlass) { public void floatAt(int x, int y, int z, boolean alwaysGlass) {
try { if (alwaysGlass || !isAllowedToFly()) {
BlockVector3 spot = BlockVector3.at(x, y - 1, z); BlockVector3 spot = BlockVector3.at(x, y - 1, z);
if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial() final World world = getWorld();
.isMovementBlocker()) { if (!world.getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) {
getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState()); 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)); setPosition(Vector3.at(x + 0.5, y, z + 0.5));
} }
@Override /**
public Location getBlockIn() { * Check whether the player is allowed to fly.
return getLocation().setPosition(getLocation().toVector().floor()); *
* @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 @Override
public Location getBlockOn() { public Location getBlockOn() {
return getLocation() return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor());
.setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor());
} }
@Override @Override
@ -407,15 +432,16 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public Direction getCardinalDirection(int yawOffset) { public Direction getCardinalDirection(int yawOffset) {
if (getLocation().getPitch() > 67.5) { final Location location = getLocation();
if (location.getPitch() > 67.5) {
return Direction.DOWN; return Direction.DOWN;
} }
if (getLocation().getPitch() < -67.5) { if (location.getPitch() < -67.5) {
return Direction.UP; return Direction.UP;
} }
// From hey0's code // 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) { if (rot < 0) {
rot += 360.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. * Advances the block target block until the current block is a wall
* * @return true if a wall is found
* @return yaw
*/ */
private boolean advanceToWall(TargetBlock hitBlox) {
@Override Location curBlock;
public boolean passThroughForwardWall(int range) { while ((curBlock = hitBlox.getCurrentBlock()) != null) {
int searchDist = 0; if (!canPassThroughBlock(curBlock)) {
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);
return true; return true;
} }
inFree = free; hitBlox.getNextBlock();
} }
return false; 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 @Override
public void setPosition(Vector3 pos) { public void setPosition(Vector3 pos) {

Datei anzeigen

@ -0,0 +1,69 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extension.platform;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Location;
public interface Locatable {
/**
* Get the location of this actor.
*
* @return the location of the actor
*/
Location getLocation();
/**
* Get the location of this actor in block coordinates.
*
* @return the block location of the actor
*/
default Location getBlockLocation() {
Location location = getLocation();
return location.setPosition(location.toVector().floor());
}
/**
* Sets the location of this actor.
*
* @param location the new location of the actor
* @return if the teleport succeeded
*/
boolean setLocation(Location location);
/**
* Sets the position of this actor.
*
* @param pos where to move them
*/
default void setPosition(Vector3 pos) {
setLocation(new Location(getExtent(), pos));
}
/**
* Get the extent that this actor is in.
*
* @return the extent
*/
Extent getExtent();
}

Datei anzeigen

@ -411,11 +411,6 @@ public final class PlatformCommandManager {
GenerationCommandsRegistration.builder(), GenerationCommandsRegistration.builder(),
new GenerationCommands(worldEdit) new GenerationCommands(worldEdit)
); );
this.registration.register(
new CFICommand(commandManager),
CFICommandsRegistration.builder(),
new CFICommands(worldEdit)
);
this.registration.register( this.registration.register(
commandManager, commandManager,
HistoryCommandsRegistration.builder(), HistoryCommandsRegistration.builder(),

Datei anzeigen

@ -232,7 +232,7 @@ public class BlockMaskBuilder {
private void suggest(String input, String property, Collection<BlockType> finalTypes) throws InputParseException { private void suggest(String input, String property, Collection<BlockType> finalTypes) throws InputParseException {
throw new SuggestInputParseException(input + " does not have: " + property, input, () -> { throw new SuggestInputParseException(input + " does not have: " + property, input, () -> {
Set<PropertyKey> keys = new HashSet<>(); Set<PropertyKey> keys = new HashSet<>();
finalTypes.forEach(t -> t.getProperties().stream().forEach(p -> keys.add(p.getKey()))); finalTypes.forEach(t -> t.getProperties().forEach(p -> keys.add(p.getKey())));
return keys.stream().map(PropertyKey::getId) return keys.stream().map(PropertyKey::getId)
.filter(p -> StringMan.blockStateMatches(property, p)) .filter(p -> StringMan.blockStateMatches(property, p))
.sorted(StringMan.blockStateComparator(property)) .sorted(StringMan.blockStateComparator(property))

Datei anzeigen

@ -22,20 +22,20 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.google.common.base.Function;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;
import java.util.AbstractMap; import java.util.AbstractMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.function.Function;
import javax.annotation.Nullable;
/** /**
@ -100,7 +100,7 @@ public class MaskIntersection extends AbstractMask {
} }
} }
public Function<Map.Entry<Mask, Mask>, Mask> pairingFunction() { public Function<Entry<Mask, Mask>, Mask> pairingFunction() {
return input -> input.getKey().tryCombine(input.getValue()); return input -> input.getKey().tryCombine(input.getValue());
} }
@ -120,12 +120,11 @@ public class MaskIntersection extends AbstractMask {
} }
if (changed) { if (changed) {
masks.clear(); masks.clear();
for (Mask mask : masksArray) masks.add(mask); Collections.addAll(masks, masksArray);
} }
// Optimize this // Optimize this
boolean formArray = false; boolean formArray = false;
for (int i = 0; i < masksArray.length; i++) { for (Mask mask : masksArray) {
Mask mask = masksArray[i];
if (mask.getClass() == this.getClass()) { if (mask.getClass() == this.getClass()) {
this.masks.remove(mask); this.masks.remove(mask);
this.masks.addAll(((MaskIntersection) mask).getMasks()); this.masks.addAll(((MaskIntersection) mask).getMasks());
@ -162,7 +161,7 @@ public class MaskIntersection extends AbstractMask {
return changed ? this : null; return changed ? this : null;
} }
private boolean combineMasks(Function<Map.Entry<Mask, Mask>, Mask> pairing, Set<Map.Entry<Mask, Mask>> failedCombines) { private boolean combineMasks(Function<Entry<Mask, Mask>, Mask> pairing, Set<Map.Entry<Mask, Mask>> failedCombines) {
boolean hasOptimized = false; boolean hasOptimized = false;
while (true) { while (true) {
Mask[] result = null; Mask[] result = null;

Datei anzeigen

@ -19,16 +19,14 @@
package com.sk89q.worldedit.function.mask; package com.sk89q.worldedit.function.mask;
import com.google.common.base.Function;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map.Entry;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.Function;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
@ -81,7 +79,7 @@ public class MaskUnion extends MaskIntersection {
} }
@Override @Override
public Function<Map.Entry<Mask, Mask>, Mask> pairingFunction() { public Function<Entry<Mask, Mask>, Mask> pairingFunction() {
return input -> input.getKey().tryOr(input.getValue()); return input -> input.getKey().tryOr(input.getValue());
} }

Datei anzeigen

@ -20,8 +20,10 @@
package com.sk89q.worldedit.function.mask; package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import javax.annotation.Nullable;
/** /**
* A mask that tests whether given positions are contained within a region. * A mask that tests whether given positions are contained within a region.

Datei anzeigen

@ -1,17 +1,10 @@
package com.sk89q.worldedit.function.visitor; 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.function.RegionFunction;
import com.sk89q.worldedit.math.BlockVector3; 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.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongArraySet; import it.unimi.dsi.fastutil.longs.LongArraySet;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
@ -24,12 +17,12 @@ public class ScanChunk {
public static final BlockVector3[] DIAGONAL_DIRECTIONS; public static final BlockVector3[] DIAGONAL_DIRECTIONS;
static { static {
DEFAULT_DIRECTIONS[0] = (BlockVector3.at(0, -1, 0)); DEFAULT_DIRECTIONS[0] = BlockVector3.at(0, -1, 0);
DEFAULT_DIRECTIONS[1] = (BlockVector3.at(0, 1, 0)); DEFAULT_DIRECTIONS[1] = BlockVector3.at(0, 1, 0);
DEFAULT_DIRECTIONS[2] = (BlockVector3.at(-1, 0, 0)); DEFAULT_DIRECTIONS[2] = BlockVector3.at(-1, 0, 0);
DEFAULT_DIRECTIONS[3] = (BlockVector3.at(1, 0, 0)); DEFAULT_DIRECTIONS[3] = BlockVector3.at(1, 0, 0);
DEFAULT_DIRECTIONS[4] = (BlockVector3.at(0, 0, -1)); DEFAULT_DIRECTIONS[4] = BlockVector3.at(0, 0, -1);
DEFAULT_DIRECTIONS[5] = (BlockVector3.at(0, 0, 1)); DEFAULT_DIRECTIONS[5] = BlockVector3.at(0, 0, 1);
List<BlockVector3> list = new ArrayList<>(); List<BlockVector3> list = new ArrayList<>();
for (int x = -1; x <= 1; x++) { for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) { for (int y = -1; y <= 1; y++) {
@ -43,13 +36,8 @@ public class ScanChunk {
} }
} }
} }
Collections.sort(list, new Comparator<BlockVector3>() { list.sort((o1, o2) -> (int) Math.signum(o1.lengthSq() - o2.lengthSq()));
@Override DIAGONAL_DIRECTIONS = list.toArray(new BlockVector3[0]);
public int compare(BlockVector3 o1, BlockVector3 o2) {
return (int) Math.signum(o1.lengthSq() - o2.lengthSq());
}
});
DIAGONAL_DIRECTIONS = list.toArray(new BlockVector3[list.size()]);
} }
private final RegionFunction function; private final RegionFunction function;
@ -57,7 +45,7 @@ public class ScanChunk {
private final Long2ObjectOpenHashMap<long[][]> visits; private final Long2ObjectOpenHashMap<long[][]> visits;
private final Long2ObjectOpenHashMap<char[][]> queues; private final Long2ObjectOpenHashMap<char[][]> queues;
public ScanChunk(final RegionFunction function) { public ScanChunk(RegionFunction function) {
this.function = function; this.function = function;
this.directions = DEFAULT_DIRECTIONS; this.directions = DEFAULT_DIRECTIONS;
@ -65,8 +53,8 @@ public class ScanChunk {
this.visits = new Long2ObjectOpenHashMap<>(); this.visits = new Long2ObjectOpenHashMap<>();
} }
public static final long pairInt(int x, int y) { public static long pairInt(int x, int y) {
return (((long) x) << 32) | (y & 0xffffffffL); return (long) x << 32 | y & 0xffffffffL;
} }
public boolean isVisited(int x, int y, int z) { public boolean isVisited(int x, int y, int z) {
@ -180,7 +168,7 @@ public class ScanChunk {
char triple = queue[index]; char triple = queue[index];
int x = index & 15; int x = index & 15;
int z = (index >> 4) & 15; int z = index >> 4 & 15;
int y = index >> 8; int y = index >> 8;
int absX = xx + x; int absX = xx + x;
@ -249,7 +237,7 @@ public class ScanChunk {
char triple = queue[index]; char triple = queue[index];
int x = index & 15; int x = index & 15;
int z = (index >> 4) & 15; int z = index >> 4 & 15;
int y = index >> 8; int y = index >> 8;
} }
queuePool.add(queue); queuePool.add(queue);
@ -327,11 +315,11 @@ public class ScanChunk {
} }
public void set(long[] bits, int i) { 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) { public boolean get(long[] bits, int i) {
return (bits[i >> 6] & (1L << (i & 0x3F))) != 0; return (bits[i >> 6] & 1L << (i & 0x3F)) != 0;
} }
public char getLocalIndex(int x, int y, int z) { public char getLocalIndex(int x, int y, int z) {

Datei anzeigen

@ -1,72 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.internal.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.MultiUserPlatform;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extension.platform.PlatformManager;
import com.sk89q.worldedit.util.command.CommandCompleter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* Provides the names of connected users as suggestions.
*/
public class UserCommandCompleter implements CommandCompleter {
private final PlatformManager platformManager;
/**
* Create a new instance.
*
* @param platformManager the platform manager
*/
public UserCommandCompleter(PlatformManager platformManager) {
checkNotNull(platformManager);
this.platformManager = platformManager;
}
@Override
public List<String> getSuggestions(String arguments, CommandLocals locals) throws CommandException {
Platform platform = platformManager.queryCapability(Capability.USER_COMMANDS);
if (platform instanceof MultiUserPlatform) {
List<String> suggestions = new ArrayList<>();
Collection<Actor> users = ((MultiUserPlatform) platform).getConnectedUsers();
for (Actor user : users) {
if (user.getName().toLowerCase().startsWith(arguments.toLowerCase().trim())) {
suggestions.add(user.getName());
}
}
return suggestions;
} else {
return Collections.emptyList();
}
}
}

Datei anzeigen

@ -20,6 +20,7 @@
package com.sk89q.worldedit.internal.command.exception; package com.sk89q.worldedit.internal.command.exception;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.DisallowedItemException; import com.sk89q.worldedit.DisallowedItemException;
import com.sk89q.worldedit.EmptyClipboardException; 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.FileSelectionAbortedException;
import com.sk89q.worldedit.util.io.file.FilenameResolutionException; import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
import com.sk89q.worldedit.util.io.file.InvalidFilenameException; import com.sk89q.worldedit.util.io.file.InvalidFilenameException;
import org.enginehub.piston.exception.CommandException; import com.sk89q.worldedit.world.storage.MissingWorldException;
import org.enginehub.piston.exception.UsageException;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; 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. * 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); 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 @ExceptionMatch
public void convert(UnknownItemException e) throws CommandException { public void convert(UnknownItemException e) throws CommandException {
throw newCommandException("Block name '" + e.getID() + "' was not recognized.", e); throw newCommandException("Block name '" + e.getID() + "' was not recognized.", e);

Datei anzeigen

@ -32,6 +32,7 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -45,7 +46,7 @@ import java.nio.file.Path;
/** /**
* Represents a world (dimension). * Represents a world (dimension).
*/ */
public interface World extends Extent { public interface World extends Extent, Keyed {
/** /**
* Get the name of the world. * Get the name of the world.