Upstream changes, prefix changes, formatting changes, variable name changes

I think that draining waterlogged items also works now?
This commit is contained in:
MattBDev 2019-06-12 17:12:12 -04:00
parent e6a433ec93
commit 1f14d4652e
40 changed files with 587 additions and 684 deletions

View File

@ -22,7 +22,7 @@ public class VoxelUndoCommand extends VoxelCommand {
int amount = Integer.parseInt(args[0]); int amount = Integer.parseInt(args[0]);
sniper.undo(amount); sniper.undo(amount);
} catch (NumberFormatException exception) { } catch (NumberFormatException exception) {
player.sendMessage(BBC.getPrefix() + "Number expected; string given."); player.sendMessage("Number expected; string given.");
} }
} else { } else {
sniper.undo(); sniper.undo();

View File

@ -85,6 +85,10 @@ public class BukkitPlayer extends FawePlayer<Player> {
this.parent.sendMessage(BBC.color(message)); this.parent.sendMessage(BBC.color(message));
} }
@Override public void printError(String msg) {
this.sendMessage(msg);
}
@Override @Override
public void executeCommand(final String cmd) { public void executeCommand(final String cmd) {
Bukkit.getServer().dispatchCommand(this.parent, cmd); Bukkit.getServer().dispatchCommand(this.parent, cmd);

View File

@ -194,9 +194,9 @@ public class FaweBukkit implements IFawe, Listener {
} }
@Override @Override
public void debug(final String s) { public void debug(final String message) {
ConsoleCommandSender console = Bukkit.getConsoleSender(); ConsoleCommandSender console = Bukkit.getConsoleSender();
console.sendMessage(BBC.color(s)); console.sendMessage(BBC.color(message));
} }
@Override @Override
@ -273,7 +273,7 @@ public class FaweBukkit implements IFawe, Listener {
try { try {
this.vault = new VaultUtil(); this.vault = new VaultUtil();
} catch (final Throwable e) { } catch (final Throwable e) {
this.debug(BBC.getPrefix() + "&dVault is used for persistent `/wea` toggles."); this.debug("&dVault is used for persistent `/wea` toggles.");
} }
} }

View File

@ -194,8 +194,8 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
fieldDirtyCount.setAccessible(true); fieldDirtyCount.setAccessible(true);
fieldDirtyBits.setAccessible(true); fieldDirtyBits.setAccessible(true);
System.out.println(BBC.getPrefix() + "Using adapter: " + getAdapter()); System.out.println("Using adapter: " + getAdapter());
System.out.println(BBC.getPrefix() + "========================================="); System.out.println("=========================================");
} catch (Throwable e) { } catch (Throwable e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -157,7 +157,7 @@ public class AnvilCommands {
// final FaweBlockMatcher matchTo = FaweBlockMatcher.setBlocks(worldEdit.getBlocks(player, to, true)); // final FaweBlockMatcher matchTo = FaweBlockMatcher.setBlocks(worldEdit.getBlocks(player, to, true));
// ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo); // ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo);
// ReplaceSimpleFilter result = runWithWorld(player, folder, filter, true); // ReplaceSimpleFilter result = runWithWorld(player, folder, filter, true);
// if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); // if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
@Command( @Command(
@ -182,7 +182,7 @@ public class AnvilCommands {
} }
RemapFilter filter = new RemapFilter(from, to); RemapFilter filter = new RemapFilter(from, to);
RemapFilter result = runWithWorld(player, folder, filter, true); RemapFilter result = runWithWorld(player, folder, filter, true);
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
@ -202,7 +202,7 @@ public class AnvilCommands {
long chunkInactivityMillis = fileDurationMillis; // Use same value for now long chunkInactivityMillis = fileDurationMillis; // Use same value for now
DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, chunkInactivityMillis); DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true); DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
@Command( @Command(
@ -223,7 +223,7 @@ public class AnvilCommands {
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis); DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
if (debug) filter.enableDebug(); if (debug) filter.enableDebug();
DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true); DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true);
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
@Command( @Command(
@ -244,7 +244,7 @@ public class AnvilCommands {
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis); DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
if (debug) filter.enableDebug(); if (debug) filter.enableDebug();
DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter); DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter);
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
@Command( @Command(
@ -263,7 +263,7 @@ public class AnvilCommands {
long duration = MainUtil.timeToSec(time) * 1000l; long duration = MainUtil.timeToSec(time) * 1000l;
DeleteOldFilter filter = new DeleteOldFilter(duration); DeleteOldFilter filter = new DeleteOldFilter(duration);
DeleteOldFilter result = runWithWorld(player, folder, filter, true); DeleteOldFilter result = runWithWorld(player, folder, filter, true);
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
@Command( @Command(
@ -283,7 +283,7 @@ public class AnvilCommands {
FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false); FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false);
MCAQueue queue = new MCAQueue(defaultQueue); MCAQueue queue = new MCAQueue(defaultQueue);
PlotTrimFilter result = queue.filterWorld(filter); PlotTrimFilter result = queue.filterWorld(filter);
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
@Command( @Command(
@ -294,7 +294,7 @@ public class AnvilCommands {
public void deleteBiome(Player player, String folder, BiomeType biome, @Switch('u') boolean unsafe) { public void deleteBiome(Player player, String folder, BiomeType biome, @Switch('u') boolean unsafe) {
DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome); DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome);
DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe); DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
@Command( @Command(
@ -305,7 +305,7 @@ public class AnvilCommands {
public void trimAllAir(Player player, String folder, @Switch('u') boolean unsafe) throws WorldEditException { public void trimAllAir(Player player, String folder, @Switch('u') boolean unsafe) throws WorldEditException {
TrimAirFilter filter = new TrimAirFilter(); TrimAirFilter filter = new TrimAirFilter();
TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe); TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe);
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
@Command( @Command(
@ -316,7 +316,7 @@ public class AnvilCommands {
public void debugfixroads(Player player, String folder) throws WorldEditException { public void debugfixroads(Player player, String folder) throws WorldEditException {
DebugFixP2Roads filter = new DebugFixP2Roads(); DebugFixP2Roads filter = new DebugFixP2Roads();
DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true); DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true);
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
@Command( @Command(
@ -335,7 +335,7 @@ public class AnvilCommands {
// List<String> split = StringMan.split(from, ','); // List<String> split = StringMan.split(from, ',');
// filter = new MappedReplacePatternFilter(from, (RandomPattern) to, useData); // filter = new MappedReplacePatternFilter(from, (RandomPattern) to, useData);
// } else { // } else {
// player.print(BBC.getPrefix() + "Must be a pattern list!"); // player.print("Must be a pattern list!");
// return; // return;
// } // }
// } else { // } else {
@ -348,7 +348,7 @@ public class AnvilCommands {
// filter = new ReplacePatternFilter(matchFrom, to); // filter = new ReplacePatternFilter(matchFrom, to);
// } // }
// MCAFilterCounter result = runWithWorld(player, folder, filter, true); // MCAFilterCounter result = runWithWorld(player, folder, filter, true);
// if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); // if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
// //
@Command( @Command(
@ -373,7 +373,7 @@ public class AnvilCommands {
// filter = counter; // filter = counter;
// } // }
// MCAFilterCounter result = runWithWorld(player, folder, filter, true); // MCAFilterCounter result = runWithWorld(player, folder, filter, true);
// if (result != null) player.print(BBC.getPrefix() + BBC.SELECTION_COUNT.format(result.getTotal())); // if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal()));
} }
@Command( @Command(
@ -423,7 +423,7 @@ public class AnvilCommands {
} }
}; };
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
@Command( @Command(
@ -448,7 +448,7 @@ public class AnvilCommands {
// filter = counter; // filter = counter;
// } // }
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) player.print(BBC.getPrefix() + BBC.SELECTION_COUNT.format(result.getTotal())); // if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal()));
} }
// //
@Command( @Command(
@ -514,7 +514,7 @@ public class AnvilCommands {
// ((c[1] * 10000) / total) / 100d, // ((c[1] * 10000) / total) / 100d,
// name == null ? "Unknown" : name, // name == null ? "Unknown" : name,
// block.getType(), block.getData()); // block.getType(), block.getData());
// player.print(BBC.getPrefix() + str); // player.print(str);
// } // }
// } else { // } else {
// for (long[] c : map) { // for (long[] c : map) {
@ -523,7 +523,7 @@ public class AnvilCommands {
// String.valueOf(c[1]), // String.valueOf(c[1]),
// ((c[1] * 10000) / total) / 100d, // ((c[1] * 10000) / total) / 100d,
// block == null ? "Unknown" : block.getName(), c[0]); // block == null ? "Unknown" : block.getName(), c[0]);
// player.print(BBC.getPrefix() + str); // player.print(str);
// } // }
// } // }
} }
@ -545,7 +545,7 @@ public class AnvilCommands {
// ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo); // ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo);
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) { // if (result != null) {
// player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// } // }
} }
// //
@ -563,7 +563,7 @@ public class AnvilCommands {
// List<String> split = StringMan.split(from, ','); // List<String> split = StringMan.split(from, ',');
// filter = new MappedReplacePatternFilter(from, (RandomPattern) to, useData); // filter = new MappedReplacePatternFilter(from, (RandomPattern) to, useData);
// } else { // } else {
// player.print(BBC.getPrefix() + "Must be a pattern list!"); // player.print("Must be a pattern list!");
// return; // return;
// } // }
// } else { // } else {
@ -577,7 +577,7 @@ public class AnvilCommands {
// } // }
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) { // if (result != null) {
// player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// } // }
} }
@ -592,7 +592,7 @@ public class AnvilCommands {
MCAFilterCounter filter = new SetPatternFilter(to); MCAFilterCounter filter = new SetPatternFilter(to);
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
if (result != null) { if (result != null) {
player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
} }
@ -611,7 +611,7 @@ public class AnvilCommands {
RemoveLayerFilter filter = new RemoveLayerFilter(minY, maxY, id); RemoveLayerFilter filter = new RemoveLayerFilter(minY, maxY, id);
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
if (result != null) { if (result != null) {
player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
} }
@ -651,7 +651,7 @@ public class AnvilCommands {
// FawePlayer fp = FawePlayer.wrap(player); // FawePlayer fp = FawePlayer.wrap(player);
// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD); // MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD);
// if (clipboard == null) { // if (clipboard == null) {
// fp.sendMessage(BBC.getPrefix() + "You must first use `//anvil copy`"); // fp.sendMessage("You must first use `//anvil copy`");
// return; // return;
// } // }
// CuboidRegion cuboid = clipboard.getRegion(); // CuboidRegion cuboid = clipboard.getRegion();
@ -676,4 +676,4 @@ public class AnvilCommands {
// }); // });
// BBC.COMMAND_PASTE.send(player, player.getPosition().toBlockVector()); // BBC.COMMAND_PASTE.send(player, player.getPosition().toBlockVector());
} }
} }

View File

@ -177,7 +177,7 @@ public class CFICommands extends MethodCommands {
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void cancel(FawePlayer fp) throws ParameterException, IOException { public void cancel(FawePlayer fp) throws ParameterException, IOException {
getSettings(fp).remove(); getSettings(fp).remove();
fp.sendMessage(BBC.getPrefix() + "Cancelled!"); fp.sendMessage("Cancelled!");
} }
@Command( @Command(
@ -196,12 +196,12 @@ public class CFICommands extends MethodCommands {
if (folder != null) { if (folder != null) {
try { try {
generator.setFolder(folder); generator.setFolder(folder);
fp.sendMessage(BBC.getPrefix() + "Generating " + folder); fp.sendMessage("Generating " + folder);
generator.generate(); generator.generate();
generator.setPacketViewer(null); generator.setPacketViewer(null);
generator.setImageViewer(null); generator.setImageViewer(null);
settings.remove(); settings.remove();
fp.sendMessage(BBC.getPrefix() + "Done!"); fp.sendMessage("Done!");
return true; return true;
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@ -215,8 +215,8 @@ public class CFICommands extends MethodCommands {
try { try {
new PlotLoader().load(fp, settings, function); new PlotLoader().load(fp, settings, function);
} catch (Throwable ignore) { } catch (Throwable e) {
ignore.printStackTrace(); e.printStackTrace();
function.apply(generator.getFolder().getParentFile()); function.apply(generator.getFolder().getParentFile());
} }
@ -879,7 +879,7 @@ public class CFICommands extends MethodCommands {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", baos ); ImageIO.write(image, "jpg", baos );
byte[] data = baos.toByteArray(); byte[] data = baos.toByteArray();
fp.sendMessage(BBC.getPrefix() + "Please wait..."); fp.sendMessage("Please wait...");
URL url = ImgurUtility.uploadImage(data); URL url = ImgurUtility.uploadImage(data);
BBC.DOWNLOAD_LINK.send(fp, url); BBC.DOWNLOAD_LINK.send(fp, url);
} }

View File

@ -50,7 +50,7 @@ public class PlotLoader {
SinglePlotArea area = sManager.getArea(); SinglePlotArea area = sManager.getArea();
PlotPlayer player = PlotPlayer.wrap(fp.parent); PlotPlayer player = PlotPlayer.wrap(fp.parent);
fp.sendMessage(BBC.getPrefix() + "Claiming world"); fp.sendMessage("Claiming world");
Plot plot = TaskManager.IMP.sync(new RunnableVal<Plot>() { Plot plot = TaskManager.IMP.sync(new RunnableVal<Plot>() {
@Override @Override
public void run(Plot o) { public void run(Plot o) {

View File

@ -10,7 +10,6 @@ import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.chat.Message; import com.boydti.fawe.util.chat.Message;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.entity.Player;
import java.io.File; import java.io.File;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -380,49 +379,25 @@ public enum BBC {
/** /**
* Translated * Translated
*/ */
private String s; private String translatedMessage;
/** /**
* Default * Default
*/ */
private String d; private String defaultMessage;
/** /**
* What locale category should this translation fall under * What locale category should this translation fall under
*/ */
private String cat; private String category;
/**
* Should the string be prefixed?
*/
private boolean prefix;
/**
* Constructor for custom strings.
*/
BBC() {
/*
* use setCustomString();
*/
}
/** /**
* Constructor * Constructor
* *
* @param d default * @param defaultMessage default
* @param prefix use prefix
*/ */
BBC(final String d, final boolean prefix, final String cat) { BBC(final String defaultMessage, final String category) {
this.d = d; this.defaultMessage = defaultMessage;
this.s = d; this.translatedMessage = defaultMessage;
this.prefix = prefix; this.category = category.toLowerCase();
this.cat = cat.toLowerCase();
}
/**
* Constructor
*
* @param d default
*/
BBC(final String d, final String cat) {
this(d, true, cat.toLowerCase());
} }
public String f(final Object... args) { public String f(final Object... args) {
@ -430,7 +405,7 @@ public enum BBC {
} }
public String format(final Object... args) { public String format(final Object... args) {
String m = this.s; String m = this.translatedMessage;
for (int i = args.length - 1; i >= 0; i--) { for (int i = args.length - 1; i >= 0; i--) {
if (args[i] == null) { if (args[i] == null) {
continue; continue;
@ -457,7 +432,7 @@ public enum BBC {
final HashSet<String> toRemove = new HashSet<>(); final HashSet<String> toRemove = new HashSet<>();
for (final BBC c : all) { for (final BBC c : all) {
allNames.add(c.name()); allNames.add(c.name());
allCats.add(c.cat.toLowerCase()); allCats.add(c.category.toLowerCase());
} }
final HashSet<BBC> captions = new HashSet<>(); final HashSet<BBC> captions = new HashSet<>();
boolean changed = false; boolean changed = false;
@ -470,13 +445,13 @@ public enum BBC {
final String node = split[split.length - 1].toUpperCase(); final String node = split[split.length - 1].toUpperCase();
final BBC caption = allNames.contains(node) ? valueOf(node) : null; final BBC caption = allNames.contains(node) ? valueOf(node) : null;
if (caption != null) { if (caption != null) {
if (!split[0].equalsIgnoreCase(caption.cat)) { if (!split[0].equalsIgnoreCase(caption.category)) {
changed = true; changed = true;
yml.set(key, null); yml.set(key, null);
yml.set(caption.cat + "." + caption.name().toLowerCase(), value); yml.set(caption.category + "." + caption.name().toLowerCase(), value);
} }
captions.add(caption); captions.add(caption);
caption.s = (String) value; caption.translatedMessage = (String) value;
} else { } else {
toRemove.add(key); toRemove.add(key);
} }
@ -488,9 +463,9 @@ public enum BBC {
for (final BBC caption : all) { for (final BBC caption : all) {
if (!captions.contains(caption)) { if (!captions.contains(caption)) {
changed = true; changed = true;
yml.set(caption.cat + "." + caption.name().toLowerCase(), caption.d); yml.set(caption.category + "." + caption.name().toLowerCase(), caption.defaultMessage);
} }
caption.s = StringMan.replaceFromMap(caption.s, replacements); caption.translatedMessage = StringMan.replaceFromMap(caption.translatedMessage, replacements);
} }
if (changed) { if (changed) {
yml.save(file); yml.save(file);
@ -523,7 +498,7 @@ public enum BBC {
} }
public String s() { public String s() {
return this.s; return this.translatedMessage;
} }
public Message m(Object... args) { public Message m(Object... args) {
@ -531,15 +506,11 @@ public enum BBC {
} }
public String original() { public String original() {
return d; return defaultMessage;
} }
public boolean usePrefix() { public String getCategory() {
return this.prefix; return this.category;
}
public String getCat() {
return this.cat;
} }
public BBC or(BBC... others) { public BBC or(BBC... others) {
@ -695,7 +666,7 @@ public enum BBC {
} }
for (Map.Entry<String, Object> entry2 : obj.entrySet()) { for (Map.Entry<String, Object> entry2 : obj.entrySet()) {
if (StringMan.isEqualIgnoreCaseToAny(entry2.getKey(), "bold", "italic", "underlined", "strikethrough", "obfuscated")) { if (StringMan.isEqualIgnoreCaseToAny(entry2.getKey(), "bold", "italic", "underlined", "strikethrough", "obfuscated")) {
boolean newValue = Boolean.valueOf((String) entry2.getValue()); boolean newValue = Boolean.parseBoolean((String) entry2.getValue());
if (properties.put(entry2.getKey(), newValue) != newValue) { if (properties.put(entry2.getKey(), newValue) != newValue) {
if (newValue) { if (newValue) {
char code = BBC.getCode(entry2.getKey().toUpperCase()); char code = BBC.getCode(entry2.getKey().toUpperCase());

View File

@ -56,7 +56,7 @@ public class CavesGen extends GenBase {
double f2 = 0.0F; double f2 = 0.0F;
if (maxAngle <= 0) { if (maxAngle <= 0) {
int checkAreaSize = this.getCheckAreaSize() * 16 - 16; int checkAreaSize = (this.getCheckAreaSize() * 16) - 16;
maxAngle = checkAreaSize - ThreadLocalRandom.current().nextInt(checkAreaSize / 4); maxAngle = checkAreaSize - ThreadLocalRandom.current().nextInt(checkAreaSize / 4);
} }
boolean isLargeCave = false; boolean isLargeCave = false;
@ -70,7 +70,7 @@ public class CavesGen extends GenBase {
int k = ThreadLocalRandom.current().nextInt(6) == 0 ? 1 : 0; int k = ThreadLocalRandom.current().nextInt(6) == 0 ? 1 : 0;
for (; angle < maxAngle; angle++) { for (; angle < maxAngle; angle++) {
double d3 = 1.5D + MathMan.sinInexact(angle * 3.141593F / maxAngle) * paramdouble1 * 1.0F; double d3 = 1.5D + MathMan.sinInexact(angle * Math.PI / maxAngle) * paramdouble1 * 1.0F;
double d4 = d3 * paramDouble4; double d4 = d3 * paramDouble4;
double f3 = MathMan.cosInexact(paramdouble3); double f3 = MathMan.cosInexact(paramdouble3);

View File

@ -27,19 +27,9 @@ public abstract class FaweCommand<T> {
execute(player, args); execute(player, args);
return true; return true;
} else if (player == null) { } else if (player == null) {
TaskManager.IMP.async(new Runnable() { TaskManager.IMP.async(() -> execute(player, args));
@Override
public void run() {
execute(player, args);
}
});
} else { } else {
if (!player.runAction(new Runnable() { if (!player.runAction(() -> execute(player, args), true, true)) {
@Override
public void run() {
execute(player, args);
}
}, true, true)) {
BBC.WORLDEDIT_COMMAND_LIMIT.send(player); BBC.WORLDEDIT_COMMAND_LIMIT.send(player);
return true; return true;
} }

View File

@ -457,6 +457,13 @@ public abstract class FawePlayer<T> extends Metadatable {
*/ */
public abstract void sendMessage(final String message); public abstract void sendMessage(final String message);
/**
* Print a WorldEdit error.
*
* @param msg The error message text
*/
public abstract void printError(String msg);
/** /**
* Have the player execute a command * Have the player execute a command
* *

View File

@ -1,12 +1,8 @@
package com.boydti.fawe.object; package com.boydti.fawe.object;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.changeset.FaweChangeSet; import com.boydti.fawe.object.changeset.FaweChangeSet;
import com.boydti.fawe.object.exception.FaweException;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
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.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.AbstractDelegateExtent;
@ -14,12 +10,10 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.history.changeset.ChangeSet;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector2;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@ -84,23 +84,14 @@ public class DefaultProgressTracker extends RunnableVal2<FaweQueue.ProgressType,
} }
private final void done() { private final void done() {
TaskManager.IMP.task(new Runnable() { TaskManager.IMP.task(this::doneTask);
@Override
public void run() {
doneTask();
}
});
} }
private long lastTick = 0; private long lastTick = 0;
private final void send() { private final void send() {
TaskManager.IMP.task(new Runnable() { // Run on main thread // Run on main thread
@Override TaskManager.IMP.task(this::sendTask);
public void run() {
sendTask();
}
});
} }
public void doneTask() { public void doneTask() {

View File

@ -23,7 +23,7 @@ public class CachedMathMan {
private static float[] ANGLES = new float[65536]; private static float[] ANGLES = new float[65536];
static { static {
for (int i = 0; i < 65536; ++i) { for (int i = 0; i < 65536; ++i) {
ANGLES[i] = (float) Math.sin((double) i * 3.141592653589793D * 2.0D / 65536.0D); ANGLES[i] = (float) Math.sin((double) i * Math.PI * 2.0D / 65536.0D);
} }
} }
@ -51,7 +51,7 @@ public class CachedMathMan {
return ANGLES[(int) (paramFloat * 10430.378F + 16384.0F) & 0xFFFF]; return ANGLES[(int) (paramFloat * 10430.378F + 16384.0F) & 0xFFFF];
} }
protected static final float atan2(float y, float x) { protected static float atan2(float y, float x) {
float add, mul; float add, mul;
if (x < 0.0f) { if (x < 0.0f) {
@ -65,7 +65,7 @@ public class CachedMathMan {
mul = -1.0f; mul = -1.0f;
} }
add = -3.141592653f; add = (float) -Math.PI;
} else { } else {
if (y < 0.0f) { if (y < 0.0f) {
y = -y; y = -y;

View File

@ -1,23 +1,14 @@
package com.boydti.fawe.util; package com.boydti.fawe.util;
import java.io.*; import java.io.DataOutput;
import java.net.URI; import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public final class IOUtil { public final class IOUtil {
public InputStream toInputStream(URI uri) throws IOException {
String scheme = uri.getScheme();
switch (scheme.toLowerCase()) {
case "file":
return new FileInputStream(uri.getPath());
case "http":
case "https":
return uri.toURL().openStream();
default:
return null;
}
}
public static final int readInt(InputStream in) throws IOException { public static int readInt(InputStream in) throws IOException {
int ch1 = in.read(); int ch1 = in.read();
int ch2 = in.read(); int ch2 = in.read();
int ch3 = in.read(); int ch3 = in.read();
@ -27,22 +18,14 @@ public final class IOUtil {
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0)); return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
} }
public static final void writeInt(OutputStream out, int v) throws IOException { public static void writeInt(OutputStream out, int v) throws IOException {
out.write((v >>> 24) & 0xFF); out.write((v >>> 24) & 0xFF);
out.write((v >>> 16) & 0xFF); out.write((v >>> 16) & 0xFF);
out.write((v >>> 8) & 0xFF); out.write((v >>> 8) & 0xFF);
out.write((v >>> 0) & 0xFF); out.write((v >>> 0) & 0xFF);
} }
public static final void writeVarInt(final OutputStream out, int i) throws IOException { public static int readVarInt(InputStream in) throws IOException {
while((i & -128) != 0) {
out.write(i & 127 | 128);
i >>>= 7;
}
out.write(i);
}
public static final int readVarInt(InputStream in) throws IOException {
int i = 0; int i = 0;
int offset = 0; int offset = 0;
int b; int b;
@ -54,7 +37,7 @@ public final class IOUtil {
return i; return i;
} }
public static final void copy(InputStream in, OutputStream out) throws IOException { public static void copy(InputStream in, OutputStream out) throws IOException {
byte[] buf = new byte[8192]; byte[] buf = new byte[8192];
while (true) { while (true) {
int r = in.read(buf); int r = in.read(buf);
@ -65,7 +48,7 @@ public final class IOUtil {
} }
} }
public static final int copy(InputStream in, OutputStream out, int len) throws IOException { public static int copy(InputStream in, OutputStream out, int len) throws IOException {
byte[] buf = new byte[8192]; byte[] buf = new byte[8192];
while (len > 0) { while (len > 0) {
int r = in.read(buf, 0, Math.min(buf.length, len)); int r = in.read(buf, 0, Math.min(buf.length, len));
@ -78,7 +61,7 @@ public final class IOUtil {
return len; return len;
} }
public static final void copy(InputStream in, DataOutput out) throws IOException { public static void copy(InputStream in, DataOutput out) throws IOException {
byte[] buf = new byte[8192]; byte[] buf = new byte[8192];
while (true) { while (true) {
int r = in.read(buf); int r = in.read(buf);

View File

@ -121,72 +121,72 @@ public class MathMan {
} }
} }
public static final long inverseRound(double val) { public static long inverseRound(double val) {
long round = Math.round(val); long round = Math.round(val);
return (long) (round + Math.signum(val - round)); return (long) (round + Math.signum(val - round));
} }
public static final int pair(short x, short y) { public static int pair(short x, short y) {
return (x << 16) | (y & 0xFFFF); return (x << 16) | (y & 0xFFFF);
} }
public static final short unpairX(int hash) { public static short unpairX(int hash) {
return (short) (hash >> 16); return (short) (hash >> 16);
} }
public static final short unpairY(int hash) { public static short unpairY(int hash) {
return (short) (hash & 0xFFFF); return (short) (hash & 0xFFFF);
} }
public static final short pairByte(int x, int y) { public static short pairByte(int x, int y) {
return (short) ((x << 8) | (y & 0xFF)); return (short) ((x << 8) | (y & 0xFF));
} }
public static final byte unpairShortX(short pair) { public static byte unpairShortX(short pair) {
return (byte) (pair >> 8); return (byte) (pair >> 8);
} }
public static final byte unpairShortY(short pair) { public static byte unpairShortY(short pair) {
return (byte) pair; return (byte) pair;
} }
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 static final long tripleWorldCoord(int x, int y, int z) { public static long tripleWorldCoord(int x, int y, int z) {
return y + (((long) x & 0x3FFFFFF) << 8) + (((long) z & 0x3FFFFFF) << 34); return y + (((long) x & 0x3FFFFFF) << 8) + (((long) z & 0x3FFFFFF) << 34);
} }
public static final long untripleWorldCoordX(long triple) { public static long untripleWorldCoordX(long triple) {
return (((triple >> 8) & 0x3FFFFFF) << 38) >> 38; return (((triple >> 8) & 0x3FFFFFF) << 38) >> 38;
} }
public static final long untripleWorldCoordY(long triple) { public static long untripleWorldCoordY(long triple) {
return triple & 0xFF; return triple & 0xFF;
} }
public static final long untripleWorldCoordZ(long triple) { public static long untripleWorldCoordZ(long triple) {
return (((triple >> 34) & 0x3FFFFFF) << 38) >> 38; return (((triple >> 34) & 0x3FFFFFF) << 38) >> 38;
} }
public static final short tripleBlockCoord(int x, int y, int z) { public static short tripleBlockCoord(int x, int y, int z) {
return (short) ((x & 15) << 12 | (z & 15) << 8 | y); return (short) ((x & 15) << 12 | (z & 15) << 8 | y);
} }
public static final char tripleBlockCoordChar(int x, int y, int z) { public static char tripleBlockCoordChar(int x, int y, int z) {
return (char) ((x & 15) << 12 | (z & 15) << 8 | y); return (char) ((x & 15) << 12 | (z & 15) << 8 | y);
} }
public static final int untripleBlockCoordX(int triple) { public static int untripleBlockCoordX(int triple) {
return (triple >> 12) & 0xF; return (triple >> 12) & 0xF;
} }
public static final int untripleBlockCoordY(int triple) { public static int untripleBlockCoordY(int triple) {
return (triple & 0xFF); return (triple & 0xFF);
} }
public static final int untripleBlockCoordZ(int triple) { public static int untripleBlockCoordZ(int triple) {
return (triple >> 8) & 0xF; return (triple >> 8) & 0xF;
} }
@ -231,31 +231,31 @@ public class MathMan {
return y3 + (y2 << 4) + (y1 << 12); return y3 + (y2 << 4) + (y1 << 12);
} }
public static final long chunkXZ2Int(int x, int z) { public static long chunkXZ2Int(int x, int z) {
return (long) x & 4294967295L | ((long) z & 4294967295L) << 32; return (long) x & 4294967295L | ((long) z & 4294967295L) << 32;
} }
public static final int unpairIntX(long pair) { public static int unpairIntX(long pair) {
return (int) (pair >> 32); return (int) (pair >> 32);
} }
public static final int unpairIntY(long pair) { public static int unpairIntY(long pair) {
return (int) pair; return (int) pair;
} }
public static final byte pair16(int x, int y) { public static byte pair16(int x, int y) {
return (byte) (x + (y << 4)); return (byte) (x + (y << 4));
} }
public static final byte unpair16x(byte value) { public static byte unpair16x(byte value) {
return (byte) (value & 0xF); return (byte) (value & 0xF);
} }
public static final byte unpair16y(byte value) { public static byte unpair16y(byte value) {
return (byte) ((value >> 4) & 0xF); return (byte) ((value >> 4) & 0xF);
} }
public static final byte pair8(int x, int y) { public static byte pair8(int x, int y) {
return (byte) (x + (y << 3)); return (byte) (x + (y << 3));
} }
@ -267,18 +267,18 @@ public class MathMan {
return (byte) ((value >> 3) & 0x7F); return (byte) ((value >> 3) & 0x7F);
} }
public static final int lossyFastDivide(int a, int b) { public static int lossyFastDivide(int a, int b) {
return (a * ((1 << 16) / b)) >> 16; return (a * ((1 << 16) / b)) >> 16;
} }
public static final int gcd(int a, int b) { public static int gcd(int a, int b) {
if (b == 0) { if (b == 0) {
return a; return a;
} }
return gcd(b, a % b); return gcd(b, a % b);
} }
public static final int gcd(int[] a) { public static int gcd(int[] a) {
int result = a[0]; int result = a[0];
for (int i = 1; i < a.length; i++) { for (int i = 1; i < a.length; i++) {
result = gcd(result, a[i]); result = gcd(result, a[i]);
@ -287,7 +287,7 @@ public class MathMan {
} }
public static final double getMean(int[] array) { public static double getMean(int[] array) {
double count = 0; double count = 0;
for (int i : array) { for (int i : array) {
count += i; count += i;
@ -295,7 +295,7 @@ public class MathMan {
return count / array.length; return count / array.length;
} }
public static final double getMean(double[] array) { public static double getMean(double[] array) {
double count = 0; double count = 0;
for (double i : array) { for (double i : array) {
count += i; count += i;
@ -310,12 +310,12 @@ public class MathMan {
* @param pitch * @param pitch
* @return * @return
*/ */
public static final float[] getDirection(float yaw, float pitch) { public static float[] getDirection(float yaw, float pitch) {
double pitch_sin = Math.sin(pitch); double pitch_sin = Math.sin(pitch);
return new float[]{(float) (pitch_sin * Math.cos(yaw)), (float) (pitch_sin * Math.sin(yaw)), (float) Math.cos(pitch)}; return new float[]{(float) (pitch_sin * Math.cos(yaw)), (float) (pitch_sin * Math.sin(yaw)), (float) Math.cos(pitch)};
} }
public static final int roundInt(double value) { public static int roundInt(double value) {
return (int) (value < 0 ? (value == (int) value) ? value : value - 1 : value); return (int) (value < 0 ? (value == (int) value) ? value : value - 1 : value);
} }
@ -327,24 +327,24 @@ public class MathMan {
* @param z * @param z
* @return * @return
*/ */
public static final float[] getPitchAndYaw(float x, float y, float z) { public static float[] getPitchAndYaw(float x, float y, float z) {
float distance = sqrtApprox((z * z) + (x * x)); float distance = sqrtApprox((z * z) + (x * x));
return new float[]{atan2(y, distance), atan2(x, z)}; return new float[]{atan2(y, distance), atan2(x, z)};
} }
public static final float atan2(float y, float x) { public static float atan2(float y, float x) {
return CachedMathMan.atan2(y, x); return CachedMathMan.atan2(y, x);
} }
public static final float sqrtApprox(float f) { public static float sqrtApprox(float f) {
return f * Float.intBitsToFloat(0x5f375a86 - (Float.floatToIntBits(f) >> 1)); return f * Float.intBitsToFloat(0x5f375a86 - (Float.floatToIntBits(f) >> 1));
} }
public static final double sqrtApprox(double d) { public static double sqrtApprox(double d) {
return Double.longBitsToDouble(((Double.doubleToLongBits(d) - (1l << 52)) >> 1) + (1l << 61)); return Double.longBitsToDouble(((Double.doubleToLongBits(d) - (1l << 52)) >> 1) + (1l << 61));
} }
public static final float invSqrt(float x) { public static float invSqrt(float x) {
float xhalf = 0.5f * x; float xhalf = 0.5f * x;
int i = Float.floatToIntBits(x); int i = Float.floatToIntBits(x);
i = 0x5f3759df - (i >> 1); i = 0x5f3759df - (i >> 1);
@ -353,7 +353,7 @@ public class MathMan {
return x; return x;
} }
public static final boolean isInteger(CharSequence str) { public static boolean isInteger(CharSequence str) {
if (str == null) { if (str == null) {
return false; return false;
} }
@ -377,7 +377,7 @@ public class MathMan {
return true; return true;
} }
public static final double getSD(double[] array, double av) { public static double getSD(double[] array, double av) {
double sd = 0; double sd = 0;
for (double element : array) { for (double element : array) {
sd += Math.pow(Math.abs(element - av), 2); sd += Math.pow(Math.abs(element - av), 2);
@ -385,7 +385,7 @@ public class MathMan {
return Math.sqrt(sd / array.length); return Math.sqrt(sd / array.length);
} }
public static final double getSD(int[] array, double av) { public static double getSD(int[] array, double av) {
double sd = 0; double sd = 0;
for (int element : array) { for (int element : array) {
sd += Math.pow(Math.abs(element - av), 2); sd += Math.pow(Math.abs(element - av), 2);
@ -393,25 +393,25 @@ public class MathMan {
return Math.sqrt(sd / array.length); return Math.sqrt(sd / array.length);
} }
public static final int absByte(int value) { public static int absByte(int value) {
return (value ^ (value >> 8)) - (value >> 8); return (value ^ (value >> 8)) - (value >> 8);
} }
public static final int mod(int x, int y) { public static int mod(int x, int y) {
if (isPowerOfTwo(y)) { if (isPowerOfTwo(y)) {
return x & (y - 1); return x & (y - 1);
} }
return x % y; return x % y;
} }
public static final int unsignedmod(int x, int y) { public static int unsignedmod(int x, int y) {
if (isPowerOfTwo(y)) { if (isPowerOfTwo(y)) {
return x & (y - 1); return x & (y - 1);
} }
return x % y; return x % y;
} }
public static final boolean isPowerOfTwo(int x) { public static boolean isPowerOfTwo(int x) {
return (x & (x - 1)) == 0; return (x & (x - 1)) == 0;
} }
} }

View File

@ -29,7 +29,7 @@ public class ReflectionUtils9 {
// 2. Copy it // 2. Copy it
T[] previousValues = (T[]) valuesField.get(enumType); T[] previousValues = (T[]) valuesField.get(enumType);
List values = new ArrayList(Arrays.asList(previousValues)); List values = new ArrayList<>(Arrays.asList(previousValues));
// 3. build new enum // 3. build new enum
T newValue = (T) makeEnum(enumType, // The target enum class T newValue = (T) makeEnum(enumType, // The target enum class

View File

@ -672,21 +672,21 @@ public class ShapeInterpolator {
} }
/** /**
* @{inheritDoc} * {@inheritDoc}
*/ */
public int getWindingRule() { public int getWindingRule() {
return (t < 0.5 ? g0.getWindingRule() : g1.getWindingRule()); return (t < 0.5 ? g0.getWindingRule() : g1.getWindingRule());
} }
/** /**
* @{inheritDoc} * {@inheritDoc}
*/ */
public boolean isDone() { public boolean isDone() {
return (cIndex > g0.getNumCoordinates()); return (cIndex > g0.getNumCoordinates());
} }
/** /**
* @{inheritDoc} * {@inheritDoc}
*/ */
public void next() { public void next() {
if (cIndex == 0) { if (cIndex == 0) {
@ -697,7 +697,7 @@ public class ShapeInterpolator {
} }
/** /**
* @{inheritDoc} * {@inheritDoc}
*/ */
public int currentSegment(float[] coordinates) { public int currentSegment(float[] coordinates) {
int type; int type;

View File

@ -127,7 +127,7 @@ public class StringMan {
int start = sb.indexOf(key, 0); int start = sb.indexOf(key, 0);
while (start > -1) { while (start > -1) {
final int end = start + key.length(); final int end = start + key.length();
final int nextSearchStart = start + 0; final int nextSearchStart = start;
sb.delete(start, end); sb.delete(start, end);
size -= end - start; size -= end - start;
start = sb.indexOf(key, nextSearchStart); start = sb.indexOf(key, nextSearchStart);
@ -209,10 +209,10 @@ public class StringMan {
} }
return "{ " + result + " }"; return "{ " + result + " }";
} else if (obj instanceof Collection<?>) { } else if (obj instanceof Collection<?>) {
String result = ""; StringBuilder result = new StringBuilder();
String prefix = ""; String prefix = "";
for (final Object element : (Collection<?>) obj) { for (final Object element : (Collection<?>) obj) {
result += prefix + getString(element); result.append(prefix).append(getString(element));
prefix = ","; prefix = ",";
} }
return "( " + result + " )"; return "( " + result + " )";
@ -299,13 +299,7 @@ public class StringMan {
public static String joinOrdered(final Collection<?> collection, final String delimiter) { public static String joinOrdered(final Collection<?> collection, final String delimiter) {
final Object[] array = collection.toArray(); final Object[] array = collection.toArray();
Arrays.sort(array, new Comparator<Object>() { Arrays.sort(array, Comparator.comparingInt(Object::hashCode));
@Override
public int compare(final Object a, final Object b) {
return a.hashCode() - b.hashCode();
}
});
return join(array, delimiter); return join(array, delimiter);
} }
@ -327,12 +321,7 @@ public class StringMan {
} }
public static Comparator<String> blockStateComparator(String input) { public static Comparator<String> blockStateComparator(String input) {
return new Comparator<String>() { return Comparator.comparingInt(o -> blockStateStringDistance(input, o));
@Override
public int compare(String o1, String o2) {
return blockStateStringDistance(input, o1) - blockStateStringDistance(input, o2);
}
};
} }
public static boolean blockStateMatches(String input, String item) { public static boolean blockStateMatches(String input, String item) {
@ -392,9 +381,9 @@ public class StringMan {
n = m; n = m;
m = t.length(); m = t.length();
} }
int p[] = new int[n + 1]; int[] p = new int[n + 1];
int d[] = new int[n + 1]; int[] d = new int[n + 1];
int _d[]; int[] _d;
int i; int i;
int j; int j;
char t_j; char t_j;

View File

@ -105,6 +105,7 @@ import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.WaterloggedRemover;
import com.sk89q.worldedit.function.util.RegionOffset; import com.sk89q.worldedit.function.util.RegionOffset;
import com.sk89q.worldedit.function.visitor.DirectionalVisitor; import com.sk89q.worldedit.function.visitor.DirectionalVisitor;
import com.sk89q.worldedit.function.visitor.DownwardVisitor; import com.sk89q.worldedit.function.visitor.DownwardVisitor;
@ -709,6 +710,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* Returns queue status. * Returns queue status.
* *
* @return whether the queue is enabled * @return whether the queue is enabled
* @deprecated Use {@link EditSession#getReorderMode()} with MULTI_STAGE instead.
*/ */
@Deprecated @Deprecated
public boolean isQueueEnabled() { public boolean isQueueEnabled() {
@ -717,6 +719,9 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
/** /**
* Queue certain types of block for better reproduction of those blocks. * Queue certain types of block for better reproduction of those blocks.
*
* Uses {@link ReorderMode#MULTI_STAGE}
* @deprecated Use {@link EditSession#setReorderMode(ReorderMode)} with MULTI_STAGE instead.
*/ */
@Deprecated @Deprecated
public void enableQueue() { public void enableQueue() {
@ -2180,17 +2185,19 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
// if (getWorld() != null) { // if (getWorld() != null) {
// liquidMask = getWorld().createLiquidMask(); // liquidMask = getWorld().createLiquidMask();
// } else { // } else {
liquidMask = new BlockTypeMask(this,
BlockTypes.LAVA,
BlockTypes.WATER);
// } // }
final MaskIntersection mask = new MaskIntersection( liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
new BoundedHeightMask(0, EditSession.this.getMaximumPoint().getBlockY()), MaskIntersection mask = new MaskIntersection(
new BoundedHeightMask(0, getWorld().getMaxY()),
new RegionMask( new RegionMask(
new EllipsoidRegion(null, origin, new EllipsoidRegion(null, origin,
Vector3.at(radius, radius, radius))), liquidMask); Vector3.at(radius, radius, radius))), liquidMask);
BlockReplace replace;
BlockReplace replace = new BlockReplace(this, BlockTypes.AIR.getDefaultState()); if (waterlogged) {
replace = new BlockReplace(this, new WaterloggedRemover(this));
} else {
replace = new BlockReplace(this, new BlockPattern(BlockTypes.AIR.getDefaultState()));
}
RecursiveVisitor visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1), this); RecursiveVisitor visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1), this);
// Around the origin in a 3x3 block // Around the origin in a 3x3 block
@ -3384,19 +3391,19 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (block.getBlockType().getMaterial().isMovementBlocker()) { if (block.getBlockType().getMaterial().isMovementBlocker()) {
continue; continue;
} }
if (!outside.add(current)) { if (!outside.add(current)) {
continue; continue;
} }
if (!region.contains(current)) { if (!region.contains(current)) {
continue; continue;
} }
for (BlockVector3 recurseDirection : recurseDirections) { for (BlockVector3 recurseDirection : recurseDirections) {
queue.add(current.add(recurseDirection)); queue.add(current.add(recurseDirection));
} }
} }
} }
public int makeBiomeShape(final Region region, final Vector3 zero, final Vector3 unit, final BiomeType biomeType, public int makeBiomeShape(final Region region, final Vector3 zero, final Vector3 unit, final BiomeType biomeType,

View File

@ -208,7 +208,7 @@ public class BrushCommands extends BrushProcessor {
@CommandPermissions("worldedit.brush.spline") @CommandPermissions("worldedit.brush.spline")
public BrushSettings splineBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, @Optional("25") Expression radius, CommandContext context) throws WorldEditException { public BrushSettings splineBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, @Optional("25") Expression radius, CommandContext context) throws WorldEditException {
getWorldEdit().checkMaxBrushRadius(radius); getWorldEdit().checkMaxBrushRadius(radius);
player.print(BBC.getPrefix() + BBC.BRUSH_SPLINE.f(radius)); player.print(BBC.BRUSH_SPLINE.f(radius));
return set(session, context, return set(session, context,
new SplineBrush(player, session)) new SplineBrush(player, session))
.setSize(radius) .setSize(radius)
@ -227,7 +227,7 @@ public class BrushCommands extends BrushProcessor {
) )
@CommandPermissions("worldedit.brush.sweep") @CommandPermissions("worldedit.brush.sweep")
public BrushSettings sweepBrush(Player player, LocalSession session, EditSession editSession, @Optional("-1") int copies, CommandContext context) throws WorldEditException { public BrushSettings sweepBrush(Player player, LocalSession session, EditSession editSession, @Optional("-1") int copies, CommandContext context) throws WorldEditException {
player.print(BBC.getPrefix() + BBC.BRUSH_SPLINE.s()); player.print(BBC.BRUSH_SPLINE.s());
return set(session, context, new SweepBrush(copies)); return set(session, context, new SweepBrush(copies));
} }
@ -263,7 +263,7 @@ public class BrushCommands extends BrushProcessor {
) )
@CommandPermissions("worldedit.brush.surfacespline") // 0, 0, 0, 10, 0, @CommandPermissions("worldedit.brush.surfacespline") // 0, 0, 0, 10, 0,
public BrushSettings surfaceSpline(Player player, EditSession editSession, LocalSession session, Pattern fill, @Optional("0") Expression radius, @Optional("0") double tension, @Optional("0") double bias, @Optional("0") double continuity, @Optional("10") double quality, CommandContext context) throws WorldEditException { public BrushSettings surfaceSpline(Player player, EditSession editSession, LocalSession session, Pattern fill, @Optional("0") Expression radius, @Optional("0") double tension, @Optional("0") double bias, @Optional("0") double continuity, @Optional("10") double quality, CommandContext context) throws WorldEditException {
player.print(BBC.getPrefix() + BBC.BRUSH_SPLINE.f(radius)); player.print(BBC.BRUSH_SPLINE.f(radius));
getWorldEdit().checkMaxBrushRadius(radius); getWorldEdit().checkMaxBrushRadius(radius);
return set(session, context, return set(session, context,
new SurfaceSpline(tension, bias, continuity, quality)) new SurfaceSpline(tension, bias, continuity, quality))
@ -794,7 +794,7 @@ public class BrushCommands extends BrushProcessor {
@CommandPermissions("worldedit.brush.copy") @CommandPermissions("worldedit.brush.copy")
public BrushSettings copy(Player player, LocalSession session, @Optional("5") Expression radius, @Switch('r') boolean randomRotate, @Switch('a') boolean autoRotate, CommandContext context) throws WorldEditException { public BrushSettings copy(Player player, LocalSession session, @Optional("5") Expression radius, @Switch('r') boolean randomRotate, @Switch('a') boolean autoRotate, CommandContext context) throws WorldEditException {
getWorldEdit().checkMaxBrushRadius(radius); getWorldEdit().checkMaxBrushRadius(radius);
player.print(BBC.getPrefix() + BBC.BRUSH_COPY.f(radius)); player.print(BBC.BRUSH_COPY.f(radius));
return set(session, context, return set(session, context,
new CopyPastaBrush(player, session, randomRotate, autoRotate)) new CopyPastaBrush(player, session, randomRotate, autoRotate))

View File

@ -355,7 +355,7 @@ public class BrushOptionsCommands extends MethodCommands {
public void mask(Player player, LocalSession session, EditSession editSession, @Optional @Switch('h') boolean offHand, CommandContext context) throws WorldEditException { public void mask(Player player, LocalSession session, EditSession editSession, @Optional @Switch('h') boolean offHand, CommandContext context) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.getPrefix() + BBC.BRUSH_NONE.f()); player.print(BBC.BRUSH_NONE.f());
return; return;
} }
if (context.argsLength() == 0) { if (context.argsLength() == 0) {
@ -388,7 +388,7 @@ public class BrushOptionsCommands extends MethodCommands {
public void smask(Player player, LocalSession session, EditSession editSession, @Optional @Switch('h') boolean offHand, CommandContext context) throws WorldEditException { public void smask(Player player, LocalSession session, EditSession editSession, @Optional @Switch('h') boolean offHand, CommandContext context) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.getPrefix() + BBC.BRUSH_NONE.f()); player.print(BBC.BRUSH_NONE.f());
return; return;
} }
if (context.argsLength() == 0) { if (context.argsLength() == 0) {
@ -420,7 +420,7 @@ public class BrushOptionsCommands extends MethodCommands {
public void transform(Player player, LocalSession session, EditSession editSession, @Optional @Switch('h') boolean offHand, CommandContext context) throws WorldEditException { public void transform(Player player, LocalSession session, EditSession editSession, @Optional @Switch('h') boolean offHand, CommandContext context) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.getPrefix() + BBC.BRUSH_NONE.f()); player.print(BBC.BRUSH_NONE.f());
return; return;
} }
if (context.argsLength() == 0) { if (context.argsLength() == 0) {
@ -452,7 +452,7 @@ public class BrushOptionsCommands extends MethodCommands {
public void material(Player player, EditSession editSession, LocalSession session, Pattern pattern, @Switch('h') boolean offHand, CommandContext context) throws WorldEditException { public void material(Player player, EditSession editSession, LocalSession session, Pattern pattern, @Switch('h') boolean offHand, CommandContext context) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.getPrefix() + BBC.BRUSH_NONE.f()); player.print(BBC.BRUSH_NONE.f());
return; return;
} }
if (context.argsLength() == 0) { if (context.argsLength() == 0) {
@ -479,7 +479,7 @@ public class BrushOptionsCommands extends MethodCommands {
int range = Math.max(0, Math.min(256, args.getInteger(0))); int range = Math.max(0, Math.min(256, args.getInteger(0)));
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.getPrefix() + BBC.BRUSH_NONE.f()); player.print(BBC.BRUSH_NONE.f());
return; return;
} }
tool.setRange(range); tool.setRange(range);
@ -499,7 +499,7 @@ public class BrushOptionsCommands extends MethodCommands {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.getPrefix() + BBC.BRUSH_NONE.f()); player.print(BBC.BRUSH_NONE.f());
return; return;
} }
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext(); BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
@ -509,4 +509,4 @@ public class BrushOptionsCommands extends MethodCommands {
} }
} }

View File

@ -31,7 +31,6 @@ import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.minecraft.util.commands.Logging; import com.sk89q.minecraft.util.commands.Logging;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -44,17 +43,16 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.function.visitor.RegionVisitor;
import com.sk89q.worldedit.internal.annotation.Selection; import com.sk89q.worldedit.internal.annotation.Selection;
import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.math.BlockVector2; 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.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator.TreeType; import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.util.command.binding.Range; import com.sk89q.worldedit.util.command.binding.Range;
import com.sk89q.worldedit.util.command.binding.Switch; import com.sk89q.worldedit.util.command.binding.Switch;
import com.sk89q.worldedit.util.command.binding.Text; import com.sk89q.worldedit.util.command.binding.Text;
import com.sk89q.worldedit.util.command.parametric.Optional; import com.sk89q.worldedit.util.command.parametric.Optional;
import com.sk89q.worldedit.util.command.parametric.ParameterException;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
@ -63,7 +61,9 @@ import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*; import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
/** /**
@ -89,7 +89,7 @@ public class GenerationCommands extends MethodCommands {
) )
@CommandPermissions("worldedit.generation.caves") @CommandPermissions("worldedit.generation.caves")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void caves(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, @Optional("8") int size, @Optional("40") int frequency, @Optional("7") int rarity, @Optional("8") int minY, @Optional("127") int maxY, @Optional("1") int systemFrequency, @Optional("25") int individualRarity, @Optional("0") int pocketChance, @Optional("0") int pocketMin, @Optional("3") int pocketMax, CommandContext context) throws WorldEditException, ParameterException { public void caves(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, @Optional("8") int size, @Optional("40") int frequency, @Optional("7") int rarity, @Optional("8") int minY, @Optional("127") int maxY, @Optional("1") int systemFrequency, @Optional("25") int individualRarity, @Optional("0") int pocketChance, @Optional("0") int pocketMin, @Optional("3") int pocketMax, CommandContext context) throws WorldEditException {
fp.checkConfirmationRegion(() -> { fp.checkConfirmationRegion(() -> {
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);
@ -108,7 +108,7 @@ public class GenerationCommands extends MethodCommands {
) )
@CommandPermissions("worldedit.generation.ore") @CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void ores(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, CommandContext context) throws WorldEditException, ParameterException { public void ores(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, CommandContext context) throws WorldEditException {
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());
@ -124,7 +124,7 @@ public class GenerationCommands extends MethodCommands {
) )
@CommandPermissions("worldedit.generation.image") @CommandPermissions("worldedit.generation.image")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void image(Player player, LocalSession session, EditSession editSession, String arg, @Optional("true") boolean randomize, @Optional("100") int threshold, @Optional BlockVector2 dimensions) throws WorldEditException, ParameterException, IOException { public void image(Player player, LocalSession session, EditSession editSession, String arg, @Optional("true") boolean randomize, @Optional("100") int threshold, @Optional BlockVector2 dimensions) throws WorldEditException, IOException {
TextureUtil tu = Fawe.get().getCachedTextureUtil(randomize, 0, threshold); TextureUtil tu = Fawe.get().getCachedTextureUtil(randomize, 0, threshold);
URL url = new URL(arg); URL url = new URL(arg);
if (!url.getHost().equalsIgnoreCase("i.imgur.com") && !url.getHost().equalsIgnoreCase("empcraft.com")) { if (!url.getHost().equalsIgnoreCase("i.imgur.com") && !url.getHost().equalsIgnoreCase("empcraft.com")) {
@ -174,7 +174,7 @@ public class GenerationCommands extends MethodCommands {
) )
@CommandPermissions("worldedit.generation.ore") @CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void ore(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, @Range(min = 0) int size, int freq, @Range(min = 0, max = 100) int rarity, @Range(min = 0, max = 255) int minY, @Range(min = 0, max = 255) int maxY, CommandContext context) throws WorldEditException, ParameterException { public void ore(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, @Range(min = 0) int size, int freq, @Range(min = 0, max = 100) int rarity, @Range(min = 0, max = 255) int minY, @Range(min = 0, max = 255) int maxY, CommandContext context) throws WorldEditException {
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());
@ -182,20 +182,20 @@ public class GenerationCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/hcyl"}, aliases = { "/hcyl" },
usage = "<pattern> <radius>[,<radius>] [height]", usage = "<pattern> <radius>[,<radius>] [height]",
desc = "Generates a hollow cylinder.", desc = "Generates a hollow cylinder.",
help = help =
"Generates a hollow cylinder.\n" + "Generates a hollow cylinder.\n" +
"By specifying 2 radii, separated by a comma,\n" + "By specifying 2 radii, separated by a comma,\n" +
"you can generate elliptical cylinders.\n" + "you can generate elliptical cylinders.\n" +
"The 1st radius is north/south, the 2nd radius is east/west.", "The 1st radius is north/south, the 2nd radius is east/west.",
min = 2, min = 2,
max = 4 max = 4
) )
@CommandPermissions("worldedit.generation.cylinder") @CommandPermissions("worldedit.generation.cylinder")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void hcyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector2 radius, @Optional("1") int height, @Range(min = 1) @Optional("1") double thickness, CommandContext context) throws WorldEditException, ParameterException { public void hcyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector2 radius, @Optional("1") int height, @Range(min = 1) @Optional("1") double thickness, CommandContext context) throws WorldEditException {
double max = MathMan.max(radius.getBlockX(), radius.getBlockZ()); double max = MathMan.max(radius.getBlockX(), radius.getBlockZ());
worldEdit.checkMaxRadius(max); worldEdit.checkMaxRadius(max);
BlockVector3 pos = session.getPlacementPosition(player); BlockVector3 pos = session.getPlacementPosition(player);
@ -206,22 +206,22 @@ public class GenerationCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/cyl"}, aliases = { "/cyl" },
usage = "<pattern> <radius>[,<radius>] [height]", usage = "<pattern> <radius>[,<radius>] [height]",
flags = "h", flags = "h",
desc = "Generates a cylinder.", desc = "Generates a cylinder.",
help = help =
"Generates a cylinder.\n" + "Generates a cylinder.\n" +
"By specifying 2 radii, separated by a comma,\n" + "By specifying 2 radii, separated by a comma,\n" +
"you can generate elliptical cylinders.\n" + "you can generate elliptical cylinders.\n" +
"The 1st radius is north/south, the 2nd radius is east/west.", "The 1st radius is north/south, the 2nd radius is east/west.",
min = 2, min = 2,
max = 3 max = 3
) )
@CommandPermissions("worldedit.generation.cylinder") @CommandPermissions("worldedit.generation.cylinder")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void cyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector2 radius, @Optional("1") int height, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException { public void cyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector2 radius, @Optional("1") int height, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException {
double max = MathMan.max(radius.getBlockX(), radius.getBlockZ()); double max = Math.max(radius.getBlockX(), radius.getBlockZ());
worldEdit.checkMaxRadius(max); worldEdit.checkMaxRadius(max);
BlockVector3 pos = session.getPlacementPosition(player); BlockVector3 pos = session.getPlacementPosition(player);
fp.checkConfirmationRadius(() -> { fp.checkConfirmationRadius(() -> {
@ -231,39 +231,39 @@ public class GenerationCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/hsphere"}, aliases = { "/hsphere" },
usage = "<pattern> <radius>[,<radius>,<radius>] [raised?]", usage = "<pattern> <radius>[,<radius>,<radius>] [raised?]",
desc = "Generates a hollow sphere.", desc = "Generates a hollow sphere.",
help = help =
"Generates a hollow sphere.\n" + "Generates a hollow sphere.\n" +
"By specifying 3 radii, separated by commas,\n" + "By specifying 3 radii, separated by commas,\n" +
"you can generate an ellipsoid. The order of the ellipsoid radii\n" + "you can generate an ellipsoid. The order of the ellipsoid radii\n" +
"is north/south, up/down, east/west.", "is north/south, up/down, east/west.",
min = 2, min = 2,
max = 3 max = 3
) )
@CommandPermissions("worldedit.generation.sphere") @CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void hsphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector3 radius, @Optional("false") boolean raised, CommandContext context) throws WorldEditException, ParameterException { public void hsphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector3 radius, @Optional("false") boolean raised, CommandContext context) throws WorldEditException {
sphere(fp, player, session, editSession, pattern, radius, raised, true, context); sphere(fp, player, session, editSession, pattern, radius, raised, true, context);
} }
@Command( @Command(
aliases = {"/sphere"}, aliases = { "/sphere" },
usage = "<pattern> <radius>[,<radius>,<radius>] [raised?]", usage = "<pattern> <radius>[,<radius>,<radius>] [raised?]",
flags = "h", flags = "h",
desc = "Generates a filled sphere.", desc = "Generates a filled sphere.",
help = help =
"Generates a filled sphere.\n" + "Generates a filled sphere.\n" +
"By specifying 3 radii, separated by commas,\n" + "By specifying 3 radii, separated by commas,\n" +
"you can generate an ellipsoid. The order of the ellipsoid radii\n" + "you can generate an ellipsoid. The order of the ellipsoid radii\n" +
"is north/south, up/down, east/west.", "is north/south, up/down, east/west.",
min = 2, min = 2,
max = 3 max = 3
) )
@CommandPermissions("worldedit.generation.sphere") @CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector3 radius, @Optional("false") boolean raised, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException { public void sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector3 radius, @Optional("false") boolean raised, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException {
double max = MathMan.max(radius.getBlockX(), radius.getBlockY(), radius.getBlockZ()); double max = MathMan.max(radius.getBlockX(), radius.getBlockY(), radius.getBlockZ());
worldEdit.checkMaxRadius(max); worldEdit.checkMaxRadius(max);
BlockVector3 pos = session.getPlacementPosition(player); BlockVector3 pos = session.getPlacementPosition(player);
@ -276,36 +276,37 @@ public class GenerationCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"forestgen"}, aliases = { "forestgen" },
usage = "[size] [tree-type] [density]", usage = "[size] [type] [density]",
desc = "Generate a forest", desc = "Generate a forest",
min = 0, min = 0,
max = 3 max = 3
) )
@CommandPermissions("worldedit.generation.forest") @CommandPermissions("worldedit.generation.forest")
@Logging(POSITION) @Logging(POSITION)
@SuppressWarnings("deprecation") public void forestGen(Player player, LocalSession session, EditSession editSession, @Optional("10") int size,
public void forestGen(Player player, LocalSession session, EditSession editSession, @Optional("10") int size, @Optional("tree") TreeType type, @Optional("5") @Range(min = 0, max = 100) double density) throws WorldEditException, ParameterException { @Optional("tree") TreeType type, @Optional("5") @Range(min = 0, max = 100) double density) throws WorldEditException {
density = density / 100; density = density / 100;
int affected = editSession.makeForest(session.getPlacementPosition(player), size, density, type); int affected = editSession.makeForest(session.getPlacementPosition(player), size, density, type);
player.print(BBC.getPrefix() + affected + " trees created."); player.print(affected + " trees created.");
} }
@Command( @Command(
aliases = {"pumpkins"}, aliases = { "pumpkins" },
usage = "[size=10]", usage = "[size]",
desc = "Generate pumpkin patches", desc = "Generate pumpkin patches",
max = 2 min = 0,
max = 2
) )
@CommandPermissions("worldedit.generation.pumpkins") @CommandPermissions("worldedit.generation.pumpkins")
@Logging(POSITION) @Logging(POSITION)
public void pumpkins(Player player, LocalSession session, EditSession editSession, @Optional("10") int apothem) throws WorldEditException, ParameterException { public void pumpkins(Player player, LocalSession session, EditSession editSession, @Optional("10") int apothem) throws WorldEditException {
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), apothem); int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), apothem);
BBC.COMMAND_PUMPKIN.send(player, affected); BBC.COMMAND_PUMPKIN.send(player, affected);
} }
@Command( @Command(
aliases = {"/hpyramid"}, aliases = { "/hpyramid" },
usage = "<pattern> <size>", usage = "<pattern> <size>",
desc = "Generate a hollow pyramid", desc = "Generate a hollow pyramid",
min = 2, min = 2,
@ -313,21 +314,21 @@ public class GenerationCommands extends MethodCommands {
) )
@CommandPermissions("worldedit.generation.pyramid") @CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void hollowPyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, CommandContext context) throws WorldEditException, ParameterException { public void hollowPyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, CommandContext context) throws WorldEditException {
pyramid(fp, player, session, editSession, pattern, size, true, context); pyramid(fp, player, session, editSession, pattern, size, true, context);
} }
@Command( @Command(
aliases = {"/pyramid"}, aliases = { "/pyramid" },
usage = "<pattern> <size>", usage = "<pattern> <size>",
flags = "h", flags = "h",
desc = "Generate a filled pyramid", desc = "Generate a filled pyramid",
min = 2, min = 2,
max = 2 max = 2
) )
@CommandPermissions("worldedit.generation.pyramid") @CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void pyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException { public void pyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException {
BlockVector3 pos = session.getPlacementPosition(player); BlockVector3 pos = session.getPlacementPosition(player);
worldEdit.checkMaxRadius(size); worldEdit.checkMaxRadius(size);
fp.checkConfirmationRadius(() -> { fp.checkConfirmationRadius(() -> {
@ -336,26 +337,26 @@ public class GenerationCommands extends MethodCommands {
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(fp, affected);
}, getArguments(context), size, context); }, getArguments(context), size, context);
} }
@Command( @Command(
aliases = {"/generate", "/gen", "/g"}, aliases = { "/generate", "/gen", "/g" },
usage = "<pattern> <expression>", usage = "<pattern> <expression>",
desc = "Generates a shape according to a formula.", desc = "Generates a shape according to a formula.",
help = help =
"Generates a shape according to a formula that is expected to\n" + "Generates a shape according to a formula that is expected to\n" +
"return positive numbers (true) if the point is inside the shape\n" + "return positive numbers (true) if the point is inside the shape\n" +
"Optionally set type/data to the desired block.\n" + "Optionally set type/data to the desired block.\n" +
"Flags:\n" + "Flags:\n" +
" -h to generate a hollow shape\n" + " -h to generate a hollow shape\n" +
" -r to use raw minecraft coordinates\n" + " -r to use raw minecraft coordinates\n" +
" -o is like -r, except offset from placement.\n" + " -o is like -r, except offset from placement.\n" +
" -c is like -r, except offset selection center.\n" + " -c is like -r, except offset selection center.\n" +
"If neither -r nor -o is given, the selection is mapped to -1..1\n" + "If neither -r nor -o is given, the selection is mapped to -1..1\n" +
"See also tinyurl.com/wesyntax.", "See also tinyurl.com/wesyntax.",
flags = "hroc", flags = "hroc",
min = 2, min = 2,
max = -1 max = -1
) )
@CommandPermissions("worldedit.generation.shape") @CommandPermissions("worldedit.generation.shape")
@Logging(ALL) @Logging(ALL)
@ -394,7 +395,7 @@ public class GenerationCommands extends MethodCommands {
if (unit.getY() == 0) unit = unit.withY(1.0); if (unit.getY() == 0) unit = unit.withY(1.0);
if (unit.getZ() == 0) unit = unit.withZ(1.0); if (unit.getZ() == 0) unit = unit.withZ(1.0);
} }
final Vector3 unit1 = unit; final Vector3 unit1 = unit;
fp.checkConfirmationRegion(() -> { fp.checkConfirmationRegion(() -> {
@ -403,29 +404,29 @@ public class GenerationCommands extends MethodCommands {
player.findFreePosition(); player.findFreePosition();
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(fp, affected);
} catch (ExpressionException e) { } catch (ExpressionException e) {
fp.sendMessage(BBC.getPrefix() + e.getMessage()); fp.sendMessage(e.getMessage());
} }
}, getArguments(context), region, context); }, getArguments(context), region, context);
} }
@Command( @Command(
aliases = {"/generatebiome", "/genbiome", "/gb"}, aliases = { "/generatebiome", "/genbiome", "/gb" },
usage = "<biome> <expression>", usage = "<biome> <expression>",
desc = "Sets biome according to a formula.", desc = "Sets biome according to a formula.",
help = help =
"Generates a shape according to a formula that is expected to\n" + "Generates a shape according to a formula that is expected to\n" +
"return positive numbers (true) if the point is inside the shape\n" + "return positive numbers (true) if the point is inside the shape\n" +
"Sets the biome of blocks in that shape.\n" + "Sets the biome of blocks in that shape.\n" +
"Flags:\n" + "Flags:\n" +
" -h to generate a hollow shape\n" + " -h to generate a hollow shape\n" +
" -r to use raw minecraft coordinates\n" + " -r to use raw minecraft coordinates\n" +
" -o is like -r, except offset from placement.\n" + " -o is like -r, except offset from placement.\n" +
" -c is like -r, except offset selection center.\n" + " -c is like -r, except offset selection center.\n" +
"If neither -r nor -o is given, the selection is mapped to -1..1\n" + "If neither -r nor -o is given, the selection is mapped to -1..1\n" +
"See also tinyurl.com/wesyntax.", "See also tinyurl.com/wesyntax.",
flags = "hroc", flags = "hroc",
min = 2, min = 2,
max = -1 max = -1
) )
@CommandPermissions("worldedit.generation.shape.biome") @CommandPermissions("worldedit.generation.shape.biome")
@Logging(ALL) @Logging(ALL)
@ -464,17 +465,18 @@ public class GenerationCommands extends MethodCommands {
if (unit.getY() == 0) unit = unit.withY(1.0); if (unit.getY() == 0) unit = unit.withY(1.0);
if (unit.getZ() == 0) unit = unit.withZ(1.0); if (unit.getZ() == 0) unit = unit.withZ(1.0);
} }
final Vector3 unit1 = unit; final Vector3 unit1 = unit;
fp.checkConfirmationRegion(() -> { fp.checkConfirmationRegion(() -> {
try { try {
final int affected = editSession.makeBiomeShape(region, zero, unit1, target, expression, hollow); final int affected = editSession.makeBiomeShape(region, zero, unit1, target, expression, hollow);
player.findFreePosition(); player.findFreePosition();
BBC.VISITOR_FLAT.send(fp, affected); BBC.VISITOR_FLAT.send(fp, affected);
} catch (ExpressionException e) { } catch (ExpressionException e) {
fp.sendMessage(BBC.getPrefix() + e.getMessage()); fp.toWorldEditPlayer().printError(e.getMessage());
} }
}, getArguments(context), region, context); }, getArguments(context), region, context);
} }
} }

View File

@ -117,7 +117,7 @@ public class HistoryCommands extends MethodCommands {
rollback.setTime(historyFile.lastModified()); rollback.setTime(historyFile.lastModified());
RollbackDatabase db = DBHandler.IMP.getDatabase(world); RollbackDatabase db = DBHandler.IMP.getDatabase(world);
db.logEdit(rollback); db.logEdit(rollback);
player.print(BBC.getPrefix() + "Logging: " + historyFile); player.print("Logging: " + historyFile);
} }
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@ -127,7 +127,7 @@ public class HistoryCommands extends MethodCommands {
} }
} }
} }
player.print(BBC.getPrefix() + "Done import!"); player.print("Done import!");
return; return;
} }
String toParse = user.substring(1); String toParse = user.substring(1);
@ -311,4 +311,4 @@ public class HistoryCommands extends MethodCommands {
} }
} }

View File

@ -42,7 +42,6 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.function.GroundFunction; import com.sk89q.worldedit.function.GroundFunction;
import com.sk89q.worldedit.function.generator.FloraGenerator; import com.sk89q.worldedit.function.generator.FloraGenerator;
import com.sk89q.worldedit.function.generator.ForestGenerator;
import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.NoiseFilter2D; import com.sk89q.worldedit.function.mask.NoiseFilter2D;
@ -136,7 +135,7 @@ public class RegionCommands extends MethodCommands {
FawePlayer fp = FawePlayer.wrap(player); FawePlayer fp = FawePlayer.wrap(player);
final Location loc = player.getLocation(); final Location loc = player.getLocation();
FaweQueue queue = fp.getFaweQueue(false); FaweQueue queue = fp.getFaweQueue(false);
fp.sendMessage(BBC.getPrefix() + "Light: " + queue.getEmmittedLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()) + " | " + queue.getSkyLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); fp.sendMessage("Light: " + queue.getEmmittedLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()) + " | " + queue.getSkyLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
} }
@Command( @Command(
@ -220,14 +219,14 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/line"}, aliases = { "/line" },
usage = "<pattern> [thickness]", usage = "<pattern> [thickness]",
desc = "Draws a line segment between cuboid selection corners", desc = "Draws a line segment between cuboid selection corners",
help = help =
"Draws a line segment between cuboid selection corners.\n" + "Draws a line segment between cuboid selection corners.\n" +
"Can only be used with cuboid selections.\n" + "Can only be used with cuboid selections.\n" +
"Flags:\n" + "Flags:\n" +
" -h generates only a shell", " -h generates only a shell",
flags = "h", flags = "h",
min = 1, min = 1,
max = 2 max = 2
@ -241,7 +240,7 @@ public class RegionCommands extends MethodCommands {
@Switch('h') boolean shell) throws WorldEditException { @Switch('h') boolean shell) throws WorldEditException {
if (!(region instanceof CuboidRegion)) { if (!(region instanceof CuboidRegion)) {
player.printError(BBC.getPrefix() + "//line only works with cuboid selections"); player.printError("//line only works with cuboid selections");
return; return;
} }
@ -258,10 +257,10 @@ public class RegionCommands extends MethodCommands {
usage = "<pattern> [thickness]", usage = "<pattern> [thickness]",
desc = "Draws a spline through selected points", desc = "Draws a spline through selected points",
help = help =
"Draws a spline through selected points.\n" + "Draws a spline through selected points.\n" +
"Can only be used with convex polyhedral selections.\n" + "Can only be used with convex polyhedral selections.\n" +
"Flags:\n" + "Flags:\n" +
" -h generates only a shell", " -h generates only a shell",
flags = "h", flags = "h",
min = 1, min = 1,
max = 2 max = 2
@ -275,7 +274,7 @@ public class RegionCommands extends MethodCommands {
@Switch('h') boolean shell, @Switch('h') boolean shell,
CommandContext context) throws WorldEditException { CommandContext context) throws WorldEditException {
if (!(region instanceof ConvexPolyhedralRegion)) { if (!(region instanceof ConvexPolyhedralRegion)) {
player.sendMessage(BBC.getPrefix() + "//curve only works with convex polyhedral selections"); player.sendMessage("//curve only works with convex polyhedral selections");
return; return;
} }
worldEdit.checkMaxRadius(thickness); worldEdit.checkMaxRadius(thickness);
@ -293,10 +292,10 @@ public class RegionCommands extends MethodCommands {
@Command( @Command(
aliases = { "/replace", "/re", "/rep" }, aliases = { "/replace", "/re", "/rep" },
usage = "[from-mask] <to-pattern>", usage = "[from-mask] <to-pattern>",
desc = "Replace all blocks in the selection with another", desc = "Replace all blocks in the selection with another",
flags = "f", flags = "f",
min = 1, min = 1,
max = 2 max = 2
) )
@CommandPermissions("worldedit.region.replace") @CommandPermissions("worldedit.region.replace")
@Logging(REGION) @Logging(REGION)
@ -316,7 +315,7 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/set", "/s"}, aliases = { "/set", "/s" },
usage = "[pattern]", usage = "[pattern]",
desc = "Set all blocks within selection", desc = "Set all blocks within selection",
min = 1, min = 1,
@ -336,11 +335,11 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/overlay"}, aliases = { "/overlay" },
usage = "<pattern>", usage = "<pattern>",
desc = "Set a block on top of blocks in the region", desc = "Set a block on top of blocks in the region",
min = 1, min = 1,
max = 1 max = 1
) )
@CommandPermissions("worldedit.region.overlay") @CommandPermissions("worldedit.region.overlay")
@Logging(REGION) @Logging(REGION)
@ -386,11 +385,11 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/center", "/middle"}, aliases = { "/center", "/middle" },
usage = "<pattern>", usage = "<pattern>",
desc = "Set the center block(s)", desc = "Set the center block(s)",
min = 1, min = 1,
max = 1 max = 1
) )
@Logging(REGION) @Logging(REGION)
@CommandPermissions("worldedit.region.center") @CommandPermissions("worldedit.region.center")
@ -400,11 +399,11 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/naturalize"}, aliases = { "/naturalize" },
usage = "", usage = "",
desc = "3 layers of dirt on top then rock below", desc = "3 layers of dirt on top then rock below",
min = 0, min = 0,
max = 0 max = 0
) )
@CommandPermissions("worldedit.region.naturalize") @CommandPermissions("worldedit.region.naturalize")
@Logging(REGION) @Logging(REGION)
@ -416,11 +415,11 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/walls"}, aliases = { "/walls" },
usage = "<pattern>", usage = "<pattern>",
desc = "Build the four sides of the selection", desc = "Build the four sides of the selection",
min = 1, min = 1,
max = 1 max = 1
) )
@CommandPermissions("worldedit.region.walls") @CommandPermissions("worldedit.region.walls")
@Logging(REGION) @Logging(REGION)
@ -432,11 +431,11 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/faces", "/outline"}, aliases = { "/faces", "/outline" },
usage = "<pattern>", usage = "<pattern>",
desc = "Build the walls, ceiling, and floor of a selection", desc = "Build the walls, ceiling, and floor of a selection",
min = 1, min = 1,
max = 1 max = 1
) )
@CommandPermissions("worldedit.region.faces") @CommandPermissions("worldedit.region.faces")
@Logging(REGION) @Logging(REGION)
@ -458,7 +457,7 @@ public class RegionCommands extends MethodCommands {
min = 0, min = 0,
max = 2 max = 2
) )
@CommandPermissions("worldedit.region.smoothsnow") @CommandPermissions("worldedit.region.smooth")
@Logging(REGION) @Logging(REGION)
public void smooth(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Optional Mask mask, @Switch('s') boolean snow, CommandContext context) throws WorldEditException { public void smooth(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Optional Mask mask, @Switch('s') boolean snow, CommandContext context) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
@ -514,16 +513,16 @@ public class RegionCommands extends MethodCommands {
@Command( @Command(
aliases = {"/move"}, aliases = { "/move" },
usage = "[count] [direction] [leave-id]", usage = "[count] [direction] [leave-id]",
flags = "sbea", flags = "saeb",
desc = "Move the contents of the selection", desc = "Move the contents of the selection",
help = help =
"Moves the contents of the selection.\n" + "Moves the contents of the selection.\n" +
"The -s flag shifts the selection to the target location.\n" + "The -s flag shifts the selection to the target location.\n" +
" -b also copies biomes\n" + "The -b also copies biomes\n" +
" -e ignores entities\n" + "The -e ignores entities\n" +
" -a ignores air\n" + "The -a ignores air blocks.\n" +
"Optionally fills the old location with <leave-id>.", "Optionally fills the old location with <leave-id>.",
min = 0, min = 0,
max = 3 max = 3
@ -550,7 +549,7 @@ public class RegionCommands extends MethodCommands {
session.getRegionSelector(player.getWorld()).learnChanges(); session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session); session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
} catch (RegionOperationException e) { } catch (RegionOperationException e) {
player.sendMessage(BBC.getPrefix() + e.getMessage()); player.sendMessage(e.getMessage());
} }
} }
@ -559,7 +558,7 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/fall"}, aliases = { "/fall" },
usage = "[replace]", usage = "[replace]",
flags = "m", flags = "m",
desc = "Have the blocks in the selection fall", desc = "Have the blocks in the selection fall",
@ -583,21 +582,21 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/stack"}, aliases = { "/stack" },
usage = "[count] [direction]", usage = "[count] [direction]",
flags = "sam", flags = "sam",
desc = "Repeat the contents of the selection", desc = "Repeat the contents of the selection",
help = help =
"Repeats the contents of the selection.\n" + "Repeats the contents of the selection.\n" +
"Flags:\n" + "Flags:\n" +
" -s shifts the selection to the last stacked copy\n" + " -s shifts the selection to the last stacked copy\n" +
" -a skips air blocks", " -a skips air blocks",
min = 0, min = 0,
max = 2 max = 2
) )
@CommandPermissions("worldedit.region.stack") @CommandPermissions("worldedit.region.stack")
@Logging(ORIENTATION_REGION) @Logging(ORIENTATION_REGION)
public void stack(FawePlayer player, LocalSession session, EditSession editSession, public void stack(FawePlayer player, EditSession editSession, LocalSession session,
@Selection Region region, @Selection Region region,
@Optional("1") @Range(min = 1) int count, @Optional("1") @Range(min = 1) int count,
@Optional(Direction.AIM) @Direction(includeDiagonals = true) BlockVector3 direction, @Optional(Direction.AIM) @Direction(includeDiagonals = true) BlockVector3 direction,
@ -620,7 +619,7 @@ public class RegionCommands extends MethodCommands {
session.getRegionSelector(player.getWorld()).learnChanges(); session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session); session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
} catch (RegionOperationException e) { } catch (RegionOperationException e) {
player.sendMessage(BBC.getPrefix() + e.getMessage()); player.sendMessage(e.getMessage());
} }
} }
@ -629,14 +628,14 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/deform"}, aliases = { "/deform" },
usage = "<expression>", usage = "<expression>",
desc = "Deforms a selected region with an expression", desc = "Deforms a selected region with an expression",
help = help =
"Deforms a selected region with an expression\n" + "Deforms a selected region with an expression\n" +
"The expression is executed for each block and is expected\n" + "The expression is executed for each block and is expected\n" +
"to modify the variables x, y and z to point to a new block\n" + "to modify the variables x, y and z to point to a new block\n" +
"to fetch. See also tinyurl.com/wesyntax.", "to fetch. See also tinyurl.com/wesyntax.",
flags = "ro", flags = "ro",
min = 1, min = 1,
max = -1 max = -1
@ -651,6 +650,7 @@ public class RegionCommands extends MethodCommands {
CommandContext context) throws WorldEditException { CommandContext context) throws WorldEditException {
final Vector3 zero; final Vector3 zero;
Vector3 unit; Vector3 unit;
if (useRawCoords) { if (useRawCoords) {
zero = Vector3.ZERO; zero = Vector3.ZERO;
unit = Vector3.ONE; unit = Vector3.ONE;
@ -676,13 +676,13 @@ public class RegionCommands extends MethodCommands {
player.findFreePosition(); player.findFreePosition();
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(fp, affected);
} catch (ExpressionException e) { } catch (ExpressionException e) {
fp.sendMessage(BBC.getPrefix() + e.getMessage()); fp.sendMessage(e.getMessage());
} }
}, getArguments(context), region, context); }, getArguments(context), region, context);
} }
@Command( @Command(
aliases = {"/regen"}, aliases = { "/regen" },
usage = "[biome] [seed]", usage = "[biome] [seed]",
desc = "Regenerates the contents of the selection", desc = "Regenerates the contents of the selection",
help = help =
@ -727,15 +727,15 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/hollow"}, aliases = { "/hollow" },
usage = "[<thickness>[ <pattern>]]", usage = "[<thickness>[ <pattern>]]",
desc = "Hollows out the object contained in this selection", desc = "Hollows out the object contained in this selection",
help = help =
"Hollows out the object contained in this selection.\n" + "Hollows out the object contained in this selection.\n" +
"Optionally fills the hollowed out part with the given block.\n" + "Optionally fills the hollowed out part with the given block.\n" +
"Thickness is measured in manhattan distance.", "Thickness is measured in manhattan distance.",
min = 0, min = 0,
max = 2 max = 2
) )
@CommandPermissions("worldedit.region.hollow") @CommandPermissions("worldedit.region.hollow")
@Logging(REGION) @Logging(REGION)
@ -751,7 +751,7 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/forest"}, aliases = { "/forest" },
usage = "[type] [density]", usage = "[type] [density]",
desc = "Make a forest within the region", desc = "Make a forest within the region",
min = 0, min = 0,
@ -766,7 +766,7 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/flora"}, aliases = { "/flora" },
usage = "[density]", usage = "[density]",
desc = "Make flora within the region", desc = "Make flora within the region",
min = 0, min = 0,
@ -786,5 +786,4 @@ public class RegionCommands extends MethodCommands {
}, getArguments(context), region, context); }, getArguments(context), region, context);
} }
} }

View File

@ -183,7 +183,7 @@ public class SchematicCommands extends MethodCommands {
for (Clipboard clip : session.getClipboard().getClipboards()) { for (Clipboard clip : session.getClipboard().getClipboards()) {
remapper.apply(clip); remapper.apply(clip);
} }
player.print(BBC.getPrefix() + "Remapped schematic"); player.print("Remapped schematic");
} }
@Command( @Command(
@ -227,7 +227,7 @@ public class SchematicCommands extends MethodCommands {
} }
f = player.openFileOpenDialog(extensions); f = player.openFileOpenDialog(extensions);
if (f == null || !f.exists()) { if (f == null || !f.exists()) {
player.printError(BBC.getPrefix() + "Schematic " + filename + " does not exist! (" + f + ")"); player.printError("Schematic " + filename + " does not exist! (" + f + ")");
return; return;
} }
} else { } else {
@ -248,7 +248,7 @@ public class SchematicCommands extends MethodCommands {
} }
} }
if (f == null || !f.exists() || !MainUtil.isInSubDirectory(working, f)) { if (f == null || !f.exists() || !MainUtil.isInSubDirectory(working, f)) {
player.printError(BBC.getPrefix() + "Schematic " + filename + " does not exist! (" + ((f != null) && f.exists()) + "|" + f + "|" + (f != null && !MainUtil.isInSubDirectory(working, f)) + ")"); player.printError("Schematic " + filename + " does not exist! (" + ((f != null) && f.exists()) + "|" + f + "|" + (f != null && !MainUtil.isInSubDirectory(working, f)) + ")");
return; return;
} }
if (format == null) { if (format == null) {
@ -264,9 +264,9 @@ public class SchematicCommands extends MethodCommands {
format.hold(player, uri, in); format.hold(player, uri, in);
BBC.SCHEMATIC_LOADED.send(player, filename); BBC.SCHEMATIC_LOADED.send(player, filename);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
player.printError(BBC.getPrefix() + "Unknown filename: " + filename); player.printError("Unknown filename: " + filename);
} catch (URISyntaxException | IOException e) { } catch (URISyntaxException | IOException e) {
player.printError(BBC.getPrefix() + "File could not be read or it does not exist: " + e.getMessage()); player.printError("File could not be read or it does not exist: " + e.getMessage());
log.warn("Failed to load a saved clipboard", e); log.warn("Failed to load a saved clipboard", e);
} finally { } finally {
if (in != null) { if (in != null) {
@ -290,7 +290,7 @@ public class SchematicCommands extends MethodCommands {
LocalConfiguration config = worldEdit.getConfiguration(); LocalConfiguration config = worldEdit.getConfiguration();
ClipboardFormat format = ClipboardFormats.findByAlias(formatName); ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
if (format == null) { if (format == null) {
player.printError(BBC.getPrefix() + "Unknown schematic format: " + formatName); player.printError("Unknown schematic format: " + formatName);
return; return;
} }
File working = worldEdit.getWorkingDirectoryFile(config.saveDir); File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
@ -322,7 +322,7 @@ public class SchematicCommands extends MethodCommands {
Files.createDirectories(parent.toPath()); Files.createDirectories(parent.toPath());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
log.info(BBC.getPrefix() + "Could not create folder for schematics!"); log.info("Could not create folder for schematics!");
return; return;
} }
} }
@ -367,11 +367,11 @@ public class SchematicCommands extends MethodCommands {
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
player.printError(BBC.getPrefix() + "Unknown filename: " + filename); player.printError("Unknown filename: " + filename);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
player.printError(BBC.getPrefix() + "Schematic could not written: " + e.getMessage()); player.printError("Schematic could not written: " + e.getMessage());
log.warn(BBC.getPrefix() + "Failed to write a saved clipboard", e); log.warn("Failed to write a saved clipboard", e);
} }
} }
@ -390,7 +390,7 @@ public class SchematicCommands extends MethodCommands {
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working; File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
File destDir = new File(dir, directory); File destDir = new File(dir, directory);
if (!MainUtil.isInSubDirectory(working, destDir)) { if (!MainUtil.isInSubDirectory(working, destDir)) {
player.printError(BBC.getPrefix() + "Directory " + destDir + " does not exist!"); player.printError("Directory " + destDir + " does not exist!");
return; return;
} }
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !player.hasPermission("worldedit.schematic.move.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !player.hasPermission("worldedit.schematic.move.other")) {
@ -404,7 +404,7 @@ public class SchematicCommands extends MethodCommands {
return; return;
} }
if (!destDir.exists() && !destDir.mkdirs()) { if (!destDir.exists() && !destDir.mkdirs()) {
player.printError(BBC.getPrefix() + "Creation of " + destDir + " failed! (check file permissions)"); player.printError("Creation of " + destDir + " failed! (check file permissions)");
return; return;
} }
for (File source : sources) { for (File source : sources) {
@ -457,7 +457,7 @@ public class SchematicCommands extends MethodCommands {
} }
for (File f : files) { for (File f : files) {
if (!MainUtil.isInSubDirectory(working, f) || !f.exists()) { if (!MainUtil.isInSubDirectory(working, f) || !f.exists()) {
player.printError(BBC.getPrefix() + "Schematic " + filename + " does not exist! (" + f.exists() + "|" + f + "|" + (!MainUtil.isInSubDirectory(working, f)) + ")"); player.printError("Schematic " + filename + " does not exist! (" + f.exists() + "|" + f + "|" + (!MainUtil.isInSubDirectory(working, f)) + ")");
continue; continue;
} }
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !player.hasPermission("worldedit.schematic.delete.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !player.hasPermission("worldedit.schematic.delete.other")) {
@ -465,7 +465,7 @@ public class SchematicCommands extends MethodCommands {
continue; continue;
} }
if (!delete(f)) { if (!delete(f)) {
player.printError(BBC.getPrefix() + "Deletion of " + filename + " failed! Maybe it is read-only."); player.printError("Deletion of " + filename + " failed! Maybe it is read-only.");
continue; continue;
} }
BBC.FILE_DELETED.send(player, filename); BBC.FILE_DELETED.send(player, filename);

View File

@ -87,7 +87,7 @@ public class ScriptingCommands {
String ext = filename.substring(index + 1, filename.length()); String ext = filename.substring(index + 1, filename.length());
if (!ext.equalsIgnoreCase("js")) { if (!ext.equalsIgnoreCase("js")) {
actor.printError(BBC.getPrefix() + "Only .js scripts are currently supported"); actor.printError("Only .js scripts are currently supported");
return null; return null;
} }
@ -100,7 +100,7 @@ public class ScriptingCommands {
file = WorldEdit.class.getResourceAsStream("craftscripts/" + filename); file = WorldEdit.class.getResourceAsStream("craftscripts/" + filename);
if (file == null) { if (file == null) {
actor.printError(BBC.getPrefix() + "Script does not exist: " + filename); actor.printError("Script does not exist: " + filename);
return null; return null;
} }
} else { } else {
@ -113,7 +113,7 @@ public class ScriptingCommands {
in.close(); in.close();
script = new String(data, 0, data.length, "utf-8"); script = new String(data, 0, data.length, "utf-8");
} catch (IOException e) { } catch (IOException e) {
actor.printError(BBC.getPrefix() + "Script read error: " + e.getMessage()); actor.printError("Script read error: " + e.getMessage());
return null; return null;
} }
@ -154,14 +154,14 @@ public class ScriptingCommands {
result = engine.evaluate(script, filename, vars); result = engine.evaluate(script, filename, vars);
} catch (ScriptException e) { } catch (ScriptException e) {
e.printStackTrace(); e.printStackTrace();
actor.printError(BBC.getPrefix() + "Failed to execute:"); actor.printError("Failed to execute:");
actor.printRaw(e.getMessage()); actor.printRaw(e.getMessage());
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw e; throw e;
} catch (WorldEditException e) { } catch (WorldEditException e) {
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
actor.printError(BBC.getPrefix() + "Failed to execute (see console):"); actor.printError("Failed to execute (see console):");
actor.printRaw(e.getClass().getCanonicalName()); actor.printRaw(e.getClass().getCanonicalName());
e.printStackTrace(); e.printStackTrace();
} }
@ -203,7 +203,7 @@ public class ScriptingCommands {
@CommandPermissions("worldedit.scripting.execute") @CommandPermissions("worldedit.scripting.execute")
@Logging(ALL) @Logging(ALL)
public void executeLast(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void executeLast(Player player, LocalSession session, CommandContext args) throws WorldEditException {
String lastScript = session.getLastScript(); String lastScript = session.getLastScript();
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) { if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {

View File

@ -81,7 +81,7 @@ public class SnapshotCommands {
BBC.SNAPSHOT_LIST_HEADER.send(player, player.getWorld().getName()); BBC.SNAPSHOT_LIST_HEADER.send(player, player.getWorld().getName());
for (byte i = 0; i < Math.min(num, snapshots.size()); i++) { for (byte i = 0; i < Math.min(num, snapshots.size()); i++) {
player.print(BBC.getPrefix() + (i + 1) + ". " + snapshots.get(i).getName()); player.print((i + 1) + ". " + snapshots.get(i).getName());
} }
BBC.SNAPSHOT_LIST_FOOTER.send(player); BBC.SNAPSHOT_LIST_FOOTER.send(player);
@ -92,10 +92,9 @@ public class SnapshotCommands {
File dir = config.snapshotRepo.getDirectory(); File dir = config.snapshotRepo.getDirectory();
try { try {
WorldEdit.logger.info(BBC.getPrefix() + "WorldEdit found no snapshots: looked in: " WorldEdit.logger.info("WorldEdit found no snapshots: looked in: " + dir.getCanonicalPath());
+ dir.getCanonicalPath());
} catch (IOException e) { } catch (IOException e) {
WorldEdit.logger.info(BBC.getPrefix() + "WorldEdit found no snapshots: looked in " WorldEdit.logger.info("WorldEdit found no snapshots: looked in "
+ "(NON-RESOLVABLE PATH - does it exist?): " + "(NON-RESOLVABLE PATH - does it exist?): "
+ dir.getPath()); + dir.getPath());
} }
@ -168,7 +167,7 @@ public class SnapshotCommands {
try { try {
index = Integer.parseInt(args.getString(0)); index = Integer.parseInt(args.getString(0));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
player.printError(BBC.getPrefix() + "Invalid index, " + args.getString(0) + " is not a valid integer."); player.printError("Invalid index, " + args.getString(0) + " is not a valid integer.");
return; return;
} }
@ -180,7 +179,7 @@ public class SnapshotCommands {
try { try {
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName()); List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
if (snapshots.size() < index) { if (snapshots.size() < index) {
player.printError(BBC.getPrefix() + "Invalid index, must be between 1 and " + snapshots.size() + "."); player.printError("Invalid index, must be between 1 and " + snapshots.size() + ".");
return; return;
} }
Snapshot snapshot = snapshots.get(index - 1); Snapshot snapshot = snapshots.get(index - 1);
@ -222,7 +221,7 @@ public class SnapshotCommands {
if (snapshot == null) { if (snapshot == null) {
dateFormat.setTimeZone(session.getTimeZone()); dateFormat.setTimeZone(session.getTimeZone());
player.printError(BBC.getPrefix() + "Couldn't find a snapshot before " player.printError("Couldn't find a snapshot before "
+ dateFormat.format(date.getTime()) + "."); + dateFormat.format(date.getTime()) + ".");
} else { } else {
session.setSnapshot(snapshot); session.setSnapshot(snapshot);
@ -260,7 +259,7 @@ public class SnapshotCommands {
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, player.getWorld().getName()); Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, player.getWorld().getName());
if (snapshot == null) { if (snapshot == null) {
dateFormat.setTimeZone(session.getTimeZone()); dateFormat.setTimeZone(session.getTimeZone());
player.printError(BBC.getPrefix() + "Couldn't find a snapshot after " player.printError("Couldn't find a snapshot after "
+ dateFormat.format(date.getTime()) + "."); + dateFormat.format(date.getTime()) + ".");
} else { } else {
session.setSnapshot(snapshot); session.setSnapshot(snapshot);

View File

@ -56,7 +56,7 @@ public class ToolUtilCommands {
String newState = args.getString(0, null); String newState = args.getString(0, null);
if (session.hasSuperPickAxe()) { if (session.hasSuperPickAxe()) {
if ("on".equals(newState)) { if ("on".equals(newState)) {
player.printError(BBC.getPrefix() + "Super pick axe already enabled."); player.printError("Super pick axe already enabled.");
return; return;
} }
@ -64,7 +64,7 @@ public class ToolUtilCommands {
player.print("Super pick axe disabled."); player.print("Super pick axe disabled.");
} else { } else {
if ("off".equals(newState)) { if ("off".equals(newState)) {
player.printError(BBC.getPrefix() + "Super pick axe already disabled."); player.printError("Super pick axe already disabled.");
return; return;
} }
session.enableSuperPickAxe(); session.enableSuperPickAxe();

View File

@ -102,6 +102,7 @@ import java.util.function.Consumer;
*/ */
@Command(aliases = {}, desc = "Various utility commands: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Utilities)") @Command(aliases = {}, desc = "Various utility commands: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Utilities)")
public class UtilityCommands extends MethodCommands { public class UtilityCommands extends MethodCommands {
private final WorldEdit we; private final WorldEdit we;
public UtilityCommands(WorldEdit we) { public UtilityCommands(WorldEdit we) {
@ -173,7 +174,7 @@ public class UtilityCommands extends MethodCommands {
} }
}.send(player); }.send(player);
} else { } else {
UtilityCommands.help(args, worldEdit, player, getCommand().aliases()[0] + " ", parser.getDispatcher()); UtilityCommands.help(args, player, getCommand().aliases()[0] + " ", parser.getDispatcher());
} }
} }
} }
@ -248,163 +249,175 @@ public class UtilityCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/fill"}, aliases = { "/fill" },
usage = "<pattern> <radius> [depth] [direction]", usage = "<pattern> <radius> [depth] [direction]",
desc = "Fill a hole", desc = "Fill a hole",
min = 2, min = 2,
max = 4 max = 4
) )
@CommandPermissions("worldedit.fill") @CommandPermissions("worldedit.fill")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void fill(Player player, LocalSession session, EditSession editSession, Pattern pattern, double radius, @Optional("1") double depth, @Optional("down") @Direction BlockVector3 direction) throws WorldEditException { public void fill(Player player, LocalSession session, EditSession editSession, Pattern pattern, double radius, @Optional("1") double depth, @Optional("down") @Direction BlockVector3 direction) throws WorldEditException {
worldEdit.checkMaxRadius(radius); we.checkMaxRadius(radius);
BlockVector3 pos = session.getPlacementPosition(player); BlockVector3 pos = session.getPlacementPosition(player);
int affected; int affected = editSession.fillDirection(pos, pattern, radius, (int) depth, direction);
affected = editSession.fillDirection(pos, pattern, radius, (int) depth, direction); player.print(affected + " block(s) have been created.");
player.print(BBC.getPrefix() + affected + " block(s) have been created.");
} }
@Command( @Command(
aliases = {"/fillr"}, aliases = { "/fillr" },
usage = "<pattern> <radius> [depth]", usage = "<pattern> <radius> [depth]",
desc = "Fill a hole recursively", desc = "Fill a hole recursively",
min = 2, min = 2,
max = 3 max = 3
) )
@CommandPermissions("worldedit.fill.recursive") @CommandPermissions("worldedit.fill.recursive")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void fillr(Player player, LocalSession session, EditSession editSession, Pattern pattern, double radius, @Optional("-1") double depth) throws WorldEditException { public void fillr(Player player, LocalSession session, EditSession editSession, Pattern pattern, double radius, @Optional("-1") double depth) throws WorldEditException {
worldEdit.checkMaxRadius(radius); we.checkMaxRadius(radius);
BlockVector3 pos = session.getPlacementPosition(player); BlockVector3 pos = session.getPlacementPosition(player);
if (depth == -1) depth = Integer.MAX_VALUE; if (depth == -1) depth = Integer.MAX_VALUE;
int affected = editSession.fillXZ(pos, pattern, radius, (int) depth, true); int affected = editSession.fillXZ(pos, pattern, radius, (int) depth, true);
player.print(BBC.getPrefix() + affected + " block(s) have been created."); player.print(affected + " block(s) have been created.");
} }
@Command( @Command(
aliases = {"/drain"}, aliases = { "/drain" },
usage = "<radius>", usage = "<radius>",
desc = "Drain a pool", flags = "w",
min = 1, desc = "Drain a pool",
max = 1 help = "Removes all connected water sources.\n" +
" If -w is specified, also makes waterlogged blocks non-waterlogged.",
min = 1,
max = 1
) )
@CommandPermissions("worldedit.drain") @CommandPermissions("worldedit.drain")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void drain(Player player, LocalSession session, EditSession editSession, double radius) throws WorldEditException { public void drain(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
worldEdit.checkMaxRadius(radius);
double radius = Math.max(0, args.getDouble(0));
boolean waterlogged = args.hasFlag('w');
we.checkMaxRadius(radius);
int affected = editSession.drainArea( int affected = editSession.drainArea(
session.getPlacementPosition(player), radius); session.getPlacementPosition(player), radius, waterlogged);
player.print(BBC.getPrefix() + affected + " block(s) have been changed."); player.print(affected + " block(s) have been changed.");
} }
@Command( @Command(
aliases = {"/fixlava", "fixlava"}, aliases = { "/fixlava", "fixlava" },
usage = "<radius>", usage = "<radius>",
desc = "Fix lava to be stationary", desc = "Fix lava to be stationary",
min = 1, min = 1,
max = 1 max = 1
) )
@CommandPermissions("worldedit.fixlava") @CommandPermissions("worldedit.fixlava")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void fixLava(Player player, LocalSession session, EditSession editSession, @Range(min = 0) double radius) throws WorldEditException { public void fixLava(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
worldEdit.checkMaxRadius(radius);
int affected = editSession.fixLiquid( double radius = Math.max(0, args.getDouble(0));
session.getPlacementPosition(player), radius, BlockTypes.LAVA); we.checkMaxRadius(radius);
player.print(BBC.getPrefix() + affected + " block(s) have been changed."); int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, BlockTypes.LAVA);
player.print(affected + " block(s) have been changed.");
} }
@Command( @Command(
aliases = {"/fixwater", "fixwater"}, aliases = { "/fixwater", "fixwater" },
usage = "<radius>", usage = "<radius>",
desc = "Fix water to be stationary", desc = "Fix water to be stationary",
min = 1, min = 1,
max = 1 max = 1
) )
@CommandPermissions("worldedit.fixwater") @CommandPermissions("worldedit.fixwater")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void fixWater(Player player, LocalSession session, EditSession editSession, @Range(min = 0) double radius) throws WorldEditException { public void fixWater(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
worldEdit.checkMaxRadius(radius);
int affected = editSession.fixLiquid( double radius = Math.max(0, args.getDouble(0));
session.getPlacementPosition(player), radius, BlockTypes.WATER); we.checkMaxRadius(radius);
int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, BlockTypes.WATER);
BBC.VISITOR_BLOCK.send(player, affected); BBC.VISITOR_BLOCK.send(player, affected);
} }
@Command( @Command(
aliases = {"/removeabove", "removeabove"}, aliases = { "/removeabove", "removeabove" },
usage = "[size] [height]", usage = "[size] [height]",
desc = "Remove blocks above your head.", desc = "Remove blocks above your head.",
min = 0, min = 0,
max = 2 max = 2
) )
@CommandPermissions("worldedit.removeabove") @CommandPermissions("worldedit.removeabove")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void removeAbove(Player player, LocalSession session, EditSession editSession, @Optional("1") double size, @Optional("256") double height) throws WorldEditException { public void removeAbove(Player player, LocalSession session, EditSession editSession, @Optional("1") double size, @Optional("256") double height) throws WorldEditException {
worldEdit.checkMaxRadius(size);
we.checkMaxRadius(size);
int affected = editSession.removeAbove(session.getPlacementPosition(player), (int) size, (int) height); int affected = editSession.removeAbove(session.getPlacementPosition(player), (int) size, (int) height);
BBC.VISITOR_BLOCK.send(player, affected); BBC.VISITOR_BLOCK.send(player, affected);
} }
@Command( @Command(
aliases = {"/removebelow", "removebelow"}, aliases = { "/removebelow", "removebelow" },
usage = "[size] [height]", usage = "[size] [height]",
desc = "Remove blocks below you.", desc = "Remove blocks below you.",
min = 0, min = 0,
max = 2 max = 2
) )
@CommandPermissions("worldedit.removebelow") @CommandPermissions("worldedit.removebelow")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void removeBelow(Player player, LocalSession session, EditSession editSession, @Optional("1") double size, @Optional("256") double height) throws WorldEditException { public void removeBelow(Player player, LocalSession session, EditSession editSession, @Optional("1") double size, @Optional("256") double height) throws WorldEditException {
worldEdit.checkMaxRadius(size);
we.checkMaxRadius(size);
int affected = editSession.removeBelow(session.getPlacementPosition(player), (int) size, (int) height); int affected = editSession.removeBelow(session.getPlacementPosition(player), (int) size, (int) height);
BBC.VISITOR_BLOCK.send(player, affected); BBC.VISITOR_BLOCK.send(player, affected);
} }
@Command( @Command(
aliases = {"/removenear", "removenear"}, aliases = { "/removenear", "removenear" },
usage = "<mask> [size]", usage = "<mask> [size]",
desc = "Remove blocks near you.", desc = "Remove blocks near you.",
min = 1, min = 1,
max = 2 max = 2
) )
@CommandPermissions("worldedit.removenear") @CommandPermissions("worldedit.removenear")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void removeNear(Player player, LocalSession session, EditSession editSession, Mask mask, @Optional("50") double size) throws WorldEditException { public void removeNear(Player player, LocalSession session, EditSession editSession, Mask mask, @Optional("50") double size) throws WorldEditException {
worldEdit.checkMaxRadius(size);
we.checkMaxRadius(size);
size = Math.max(1, size); size = Math.max(1, size);
int affected = editSession.removeNear(session.getPlacementPosition(player), mask, (int) size); int affected = editSession.removeNear(session.getPlacementPosition(player), mask, (int) size);
BBC.VISITOR_BLOCK.send(player, affected); BBC.VISITOR_BLOCK.send(player, affected);
} }
@Command( @Command(
aliases = {"/replacenear", "replacenear"}, aliases = { "/replacenear", "replacenear" },
usage = "<size> <from-id> <to-id>", usage = "<size> <from-id> <to-id>",
desc = "Replace nearby blocks", desc = "Replace nearby blocks",
flags = "f", flags = "f",
min = 3, min = 3,
max = 3 max = 3
) )
@CommandPermissions("worldedit.replacenear") @CommandPermissions("worldedit.replacenear")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void replaceNear(Player player, LocalSession session, EditSession editSession, double size, @Optional Mask from, Pattern to) throws WorldEditException { public void replaceNear(Player player, LocalSession session, EditSession editSession, double size, @Optional Mask from, Pattern to) throws WorldEditException {
if (from == null) { if (from == null) {
from = new ExistingBlockMask(editSession); from = new ExistingBlockMask(editSession);
} }
int affected;
BlockVector3 base = session.getPlacementPosition(player); BlockVector3 base = session.getPlacementPosition(player);
BlockVector3 min = base.subtract((int)size, (int)size, (int)size); BlockVector3 min = base.subtract((int)size, (int)size, (int)size);
BlockVector3 max = base.add((int)size, (int)size, (int)size); BlockVector3 max = base.add((int)size, (int)size, (int)size);
Region region = new CuboidRegion(player.getWorld(), min, max); Region region = new CuboidRegion(player.getWorld(), min, max);
int affected = editSession.replaceBlocks(region, from, to); affected = editSession.replaceBlocks(region, from, to);
BBC.VISITOR_BLOCK.send(player, affected); BBC.VISITOR_BLOCK.send(player, affected);
} }
@Command( @Command(
aliases = {"/snow", "snow"}, aliases = { "/snow", "snow" },
usage = "[radius]", usage = "[radius]",
desc = "Simulates snow", desc = "Simulates snow",
min = 0, min = 0,
max = 1 max = 1
) )
@CommandPermissions("worldedit.snow") @CommandPermissions("worldedit.snow")
@Logging(PLACEMENT) @Logging(PLACEMENT)
@ -413,15 +426,15 @@ public class UtilityCommands extends MethodCommands {
we.checkMaxRadius(size); we.checkMaxRadius(size);
int affected = editSession.simulateSnow(session.getPlacementPosition(player), size); int affected = editSession.simulateSnow(session.getPlacementPosition(player), size);
player.print(BBC.getPrefix() + affected + " surfaces covered. Let it snow~"); player.print(affected + " surfaces covered. Let it snow~");
} }
@Command( @Command(
aliases = {"/thaw", "thaw"}, aliases = {"/thaw", "thaw"},
usage = "[radius]", usage = "[radius]",
desc = "Thaws the area", desc = "Thaws the area",
min = 0, min = 0,
max = 1 max = 1
) )
@CommandPermissions("worldedit.thaw") @CommandPermissions("worldedit.thaw")
@Logging(PLACEMENT) @Logging(PLACEMENT)
@ -430,17 +443,17 @@ public class UtilityCommands extends MethodCommands {
we.checkMaxRadius(size); we.checkMaxRadius(size);
int affected = editSession.thaw(session.getPlacementPosition(player), size); int affected = editSession.thaw(session.getPlacementPosition(player), size);
player.print(BBC.getPrefix() + affected + " surfaces thawed."); player.print(affected + " surfaces thawed.");
} }
@Command( @Command(
aliases = {"/green", "green"}, aliases = { "/green", "green" },
usage = "[radius]", usage = "[radius]",
desc = "Greens the area", desc = "Greens the area",
help = "Converts dirt to grass blocks. -f also converts coarse dirt.", help = "Converts dirt to grass blocks. -f also converts coarse dirt.",
flags = "f", flags = "f",
min = 0, min = 0,
max = 1 max = 1
) )
@CommandPermissions("worldedit.green") @CommandPermissions("worldedit.green")
@Logging(PLACEMENT) @Logging(PLACEMENT)
@ -454,51 +467,51 @@ public class UtilityCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/ex", "/ext", "/extinguish", "ex", "ext", "extinguish"}, aliases = { "/ex", "/ext", "/extinguish", "ex", "ext", "extinguish" },
usage = "[radius]", usage = "[radius]",
desc = "Extinguish nearby fire", desc = "Extinguish nearby fire",
min = 0, min = 0,
max = 1 max = 1
) )
@CommandPermissions("worldedit.extinguish") @CommandPermissions("worldedit.extinguish")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void extinguish(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { public void extinguish(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
LocalConfiguration config = worldEdit.getConfiguration(); LocalConfiguration config = we.getConfiguration();
int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40; int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40;
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0))
: defaultRadius; : defaultRadius;
worldEdit.checkMaxRadius(size); we.checkMaxRadius(size);
int affected = editSession.removeNear(session.getPlacementPosition(player), BlockTypes.FIRE.toMask(editSession), size); int affected = editSession.removeNear(session.getPlacementPosition(player), BlockTypes.FIRE.toMask(editSession), size);
BBC.VISITOR_BLOCK.send(player, affected); BBC.VISITOR_BLOCK.send(player, affected);
} }
@Command( @Command(
aliases = {"butcher"}, aliases = { "butcher" },
usage = "[radius]", usage = "[radius]",
flags = "plangbtfr", flags = "plangbtfr",
desc = "Kill all or nearby mobs", desc = "Kill all or nearby mobs",
help = help =
"Kills nearby mobs, based on radius, if none is given uses default in configuration.\n" + "Kills nearby mobs, based on radius, if none is given uses default in configuration.\n" +
"Flags:\n" + "Flags:\n" +
" -p also kills pets.\n" + " -p also kills pets.\n" +
" -n also kills NPCs.\n" + " -n also kills NPCs.\n" +
" -g also kills Golems.\n" + " -g also kills Golems.\n" +
" -a also kills animals.\n" + " -a also kills animals.\n" +
" -b also kills ambient mobs.\n" + " -b also kills ambient mobs.\n" +
" -t also kills mobs with name tags.\n" + " -t also kills mobs with name tags.\n" +
" -f compounds all previous flags.\n" + " -f compounds all previous flags.\n" +
" -r also destroys armor stands.\n" + " -r also destroys armor stands.\n" +
" -l currently does nothing.", " -l currently does nothing.",
min = 0, min = 0,
max = 1 max = 1
) )
@CommandPermissions("worldedit.butcher") @CommandPermissions("worldedit.butcher")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void butcher(Actor actor, CommandContext args) throws WorldEditException { public void butcher(Actor actor, CommandContext args) throws WorldEditException {
LocalConfiguration config = worldEdit.getConfiguration(); LocalConfiguration config = we.getConfiguration();
Player player = actor instanceof Player ? (Player) actor : null; Player player = actor instanceof Player ? (Player) actor : null;
// technically the default can be larger than the max, but that's not my problem // technically the default can be larger than the max, but that's not my problem
@ -562,11 +575,11 @@ public class UtilityCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"remove", "rem", "rement"}, aliases = { "remove", "rem", "rement" },
usage = "<type> <radius>", usage = "<type> <radius>",
desc = "Remove all entities of a type", desc = "Remove all entities of a type",
min = 2, min = 2,
max = 2 max = 2
) )
@CommandPermissions("worldedit.remove") @CommandPermissions("worldedit.remove")
@Logging(PLACEMENT) @Logging(PLACEMENT)
@ -588,7 +601,7 @@ public class UtilityCommands extends MethodCommands {
EditSession editSession = null; EditSession editSession = null;
if (player != null) { if (player != null) {
session = worldEdit.getSessionManager().get(player); session = we.getSessionManager().get(player);
BlockVector3 center = session.getPlacementPosition(player); BlockVector3 center = session.getPlacementPosition(player);
editSession = session.createEditSession(player); editSession = session.createEditSession(player);
List<? extends Entity> entities; List<? extends Entity> entities;
@ -600,7 +613,7 @@ public class UtilityCommands extends MethodCommands {
} }
visitors.add(new EntityVisitor(entities.iterator(), remover.createFunction())); visitors.add(new EntityVisitor(entities.iterator(), remover.createFunction()));
} else { } else {
Platform platform = worldEdit.getPlatformManager().queryCapability(Capability.WORLD_EDITING); Platform platform = we.getPlatformManager().queryCapability(Capability.WORLD_EDITING);
for (World world : platform.getWorlds()) { for (World world : platform.getWorlds()) {
List<? extends Entity> entities = world.getEntities(); List<? extends Entity> entities = world.getEntities();
visitors.add(new EntityVisitor(entities.iterator(), remover.createFunction())); visitors.add(new EntityVisitor(entities.iterator(), remover.createFunction()));
@ -622,9 +635,9 @@ public class UtilityCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/calc", "/calculate", "/eval", "/evaluate", "/solve"}, aliases = { "/calc", "/calculate", "/eval", "/evaluate", "/solve" },
usage = "<expression>", usage = "<expression>",
desc = "Evaluate a mathematical expression" desc = "Evaluate a mathematical expression"
) )
@CommandPermissions("worldedit.calc") @CommandPermissions("worldedit.calc")
public void calc(final Actor actor, @Text String input) throws CommandException { public void calc(final Actor actor, @Text String input) throws CommandException {
@ -646,7 +659,7 @@ public class UtilityCommands extends MethodCommands {
} }
executor.shutdownNow(); executor.shutdownNow();
actor.print(BBC.getPrefix() + "= " + result); actor.print("= " + result);
} catch (EvaluationException e) { } catch (EvaluationException e) {
actor.printError(String.format( actor.printError(String.format(
"'%s' could not be evaluated (error: %s)", input, e.getMessage())); "'%s' could not be evaluated (error: %s)", input, e.getMessage()));
@ -667,15 +680,16 @@ public class UtilityCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/help"}, aliases = { "/help" },
usage = "[<command>]", usage = "[<command>]",
desc = "Displays help for WorldEdit commands", desc = "Displays help for WorldEdit commands",
min = 0, min = 0,
max = -1, max = -1,
queued = false queued = false
) )
@CommandPermissions("worldedit.help")
public void help(Actor actor, CommandContext args) throws WorldEditException { public void help(Actor actor, CommandContext args) throws WorldEditException {
help(args, worldEdit, actor); help(args, we, actor);
} }
protected static CommandMapping detectCommand(Dispatcher dispatcher, String command, boolean isRootLevel) { protected static CommandMapping detectCommand(Dispatcher dispatcher, String command, boolean isRootLevel) {
@ -720,7 +734,7 @@ public class UtilityCommands extends MethodCommands {
AtomicInteger pageInt = new AtomicInteger(page); AtomicInteger pageInt = new AtomicInteger(page);
List<File> fileList = new ArrayList<>(); List<File> fileList = new ArrayList<>();
if (perPage == -1) perPage = actor instanceof Player ? 12 : 20; // More pages for console if (perPage == -1) perPage = actor instanceof Player ? 12 : 20; // More pages for console
page = getFiles(dir, actor, args, page, perPage, formatName, playerFolder, file -> fileList.add(file)); page = getFiles(dir, actor, args, page, perPage, formatName, playerFolder, fileList::add);
if (fileList.isEmpty()) { if (fileList.isEmpty()) {
BBC.SCHEMATIC_NONE.send(actor); BBC.SCHEMATIC_NONE.send(actor);
@ -843,16 +857,6 @@ public class UtilityCommands extends MethodCommands {
listMine = true; listMine = true;
} }
FileFilter ignoreUUIDs = f -> {
try {
if (f.isDirectory()) {
UUID uuid = UUID.fromString(f.getName());
return false;
}
} catch (IllegalArgumentException ignored) {}
return true;
};
List<File> toFilter = new ArrayList<>(); List<File> toFilter = new ArrayList<>();
if (!filters.isEmpty()) { if (!filters.isEmpty()) {
forEachFile = new DelegateConsumer<File>(forEachFile) { forEachFile = new DelegateConsumer<File>(forEachFile) {
@ -986,10 +990,10 @@ public class UtilityCommands extends MethodCommands {
} }
public static void help(CommandContext args, WorldEdit we, Actor actor) { public static void help(CommandContext args, WorldEdit we, Actor actor) {
help(args, we, actor, "/", we.getPlatformManager().getCommandManager().getDispatcher()); help(args, actor, "/", we.getPlatformManager().getCommandManager().getDispatcher());
} }
public static void help(CommandContext args, WorldEdit we, Actor actor, String prefix, CommandCallable callable) { public static void help(CommandContext args, Actor actor, String prefix, CommandCallable callable) {
final int perPage = actor instanceof Player ? 12 : 20; // More pages for console final int perPage = actor instanceof Player ? 12 : 20; // More pages for console
HelpBuilder builder = new HelpBuilder(callable, args, perPage) { HelpBuilder builder = new HelpBuilder(callable, args, perPage) {
@ -1007,7 +1011,6 @@ public class UtilityCommands extends MethodCommands {
public void displayCategories(Map<String, Map<CommandMapping, String>> categories) { public void displayCategories(Map<String, Map<CommandMapping, String>> categories) {
Message msg = new Message(); Message msg = new Message();
msg.prefix().text(BBC.HELP_HEADER_CATEGORIES).newline(); msg.prefix().text(BBC.HELP_HEADER_CATEGORIES).newline();
boolean first = true;
for (Map.Entry<String, Map<CommandMapping, String>> entry : categories.entrySet()) { for (Map.Entry<String, Map<CommandMapping, String>> entry : categories.entrySet()) {
String s1 = Commands.getAlias(UtilityCommands.class, "/help") + " " + entry.getKey(); String s1 = Commands.getAlias(UtilityCommands.class, "/help") + " " + entry.getKey();
String s2 = entry.getValue().size() + ""; String s2 = entry.getValue().size() + "";

View File

@ -71,12 +71,12 @@ public class BlockDataCyler implements DoubleActionBlockTool {
BBC.BLOCK_CYCLER_CANNOT_CYCLE.send(player); BBC.BLOCK_CYCLER_CANNOT_CYCLE.send(player);
} else { } else {
Property<?> currentProperty = selectedProperties.get(player.getUniqueId()); Property<?> currentProperty = selectedProperties.get(player.getUniqueId());
if (currentProperty == null || (forward && block.getState(currentProperty) == null)) { if (currentProperty == null || (forward && block.getState(currentProperty) == null)) {
currentProperty = block.getStates().keySet().stream().findFirst().get(); currentProperty = block.getStates().keySet().stream().findFirst().get();
selectedProperties.put(player.getUniqueId(), currentProperty); selectedProperties.put(player.getUniqueId(), currentProperty);
} }
if (forward) { if (forward) {
block.getState(currentProperty); block.getState(currentProperty);
int index = currentProperty.getValues().indexOf(block.getState(currentProperty)); int index = currentProperty.getValues().indexOf(block.getState(currentProperty));
@ -84,12 +84,12 @@ public class BlockDataCyler implements DoubleActionBlockTool {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Property<Object> objProp = (Property<Object>) currentProperty; Property<Object> objProp = (Property<Object>) currentProperty;
BlockState newBlock = block.with(objProp, currentProperty.getValues().get(index)); BlockState newBlock = block.with(objProp, currentProperty.getValues().get(index));
try { try {
EditSession editSession = session.createEditSession(player); EditSession editSession = session.createEditSession(player);
try { try {
editSession.setBlock(blockPoint, newBlock); editSession.setBlock(blockPoint, newBlock);
player.print(BBC.getPrefix() + "Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index).toString()); player.print("Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index).toString());
} catch (MaxChangedBlocksException e) { } catch (MaxChangedBlocksException e) {
BBC.BLOCK_CYCLER_LIMIT.send(player); BBC.BLOCK_CYCLER_LIMIT.send(player);
} finally { } finally {
@ -102,7 +102,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
index = (index + 1) % properties.size(); index = (index + 1) % properties.size();
currentProperty = properties.get(index); currentProperty = properties.get(index);
selectedProperties.put(player.getUniqueId(), currentProperty); selectedProperties.put(player.getUniqueId(), currentProperty);
player.print(BBC.getPrefix() + "Now cycling " + currentProperty.getName()); player.print("Now cycling " + currentProperty.getName());
} }
} }

View File

@ -80,7 +80,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
if (type != null) { if (type != null) {
this.pattern = targetBlock; this.pattern = targetBlock;
player.print(BBC.getPrefix() + "Replacer tool switched to: " + type.getName()); player.print("Replacer tool switched to: " + type.getName());
} }
return true; return true;

View File

@ -483,9 +483,9 @@ public final class CommandManager {
} catch (CommandException e) { } catch (CommandException e) {
String message = e.getMessage(); String message = e.getMessage();
if (message != null) { if (message != null) {
actor.printError(BBC.getPrefix() + e.getMessage()); actor.printError(e.getMessage());
} else { } else {
actor.printError(BBC.getPrefix() + "An unknown FAWE error has occurred! Please see console."); actor.printError("An unknown FAWE error has occurred! Please see console.");
log.error("An unknown FAWE error occurred", e); log.error("An unknown FAWE error occurred", e);
} }
} catch (Throwable e) { } catch (Throwable e) {
@ -493,7 +493,7 @@ public final class CommandManager {
if (faweException != null) { if (faweException != null) {
BBC.WORLDEDIT_CANCEL_REASON.send(actor, faweException.getMessage()); BBC.WORLDEDIT_CANCEL_REASON.send(actor, faweException.getMessage());
} else { } else {
actor.printError(BBC.getPrefix() + "There was an error handling a FAWE command: [See console]"); actor.printError("There was an error handling a FAWE command: [See console]");
actor.printRaw(e.getClass().getName() + ": " + e.getMessage()); actor.printRaw(e.getClass().getName() + ": " + e.getMessage());
log.error("An unexpected error occurred while handling a FAWE command", e); log.error("An unexpected error occurred while handling a FAWE command", e);
} }

View File

@ -516,7 +516,7 @@ public class PlatformManager {
if (faweException != null) { if (faweException != null) {
BBC.WORLDEDIT_CANCEL_REASON.send(player, faweException.getMessage()); BBC.WORLDEDIT_CANCEL_REASON.send(player, faweException.getMessage());
} else { } else {
player.printError(BBC.getPrefix() + "Please report this error: [See console]"); player.printError("Please report this error: [See console]");
player.printRaw(e.getClass().getName() + ": " + e.getMessage()); player.printRaw(e.getClass().getName() + ": " + e.getMessage());
MainUtil.handleError(e); MainUtil.handleError(e);
} }

View File

@ -124,17 +124,16 @@ public class ClipboardFormats {
return null; return null;
} }
/** /**
* Detect the format using the given extension * Detect the format using the given extension
* @param string * @param extension the extension
* the extension
* @return the format, otherwise null if one cannot be detected * @return the format, otherwise null if one cannot be detected
*/ */
@Nullable @Nullable
public static ClipboardFormat findByExtension(String extension) { public static ClipboardFormat findByExtension(String extension) {
checkNotNull(extension); checkNotNull(extension);
Collection<Entry<String, ClipboardFormat>> entries = getFileExtensionMap().entries(); Collection<Entry<String, ClipboardFormat>> entries = getFileExtensionMap().entries();
for(Map.Entry<String, ClipboardFormat> entry : entries) { for(Map.Entry<String, ClipboardFormat> entry : entries) {
if(entry.getKey().equalsIgnoreCase(extension)) { if(entry.getKey().equalsIgnoreCase(extension)) {
@ -142,7 +141,7 @@ public class ClipboardFormats {
} }
} }
return null; return null;
} }
/** /**
@ -210,7 +209,7 @@ public class ClipboardFormats {
} }
f = player.openFileOpenDialog(extensions); f = player.openFileOpenDialog(extensions);
if (f == null || !f.exists()) { if (f == null || !f.exists()) {
if (message) player.printError(BBC.getPrefix() + "Schematic " + input + " does not exist! (" + f + ")"); if (message) player.printError("Schematic " + input + " does not exist! (" + f + ")");
return null; return null;
} }
} else { } else {
@ -231,7 +230,7 @@ public class ClipboardFormats {
} }
} }
if (f == null || !f.exists() || !MainUtil.isInSubDirectory(working, f)) { if (f == null || !f.exists() || !MainUtil.isInSubDirectory(working, f)) {
if (message) player.printError(BBC.getPrefix() + "Schematic " + input + " does not exist! (" + ((f == null) ? false : f.exists()) + "|" + f + "|" + (f == null ? false : !MainUtil.isInSubDirectory(working, f)) + ")"); if (message) player.printError("Schematic " + input + " does not exist! (" + ((f == null) ? false : f.exists()) + "|" + f + "|" + (f == null ? false : !MainUtil.isInSubDirectory(working, f)) + ")");
return null; return null;
} }
if (format == null && f.isFile()) { if (format == null && f.isFile()) {

View File

@ -19,13 +19,12 @@
package com.sk89q.worldedit.regions; package com.sk89q.worldedit.regions;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.math.BlockVector2; 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.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.storage.ChunkStore; import com.sk89q.worldedit.world.storage.ChunkStore;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -43,9 +42,6 @@ public class EllipsoidRegion extends AbstractRegion {
* Stores the radii plus 0.5 on each axis. * Stores the radii plus 0.5 on each axis.
*/ */
private Vector3 radius; private Vector3 radius;
private Vector3 radiusSqr;
private int radiusLengthSqr;
private boolean sphere;
/** /**
* Construct a new instance of this ellipsoid region. * Construct a new instance of this ellipsoid region.
@ -57,11 +53,10 @@ public class EllipsoidRegion extends AbstractRegion {
this(null, pos1, pos2); this(null, pos1, pos2);
} }
/** /**
* Construct a new instance of this ellipsoid region. * Construct a new instance of this ellipsoid region.
* *
* @param world the world * @param world the world
* @param center the center * @param center the center
* @param radius the radius * @param radius the radius
*/ */
@ -87,7 +82,6 @@ public class EllipsoidRegion extends AbstractRegion {
@Override @Override
public int getArea() { public int getArea() {
if (radius == null) return 0;
return (int) Math.floor((4.0 / 3.0) * Math.PI * radius.getX() * radius.getY() * radius.getZ()); return (int) Math.floor((4.0 / 3.0) * Math.PI * radius.getX() * radius.getY() * radius.getZ());
} }
@ -98,7 +92,7 @@ public class EllipsoidRegion extends AbstractRegion {
@Override @Override
public int getHeight() { public int getHeight() {
return Math.max((int) (2 * radius.getY()), 256); return (int) (2 * radius.getY());
} }
@Override @Override
@ -129,7 +123,7 @@ public class EllipsoidRegion extends AbstractRegion {
@Override @Override
public void expand(BlockVector3... changes) throws RegionOperationException { public void expand(BlockVector3... changes) throws RegionOperationException {
center = center.add(calculateDiff(changes)); center = center.add(calculateDiff(changes));
setRadius(radius.add(calculateChanges(changes))); radius = radius.add(calculateChanges(changes));
} }
@Override @Override
@ -169,7 +163,6 @@ public class EllipsoidRegion extends AbstractRegion {
* @return radii * @return radii
*/ */
public Vector3 getRadius() { public Vector3 getRadius() {
if (radius == null) return null;
return radius.subtract(0.5, 0.5, 0.5); return radius.subtract(0.5, 0.5, 0.5);
} }
@ -179,14 +172,7 @@ public class EllipsoidRegion extends AbstractRegion {
* @param radius the radius * @param radius the radius
*/ */
public void setRadius(Vector3 radius) { public void setRadius(Vector3 radius) {
this.radius = radius; this.radius = radius.add(0.5, 0.5, 0.5);
radiusSqr = radius.multiply(radius);
radiusLengthSqr = (int) radiusSqr.getX();
if (radius.getY() == radius.getX() && radius.getX() == radius.getZ()) {
this.sphere = true;
} else {
this.sphere = false;
}
} }
@Override @Override
@ -214,29 +200,8 @@ public class EllipsoidRegion extends AbstractRegion {
} }
@Override @Override
public boolean contains(BlockVector3 position) { public boolean contains(BlockVector3 position) {
int cx = position.getBlockX() - center.getBlockX(); return position.subtract(center).toVector3().divide(radius).lengthSq() <= 1;
int cx2 = cx * cx;
if (cx2 > radiusSqr.getBlockX()) {
return false;
}
int cz = position.getBlockZ() - center.getBlockZ();
int cz2 = cz * cz;
if (cz2 > radiusSqr.getBlockZ()) {
return false;
}
int cy = position.getBlockY() - center.getBlockY();
int cy2 = cy * cy;
if (radiusSqr.getBlockY() < 255 && cy2 > radiusSqr.getBlockY()) {
return false;
}
if (sphere) {
return cx2 + cy2 + cz2 <= radiusLengthSqr;
}
double cxd = (double) cx / radius.getBlockX();
double cyd = (double) cy / radius.getBlockY();
double czd = (double) cz / radius.getBlockZ();
return cxd * cxd + cyd * cyd + czd * czd <= 1;
} }
/** /**
@ -258,4 +223,5 @@ public class EllipsoidRegion extends AbstractRegion {
public EllipsoidRegion clone() { public EllipsoidRegion clone() {
return (EllipsoidRegion) super.clone(); return (EllipsoidRegion) super.clone();
} }
} }

View File

@ -142,7 +142,7 @@ public class SimpleDispatcher implements Dispatcher {
} }
throw new InvalidUsageException(BBC.getPrefix() + "Please choose a sub-command.", this, true); throw new InvalidUsageException("Please choose a sub-command.", this, true);
} }
@Override @Override

View File

@ -275,14 +275,14 @@ public class FunctionParametricCallable extends AParametricCallable {
} }
return result; return result;
} catch (MissingParameterException e) { } catch (MissingParameterException e) {
throw new InvalidUsageException(BBC.getPrefix() + "Too few parameters!", this, true); throw new InvalidUsageException("Too few parameters!", this, true);
} catch (UnconsumedParameterException e) { } catch (UnconsumedParameterException e) {
throw new InvalidUsageException(BBC.getPrefix() + "Too many parameters! Unused parameters: " + e.getUnconsumed(), this, true); throw new InvalidUsageException("Too many parameters! Unused parameters: " + e.getUnconsumed(), this, true);
} catch (ParameterException e) { } catch (ParameterException e) {
assert parameter != null; assert parameter != null;
String name = parameter.getName(); String name = parameter.getName();
throw new InvalidUsageException(BBC.getPrefix() + "For parameter '" + name + "': " + e.getMessage(), this, true); throw new InvalidUsageException("For parameter '" + name + "': " + e.getMessage(), this, true);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
if (e.getCause() instanceof CommandException) { if (e.getCause() instanceof CommandException) {
throw (CommandException) e.getCause(); throw (CommandException) e.getCause();

View File

@ -271,9 +271,9 @@ public class ParametricCallable extends AParametricCallable {
} }
return result; return result;
} catch (MissingParameterException e) { } catch (MissingParameterException e) {
throw new InvalidUsageException(BBC.getPrefix() + "Too few parameters!", this, true); throw new InvalidUsageException("Too few parameters!", this, true);
} catch (UnconsumedParameterException e) { } catch (UnconsumedParameterException e) {
throw new InvalidUsageException(BBC.getPrefix() + "Too many parameters! Unused parameters: " + e.getUnconsumed(), this, true); throw new InvalidUsageException("Too many parameters! Unused parameters: " + e.getUnconsumed(), this, true);
} catch (ParameterException e) { } catch (ParameterException e) {
assert parameter != null; assert parameter != null;
String name = parameter.getName(); String name = parameter.getName();

View File

@ -20,8 +20,6 @@
package com.sk89q.worldedit.world; package com.sk89q.worldedit.world;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
@ -32,6 +30,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.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
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;
@ -144,7 +143,6 @@ public abstract class AbstractWorld implements World {
this.priority = priority; this.priority = priority;
} }
@SuppressWarnings("deprecation")
public void play() { public void play() {
playEffect(position, 2001, blockType.getLegacyCombinedId() >> 4); playEffect(position, 2001, blockType.getLegacyCombinedId() >> 4);
} }
@ -154,4 +152,5 @@ public abstract class AbstractWorld implements World {
return Double.compare(priority, other != null ? other.priority : 0); return Double.compare(priority, other != null ? other.priority : 0);
} }
} }
}
}