mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 10:56:42 +00:00
Upstream changes, prefix changes, formatting changes, variable name changes
I think that draining waterlogged items also works now?
This commit is contained in:
@ -157,7 +157,7 @@ public class AnvilCommands {
|
||||
// final FaweBlockMatcher matchTo = FaweBlockMatcher.setBlocks(worldEdit.getBlocks(player, to, true));
|
||||
// ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo);
|
||||
// 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(
|
||||
@ -182,7 +182,7 @@ public class AnvilCommands {
|
||||
}
|
||||
RemapFilter filter = new RemapFilter(from, to);
|
||||
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
|
||||
DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
|
||||
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(
|
||||
@ -223,7 +223,7 @@ public class AnvilCommands {
|
||||
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
|
||||
if (debug) filter.enableDebug();
|
||||
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(
|
||||
@ -244,7 +244,7 @@ public class AnvilCommands {
|
||||
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
|
||||
if (debug) filter.enableDebug();
|
||||
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(
|
||||
@ -263,7 +263,7 @@ public class AnvilCommands {
|
||||
long duration = MainUtil.timeToSec(time) * 1000l;
|
||||
DeleteOldFilter filter = new DeleteOldFilter(duration);
|
||||
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(
|
||||
@ -283,7 +283,7 @@ public class AnvilCommands {
|
||||
FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false);
|
||||
MCAQueue queue = new MCAQueue(defaultQueue);
|
||||
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(
|
||||
@ -294,7 +294,7 @@ public class AnvilCommands {
|
||||
public void deleteBiome(Player player, String folder, BiomeType biome, @Switch('u') boolean unsafe) {
|
||||
DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome);
|
||||
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(
|
||||
@ -305,7 +305,7 @@ public class AnvilCommands {
|
||||
public void trimAllAir(Player player, String folder, @Switch('u') boolean unsafe) throws WorldEditException {
|
||||
TrimAirFilter filter = new TrimAirFilter();
|
||||
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(
|
||||
@ -316,7 +316,7 @@ public class AnvilCommands {
|
||||
public void debugfixroads(Player player, String folder) throws WorldEditException {
|
||||
DebugFixP2Roads filter = new DebugFixP2Roads();
|
||||
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(
|
||||
@ -335,7 +335,7 @@ public class AnvilCommands {
|
||||
// List<String> split = StringMan.split(from, ',');
|
||||
// filter = new MappedReplacePatternFilter(from, (RandomPattern) to, useData);
|
||||
// } else {
|
||||
// player.print(BBC.getPrefix() + "Must be a pattern list!");
|
||||
// player.print("Must be a pattern list!");
|
||||
// return;
|
||||
// }
|
||||
// } else {
|
||||
@ -348,7 +348,7 @@ public class AnvilCommands {
|
||||
// filter = new ReplacePatternFilter(matchFrom, to);
|
||||
// }
|
||||
// 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(
|
||||
@ -373,7 +373,7 @@ public class AnvilCommands {
|
||||
// filter = counter;
|
||||
// }
|
||||
// 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(
|
||||
@ -423,7 +423,7 @@ public class AnvilCommands {
|
||||
}
|
||||
};
|
||||
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(
|
||||
@ -448,7 +448,7 @@ public class AnvilCommands {
|
||||
// filter = counter;
|
||||
// }
|
||||
// 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(
|
||||
@ -514,7 +514,7 @@ public class AnvilCommands {
|
||||
// ((c[1] * 10000) / total) / 100d,
|
||||
// name == null ? "Unknown" : name,
|
||||
// block.getType(), block.getData());
|
||||
// player.print(BBC.getPrefix() + str);
|
||||
// player.print(str);
|
||||
// }
|
||||
// } else {
|
||||
// for (long[] c : map) {
|
||||
@ -523,7 +523,7 @@ public class AnvilCommands {
|
||||
// String.valueOf(c[1]),
|
||||
// ((c[1] * 10000) / total) / 100d,
|
||||
// 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);
|
||||
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
||||
// 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, ',');
|
||||
// filter = new MappedReplacePatternFilter(from, (RandomPattern) to, useData);
|
||||
// } else {
|
||||
// player.print(BBC.getPrefix() + "Must be a pattern list!");
|
||||
// player.print("Must be a pattern list!");
|
||||
// return;
|
||||
// }
|
||||
// } else {
|
||||
@ -577,7 +577,7 @@ public class AnvilCommands {
|
||||
// }
|
||||
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
||||
// 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 result = runWithSelection(player, editSession, selection, filter);
|
||||
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);
|
||||
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
||||
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);
|
||||
// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD);
|
||||
// if (clipboard == null) {
|
||||
// fp.sendMessage(BBC.getPrefix() + "You must first use `//anvil copy`");
|
||||
// fp.sendMessage("You must first use `//anvil copy`");
|
||||
// return;
|
||||
// }
|
||||
// CuboidRegion cuboid = clipboard.getRegion();
|
||||
@ -676,4 +676,4 @@ public class AnvilCommands {
|
||||
// });
|
||||
// BBC.COMMAND_PASTE.send(player, player.getPosition().toBlockVector());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ public class CFICommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void cancel(FawePlayer fp) throws ParameterException, IOException {
|
||||
getSettings(fp).remove();
|
||||
fp.sendMessage(BBC.getPrefix() + "Cancelled!");
|
||||
fp.sendMessage("Cancelled!");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -196,12 +196,12 @@ public class CFICommands extends MethodCommands {
|
||||
if (folder != null) {
|
||||
try {
|
||||
generator.setFolder(folder);
|
||||
fp.sendMessage(BBC.getPrefix() + "Generating " + folder);
|
||||
fp.sendMessage("Generating " + folder);
|
||||
generator.generate();
|
||||
generator.setPacketViewer(null);
|
||||
generator.setImageViewer(null);
|
||||
settings.remove();
|
||||
fp.sendMessage(BBC.getPrefix() + "Done!");
|
||||
fp.sendMessage("Done!");
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -215,8 +215,8 @@ public class CFICommands extends MethodCommands {
|
||||
|
||||
try {
|
||||
new PlotLoader().load(fp, settings, function);
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
function.apply(generator.getFolder().getParentFile());
|
||||
}
|
||||
|
||||
@ -879,7 +879,7 @@ public class CFICommands extends MethodCommands {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ImageIO.write(image, "jpg", baos );
|
||||
byte[] data = baos.toByteArray();
|
||||
fp.sendMessage(BBC.getPrefix() + "Please wait...");
|
||||
fp.sendMessage("Please wait...");
|
||||
URL url = ImgurUtility.uploadImage(data);
|
||||
BBC.DOWNLOAD_LINK.send(fp, url);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class PlotLoader {
|
||||
SinglePlotArea area = sManager.getArea();
|
||||
PlotPlayer player = PlotPlayer.wrap(fp.parent);
|
||||
|
||||
fp.sendMessage(BBC.getPrefix() + "Claiming world");
|
||||
fp.sendMessage("Claiming world");
|
||||
Plot plot = TaskManager.IMP.sync(new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(Plot o) {
|
||||
|
@ -10,7 +10,6 @@ import com.boydti.fawe.util.StringMan;
|
||||
import com.boydti.fawe.util.chat.Message;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -380,49 +379,25 @@ public enum BBC {
|
||||
/**
|
||||
* Translated
|
||||
*/
|
||||
private String s;
|
||||
private String translatedMessage;
|
||||
/**
|
||||
* Default
|
||||
*/
|
||||
private String d;
|
||||
private String defaultMessage;
|
||||
/**
|
||||
* What locale category should this translation fall under
|
||||
*/
|
||||
private String cat;
|
||||
/**
|
||||
* Should the string be prefixed?
|
||||
*/
|
||||
private boolean prefix;
|
||||
|
||||
/**
|
||||
* Constructor for custom strings.
|
||||
*/
|
||||
BBC() {
|
||||
/*
|
||||
* use setCustomString();
|
||||
*/
|
||||
}
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param d default
|
||||
* @param prefix use prefix
|
||||
* @param defaultMessage default
|
||||
*/
|
||||
BBC(final String d, final boolean prefix, final String cat) {
|
||||
this.d = d;
|
||||
this.s = d;
|
||||
this.prefix = prefix;
|
||||
this.cat = cat.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param d default
|
||||
*/
|
||||
BBC(final String d, final String cat) {
|
||||
this(d, true, cat.toLowerCase());
|
||||
BBC(final String defaultMessage, final String category) {
|
||||
this.defaultMessage = defaultMessage;
|
||||
this.translatedMessage = defaultMessage;
|
||||
this.category = category.toLowerCase();
|
||||
}
|
||||
|
||||
public String f(final Object... args) {
|
||||
@ -430,7 +405,7 @@ public enum BBC {
|
||||
}
|
||||
|
||||
public String format(final Object... args) {
|
||||
String m = this.s;
|
||||
String m = this.translatedMessage;
|
||||
for (int i = args.length - 1; i >= 0; i--) {
|
||||
if (args[i] == null) {
|
||||
continue;
|
||||
@ -457,7 +432,7 @@ public enum BBC {
|
||||
final HashSet<String> toRemove = new HashSet<>();
|
||||
for (final BBC c : all) {
|
||||
allNames.add(c.name());
|
||||
allCats.add(c.cat.toLowerCase());
|
||||
allCats.add(c.category.toLowerCase());
|
||||
}
|
||||
final HashSet<BBC> captions = new HashSet<>();
|
||||
boolean changed = false;
|
||||
@ -470,13 +445,13 @@ public enum BBC {
|
||||
final String node = split[split.length - 1].toUpperCase();
|
||||
final BBC caption = allNames.contains(node) ? valueOf(node) : null;
|
||||
if (caption != null) {
|
||||
if (!split[0].equalsIgnoreCase(caption.cat)) {
|
||||
if (!split[0].equalsIgnoreCase(caption.category)) {
|
||||
changed = true;
|
||||
yml.set(key, null);
|
||||
yml.set(caption.cat + "." + caption.name().toLowerCase(), value);
|
||||
yml.set(caption.category + "." + caption.name().toLowerCase(), value);
|
||||
}
|
||||
captions.add(caption);
|
||||
caption.s = (String) value;
|
||||
caption.translatedMessage = (String) value;
|
||||
} else {
|
||||
toRemove.add(key);
|
||||
}
|
||||
@ -488,9 +463,9 @@ public enum BBC {
|
||||
for (final BBC caption : all) {
|
||||
if (!captions.contains(caption)) {
|
||||
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) {
|
||||
yml.save(file);
|
||||
@ -523,7 +498,7 @@ public enum BBC {
|
||||
}
|
||||
|
||||
public String s() {
|
||||
return this.s;
|
||||
return this.translatedMessage;
|
||||
}
|
||||
|
||||
public Message m(Object... args) {
|
||||
@ -531,15 +506,11 @@ public enum BBC {
|
||||
}
|
||||
|
||||
public String original() {
|
||||
return d;
|
||||
return defaultMessage;
|
||||
}
|
||||
|
||||
public boolean usePrefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
public String getCat() {
|
||||
return this.cat;
|
||||
public String getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
public BBC or(BBC... others) {
|
||||
@ -695,7 +666,7 @@ public enum BBC {
|
||||
}
|
||||
for (Map.Entry<String, Object> entry2 : obj.entrySet()) {
|
||||
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 (newValue) {
|
||||
char code = BBC.getCode(entry2.getKey().toUpperCase());
|
||||
|
@ -56,7 +56,7 @@ public class CavesGen extends GenBase {
|
||||
double f2 = 0.0F;
|
||||
|
||||
if (maxAngle <= 0) {
|
||||
int checkAreaSize = this.getCheckAreaSize() * 16 - 16;
|
||||
int checkAreaSize = (this.getCheckAreaSize() * 16) - 16;
|
||||
maxAngle = checkAreaSize - ThreadLocalRandom.current().nextInt(checkAreaSize / 4);
|
||||
}
|
||||
boolean isLargeCave = false;
|
||||
@ -70,7 +70,7 @@ public class CavesGen extends GenBase {
|
||||
int k = ThreadLocalRandom.current().nextInt(6) == 0 ? 1 : 0;
|
||||
|
||||
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 f3 = MathMan.cosInexact(paramdouble3);
|
||||
|
@ -27,19 +27,9 @@ public abstract class FaweCommand<T> {
|
||||
execute(player, args);
|
||||
return true;
|
||||
} else if (player == null) {
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
execute(player, args);
|
||||
}
|
||||
});
|
||||
TaskManager.IMP.async(() -> execute(player, args));
|
||||
} else {
|
||||
if (!player.runAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
execute(player, args);
|
||||
}
|
||||
}, true, true)) {
|
||||
if (!player.runAction(() -> execute(player, args), true, true)) {
|
||||
BBC.WORLDEDIT_COMMAND_LIMIT.send(player);
|
||||
return true;
|
||||
}
|
||||
|
@ -457,6 +457,13 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
*/
|
||||
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
|
||||
*
|
||||
|
@ -1,12 +1,8 @@
|
||||
package com.boydti.fawe.object;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
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.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
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.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -84,23 +84,14 @@ public class DefaultProgressTracker extends RunnableVal2<FaweQueue.ProgressType,
|
||||
}
|
||||
|
||||
private final void done() {
|
||||
TaskManager.IMP.task(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doneTask();
|
||||
}
|
||||
});
|
||||
TaskManager.IMP.task(this::doneTask);
|
||||
}
|
||||
|
||||
private long lastTick = 0;
|
||||
|
||||
private final void send() {
|
||||
TaskManager.IMP.task(new Runnable() { // Run on main thread
|
||||
@Override
|
||||
public void run() {
|
||||
sendTask();
|
||||
}
|
||||
});
|
||||
// Run on main thread
|
||||
TaskManager.IMP.task(this::sendTask);
|
||||
}
|
||||
|
||||
public void doneTask() {
|
||||
|
@ -23,7 +23,7 @@ public class CachedMathMan {
|
||||
private static float[] ANGLES = new float[65536];
|
||||
static {
|
||||
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];
|
||||
}
|
||||
|
||||
protected static final float atan2(float y, float x) {
|
||||
protected static float atan2(float y, float x) {
|
||||
float add, mul;
|
||||
|
||||
if (x < 0.0f) {
|
||||
@ -65,7 +65,7 @@ public class CachedMathMan {
|
||||
mul = -1.0f;
|
||||
}
|
||||
|
||||
add = -3.141592653f;
|
||||
add = (float) -Math.PI;
|
||||
} else {
|
||||
if (y < 0.0f) {
|
||||
y = -y;
|
||||
|
@ -1,23 +1,14 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.io.DataOutput;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
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 ch2 = in.read();
|
||||
int ch3 = in.read();
|
||||
@ -27,22 +18,14 @@ public final class IOUtil {
|
||||
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 >>> 16) & 0xFF);
|
||||
out.write((v >>> 8) & 0xFF);
|
||||
out.write((v >>> 0) & 0xFF);
|
||||
}
|
||||
|
||||
public static final void writeVarInt(final OutputStream out, int i) 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 {
|
||||
public static int readVarInt(InputStream in) throws IOException {
|
||||
int i = 0;
|
||||
int offset = 0;
|
||||
int b;
|
||||
@ -54,7 +37,7 @@ public final class IOUtil {
|
||||
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];
|
||||
while (true) {
|
||||
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];
|
||||
while (len > 0) {
|
||||
int r = in.read(buf, 0, Math.min(buf.length, len));
|
||||
@ -78,7 +61,7 @@ public final class IOUtil {
|
||||
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];
|
||||
while (true) {
|
||||
int r = in.read(buf);
|
||||
|
@ -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);
|
||||
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);
|
||||
}
|
||||
|
||||
public static final short unpairX(int hash) {
|
||||
public static short unpairX(int hash) {
|
||||
return (short) (hash >> 16);
|
||||
}
|
||||
|
||||
public static final short unpairY(int hash) {
|
||||
public static short unpairY(int hash) {
|
||||
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));
|
||||
}
|
||||
|
||||
public static final byte unpairShortX(short pair) {
|
||||
public static byte unpairShortX(short pair) {
|
||||
return (byte) (pair >> 8);
|
||||
}
|
||||
|
||||
public static final byte unpairShortY(short pair) {
|
||||
public static byte unpairShortY(short 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static final long untripleWorldCoordX(long triple) {
|
||||
public static long untripleWorldCoordX(long triple) {
|
||||
return (((triple >> 8) & 0x3FFFFFF) << 38) >> 38;
|
||||
}
|
||||
|
||||
public static final long untripleWorldCoordY(long triple) {
|
||||
public static long untripleWorldCoordY(long triple) {
|
||||
return triple & 0xFF;
|
||||
}
|
||||
|
||||
public static final long untripleWorldCoordZ(long triple) {
|
||||
public static long untripleWorldCoordZ(long triple) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static final int untripleBlockCoordX(int triple) {
|
||||
public static int untripleBlockCoordX(int triple) {
|
||||
return (triple >> 12) & 0xF;
|
||||
}
|
||||
|
||||
public static final int untripleBlockCoordY(int triple) {
|
||||
public static int untripleBlockCoordY(int triple) {
|
||||
return (triple & 0xFF);
|
||||
}
|
||||
|
||||
public static final int untripleBlockCoordZ(int triple) {
|
||||
public static int untripleBlockCoordZ(int triple) {
|
||||
return (triple >> 8) & 0xF;
|
||||
}
|
||||
|
||||
@ -231,31 +231,31 @@ public class MathMan {
|
||||
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;
|
||||
}
|
||||
|
||||
public static final int unpairIntX(long pair) {
|
||||
public static int unpairIntX(long pair) {
|
||||
return (int) (pair >> 32);
|
||||
}
|
||||
|
||||
public static final int unpairIntY(long pair) {
|
||||
public static int unpairIntY(long 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));
|
||||
}
|
||||
|
||||
public static final byte unpair16x(byte value) {
|
||||
public static byte unpair16x(byte value) {
|
||||
return (byte) (value & 0xF);
|
||||
}
|
||||
|
||||
public static final byte unpair16y(byte value) {
|
||||
public static byte unpair16y(byte value) {
|
||||
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));
|
||||
}
|
||||
|
||||
@ -267,18 +267,18 @@ public class MathMan {
|
||||
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;
|
||||
}
|
||||
|
||||
public static final int gcd(int a, int b) {
|
||||
public static int gcd(int a, int b) {
|
||||
if (b == 0) {
|
||||
return a;
|
||||
}
|
||||
return gcd(b, a % b);
|
||||
}
|
||||
|
||||
public static final int gcd(int[] a) {
|
||||
public static int gcd(int[] a) {
|
||||
int result = a[0];
|
||||
for (int i = 1; i < a.length; 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;
|
||||
for (int i : array) {
|
||||
count += i;
|
||||
@ -295,7 +295,7 @@ public class MathMan {
|
||||
return count / array.length;
|
||||
}
|
||||
|
||||
public static final double getMean(double[] array) {
|
||||
public static double getMean(double[] array) {
|
||||
double count = 0;
|
||||
for (double i : array) {
|
||||
count += i;
|
||||
@ -310,12 +310,12 @@ public class MathMan {
|
||||
* @param pitch
|
||||
* @return
|
||||
*/
|
||||
public static final float[] getDirection(float yaw, float pitch) {
|
||||
public static float[] getDirection(float yaw, float 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)};
|
||||
}
|
||||
|
||||
public static final int roundInt(double value) {
|
||||
public static int roundInt(double value) {
|
||||
return (int) (value < 0 ? (value == (int) value) ? value : value - 1 : value);
|
||||
}
|
||||
|
||||
@ -327,24 +327,24 @@ public class MathMan {
|
||||
* @param z
|
||||
* @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));
|
||||
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);
|
||||
}
|
||||
|
||||
public static final float sqrtApprox(float f) {
|
||||
public static float sqrtApprox(float f) {
|
||||
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));
|
||||
}
|
||||
|
||||
public static final float invSqrt(float x) {
|
||||
public static float invSqrt(float x) {
|
||||
float xhalf = 0.5f * x;
|
||||
int i = Float.floatToIntBits(x);
|
||||
i = 0x5f3759df - (i >> 1);
|
||||
@ -353,7 +353,7 @@ public class MathMan {
|
||||
return x;
|
||||
}
|
||||
|
||||
public static final boolean isInteger(CharSequence str) {
|
||||
public static boolean isInteger(CharSequence str) {
|
||||
if (str == null) {
|
||||
return false;
|
||||
}
|
||||
@ -377,7 +377,7 @@ public class MathMan {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final double getSD(double[] array, double av) {
|
||||
public static double getSD(double[] array, double av) {
|
||||
double sd = 0;
|
||||
for (double element : array) {
|
||||
sd += Math.pow(Math.abs(element - av), 2);
|
||||
@ -385,7 +385,7 @@ public class MathMan {
|
||||
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;
|
||||
for (int element : array) {
|
||||
sd += Math.pow(Math.abs(element - av), 2);
|
||||
@ -393,25 +393,25 @@ public class MathMan {
|
||||
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);
|
||||
}
|
||||
|
||||
public static final int mod(int x, int y) {
|
||||
public static int mod(int x, int y) {
|
||||
if (isPowerOfTwo(y)) {
|
||||
return x & (y - 1);
|
||||
}
|
||||
return x % y;
|
||||
}
|
||||
|
||||
public static final int unsignedmod(int x, int y) {
|
||||
public static int unsignedmod(int x, int y) {
|
||||
if (isPowerOfTwo(y)) {
|
||||
return x & (y - 1);
|
||||
}
|
||||
return x % y;
|
||||
}
|
||||
|
||||
public static final boolean isPowerOfTwo(int x) {
|
||||
public static boolean isPowerOfTwo(int x) {
|
||||
return (x & (x - 1)) == 0;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class ReflectionUtils9 {
|
||||
|
||||
// 2. Copy it
|
||||
T[] previousValues = (T[]) valuesField.get(enumType);
|
||||
List values = new ArrayList(Arrays.asList(previousValues));
|
||||
List values = new ArrayList<>(Arrays.asList(previousValues));
|
||||
|
||||
// 3. build new enum
|
||||
T newValue = (T) makeEnum(enumType, // The target enum class
|
||||
|
@ -672,21 +672,21 @@ public class ShapeInterpolator {
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public int getWindingRule() {
|
||||
return (t < 0.5 ? g0.getWindingRule() : g1.getWindingRule());
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isDone() {
|
||||
return (cIndex > g0.getNumCoordinates());
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void next() {
|
||||
if (cIndex == 0) {
|
||||
@ -697,7 +697,7 @@ public class ShapeInterpolator {
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public int currentSegment(float[] coordinates) {
|
||||
int type;
|
||||
|
@ -127,7 +127,7 @@ public class StringMan {
|
||||
int start = sb.indexOf(key, 0);
|
||||
while (start > -1) {
|
||||
final int end = start + key.length();
|
||||
final int nextSearchStart = start + 0;
|
||||
final int nextSearchStart = start;
|
||||
sb.delete(start, end);
|
||||
size -= end - start;
|
||||
start = sb.indexOf(key, nextSearchStart);
|
||||
@ -209,10 +209,10 @@ public class StringMan {
|
||||
}
|
||||
return "{ " + result + " }";
|
||||
} else if (obj instanceof Collection<?>) {
|
||||
String result = "";
|
||||
StringBuilder result = new StringBuilder();
|
||||
String prefix = "";
|
||||
for (final Object element : (Collection<?>) obj) {
|
||||
result += prefix + getString(element);
|
||||
result.append(prefix).append(getString(element));
|
||||
prefix = ",";
|
||||
}
|
||||
return "( " + result + " )";
|
||||
@ -299,13 +299,7 @@ public class StringMan {
|
||||
|
||||
public static String joinOrdered(final Collection<?> collection, final String delimiter) {
|
||||
final Object[] array = collection.toArray();
|
||||
Arrays.sort(array, new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(final Object a, final Object b) {
|
||||
return a.hashCode() - b.hashCode();
|
||||
}
|
||||
|
||||
});
|
||||
Arrays.sort(array, Comparator.comparingInt(Object::hashCode));
|
||||
return join(array, delimiter);
|
||||
}
|
||||
|
||||
@ -327,12 +321,7 @@ public class StringMan {
|
||||
}
|
||||
|
||||
public static Comparator<String> blockStateComparator(String input) {
|
||||
return new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
return blockStateStringDistance(input, o1) - blockStateStringDistance(input, o2);
|
||||
}
|
||||
};
|
||||
return Comparator.comparingInt(o -> blockStateStringDistance(input, o));
|
||||
}
|
||||
|
||||
public static boolean blockStateMatches(String input, String item) {
|
||||
@ -392,9 +381,9 @@ public class StringMan {
|
||||
n = m;
|
||||
m = t.length();
|
||||
}
|
||||
int p[] = new int[n + 1];
|
||||
int d[] = new int[n + 1];
|
||||
int _d[];
|
||||
int[] p = new int[n + 1];
|
||||
int[] d = new int[n + 1];
|
||||
int[] _d;
|
||||
int i;
|
||||
int j;
|
||||
char t_j;
|
||||
|
Reference in New Issue
Block a user