Use clipboard instead
This commit is contained in:
parent
a7cc08a882
commit
bf0903246b
@ -123,20 +123,6 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
debug("&6Metrics enabled.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Kinda a really messy class I just copied over from an old project<br>
|
||||
* - Still works, so cbf cleaning it up<br>
|
||||
* - Completely optional to have this class enabled since things get cancelled further down anyway<br>
|
||||
* - Useful since it informs the player why an edit changed no blocks etc.<br>
|
||||
* - Predicts the number of blocks changed and cancels the edit if it's too large<br>
|
||||
* - Predicts where the edit will effect and cancels it if it's outside a region<br>
|
||||
* - Restricts the brush iteration limit<br>
|
||||
*/
|
||||
@Override
|
||||
public void setupWEListener() {
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new WEListener(), plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vault isn't required, but used for setting player permissions (WorldEdit bypass)
|
||||
* @return
|
||||
|
@ -1,320 +0,0 @@
|
||||
package com.boydti.fawe.bukkit;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.Perm;
|
||||
import com.boydti.fawe.util.WEManager;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
/**
|
||||
* Kinda a really messy class I just copied over from an old project<br>
|
||||
* - Still works, so cbf cleaning it up<br>
|
||||
* - Completely optional to have this class enabled since things get cancelled further down anyway<br>
|
||||
* - Useful since it informs the player why an edit changed no blocks etc.<br>
|
||||
* - Predicts the number of blocks changed and cancels the edit if it's too large<br>
|
||||
* - Predicts where the edit will effect and cancels it if it's outside a region<br>
|
||||
* - Restricts the brush iteration limit<br>
|
||||
* @deprecated as I plan on replacing it at some point
|
||||
*/
|
||||
@Deprecated
|
||||
public class WEListener implements Listener {
|
||||
|
||||
public final HashSet<String> rad1 = new HashSet<>(Arrays.asList("forestgen", "pumpkins", "drain", "fixwater", "fixlava", "replacenear", "snow", "thaw", "ex", "butcher", "size"));
|
||||
public final HashSet<String> rad2 = new HashSet<>(Arrays.asList("fill", "fillr", "removenear", "remove"));
|
||||
public final HashSet<String> rad2_1 = new HashSet<>(Arrays.asList("hcyl", "cyl"));
|
||||
public final HashSet<String> rad2_2 = new HashSet<>(Arrays.asList("sphere", "pyramid"));
|
||||
public final HashSet<String> rad2_3 = new HashSet<>(Arrays.asList("brush smooth"));
|
||||
public final HashSet<String> rad3_1 = new HashSet<>(Arrays.asList("brush gravity"));
|
||||
public final HashSet<String> rad3_2 = new HashSet<>(Arrays.asList("brush sphere", "brush cylinder"));
|
||||
|
||||
public final HashSet<String> region = new HashSet<>(Arrays.asList("move", "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "naturalize", "paste", "count", "distr",
|
||||
"copy", "cut", "green", "setbiome"));
|
||||
public final HashSet<String> regionExtend = new HashSet<>(Arrays.asList("stack"));
|
||||
public final HashSet<String> unregioned = new HashSet<>(Arrays.asList("paste", "redo", "undo", "rotate", "flip", "generate", "schematic", "schem"));
|
||||
public final HashSet<String> unsafe1 = new HashSet<>(Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks"));
|
||||
public final HashSet<String> restricted = new HashSet<>(Arrays.asList("up"));
|
||||
public final HashSet<String> other = new HashSet<>(Arrays.asList("undo", "redo", "schematic", "schem", "count"));
|
||||
|
||||
public boolean checkCommand(final List<String> list, final String cmd) {
|
||||
for (final String identifier : list) {
|
||||
if (("/" + identifier).equals(cmd) || ("//" + identifier).equals(cmd) || ("/worldedit:/" + identifier).equals(cmd) || ("/worldedit:" + identifier).equals(cmd)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String reduceCmd(final String cmd, final boolean single) {
|
||||
if (cmd.startsWith("/worldedit:/")) {
|
||||
return cmd.substring(12);
|
||||
}
|
||||
if (cmd.startsWith("/worldedit:")) {
|
||||
return cmd.substring(11);
|
||||
}
|
||||
if (cmd.startsWith("//")) {
|
||||
return cmd.substring(2);
|
||||
}
|
||||
if (single && cmd.startsWith("/")) {
|
||||
return cmd.substring(1);
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public int getInt(final String s) {
|
||||
try {
|
||||
int max = 0;
|
||||
final String[] split = s.split(",");
|
||||
for (final String rad : split) {
|
||||
final int val = Integer.parseInt(rad);
|
||||
if (val > max) {
|
||||
max = val;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
} catch (final NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkVolume(final FawePlayer<Player> player, final long volume, final long max, final Cancellable e) {
|
||||
if (volume > max) {
|
||||
MainUtil.sendMessage(FawePlayer.wrap(player.getName()), BBC.WORLDEDIT_VOLUME.s().replaceAll("%current%", volume + "").replaceAll("%max%", max + ""));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
if (Perm.hasPermission(player, "fawe.admin") && !Perm.hasPermission(player, "fawe.bypass")) {
|
||||
BBC.WORLDEDIT_BYPASS.send(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkSelection(final FawePlayer<Player> player, final int modifier, final long max, final Cancellable e) {
|
||||
final LocalSession session = Fawe.get().getWorldEdit().getSession(player.getName());
|
||||
final LocalWorld w = BukkitUtil.getLocalWorld(player.parent.getWorld());
|
||||
Region selection = null;
|
||||
try {
|
||||
selection = session.getSelection(w);
|
||||
} catch (final IncompleteRegionException e2) {}
|
||||
if (selection == null) {
|
||||
return true;
|
||||
}
|
||||
final BlockVector pos1 = selection.getMinimumPoint().toBlockVector();
|
||||
final BlockVector pos2 = selection.getMaximumPoint().toBlockVector();
|
||||
final HashSet<RegionWrapper> mask = WEManager.IMP.getMask(player);
|
||||
final RegionWrapper region = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ());
|
||||
if (Settings.REQUIRE_SELECTION) {
|
||||
String arg = null;
|
||||
if (!WEManager.IMP.regionContains(region, mask)) {
|
||||
arg = "pos1 + pos2";
|
||||
} else if (!WEManager.IMP.maskContains(mask, pos1.getBlockX(), pos1.getBlockZ())) {
|
||||
arg = "pos1";
|
||||
} else if (!WEManager.IMP.maskContains(mask, pos2.getBlockX(), pos2.getBlockZ())) {
|
||||
arg = "pos2";
|
||||
}
|
||||
if (arg != null) {
|
||||
BBC.REQUIRE_SELECTION_IN_MASK.send(player, arg);
|
||||
e.setCancelled(true);
|
||||
if (Perm.hasPermission(player, "fawe.admin") && !Perm.hasPermission(player, "fawe.bypass")) {
|
||||
BBC.WORLDEDIT_BYPASS.send(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!WEManager.IMP.regionContains(region, mask)) {
|
||||
BBC.REQUIRE_SELECTION_IN_MASK.send(player, "pos1 + pos2");
|
||||
e.setCancelled(true);
|
||||
if (Perm.hasPermission(player, "fawe.admin") && !Perm.hasPermission(player, "fawe.bypass")) {
|
||||
BBC.WORLDEDIT_BYPASS.send(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
final long volume = Math.abs((pos1.getBlockX() - pos2.getBlockX()) * (pos1.getBlockY() - pos2.getBlockY()) * (pos1.getBlockZ() - pos2.getBlockZ())) * modifier;
|
||||
return this.checkVolume(player, volume, max, e);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public boolean onPlayerCommand(final PlayerCommandPreprocessEvent e) {
|
||||
final FawePlayer<Player> player = FawePlayer.wrap(e.getPlayer());
|
||||
final String message = e.getMessage();
|
||||
final String cmd = message.toLowerCase();
|
||||
final boolean single = true;
|
||||
final String[] split = cmd.split(" ");
|
||||
FaweLimit limit = player.getLimit();
|
||||
final long maxVolume = limit.MAX_FAILS + limit.MAX_CHANGES;
|
||||
final long maxIterations = limit.MAX_ITERATIONS;
|
||||
// if (player.hasPermission("fawe.bypass")) {
|
||||
// return true;
|
||||
// }
|
||||
if (split.length >= 2) {
|
||||
final String reduced = this.reduceCmd(split[0], single);
|
||||
final String reduced2 = this.reduceCmd(split[0] + " " + split[1], single);
|
||||
if (this.rad1.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
final long volume = this.getInt(split[1]) * 256;
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
if (this.rad2.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
if (split.length >= 3) {
|
||||
final long volume = this.getInt(split[2]) * 256;
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.rad2_1.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
if (split.length >= 4) {
|
||||
final long volume = this.getInt(split[2]) * this.getInt(split[3]);
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.rad2_2.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
if (split.length >= 3) {
|
||||
final long radius = this.getInt(split[2]);
|
||||
final long volume = radius * radius;
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.rad2_3.contains(reduced2)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
if (split.length >= 3) {
|
||||
if (split.length == 4) {
|
||||
final int iterations = this.getInt(split[3]);
|
||||
if (iterations > maxIterations) {
|
||||
MainUtil.sendMessage(player, BBC.WORLDEDIT_ITERATIONS.s().replaceAll("%current%", iterations + "").replaceAll("%max%", maxIterations + ""));
|
||||
e.setCancelled(true);
|
||||
if (Perm.hasPermission(player, "fawe.admin") && !Perm.hasPermission(player, "fawe.bypass")) {
|
||||
BBC.WORLDEDIT_BYPASS.send(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
final long radius = this.getInt(split[2]);
|
||||
final long volume = radius * radius;
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.rad3_1.contains(reduced2)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
if (split.length >= 3) {
|
||||
int i = 2;
|
||||
if (split[i].equalsIgnoreCase("-h")) {
|
||||
i = 3;
|
||||
}
|
||||
final long radius = this.getInt(split[i]);
|
||||
final long volume = radius * radius;
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.rad3_2.contains(reduced2)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
if (split.length >= 4) {
|
||||
int i = 3;
|
||||
if (split[i].equalsIgnoreCase("-h")) {
|
||||
i = 4;
|
||||
}
|
||||
final long radius = this.getInt(split[i]);
|
||||
final long volume = radius * radius;
|
||||
return this.checkVolume(player, volume, maxVolume, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.regionExtend.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
return this.checkSelection(player, this.getInt(split[1]), maxVolume, e);
|
||||
}
|
||||
}
|
||||
final String reduced = this.reduceCmd(split[0], single);
|
||||
if (Settings.WE_BLACKLIST.contains(reduced)) {
|
||||
BBC.WORLDEDIT_UNSAFE.send(player);
|
||||
e.setCancelled(true);
|
||||
if (Perm.hasPermission(player, "fawe.admin") && !Perm.hasPermission(player, "fawe.bypass")) {
|
||||
BBC.WORLDEDIT_BYPASS.send(player);
|
||||
}
|
||||
}
|
||||
if (this.restricted.contains(reduced)) {
|
||||
final HashSet<RegionWrapper> mask = WEManager.IMP.getMask(player);
|
||||
final Location loc = player.parent.getLocation();
|
||||
for (final RegionWrapper region : mask) {
|
||||
if (region.isIn(loc.getBlockX(), loc.getBlockZ())) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
e.setCancelled(true);
|
||||
BBC.REQUIRE_SELECTION_IN_MASK.send(player);
|
||||
return true;
|
||||
}
|
||||
if (this.region.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
return this.checkSelection(player, 1, maxVolume, e);
|
||||
}
|
||||
if (this.unregioned.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (this.other.contains(reduced)) {
|
||||
if (WEManager.IMP.delay(player, message)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -74,6 +74,12 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
|
||||
return world.isChunkLoaded(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getCachedSection(ChunkSection[] chunkSections, int cy) {
|
||||
ChunkSection section = chunkSections[cy];
|
||||
return section == null ? null : section.getIdArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setComponents(FaweChunk fc) {
|
||||
CharFaweChunk<Chunk> fs = (CharFaweChunk<Chunk>) fc;
|
||||
|
@ -199,9 +199,6 @@ public class Fawe {
|
||||
|
||||
private void setupEvents() {
|
||||
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
||||
if (Settings.COMMAND_PROCESSOR) {
|
||||
this.IMP.setupWEListener();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupCommands() {
|
||||
|
@ -21,8 +21,6 @@ public interface IFawe {
|
||||
|
||||
public FawePlayer wrap(final Object obj);
|
||||
|
||||
public void setupWEListener();
|
||||
|
||||
public void setupVault();
|
||||
|
||||
public TaskManager getTaskManager();
|
||||
|
@ -7,7 +7,6 @@ import com.sk89q.worldedit.LocalSession;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -15,9 +14,9 @@ import java.util.Map.Entry;
|
||||
|
||||
public class Settings {
|
||||
|
||||
public static boolean REQUIRE_SELECTION = false;
|
||||
public static boolean COMMAND_PROCESSOR = false;
|
||||
public static List<String> WE_BLACKLIST = Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks");
|
||||
// public static boolean REQUIRE_SELECTION = false;
|
||||
// public static boolean COMMAND_PROCESSOR = false;
|
||||
// public static List<String> WE_BLACKLIST = Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks");
|
||||
public static long MEM_FREE = 95;
|
||||
public static boolean ENABLE_HARD_LIMIT = true;
|
||||
public static boolean STORE_HISTORY_ON_DISK = false;
|
||||
@ -80,9 +79,9 @@ public class Settings {
|
||||
limits = new HashMap<>();
|
||||
|
||||
final Map<String, Object> options = new HashMap<>();
|
||||
options.put("require-selection-in-mask", REQUIRE_SELECTION);
|
||||
options.put("command-blacklist", WE_BLACKLIST);
|
||||
options.put("command-processor", COMMAND_PROCESSOR);
|
||||
// options.put("require-selection-in-mask", REQUIRE_SELECTION);
|
||||
// options.put("command-blacklist", WE_BLACKLIST);
|
||||
// options.put("command-processor", COMMAND_PROCESSOR);
|
||||
options.put("max-memory-percent", MEM_FREE);
|
||||
options.put("crash-mitigation", ENABLE_HARD_LIMIT);
|
||||
options.put("lighting.fix-all", FIX_ALL_LIGHTING);
|
||||
@ -125,10 +124,10 @@ public class Settings {
|
||||
}
|
||||
FIX_ALL_LIGHTING = config.getBoolean("lighting.fix-all");
|
||||
ASYNC_LIGHTING = config.getBoolean("lighting.async");
|
||||
COMMAND_PROCESSOR = config.getBoolean("command-processor");
|
||||
MEM_FREE = config.getInt("max-memory-percent");
|
||||
REQUIRE_SELECTION = config.getBoolean("require-selection-in-mask");
|
||||
WE_BLACKLIST = config.getStringList("command-blacklist");
|
||||
// COMMAND_PROCESSOR = config.getBoolean("command-processor");
|
||||
// REQUIRE_SELECTION = config.getBoolean("require-selection-in-mask");
|
||||
// WE_BLACKLIST = config.getStringList("command-blacklist");
|
||||
ENABLE_HARD_LIMIT = config.getBoolean("crash-mitigation");
|
||||
REGION_RESTRICTIONS = config.getBoolean("region-restrictions");
|
||||
METRICS = config.getBoolean("metrics");
|
||||
|
@ -10,10 +10,10 @@ import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.Raster;
|
||||
import java.io.File;
|
||||
@ -27,23 +27,32 @@ public class HeightBrush implements Brush {
|
||||
double yscale = 1;
|
||||
private final BrushTool tool;
|
||||
|
||||
public HeightBrush(File file, int rotation, double yscale, BrushTool tool, EditSession session, CuboidRegion selection) {
|
||||
public HeightBrush(File file, int rotation, double yscale, BrushTool tool, EditSession session, Clipboard clipboard) {
|
||||
this.tool = tool;
|
||||
this.rotation = (rotation / 90) % 4;
|
||||
this.yscale = yscale;
|
||||
if (file == null || !file.exists()) {
|
||||
if (file.getName().equalsIgnoreCase("#selection.png") && selection != null) {
|
||||
byte[][] heightArray = new byte[selection.getWidth()][selection.getLength()];
|
||||
int minX = selection.getMinimumPoint().getBlockX();
|
||||
int minZ = selection.getMinimumPoint().getBlockZ();
|
||||
int minY = selection.getMinimumY() - 1;
|
||||
int maxY = selection.getMaximumY() + 1;
|
||||
int selHeight = selection.getHeight();
|
||||
for (Vector pos : selection) {
|
||||
// Since I can't be bothered using separate args, we'll get it from the filename
|
||||
if (file.getName().equalsIgnoreCase("#clipboard.png") && clipboard != null) {
|
||||
Vector dim = clipboard.getDimensions();
|
||||
byte[][] heightArray = new byte[dim.getBlockX()][dim.getBlockZ()];
|
||||
int minX = clipboard.getMinimumPoint().getBlockX();
|
||||
int minZ = clipboard.getMinimumPoint().getBlockZ();
|
||||
int minY = clipboard.getMinimumPoint().getBlockY();
|
||||
int maxY = clipboard.getMaximumPoint().getBlockY();
|
||||
int clipHeight = maxY - minY + 1;
|
||||
for (Vector pos : clipboard.getRegion()) {
|
||||
int xx = pos.getBlockX();
|
||||
int zz = pos.getBlockZ();
|
||||
int worldPointHeight = session.getHighestTerrainBlock(xx, zz, minY, maxY);
|
||||
int pointHeight = Math.min(255, (256 * (worldPointHeight - minY)) / selHeight);
|
||||
int highestY = 0;
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
pos.y = y;
|
||||
BaseBlock block = clipboard.getBlock(pos);
|
||||
if (block != EditSession.nullBlock) {
|
||||
highestY = y + 1;
|
||||
}
|
||||
}
|
||||
int pointHeight = Math.min(255, (256 * (highestY - minY)) / clipHeight);
|
||||
int x = xx - minX;
|
||||
int z = zz - minZ;
|
||||
heightArray[x][z] = (byte) pointHeight;
|
||||
|
@ -29,7 +29,7 @@ import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.EmptyClipboardException;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
@ -52,7 +52,6 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
@ -234,7 +233,7 @@ public class BrushCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "height", "heightmap" },
|
||||
usage = "[radius] [file|#selection|null] [rotation] [yscale]",
|
||||
usage = "[radius] [file|#clipboard|null] [rotation] [yscale]",
|
||||
flags = "h",
|
||||
desc = "Height brush",
|
||||
help =
|
||||
@ -249,9 +248,8 @@ public class BrushCommands {
|
||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||
tool.setSize(radius);
|
||||
try {
|
||||
tool.setBrush(new HeightBrush(file, rotation, yscale, tool, editSession, (CuboidRegion) session.getSelection(player.getWorld())), "worldedit.brush.height");
|
||||
} catch (IncompleteRegionException ignore) {
|
||||
ignore.printStackTrace();
|
||||
tool.setBrush(new HeightBrush(file, rotation, yscale, tool, editSession, session.getClipboard().getClipboard()), "worldedit.brush.height");
|
||||
} catch (EmptyClipboardException ignore) {
|
||||
tool.setBrush(new HeightBrush(file, rotation, yscale, tool, editSession, null), "worldedit.brush.height");
|
||||
}
|
||||
BBC.BRUSH_HEIGHT.send(player, radius);
|
||||
|
@ -83,11 +83,6 @@ public class FaweForge implements IFawe {
|
||||
return existing != null ? existing : new ForgePlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupWEListener() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupVault() {
|
||||
// Do nothing
|
||||
|
@ -84,11 +84,6 @@ public class FaweForge implements IFawe {
|
||||
return existing != null ? existing : new ForgePlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupWEListener() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupVault() {
|
||||
// Do nothing
|
||||
|
@ -89,11 +89,6 @@ public class FaweSponge implements IFawe {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupWEListener() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupVault() {
|
||||
debug("Permission hook not implemented yet!");
|
||||
|
Loading…
Reference in New Issue
Block a user