minor cleanup

This commit is contained in:
Jesse Boyd 2017-06-20 19:00:30 +10:00
parent 283fd746d5
commit 043f1e6002
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
316 changed files with 8446 additions and 7876 deletions

View File

@ -55,11 +55,11 @@ public class RenderListener implements Listener {
int nowTick = (int) (Fawe.get().getTimer().getTick());
while (entrySet.hasNext()) {
Map.Entry<UUID, int[]> entry = entrySet.next();
Player player = Bukkit.getPlayer(entry.getKey());
if (player != null) {
int[] value = entry.getValue();
if (nowTick - value[1] >= timeOut) {
value[1] = nowTick + 1;
Player player = Bukkit.getPlayer(entry.getKey());
if (player != null) {
setViewDistance(player, Math.max(4, value[0] + 1));
long spent = System.currentTimeMillis() - now;
if (spent > 5) {

View File

@ -151,42 +151,43 @@ import javax.management.Notification;
import javax.management.NotificationEmitter;
import javax.management.NotificationListener;
/**[ WorldEdit action]
* |
* \|/
* [ EditSession ] - The change is processed (area restrictions, change limit, block type)
* |
* \|/
* [Block change] - A block change from some location
* |
* \|/
* [ Set Queue ] - The SetQueue manages the implementation specific queue
* |
* \|/
* [ Fawe Queue] - A queue of chunks - check if the queue has the chunk for a change
* |
* \|/
* [ Fawe Chunk Implementation ] - Otherwise create a new FaweChunk object which is a wrapper around the Chunk object
* |
* \|/
* [ Execution ] - When done, the queue then sets the blocks for the chunk, performs lighting updates and sends the chunk packet to the clients
*
* Why it's faster:
* - The chunk is modified directly rather than through the API
* \ Removes some overhead, and means some processing can be done async
* - Lighting updates are performed on the chunk level rather than for every block
* \ e.g. A blob of stone: only the visible blocks need to have the lighting calculated
* - Block changes are sent with a chunk packet
* \ A chunk packet is generally quicker to create and smaller for large world edits
* - No physics updates
* \ Physics updates are slow, and are usually performed on each block
* - Block data shortcuts
* \ Some known blocks don't need to have the data set or accessed (e.g. air is never going to have data)
* - Remove redundant extents
* \ Up to 11 layers of extents can be removed
* - History bypassing
* \ FastMode bypasses history and means blocks in the world don't need to be checked and recorded
*/
/**
* [ WorldEdit action]
* |
* \|/
* [ EditSession ] - The change is processed (area restrictions, change limit, block type)
* |
* \|/
* [Block change] - A block change from some location
* |
* \|/
* [ Set Queue ] - The SetQueue manages the implementation specific queue
* |
* \|/
* [ Fawe Queue] - A queue of chunks - check if the queue has the chunk for a change
* |
* \|/
* [ Fawe Chunk Implementation ] - Otherwise create a new FaweChunk object which is a wrapper around the Chunk object
* |
* \|/
* [ Execution ] - When done, the queue then sets the blocks for the chunk, performs lighting updates and sends the chunk packet to the clients
* <p>
* Why it's faster:
* - The chunk is modified directly rather than through the API
* \ Removes some overhead, and means some processing can be done async
* - Lighting updates are performed on the chunk level rather than for every block
* \ e.g. A blob of stone: only the visible blocks need to have the lighting calculated
* - Block changes are sent with a chunk packet
* \ A chunk packet is generally quicker to create and smaller for large world edits
* - No physics updates
* \ Physics updates are slow, and are usually performed on each block
* - Block data shortcuts
* \ Some known blocks don't need to have the data set or accessed (e.g. air is never going to have data)
* - Remove redundant extents
* \ Up to 11 layers of extents can be removed
* - History bypassing
* \ FastMode bypasses history and means blocks in the world don't need to be checked and recorded
*/
public class Fawe {
/**
* The FAWE instance;
@ -208,6 +209,7 @@ public class Fawe {
/**
* Get the implementation specific class
*
* @return
*/
@SuppressWarnings("unchecked")
@ -217,6 +219,7 @@ public class Fawe {
/**
* Get the implementation independent class
*
* @return
*/
public static Fawe get() {
@ -225,6 +228,7 @@ public class Fawe {
/**
* Setup Fawe
*
* @param implementation
* @throws InstanceAlreadyExistsException
*/
@ -248,6 +252,7 @@ public class Fawe {
/**
* Write something to the console
*
* @param s
*/
public static void debug(Object s) {
@ -293,7 +298,8 @@ public class Fawe {
WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers());
WEManager.IMP.managers.add(new PlotSquaredFeature());
Fawe.debug("Plugin 'PlotSquared' found. Using it now.");
} catch (Throwable e) {}
} catch (Throwable e) {
}
}
}, 0);
@ -337,6 +343,7 @@ public class Fawe {
/**
* The FAWE updater class
* - Use to get basic update information (changelog/version etc)
*
* @return
*/
public Updater getUpdater() {
@ -348,7 +355,9 @@ public class Fawe {
try {
tu = min == 0 && max == 100 ? tu : new CleanTextureUtil(tu, min, max);
tu = randomize ? new RandomTextureUtil(tu) : new CachedTextureUtil(tu);
} catch (FileNotFoundException neverHappens) { neverHappens.printStackTrace(); }
} catch (FileNotFoundException neverHappens) {
neverHappens.printStackTrace();
}
return tu;
}
@ -372,6 +381,7 @@ public class Fawe {
/**
* The FaweTimer is a useful class for monitoring TPS
*
* @return FaweTimer
*/
public FaweTimer getTimer() {
@ -380,6 +390,7 @@ public class Fawe {
/**
* The visual queue is used to queue visualizations
*
* @return
*/
public VisualQueue getVisualQueue() {
@ -389,9 +400,12 @@ public class Fawe {
/**
* The FAWE version
* - Unofficial jars may be lacking version information
*
* @return FaweVersion
*/
public @Nullable FaweVersion getVersion() {
public
@Nullable
FaweVersion getVersion() {
return version;
}
@ -419,7 +433,8 @@ public class Fawe {
Settings.IMP.DATE = new Date(100 + version.year, version.month, version.day).toGMTString();
Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit/" + version.build;
Settings.IMP.COMMIT = "https://github.com/boy0001/FastAsyncWorldedit/commit/" + Integer.toHexString(version.hash);
} catch (Throwable ignore) {}
} catch (Throwable ignore) {
}
Settings.IMP.reload(file);
// Setting up message.yml
BBC.load(new File(this.IMP.getDirectory(), "message.yml"));
@ -638,7 +653,8 @@ public class Fawe {
debug(" - This is only a recommendation");
debug("====================================");
}
} catch (Throwable ignore) {}
} catch (Throwable ignore) {
}
if (MainUtil.getJavaVersion() < 1.8) {
debug("====== UPGRADE TO JAVA 8 ======");
debug("You are running " + System.getProperty("java.version"));
@ -692,6 +708,7 @@ public class Fawe {
/**
* Get the main thread
*
* @return
*/
public Thread getMainThread() {
@ -704,6 +721,7 @@ public class Fawe {
/**
* Sets the main thread to the current thread
*
* @return
*/
public Thread setMainThread() {

View File

@ -71,9 +71,10 @@ import javax.annotation.Nullable;
public class FaweAPI {
/**
* Offers a lot of options for building an EditSession
* @see com.boydti.fawe.util.EditSessionBuilder
*
* @param world
* @return A new EditSessionBuilder
* @see com.boydti.fawe.util.EditSessionBuilder
*/
public static EditSessionBuilder getEditSessionBuilder(World world) {
return new EditSessionBuilder(world);
@ -81,6 +82,7 @@ public class FaweAPI {
/**
* The TaskManager has some useful methods for doing things asynchronously
*
* @return TaskManager
*/
public static TaskManager getTaskManager() {
@ -89,9 +91,10 @@ public class FaweAPI {
/**
* Add a custom mask for use in e.g {@literal //mask #id:<input>}
* @see com.sk89q.worldedit.command.MaskCommands
*
* @param methods The class with a bunch of mask methods
* @return true if the mask was registered
* @see com.sk89q.worldedit.command.MaskCommands
*/
public static boolean registerMasks(Object methods) {
DefaultMaskParser parser = getParser(DefaultMaskParser.class);
@ -101,9 +104,10 @@ public class FaweAPI {
/**
* Add a custom material for use in e.g {@literal //material #id:<input>}
* @see com.sk89q.worldedit.command.PatternCommands
*
* @param methods The class with a bunch of pattern methods
* @return true if the mask was registered
* @see com.sk89q.worldedit.command.PatternCommands
*/
public static boolean registerPatterns(Object methods) {
HashTagPatternParser parser = getParser(HashTagPatternParser.class);
@ -113,9 +117,10 @@ public class FaweAPI {
/**
* Add a custom transform for use in
* @see com.sk89q.worldedit.command.TransformCommands
*
* @param methods The class with a bunch of transform methods
* @return true if the transform was registered
* @see com.sk89q.worldedit.command.TransformCommands
*/
public static boolean registerTransforms(Object methods) {
DefaultTransformParser parser = Fawe.get().getTransformParser();
@ -148,6 +153,7 @@ public class FaweAPI {
* Create a command with the provided aliases and register all methods of the class as sub commands.<br>
* - You should try to register commands during startup
* - If no aliases are specified, all methods become root commands
*
* @param clazz The class containing all the sub command methods
* @param aliases The aliases to give the command (or none)
*/
@ -162,6 +168,7 @@ public class FaweAPI {
* - com.sk89q.worldedit.entity.Player
* - String (name)
* - UUID (player UUID)
*
* @param obj
* @return
*/
@ -178,10 +185,11 @@ public class FaweAPI {
* - The FaweQueue skips a bit of overhead so it's faster<br>
* - The WorldEdit EditSession can do a lot more<br>
* Remember to enqueue it when you're done!<br>
* @see com.boydti.fawe.object.FaweQueue#enqueue()
*
* @param world The name of the world
* @param autoqueue If it should start dispatching before you enqueue it.
* @return
* @see com.boydti.fawe.object.FaweQueue#enqueue()
*/
public static FaweQueue createQueue(World world, boolean autoqueue) {
return SetQueue.IMP.getNewQueue(world, true, autoqueue);
@ -204,6 +212,7 @@ public class FaweAPI {
/**
* Upload the clipboard to the configured web interface
*
* @param clipboard The clipboard (may not be null)
* @param format The format to use (some formats may not be supported)
* @return The download URL or null
@ -214,10 +223,11 @@ public class FaweAPI {
/**
* Just forwards to ClipboardFormat.SCHEMATIC.load(file)
* @see com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat
* @see com.boydti.fawe.object.schematic.Schematic
*
* @param file
* @return
* @see com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat
* @see com.boydti.fawe.object.schematic.Schematic
*/
public static Schematic load(File file) throws IOException {
return ClipboardFormat.SCHEMATIC.load(file);
@ -225,6 +235,7 @@ public class FaweAPI {
/**
* Get a list of supported protection plugin masks.
*
* @return Set of FaweMaskManager
*/
public static Set<FaweMaskManager> getMaskManagers() {
@ -233,6 +244,7 @@ public class FaweAPI {
/**
* Check if the server has more than the configured low memory threshold
*
* @return True if the server has limited memory
*/
public static boolean isMemoryLimited() {
@ -241,6 +253,7 @@ public class FaweAPI {
/**
* Use ThreadLocalRandom instead
*
* @return
*/
@Deprecated
@ -250,6 +263,7 @@ public class FaweAPI {
/**
* Get a player's allowed WorldEdit region
*
* @param player
* @return
*/
@ -261,14 +275,16 @@ public class FaweAPI {
* Cancel the edit with the following extent<br>
* - The extent must be the one being used by an EditSession, otherwise an error may be thrown <br>
* - Insert an extent into the EditSession using the EditSessionEvent: http://wiki.sk89q.com/wiki/WorldEdit/API/Hooking_EditSession <br>
* @see com.sk89q.worldedit.EditSession#getRegionExtent() To get the FaweExtent for an EditSession
*
* @param extent
* @param reason
* @see com.sk89q.worldedit.EditSession#getRegionExtent() To get the FaweExtent for an EditSession
*/
public static void cancelEdit(Extent extent, BBC reason) {
try {
WEManager.IMP.cancelEdit(extent, reason);
} catch (WorldEditException ignore) {}
} catch (WorldEditException ignore) {
}
}
public static void addMaskManager(FaweMaskManager maskMan) {
@ -277,6 +293,7 @@ public class FaweAPI {
/**
* Get the DiskStorageHistory object representing a File
*
* @param file
* @return
*/
@ -313,6 +330,7 @@ public class FaweAPI {
/**
* Used in the RollBack to generate a list of DiskStorageHistory objects<br>
* - Note: An edit outside the radius may be included if it overlaps with an edit inside that depends on it.
*
* @param origin - The origin location
* @param user - The uuid (may be null)
* @param radius - The radius from the origin of the edit
@ -397,11 +415,12 @@ public class FaweAPI {
/**
* The DiskStorageHistory class is what FAWE uses to represent the undo on disk.
* @see com.boydti.fawe.object.changeset.DiskStorageHistory#toEditSession(com.boydti.fawe.object.FawePlayer)
*
* @param world
* @param uuid
* @param index
* @return
* @see com.boydti.fawe.object.changeset.DiskStorageHistory#toEditSession(com.boydti.fawe.object.FawePlayer)
*/
public static DiskStorageHistory getChangeSetFromDisk(World world, UUID uuid, int index) {
return new DiskStorageHistory(world, uuid, index);
@ -409,6 +428,7 @@ public class FaweAPI {
/**
* Compare two versions
*
* @param version
* @param major
* @param minor
@ -439,6 +459,7 @@ public class FaweAPI {
* - First removes all lighting, then relights
* - Relights in parallel (if enabled) for best performance<br>
* - Also resends chunks<br>
*
* @param world
* @param selection (assumes cuboid)
* @return
@ -462,7 +483,7 @@ public class FaweAPI {
final NMSMappedFaweQueue nmsQueue = (NMSMappedFaweQueue) queue;
NMSRelighter relighter = new NMSRelighter(nmsQueue);
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z ++) {
for (int z = minZ; z <= maxZ; z++) {
relighter.addChunk(x, z, null, 65535);
count++;
}
@ -485,6 +506,7 @@ public class FaweAPI {
* If a schematic is too large to be pasted normally<br>
* - Skips any block history
* - Ignores nbt
*
* @param file
* @param loc
* @return
@ -500,12 +522,12 @@ public class FaweAPI {
}
/**
* @param url
* @param loc
* @deprecated Since I haven't finished it yet
* If a schematic is too large to be pasted normally<br>
* - Skips any block history
* - Ignores nbt
* @param url
* @param loc
*/
@Deprecated
public static void streamSchematic(final URL url, final FaweLocation loc) {
@ -519,14 +541,14 @@ public class FaweAPI {
}
/**
* @param is
* @param loc
* @throws IOException
* @deprecated Since I haven't finished it yet
* If a schematic is too large to be pasted normally<br>
* - Skips any block history
* - Ignores some block data
* - Not actually streaming from disk, but it does skip a lot of overhead
* @param is
* @param loc
* @throws IOException
*/
@Deprecated
public static void streamSchematic(final InputStream is, final FaweLocation loc) throws IOException {
@ -573,6 +595,7 @@ public class FaweAPI {
/**
* Set a task to run when the global queue (SetQueue class) is empty
*
* @param whenDone
*/
public static void addTask(final Runnable whenDone) {
@ -581,6 +604,7 @@ public class FaweAPI {
/**
* Have a task run when the server is low on memory (configured threshold)
*
* @param run
*/
public static void addMemoryLimitedTask(Runnable run) {
@ -589,6 +613,7 @@ public class FaweAPI {
/**
* Have a task run when the server is no longer low on memory (configured threshold)
*
* @param run
*/
public static void addMemoryPlentifulTask(Runnable run) {
@ -596,16 +621,16 @@ public class FaweAPI {
}
/**
* @see BBC
* @return
* @see BBC
*/
public static BBC[] getTranslations() {
return BBC.values();
}
/**
* @deprecated
* @see #getEditSessionBuilder(com.sk89q.worldedit.world.World)
* @deprecated
*/
@Deprecated
public static EditSession getNewEditSession(@Nonnull FawePlayer player) {
@ -616,8 +641,8 @@ public class FaweAPI {
}
/**
* @deprecated
* @see #getEditSessionBuilder(com.sk89q.worldedit.world.World)
* @deprecated
*/
@Deprecated
public static EditSession getNewEditSession(World world) {

View File

@ -82,6 +82,7 @@ public class FaweCache {
/**
* Get the cached BaseBlock object for an id/data<br>
* - The block is immutable
*
* @param id
* @param data
* @return
@ -96,6 +97,7 @@ public class FaweCache {
/**
* Get the combined data for a block
*
* @param id
* @param data
* @return
@ -114,6 +116,7 @@ public class FaweCache {
/**
* Get the combined id for a block
*
* @param block
* @return
*/
@ -558,12 +561,14 @@ public class FaweCache {
case 212:
case 217:
return true;
default: return false;
default:
return false;
}
}
/**
* Check if an id might have data
*
* @param id
* @return
*/
@ -643,6 +648,7 @@ public class FaweCache {
/**
* Check if an id might have nbt
*
* @param id
* @return
*/
@ -720,12 +726,12 @@ public class FaweCache {
if (entry == null) {
return data != 0 ? id + ":" + data : id + "";
}
return data != 0 ? entry.id.replace("minecraft:","") + ":" + data : entry.id.replace("minecraft:","");
return data != 0 ? entry.id.replace("minecraft:", "") + ":" + data : entry.id.replace("minecraft:", "");
}
public static Map<String, Object> asMap(Object... pairs) {
HashMap<String, Object> map = new HashMap<String, Object>(pairs.length >> 1);
for (int i = 0; i < pairs.length; i+=2) {
for (int i = 0; i < pairs.length; i += 2) {
String key = (String) pairs[i];
Object value = pairs[i + 1];
map.put(key, value);

View File

@ -69,6 +69,7 @@ public class AnvilCommands {
/**
* Run safely on an unloaded world (no selection)
*
* @param player
* @param folder
* @param filter
@ -88,6 +89,7 @@ public class AnvilCommands {
/**
* Run safely on an existing world within a selection
*
* @param player
* @param editSession
* @param selection
@ -221,7 +223,7 @@ public class AnvilCommands {
aliases = {"clear", "unset"},
desc = "Clear the chunks in a selection (delete without defrag)"
)
@CommandPermissions("worldedit.anvil.replaceall")
@CommandPermissions("worldedit.anvil.clear")
public void unset(Player player, EditSession editSession, @Selection Region selection) throws WorldEditException {
Vector bot = selection.getMinimumPoint();
Vector top = selection.getMaximumPoint();
@ -239,7 +241,7 @@ public class AnvilCommands {
if (region.isIn(bx, bz) && region.isIn(bx + 511, bz + 511)) {
file.setDeleted(true);
get().add(512 * 512 * 256);
} else if (region.isInMCA(X, Z)){
} else if (region.isInMCA(X, Z)) {
file.init();
final byte[] empty = new byte[4];
RandomAccessFile raf = file.getRandomAccessFile();
@ -307,6 +309,7 @@ public class AnvilCommands {
public void applyBlock(int x, int y, int z, BaseBlock block, long[] counts) {
counts[block.getCombined()]++;
}
@Override
public long[] init() {
return new long[Character.MAX_VALUE + 1];
@ -319,6 +322,7 @@ public class AnvilCommands {
public void applyBlock(int x, int y, int z, BaseBlock block, long[] counts) {
counts[block.getId()]++;
}
@Override
public long[] init() {
return new long[4096];
@ -334,7 +338,7 @@ public class AnvilCommands {
}
ArrayList<long[]> map = new ArrayList<>();
for (int i = 0; i < count.length; i++) {
if (count[i] != 0) map.add(new long[] { i, count[i]});
if (count[i] != 0) map.add(new long[]{i, count[i]});
}
Collections.sort(map, new Comparator<long[]>() {
@Override
@ -467,7 +471,7 @@ public class AnvilCommands {
desc = "Paste chunks from your anvil clipboard",
help =
"Paste the chunks from your anvil clipboard.\n" +
"The -c will align the paste to the chunks.",
"The -c flag will align the paste to the chunks.",
flags = "c"
)

View File

@ -36,7 +36,7 @@ public class Cancel extends FaweCommand {
}
}
}
BBC.WORLDEDIT_CANCEL_COUNT.send(player,cancelled);
BBC.WORLDEDIT_CANCEL_COUNT.send(player, cancelled);
return true;
}

View File

@ -27,7 +27,7 @@ import java.lang.annotation.Annotation;
import javax.annotation.Nullable;
public class FawePrimitiveBinding extends BindingHelper {
@BindingMatch(type = { Long.class, long.class },
@BindingMatch(type = {Long.class, long.class},
behavior = BindingBehavior.CONSUMES,
consumedCount = 1,
provideModifiers = true)
@ -153,7 +153,7 @@ public class FawePrimitiveBinding extends BindingHelper {
* @return the requested type
* @throws ParameterException on error
*/
@BindingMatch(type = { Boolean.class, boolean.class },
@BindingMatch(type = {Boolean.class, boolean.class},
behavior = BindingBehavior.CONSUMES,
consumedCount = 1)
public Boolean getBoolean(ArgumentStack context) throws ParameterException {
@ -167,7 +167,8 @@ public class FawePrimitiveBinding extends BindingHelper {
* @return a number
* @throws ParameterException thrown on parse error
*/
public static @Nullable
public static
@Nullable
Double parseNumericInput(@Nullable String input) throws ParameterException {
if (input == null) {
return null;
@ -196,7 +197,7 @@ public class FawePrimitiveBinding extends BindingHelper {
* @return the requested type
* @throws ParameterException on error
*/
@BindingMatch(type = { Integer.class, int.class },
@BindingMatch(type = {Integer.class, int.class},
behavior = BindingBehavior.CONSUMES,
consumedCount = 1,
provideModifiers = true)
@ -219,7 +220,7 @@ public class FawePrimitiveBinding extends BindingHelper {
* @return the requested type
* @throws ParameterException on error
*/
@BindingMatch(type = { Short.class, short.class },
@BindingMatch(type = {Short.class, short.class},
behavior = BindingBehavior.CONSUMES,
consumedCount = 1,
provideModifiers = true)
@ -239,7 +240,7 @@ public class FawePrimitiveBinding extends BindingHelper {
* @return the requested type
* @throws ParameterException on error
*/
@BindingMatch(type = { Double.class, double.class },
@BindingMatch(type = {Double.class, double.class},
behavior = BindingBehavior.CONSUMES,
consumedCount = 1,
provideModifiers = true)
@ -261,7 +262,7 @@ public class FawePrimitiveBinding extends BindingHelper {
* @return the requested type
* @throws ParameterException on error
*/
@BindingMatch(type = { Float.class, float.class },
@BindingMatch(type = {Float.class, float.class},
behavior = BindingBehavior.CONSUMES,
consumedCount = 1,
provideModifiers = true)

View File

@ -149,7 +149,8 @@ public class Rollback extends FaweCommand {
} else {
user = Fawe.imp().getUUID(split[1]);
}
} catch (IllegalArgumentException e) {}
} catch (IllegalArgumentException e) {
}
if (user == null) {
player.sendMessage("&dInvalid user: " + split[1]);
return;

View File

@ -63,7 +63,8 @@ public class SuggestInputParseException extends InputParseException {
}
if (suggestions.isEmpty()) {
suggestions.addAll(inputs);
} return suggestions;
}
return suggestions;
}
private static ArrayList<String> getSuggestions(String input, String... inputs) {

View File

@ -138,8 +138,8 @@ public enum BBC {
ROLLBACK_ELEMENT("Undoing %s0", "WorldEdit.Rollback"),
TOOL_INSPECT("Inspect tool bound to %s0.", "WorldEdit.Tool"),
TOOL_INSPECT_INFO("&7%s0 changed %s1 to %s2 %s3 ago","WorldEdit.Tool"),
TOOL_INSPECT_INFO_FOOTER("&6Total: &7%s0 changes","WorldEdit.Tool"),
TOOL_INSPECT_INFO("&7%s0 changed %s1 to %s2 %s3 ago", "WorldEdit.Tool"),
TOOL_INSPECT_INFO_FOOTER("&6Total: &7%s0 changes", "WorldEdit.Tool"),
TOOL_NONE("Tool unbound from your current item.", "WorldEdit.Tool"),
TOOL_INFO("Info tool bound to %s0.", "WorldEdit.Tool"),
TOOL_TREE("Tree tool bound to %s0.", "WorldEdit.Tool"),
@ -220,7 +220,7 @@ public enum BBC {
COMMAND_SYNTAX("&cUsage: &7%s0", "Error"),
NO_PERM("&cYou are lacking the permission node: %s0", "Error"),
SETTING_DISABLE("&cLacking setting: %s0","Error"),
SETTING_DISABLE("&cLacking setting: %s0", "Error"),
BRUSH_NOT_FOUND("&cAvailable brushes: %s0", "Error"),
BRUSH_INCOMPATIBLE("&cBrush not compatible with this version", "Error"),
SCHEMATIC_NOT_FOUND("&cSchematic not found: &7%s0", "Error"),
@ -313,32 +313,7 @@ public enum BBC {
TIP_REGEN_1("Tip: Use a seed with /regen [biome] [seed]", "Tips"),
TIP_BIOME_PATTERN("Tip: The &c#biome:forest&7 pattern can be used in any command", "Tips"),
TIP_BIOME_MASK("Tip: Restrict to a biome with the `$jungle` mask", "Tips"),
;
TIP_BIOME_MASK("Tip: Restrict to a biome with the `$jungle` mask", "Tips"),;
private static final HashMap<String, String> replacements = new HashMap<>();
@ -550,34 +525,55 @@ public enum BBC {
public static String getColorName(char code) {
switch (code) {
case '0': return "BLACK";
case '1': return "DARK_BLUE";
case '2': return "DARK_GREEN";
case '3': return "DARK_AQUA";
case '4': return "DARK_RED";
case '5': return "DARK_PURPLE";
case '6': return "GOLD";
case '0':
return "BLACK";
case '1':
return "DARK_BLUE";
case '2':
return "DARK_GREEN";
case '3':
return "DARK_AQUA";
case '4':
return "DARK_RED";
case '5':
return "DARK_PURPLE";
case '6':
return "GOLD";
default:
case '7': return "GRAY";
case '8': return "DARK_GRAY";
case '9': return "BLUE";
case 'a': return "GREEN";
case 'b': return "AQUA";
case 'c': return "RED";
case 'd': return "LIGHT_PURPLE";
case 'e': return "YELLOW";
case 'f': return "WHITE";
case 'k': return "OBFUSCATED";
case 'l': return "BOLD";
case 'm': return "STRIKETHROUGH";
case 'n': return "UNDERLINE";
case 'o': return "ITALIC";
case 'r': return "RESET";
case '7':
return "GRAY";
case '8':
return "DARK_GRAY";
case '9':
return "BLUE";
case 'a':
return "GREEN";
case 'b':
return "AQUA";
case 'c':
return "RED";
case 'd':
return "LIGHT_PURPLE";
case 'e':
return "YELLOW";
case 'f':
return "WHITE";
case 'k':
return "OBFUSCATED";
case 'l':
return "BOLD";
case 'm':
return "STRIKETHROUGH";
case 'n':
return "UNDERLINE";
case 'o':
return "ITALIC";
case 'r':
return "RESET";
}
}
/**
*
* @param m
* @param runPart Part, Color, NewLine
*/

View File

@ -30,6 +30,7 @@ public class Config {
/**
* Get the value for a node<br>
* Probably throws some error if you try to get a non existent key
*
* @param key
* @param <T>
* @return
@ -54,9 +55,9 @@ public class Config {
/**
* Set the value of a specific node<br>
* Probably throws some error if you supply non existing keys or invalid values
*
* @param key config node
* @param value value
*
*/
private void set(String key, Object value, Class root) {
String[] split = key.split("\\.");
@ -98,6 +99,7 @@ public class Config {
/**
* Set all values in the file (load first to avoid overwriting)
*
* @param file
*/
public void save(File file) {
@ -124,20 +126,22 @@ public class Config {
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface Create {}
public @interface Create {
}
/**
* Indicates that a field cannot be modified
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface Final {}
public @interface Final {
}
/**
* Creates a comment
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD,ElementType.TYPE})
@Target({ElementType.FIELD, ElementType.TYPE})
public @interface Comment {
String[] value();
}
@ -146,7 +150,7 @@ public class Config {
* The names of any default blocks
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD,ElementType.TYPE})
@Target({ElementType.FIELD, ElementType.TYPE})
public @interface BlockName {
String[] value();
}
@ -155,8 +159,9 @@ public class Config {
* Any field or class with is not part of the config
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD,ElementType.TYPE})
public @interface Ignore {}
@Target({ElementType.FIELD, ElementType.TYPE})
public @interface Ignore {
}
@Ignore // This is not part of the config
public static class ConfigBlock<T> {
@ -190,6 +195,7 @@ public class Config {
/**
* Get the static fields in a section
*
* @param clazz
* @return
*/
@ -307,6 +313,7 @@ public class Config {
/**
* Get the field for a specific config node
*
* @param split the node (split by period)
* @return
*/
@ -321,6 +328,7 @@ public class Config {
/**
* Get the field for a specific config node and instance<br>
* Note: As expiry can have multiple blocks there will be multiple instances
*
* @param split the node (split by period)
* @param instance the instance
* @return
@ -339,12 +347,14 @@ public class Config {
private Object getInstance(Object instance, Class clazz) throws IllegalAccessException, InstantiationException {
try {
Field instanceField = clazz.getDeclaredField(clazz.getSimpleName());
} catch (Throwable ignore) {}
} catch (Throwable ignore) {
}
return clazz.newInstance();
}
/**
* Get the instance for a specific config node
*
* @param split the node (split by period)
* @return The instance or null
*/
@ -392,7 +402,8 @@ public class Config {
clazz = found;
split = Arrays.copyOfRange(split, 2, split.length);
continue;
} catch (NoSuchFieldException ignore) {}
} catch (NoSuchFieldException ignore) {
}
if (found != null) {
split = Arrays.copyOfRange(split, 1, split.length);
clazz = found;
@ -410,24 +421,27 @@ public class Config {
/**
* Translate a node to a java field name
*
* @param node
* @return
*/
private String toFieldName(String node) {
return node.toUpperCase().replaceAll("-","_");
return node.toUpperCase().replaceAll("-", "_");
}
/**
* Translate a field to a config node
*
* @param field
* @return
*/
private String toNodeName(String field) {
return field.toLowerCase().replace("_","-");
return field.toLowerCase().replace("_", "-");
}
/**
* Set some field to be accesible
*
* @param field
* @throws NoSuchFieldException
* @throws IllegalAccessException

View File

@ -20,7 +20,8 @@ public interface Configuration extends ConfigurationSection {
* @param value Value to set the default to.
* @throws IllegalArgumentException Thrown if path is null.
*/
@Override void addDefault(final String path, final Object value);
@Override
void addDefault(final String path, final Object value);
/**
* Sets the default values of the given paths as provided.

View File

@ -222,7 +222,7 @@ public interface ConfigurationSection {
/**
* Checks if the specified path is a String.
*
* <p>
* <p> If the path exists but is not a String, this will return false. If the
* path does not exist, this will return false. If the path does not exist
* but a default value has been specified, this will check if that default
@ -235,7 +235,7 @@ public interface ConfigurationSection {
/**
* Gets the requested int by path.
*
* <p>
* <p>If the int does not exist but a default value has been specified, this
* will return the default value. If the int does not exist and no default
* value was specified, this will return 0.</p>
@ -247,7 +247,7 @@ public interface ConfigurationSection {
/**
* Gets the requested int by path, returning a default value if not found.
*
* <p>
* <p>If the int does not exist then the specified default value will
* returned regardless of if a default has been identified in the root
* {@link com.boydti.fawe.configuration.Configuration}.</p>
@ -261,7 +261,7 @@ public interface ConfigurationSection {
/**
* Checks if the specified path is an int.
*
* <p>
* <p>If the path exists but is not a int, this will return false. If the
* path does not exist, this will return false. If the path does not exist
* but a default value has been specified, this will check if that default

View File

@ -10,7 +10,8 @@ public class InvalidConfigurationException extends Exception {
* Creates a new instance of InvalidConfigurationException without a
* message or cause.
*/
public InvalidConfigurationException() {}
public InvalidConfigurationException() {
}
/**
* Constructs an instance of InvalidConfigurationException with the

View File

@ -14,7 +14,8 @@ public class MemoryConfiguration extends MemorySection implements Configuration
/**
* Creates an empty {@link com.boydti.fawe.configuration.MemoryConfiguration} with no default values.
*/
public MemoryConfiguration() {}
public MemoryConfiguration() {
}
/**
* Creates an empty {@link com.boydti.fawe.configuration.MemoryConfiguration} using the specified {@link

View File

@ -1,12 +1,12 @@
/**
* Copyright (c) 2008, http://www.snakeyaml.org
*
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -17,7 +17,6 @@ package org.yaml.snakeyaml;
import java.util.HashMap;
import java.util.Map;
import org.yaml.snakeyaml.nodes.Tag;
/**

View File

@ -1,12 +1,12 @@
/**
* Copyright (c) 2008, http://www.snakeyaml.org
*
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
import org.yaml.snakeyaml.DumperOptions.FlowStyle;
import org.yaml.snakeyaml.composer.Composer;
import org.yaml.snakeyaml.constructor.BaseConstructor;

View File

@ -26,11 +26,11 @@ public class ConfigurationSerialization {
/**
* Attempts to deserialize the given arguments into a new instance of the
* given class.
*
* <p>
* <p>The class must implement {@link com.boydti.fawe.configuration.serialization.ConfigurationSerializable}, including
* the extra methods as specified in the javadoc of
* ConfigurationSerializable.</p>
*
* <p>
* <p>If a new instance could not be made, an example being the class not
* fully implementing the interface, null will be returned.</p>
*
@ -44,13 +44,13 @@ public class ConfigurationSerialization {
/**
* Attempts to deserialize the given arguments into a new instance of the
*
* <p>
* given class.
* <p>
* The class must implement {@link com.boydti.fawe.configuration.serialization.ConfigurationSerializable}, including
* the extra methods as specified in the javadoc of
* ConfigurationSerializable.</p>
*
* <p>
* <p>
* If a new instance could not be made, an example being the class not
* fully implementing the interface, null will be returned.</p>

View File

@ -32,7 +32,7 @@ public class RollbackDatabase {
private String INSERT_EDIT;
private String CREATE_TABLE;
// private String GET_EDITS_POINT;
// private String GET_EDITS_POINT;
private String GET_EDITS;
private String GET_EDITS_USER;
private String DELETE_EDITS_USER;

View File

@ -71,6 +71,7 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
/**
* Get the number of block changes in a specified section
*
* @param i
* @return
*/
@ -115,6 +116,7 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
/**
* Get the raw data for a section
*
* @param i
* @return
*/

View File

@ -139,7 +139,8 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
return section[j] >> 4;
}
public void saveChunk(CHUNK chunk) {}
public void saveChunk(CHUNK chunk) {
}
public abstract void relight(int x, int y, int z);

View File

@ -164,7 +164,7 @@ public class NMSRelighter implements Relighter {
if (!visited.containsKey(mutableBlockPos)) {
IntegerTrio index = new IntegerTrio(x, y, z);
visited.put(index, present);
queue.add(new Object[] { index, current });
queue.add(new Object[]{index, current});
}
}
} else if (current >= currentLight) {
@ -315,9 +315,9 @@ public class NMSRelighter implements Relighter {
int bz = chunk.z << 4;
Object chunkObj = queue.ensureChunkLoaded(chunk.x, chunk.z);
Object sections = queue.getCachedSections(queue.getWorld(), chunk.x, chunk.z);
if (sections == null)continue;
if (sections == null) continue;
Object section = queue.getCachedSection(sections, layer);
if (section == null)continue;
if (section == null) continue;
chunk.smooth = false;
for (int j = 0; j <= maxY; j++) {
int x = cacheX[j];
@ -379,7 +379,7 @@ public class NMSRelighter implements Relighter {
smoothSkyLight(chunk, y, true);
}
}
for (int i = chunks.length - 1; i>= 0; i--) { // Smooth backwards
for (int i = chunks.length - 1; i >= 0; i--) { // Smooth backwards
RelightSkyEntry chunk = chunks[i];
if (chunk.smooth) {
smoothSkyLight(chunk, y, false);
@ -405,8 +405,8 @@ public class NMSRelighter implements Relighter {
continue;
}
byte value = mask[j];
if ((value = (byte) Math.max(queue.getSkyLight(bx + x - 1, y, bz + z) - 1, value)) >= 14);
else if ((value = (byte) Math.max(queue.getSkyLight(bx + x, y, bz + z - 1) - 1, value)) >= 14);
if ((value = (byte) Math.max(queue.getSkyLight(bx + x - 1, y, bz + z) - 1, value)) >= 14) ;
else if ((value = (byte) Math.max(queue.getSkyLight(bx + x, y, bz + z - 1) - 1, value)) >= 14) ;
if (value > mask[j]) queue.setSkyLight(section, x, y, z, mask[j] = value);
}
} else {
@ -417,8 +417,8 @@ public class NMSRelighter implements Relighter {
continue;
}
byte value = mask[j];
if ((value = (byte) Math.max(queue.getSkyLight(bx + x + 1, y, bz + z) - 1, value)) >= 14);
else if ((value = (byte) Math.max(queue.getSkyLight(bx + x, y, bz + z + 1) - 1, value)) >= 14);
if ((value = (byte) Math.max(queue.getSkyLight(bx + x + 1, y, bz + z) - 1, value)) >= 14) ;
else if ((value = (byte) Math.max(queue.getSkyLight(bx + x, y, bz + z + 1) - 1, value)) >= 14) ;
if (value > mask[j]) queue.setSkyLight(section, x, y, z, mask[j] = value);
}
}

View File

@ -11,7 +11,8 @@ import java.util.Set;
import java.util.UUID;
public class NullFaweChunk extends FaweChunk<Void> {
public static final NullFaweChunk INSTANCE = new NullFaweChunk(null, 0 ,0);
public static final NullFaweChunk INSTANCE = new NullFaweChunk(null, 0, 0);
/**
* A FaweSections object represents a chunk and the blocks that you wish to change in it.
*

View File

@ -4,7 +4,8 @@ public class NullRelighter implements Relighter {
public static NullRelighter INSTANCE = new NullRelighter();
private NullRelighter() {}
private NullRelighter() {
}
@Override
public boolean addChunk(int cx, int cz, byte[] fix, int bitmask) {

View File

@ -186,7 +186,7 @@ public class WeakFaweQueueMap implements IFaweQueueMap {
ForkJoinPool pool = SetQueue.IMP.getForkJoinPool();
boolean result = true;
// amount = 8;
for (int i = 0; i < amount && (result = iter.hasNext());) {
for (int i = 0; i < amount && (result = iter.hasNext()); ) {
Map.Entry<Long, Reference<FaweChunk>> item = iter.next();
Reference<FaweChunk> chunkReference = item.getValue();
FaweChunk chunk = chunkReference.get();

View File

@ -223,7 +223,8 @@ public class InstallerFrame extends JFrame {
Class.forName("com.boydti.fawe.forge." + version + ".ForgeChunk_All");
supportedString = version;
break;
} catch (ClassNotFoundException ignore){}
} catch (ClassNotFoundException ignore) {
}
}
if (supportedString == null) {
prompt("This version of FAWE cannot be installed this way.");
@ -352,7 +353,7 @@ public class InstallerFrame extends JFrame {
thread.start();
}
public static void main(String[] args) throws Exception{
public static void main(String[] args) throws Exception {
InstallerFrame window = new InstallerFrame();
}
}

View File

@ -11,6 +11,7 @@ public class MinimizeButton extends InteractiveButton {
super("-");
this.window = window;
}
@Override
public void actionPerformed(ActionEvent e) {
window.setState(Frame.ICONIFIED);

View File

@ -11,6 +11,7 @@ public class TextAreaOutputStream extends PrintStream {
super(new OutputStream() {
private StringBuffer buffer = new StringBuffer();
private String newLine = "";
@Override
public void write(int b) throws IOException {
if (b != '\n') {

View File

@ -60,7 +60,7 @@ public class CorruptSchematicStreamer {
if (++matchIndex == match.length) {
break;
}
} else if (read == expected){
} else if (read == expected) {
if (++matchIndex == match.length) {
reader.run(dataInput);
break;
@ -253,7 +253,7 @@ public class CorruptSchematicStreamer {
for (int i = (int) Math.sqrt(volume); i > 0; i--) {
if (volume % i == 0) {
factors.add(i);
factors.add(volume/i);
factors.add(volume / i);
}
}
int min = Integer.MAX_VALUE;

View File

@ -28,12 +28,12 @@ public class JSON2NBT {
public static CompoundTag getTagFromJson(String jsonString) throws NBTException {
jsonString = jsonString.trim();
if(!jsonString.startsWith("{")) {
if (!jsonString.startsWith("{")) {
throw new NBTException("Invalid tag encountered, expected \'{\' as first char.");
} else if(topTagsCount(jsonString) != 1) {
} else if (topTagsCount(jsonString) != 1) {
throw new NBTException("Encountered multiple top tags, only one expected");
} else {
return (CompoundTag)nameValueToNBT("tag", jsonString).parse();
return (CompoundTag) nameValueToNBT("tag", jsonString).parse();
}
}
@ -42,27 +42,27 @@ public class JSON2NBT {
boolean flag = false;
Stack stack = new Stack();
for(int j = 0; j < str.length(); ++j) {
for (int j = 0; j < str.length(); ++j) {
char c0 = str.charAt(j);
if(c0 == 34) {
if(isCharEscaped(str, j)) {
if(!flag) {
if (c0 == 34) {
if (isCharEscaped(str, j)) {
if (!flag) {
throw new NBTException("Illegal use of \\\": " + str);
}
} else {
flag = !flag;
}
} else if(!flag) {
if(c0 != 123 && c0 != 91) {
if(c0 == 125 && (stack.isEmpty() || ((Character)stack.pop()).charValue() != 123)) {
} else if (!flag) {
if (c0 != 123 && c0 != 91) {
if (c0 == 125 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 123)) {
throw new NBTException("Unbalanced curly brackets {}: " + str);
}
if(c0 == 93 && (stack.isEmpty() || ((Character)stack.pop()).charValue() != 91)) {
if (c0 == 93 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 91)) {
throw new NBTException("Unbalanced square brackets []: " + str);
}
} else {
if(stack.isEmpty()) {
if (stack.isEmpty()) {
++i;
}
@ -71,12 +71,12 @@ public class JSON2NBT {
}
}
if(flag) {
if (flag) {
throw new NBTException("Unbalanced quotation: " + str);
} else if(!stack.isEmpty()) {
} else if (!stack.isEmpty()) {
throw new NBTException("Unbalanced brackets: " + str);
} else {
if(i == 0 && !str.isEmpty()) {
if (i == 0 && !str.isEmpty()) {
i = 1;
}
@ -93,45 +93,45 @@ public class JSON2NBT {
String s;
boolean c0;
char c01;
if(value.startsWith("{")) {
if (value.startsWith("{")) {
value = value.substring(1, value.length() - 1);
JSON2NBT.Compound JSON2NBT$list1;
for(JSON2NBT$list1 = new JSON2NBT.Compound(key); value.length() > 0; value = value.substring(s.length() + 1)) {
for (JSON2NBT$list1 = new JSON2NBT.Compound(key); value.length() > 0; value = value.substring(s.length() + 1)) {
s = nextNameValuePair(value, true);
if(s.length() > 0) {
if (s.length() > 0) {
c0 = false;
JSON2NBT$list1.tagList.add(getTagFromNameValue(s, false));
}
if(value.length() < s.length() + 1) {
if (value.length() < s.length() + 1) {
break;
}
c01 = value.charAt(s.length());
if(c01 != 44 && c01 != 123 && c01 != 125 && c01 != 91 && c01 != 93) {
if (c01 != 44 && c01 != 123 && c01 != 125 && c01 != 91 && c01 != 93) {
throw new NBTException("Unexpected token \'" + c01 + "\' at: " + value.substring(s.length()));
}
}
return JSON2NBT$list1;
} else if(value.startsWith("[") && !INT_ARRAY_MATCHER.matcher(value).matches()) {
} else if (value.startsWith("[") && !INT_ARRAY_MATCHER.matcher(value).matches()) {
value = value.substring(1, value.length() - 1);
JSON2NBT.List JSON2NBT$list;
for(JSON2NBT$list = new JSON2NBT.List(key); value.length() > 0; value = value.substring(s.length() + 1)) {
for (JSON2NBT$list = new JSON2NBT.List(key); value.length() > 0; value = value.substring(s.length() + 1)) {
s = nextNameValuePair(value, false);
if(s.length() > 0) {
if (s.length() > 0) {
c0 = true;
JSON2NBT$list.tagList.add(getTagFromNameValue(s, true));
}
if(value.length() < s.length() + 1) {
if (value.length() < s.length() + 1) {
break;
}
c01 = value.charAt(s.length());
if(c01 != 44 && c01 != 123 && c01 != 125 && c01 != 91 && c01 != 93) {
if (c01 != 44 && c01 != 123 && c01 != 125 && c01 != 91 && c01 != 93) {
throw new NBTException("Unexpected token \'" + c01 + "\' at: " + value.substring(s.length()));
}
}
@ -151,15 +151,15 @@ public class JSON2NBT {
private static String nextNameValuePair(String str, boolean isCompound) throws NBTException {
int i = getNextCharIndex(str, ':');
int j = getNextCharIndex(str, ',');
if(isCompound) {
if(i == -1) {
if (isCompound) {
if (i == -1) {
throw new NBTException("Unable to locate name/value separator for string: " + str);
}
if(j != -1 && j < i) {
if (j != -1 && j < i) {
throw new NBTException("Name error at: " + str);
}
} else if(i == -1 || i > j) {
} else if (i == -1 || i > j) {
i = -1;
}
@ -173,34 +173,34 @@ public class JSON2NBT {
boolean flag1 = false;
boolean flag2 = false;
for(int j = 0; i < str.length(); ++i) {
for (int j = 0; i < str.length(); ++i) {
char c0 = str.charAt(i);
if(c0 == 34) {
if(isCharEscaped(str, i)) {
if(!flag) {
if (c0 == 34) {
if (isCharEscaped(str, i)) {
if (!flag) {
throw new NBTException("Illegal use of \\\": " + str);
}
} else {
flag = !flag;
if(flag && !flag2) {
if (flag && !flag2) {
flag1 = true;
}
if(!flag) {
if (!flag) {
j = i;
}
}
} else if(!flag) {
if(c0 != 123 && c0 != 91) {
if(c0 == 125 && (stack.isEmpty() || ((Character)stack.pop()).charValue() != 123)) {
} else if (!flag) {
if (c0 != 123 && c0 != 91) {
if (c0 == 125 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 123)) {
throw new NBTException("Unbalanced curly brackets {}: " + str);
}
if(c0 == 93 && (stack.isEmpty() || ((Character)stack.pop()).charValue() != 91)) {
if (c0 == 93 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 91)) {
throw new NBTException("Unbalanced square brackets []: " + str);
}
if(c0 == 44 && stack.isEmpty()) {
if (c0 == 44 && stack.isEmpty()) {
return str.substring(0, i);
}
} else {
@ -208,8 +208,8 @@ public class JSON2NBT {
}
}
if(!Character.isWhitespace(c0)) {
if(!flag && flag1 && j != i) {
if (!Character.isWhitespace(c0)) {
if (!flag && flag1 && j != i) {
return str.substring(0, j + 1);
}
@ -221,16 +221,16 @@ public class JSON2NBT {
}
private static String locateName(String str, boolean isArray) throws NBTException {
if(isArray) {
if (isArray) {
str = str.trim();
if(str.startsWith("{") || str.startsWith("[")) {
if (str.startsWith("{") || str.startsWith("[")) {
return "";
}
}
int i = getNextCharIndex(str, ':');
if(i == -1) {
if(isArray) {
if (i == -1) {
if (isArray) {
return "";
} else {
throw new NBTException("Unable to locate name/value separator for string: " + str);
@ -241,16 +241,16 @@ public class JSON2NBT {
}
private static String locateValue(String str, boolean isArray) throws NBTException {
if(isArray) {
if (isArray) {
str = str.trim();
if(str.startsWith("{") || str.startsWith("[")) {
if (str.startsWith("{") || str.startsWith("[")) {
return str;
}
}
int i = getNextCharIndex(str, ':');
if(i == -1) {
if(isArray) {
if (i == -1) {
if (isArray) {
return str;
} else {
throw new NBTException("Unable to locate name/value separator for string: " + str);
@ -263,18 +263,18 @@ public class JSON2NBT {
private static int getNextCharIndex(String str, char targetChar) {
int i = 0;
for(boolean flag = true; i < str.length(); ++i) {
for (boolean flag = true; i < str.length(); ++i) {
char c0 = str.charAt(i);
if(c0 == 34) {
if(!isCharEscaped(str, i)) {
if (c0 == 34) {
if (!isCharEscaped(str, i)) {
flag = !flag;
}
} else if(flag) {
if(c0 == targetChar) {
} else if (flag) {
if (c0 == targetChar) {
return i;
}
if(c0 == 123 || c0 == 91) {
if (c0 == 123 || c0 == 91) {
return -1;
}
}
@ -305,50 +305,50 @@ public class JSON2NBT {
public Tag parse() throws NBTException {
try {
if(DOUBLE.matcher(this.jsonValue).matches()) {
if (DOUBLE.matcher(this.jsonValue).matches()) {
return new DoubleTag(Double.parseDouble(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
}
if(FLOAT.matcher(this.jsonValue).matches()) {
if (FLOAT.matcher(this.jsonValue).matches()) {
return new FloatTag(Float.parseFloat(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
}
if(BYTE.matcher(this.jsonValue).matches()) {
if (BYTE.matcher(this.jsonValue).matches()) {
return new ByteTag(Byte.parseByte(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
}
if(LONG.matcher(this.jsonValue).matches()) {
if (LONG.matcher(this.jsonValue).matches()) {
return new LongTag(Long.parseLong(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
}
if(SHORT.matcher(this.jsonValue).matches()) {
if (SHORT.matcher(this.jsonValue).matches()) {
return new ShortTag(Short.parseShort(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
}
if(INTEGER.matcher(this.jsonValue).matches()) {
if (INTEGER.matcher(this.jsonValue).matches()) {
return new IntTag(Integer.parseInt(this.jsonValue));
}
if(DOUBLE_UNTYPED.matcher(this.jsonValue).matches()) {
if (DOUBLE_UNTYPED.matcher(this.jsonValue).matches()) {
return new DoubleTag(Double.parseDouble(this.jsonValue));
}
if("true".equalsIgnoreCase(this.jsonValue) || "false".equalsIgnoreCase(this.jsonValue)) {
return new ByteTag((byte)(Boolean.parseBoolean(this.jsonValue)?1:0));
if ("true".equalsIgnoreCase(this.jsonValue) || "false".equalsIgnoreCase(this.jsonValue)) {
return new ByteTag((byte) (Boolean.parseBoolean(this.jsonValue) ? 1 : 0));
}
} catch (NumberFormatException var6) {
this.jsonValue = this.jsonValue.replaceAll("\\\\\"", "\"");
return new StringTag(this.jsonValue);
}
if(this.jsonValue.startsWith("[") && this.jsonValue.endsWith("]")) {
if (this.jsonValue.startsWith("[") && this.jsonValue.endsWith("]")) {
String var7 = this.jsonValue.substring(1, this.jsonValue.length() - 1);
String[] var8 = (String[])((String[]) Iterables.toArray(SPLITTER.split(var7), String.class));
String[] var8 = (String[]) ((String[]) Iterables.toArray(SPLITTER.split(var7), String.class));
try {
int[] var5 = new int[var8.length];
for(int j = 0; j < var8.length; ++j) {
for (int j = 0; j < var8.length; ++j) {
var5[j] = Integer.parseInt(var8[j].trim());
}
@ -357,15 +357,15 @@ public class JSON2NBT {
return new StringTag(this.jsonValue);
}
} else {
if(this.jsonValue.startsWith("\"") && this.jsonValue.endsWith("\"")) {
if (this.jsonValue.startsWith("\"") && this.jsonValue.endsWith("\"")) {
this.jsonValue = this.jsonValue.substring(1, this.jsonValue.length() - 1);
}
this.jsonValue = this.jsonValue.replaceAll("\\\\\"", "\"");
StringBuilder stringbuilder = new StringBuilder();
for(int i = 0; i < this.jsonValue.length(); ++i) {
if(i < this.jsonValue.length() - 1 && this.jsonValue.charAt(i) == 92 && this.jsonValue.charAt(i + 1) == 92) {
for (int i = 0; i < this.jsonValue.length(); ++i) {
if (i < this.jsonValue.length() - 1 && this.jsonValue.charAt(i) == 92 && this.jsonValue.charAt(i + 1) == 92) {
stringbuilder.append('\\');
++i;
} else {
@ -389,8 +389,8 @@ public class JSON2NBT {
ArrayList<Tag> list = new ArrayList<>();
Iterator var2 = this.tagList.iterator();
while(var2.hasNext()) {
JSON2NBT.Any JSON2NBT$any = (JSON2NBT.Any)var2.next();
while (var2.hasNext()) {
JSON2NBT.Any JSON2NBT$any = (JSON2NBT.Any) var2.next();
list.add(JSON2NBT$any.parse());
}
Class<? extends Tag> tagType = list.isEmpty() ? CompoundTag.class : list.get(0).getClass();
@ -409,8 +409,8 @@ public class JSON2NBT {
HashMap<String, Tag> map = new HashMap<String, Tag>();
Iterator var2 = this.tagList.iterator();
while(var2.hasNext()) {
JSON2NBT.Any JSON2NBT$any = (JSON2NBT.Any)var2.next();
while (var2.hasNext()) {
JSON2NBT.Any JSON2NBT$any = (JSON2NBT.Any) var2.next();
map.put(JSON2NBT$any.json, JSON2NBT$any.parse());
}

View File

@ -1,11 +1,13 @@
package com.boydti.fawe.jnbt;
public class NBTException extends RuntimeException{
public class NBTException extends RuntimeException {
public NBTException(String message) {
super(message);
}
/**
* Faster exception throwing if you don't fill the stacktrace
*
* @return
*/
@Override

View File

@ -18,6 +18,7 @@ public class NBTStreamer {
/**
* Reads the entire stream and runs the applicable readers
*
* @throws IOException
*/
public void readFully() throws IOException {
@ -34,6 +35,7 @@ public class NBTStreamer {
* Reads the stream until all readers have been used<br>
* - Use readFully if you expect a reader to appear more than once
* - Can exit early without having reading the entire file
*
* @throws IOException
*/
public void readQuick() throws IOException {
@ -47,7 +49,8 @@ public class NBTStreamer {
this.value2 = readers.remove(node);
}
});
} catch (FaweException ignore) {}
} catch (FaweException ignore) {
}
is.close();
}
@ -66,6 +69,7 @@ public class NBTStreamer {
public static abstract class NBTStreamReader<T, V> extends RunnableVal2<T, V> {
private String node;
public void init(String node) {
this.node = node;
}

View File

@ -88,7 +88,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
} else {
return new CachedTextureUtil(textureUtil);
}
} catch (FileNotFoundException neverHappens) { neverHappens.printStackTrace(); return null; }
} catch (FileNotFoundException neverHappens) {
neverHappens.printStackTrace();
return null;
}
}
public void setWaterHeight(int waterHeight) {
@ -176,7 +179,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
public void setHeight(BufferedImage img) {
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
heights[index] = (byte) (img.getRGB(x, z) >> 8);
}
}
@ -188,20 +191,21 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
}
@Deprecated
public void addSchems(Mask mask, WorldData worldData, ClipboardHolder[] clipboards, int rarity, boolean rotate) throws WorldEditException{
public void addSchems(Mask mask, WorldData worldData, ClipboardHolder[] clipboards, int rarity, boolean rotate) throws WorldEditException {
CuboidRegion region = new CuboidRegion(new Vector(0, 0, 0), new Vector(getWidth(), 255, getLength()));
addSchems(region, mask, worldData, clipboards, rarity, rotate);
}
public void addSchems(BufferedImage img, Mask mask, WorldData worldData, ClipboardHolder[] clipboards, int rarity, int distance, boolean randomRotate) throws WorldEditException{
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
public void addSchems(BufferedImage img, Mask mask, WorldData worldData, ClipboardHolder[] clipboards, int rarity, int distance, boolean randomRotate) throws WorldEditException {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
double doubleRarity = rarity / 100d;
int index = 0;
AffineTransform identity = new AffineTransform();
LocalBlockVector2DSet placed = new LocalBlockVector2DSet();
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int y = heights[index];
int height = img.getRGB(x, z) & 0xFF;
if (height == 0 || PseudoRandom.random.nextInt(256) > height * doubleRarity) {
@ -243,14 +247,14 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
}
}
public void addSchems(Mask mask, WorldData worldData, ClipboardHolder[] clipboards, int rarity, int distance, boolean randomRotate) throws WorldEditException{
public void addSchems(Mask mask, WorldData worldData, ClipboardHolder[] clipboards, int rarity, int distance, boolean randomRotate) throws WorldEditException {
int scaledRarity = (256 * rarity) / 100;
int index = 0;
AffineTransform identity = new AffineTransform();
LocalBlockVector2DSet placed = new LocalBlockVector2DSet();
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int y = heights[index];
if (PseudoRandom.random.nextInt(256) > scaledRarity) {
continue;
@ -439,10 +443,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
}
public void setBiome(BufferedImage img, byte biome, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && PseudoRandom.random.nextInt(256) <= height) {
biomes[index] = biome;
@ -545,7 +550,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
int index = 0;
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int y = heights[index] & 0xFF;
mutable.mutX(x);
mutable.mutY(y);
@ -561,12 +566,13 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
setOverlay(img, (char) ((BlockPattern) pattern).getBlock().getCombined(), white);
return;
}
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (overlay == null) overlay = new char[getArea()];
int index = 0;
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && PseudoRandom.random.nextInt(256) <= height) {
mutable.mutX(x);
@ -582,12 +588,13 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
setMain(img, (char) ((BlockPattern) pattern).getBlock().getCombined(), white);
return;
}
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
modifiedMain = true;
int index = 0;
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && PseudoRandom.random.nextInt(256) <= height) {
mutable.mutX(x);
@ -603,11 +610,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
setFloor(img, (char) ((BlockPattern) pattern).getBlock().getCombined(), white);
return;
}
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
int index = 0;
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && PseudoRandom.random.nextInt(256) <= height) {
mutable.mutX(x);
@ -623,12 +631,13 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
setColumn(img, (char) ((BlockPattern) pattern).getBlock().getCombined(), white);
return;
}
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
modifiedMain = true;
int index = 0;
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && PseudoRandom.random.nextInt(256) <= height) {
mutable.mutX(x);
@ -650,7 +659,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
if (overlay == null) overlay = new char[getArea()];
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int y = heights[index] & 0xFF;
mutable.mutX(x);
mutable.mutY(y);
@ -669,7 +678,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
int index = 0;
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int y = heights[index] & 0xFF;
mutable.mutX(x);
mutable.mutY(y);
@ -689,7 +698,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
int index = 0;
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int y = heights[index] & 0xFF;
mutable.mutX(x);
mutable.mutY(y);
@ -709,7 +718,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
int index = 0;
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int y = heights[index] & 0xFF;
mutable.mutX(x);
mutable.mutY(y);
@ -1034,7 +1043,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
if (overlay == null) overlay = new char[getArea()];
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int y = heights[index] & 0xFF;
mutable.mutX(x);
mutable.mutY(y);
@ -1049,7 +1058,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
int index = 0;
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int y = heights[index] & 0xFF;
mutable.mutX(x);
mutable.mutY(y);
@ -1065,7 +1074,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
int index = 0;
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int y = heights[index] & 0xFF;
mutable.mutX(x);
mutable.mutY(y);
@ -1081,7 +1090,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
int index = 0;
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int y = heights[index] & 0xFF;
mutable.mutX(x);
mutable.mutY(y);
@ -1113,11 +1122,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
}
private void setOverlay(BufferedImage img, char combined, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (overlay == null) overlay = new char[getArea()];
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && white && PseudoRandom.random.nextInt(256) <= height) {
overlay[index] = combined;
@ -1127,11 +1137,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
}
private void setMain(BufferedImage img, char combined, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
modifiedMain = true;
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && PseudoRandom.random.nextInt(256) <= height) {
main[index] = combined;
@ -1141,10 +1152,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
}
private void setFloor(BufferedImage img, char combined, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && PseudoRandom.random.nextInt(256) <= height) {
floor[index] = combined;
@ -1154,11 +1166,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
}
private void setColumn(BufferedImage img, char combined, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
modifiedMain = true;
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++){
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && PseudoRandom.random.nextInt(256) <= height) {
main[index] = combined;

View File

@ -396,6 +396,7 @@ public class MCAChunk extends FaweChunk<Void> {
/**
* Deprecated, use the toBytes method
*
* @return
*/
@Deprecated
@ -687,7 +688,7 @@ public class MCAChunk extends FaweChunk<Void> {
public int getNibble(int index, byte[] array) {
int indexShift = index >> 1;
if((index & 1) == 0) {
if ((index & 1) == 0) {
return array[indexShift] & 15;
} else {
return array[indexShift] >> 4 & 15;
@ -701,10 +702,10 @@ public class MCAChunk extends FaweChunk<Void> {
if (existing == value + valueShift) {
return;
}
if((index & 1) == 0) {
array[indexShift] = (byte)(existing & 240 | value);
if ((index & 1) == 0) {
array[indexShift] = (byte) (existing & 240 | value);
} else {
array[indexShift] = (byte)(existing & 15 | valueShift);
array[indexShift] = (byte) (existing & 15 | valueShift);
}
}

View File

@ -35,6 +35,7 @@ public class MCAFile {
private static Field fieldBuf2;
private static Field fieldBuf3;
static {
try {
fieldBuf2 = InflaterInputStream.class.getDeclaredField("buf");
@ -170,7 +171,7 @@ public class MCAFile {
public MCAChunk readChunk(int cx, int cz) throws IOException {
int i = ((cx & 31) << 2) + ((cz & 31) << 7);
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i+ 2] & 0xFF))) << 12;
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i + 2] & 0xFF))) << 12;
int size = (locations[i + 3] & 0xFF) << 12;
if (offset == 0) {
return null;
@ -187,6 +188,7 @@ public class MCAFile {
/**
* CX, CZ, OFFSET, SIZE
*
* @param onEach
* @throws IOException
*/
@ -196,7 +198,7 @@ public class MCAFile {
char i = 0;
for (int z = 0; z < 32; z++) {
for (int x = 0; x < 32; x++, i += 4) {
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i+ 2] & 0xFF))) - 2;
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i + 2] & 0xFF))) - 2;
int size = locations[i + 3] & 0xFF;
if (size != 0) {
if (offset < offsets.length) {
@ -227,7 +229,7 @@ public class MCAFile {
int i = 0;
for (int z = 0; z < 32; z++) {
for (int x = 0; x < 32; x++, i += 4) {
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i+ 2] & 0xFF)));
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i + 2] & 0xFF)));
int size = locations[i + 3] & 0xFF;
if (size != 0) {
onEach.run(x, z, offset << 12, size << 12);
@ -240,12 +242,13 @@ public class MCAFile {
int i = 0;
for (int z = 0; z < 32; z++) {
for (int x = 0; x < 32; x++, i += 4) {
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i+ 2] & 0xFF)));
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i + 2] & 0xFF)));
int size = locations[i + 3] & 0xFF;
if (size != 0) {
try {
onEach.run(getChunk(x, z));
} catch (Throwable ignore) {}
} catch (Throwable ignore) {
}
}
}
}
@ -253,7 +256,7 @@ public class MCAFile {
public int getOffset(int cx, int cz) {
int i = ((cx & 31) << 2) + ((cz & 31) << 7);
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i+ 2] & 0xFF)));
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i + 2] & 0xFF)));
return offset << 12;
}
@ -264,14 +267,14 @@ public class MCAFile {
public List<Integer> getChunks() {
final List<Integer> values = new ArrayList<>(chunks.size());
for (int i = 0; i < locations.length; i+=4) {
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i+ 2] & 0xFF)));
for (int i = 0; i < locations.length; i += 4) {
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i + 2] & 0xFF)));
values.add(offset);
}
return values;
}
public byte[] getChunkCompressedBytes(int offset) throws IOException{
public byte[] getChunkCompressedBytes(int offset) throws IOException {
if (offset == 0) {
return null;
}
@ -362,7 +365,7 @@ public class MCAFile {
return compressed;
}
private byte[] getChunkBytes(int cx, int cz) throws Exception{
private byte[] getChunkBytes(int cx, int cz) throws Exception {
MCAChunk mca = getCachedChunk(cx, cz);
if (mca == null) {
int offset = getOffset(cx, cz);

View File

@ -11,6 +11,7 @@ public class MCAFilter<T> extends IterableThreadLocal<T> {
/**
* Check whether a .mca file should be read
*
* @param mcaX
* @param mcaZ
* @return
@ -23,6 +24,7 @@ public class MCAFilter<T> extends IterableThreadLocal<T> {
* Do something with the MCAFile<br>
* - Return null if you don't want to filter chunks<br>
* - Return the same file if you do want to filter chunks<br>
*
* @param file
* @return file or null
*/
@ -32,6 +34,7 @@ public class MCAFilter<T> extends IterableThreadLocal<T> {
/**
* Check whether a chunk should be read
*
* @param cx
* @param cz
* @return
@ -44,6 +47,7 @@ public class MCAFilter<T> extends IterableThreadLocal<T> {
* Do something with the MCAChunk<br>
* - Return null if you don't want to filter blocks<br>
* - Return the chunk if you do want to filter blocks<br>
*
* @param chunk
* @return
*/
@ -55,18 +59,22 @@ public class MCAFilter<T> extends IterableThreadLocal<T> {
* Make changes to the block here<br>
* - e.g. block.setId(...)<br>
* - Note: Performance is critical here<br>
*
* @param x
* @param y
* @param z
* @param block
*/
public void applyBlock(int x, int y, int z, BaseBlock block, T cache) {}
public void applyBlock(int x, int y, int z, BaseBlock block, T cache) {
}
/**
* Do something with the MCAChunk after block filtering<br>
*
* @param chunk
* @param cache
* @return
*/
public void finishChunk(MCAChunk chunk, T cache) {}
public void finishChunk(MCAChunk chunk, T cache) {
}
}

View File

@ -75,7 +75,7 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
public int getBiome(FaweChunk faweChunk, int x, int z) {
if (faweChunk instanceof MCAChunk) {
return ((MCAChunk) faweChunk).getBiomeArray()[((z & 0xF) << 4 | x & 0xF)];
} else if (parent != null){
} else if (parent != null) {
return parent.getBiomeId(x, z);
} else {
return 0;

View File

@ -111,7 +111,7 @@ public class MCAQueueMap implements IFaweQueueMap {
ignore.printStackTrace();
}
if (isHybridQueue) { // Use parent queue for in use chunks
lastChunk = ((MappedFaweQueue)queue).getFaweQueueMap().getFaweChunk(cx, cz);
lastChunk = ((MappedFaweQueue) queue).getFaweQueueMap().getFaweChunk(cx, cz);
return lastChunk;
}
nullChunk.setLoc(queue, lastX, lastZ);

View File

@ -42,6 +42,7 @@ public abstract class MCAWriter {
* Set the MCA file offset (each mca file is 512 blocks)
* - A negative value will shift the map negative
* - This only applies to generation, not block get/set
*
* @param mcaOX
* @param mcaOZ
*/

View File

@ -81,10 +81,10 @@ public class MutableMCABackedBaseBlock extends BaseBlock {
@Override
public void setData(int value) {
int indexShift = index >> 1;
if((index & 1) == 0) {
data[indexShift] = (byte)(data[indexShift] & 240 | value & 15);
if ((index & 1) == 0) {
data[indexShift] = (byte) (data[indexShift] & 240 | value & 15);
} else {
data[indexShift] = (byte)(data[indexShift] & 15 | (value & 15) << 4);
data[indexShift] = (byte) (data[indexShift] & 15 | (value & 15) << 4);
}
chunk.setModified();
}

View File

@ -10,7 +10,8 @@ public class CountFilter extends MCAFilterCounter {
private final boolean[] allowedId = new boolean[FaweCache.getId(Character.MAX_VALUE)];
private final boolean[] allowed = new boolean[Character.MAX_VALUE];
public CountFilter() {}
public CountFilter() {
}
public CountFilter addBlock(BaseBlock block) {
addBlock(block.getId(), block.getData());

View File

@ -9,7 +9,8 @@ import com.sk89q.worldedit.blocks.BaseBlock;
public class CountIdFilter extends MCAFilterCounter {
private final boolean[] allowedId = new boolean[FaweCache.getId(Character.MAX_VALUE)];
public CountIdFilter() {}
public CountIdFilter() {
}
public CountIdFilter addBlock(int id) {
allowedId[id] = true;

View File

@ -26,6 +26,7 @@ public class DeleteUninhabitedFilter extends MCAFilterCounter {
this.fileAgeMillis = fileAgeMillis;
this.inhabitedTicks = inhabitedTicks;
}
@Override
public MCAFile applyFile(MCAFile mca) {
File file = mca.getFile();
@ -38,7 +39,8 @@ public class DeleteUninhabitedFilter extends MCAFilterCounter {
get().add(512 * 512 * 256);
return null;
}
} catch (IOException | UnsupportedOperationException ignore) {}
} catch (IOException | UnsupportedOperationException ignore) {
}
try {
ForkJoinPool pool = new ForkJoinPool();
mca.init();

View File

@ -15,7 +15,8 @@ import java.util.List;
public class MappedReplacePatternFilter extends MCAFilterCounter {
private Pattern[] map = new Pattern[Character.MAX_VALUE + 1];
public MappedReplacePatternFilter() {}
public MappedReplacePatternFilter() {
}
public MappedReplacePatternFilter(String from, RandomPattern to, boolean useData) throws InputParseException {
List<String> split = StringMan.split(from, ',');

View File

@ -13,6 +13,7 @@ public class ReplaceSimpleFilter extends MCAFilterCounter {
this.from = from;
this.to = to;
}
@Override
public void applyBlock(int x, int y, int z, BaseBlock block, MutableLong count) {
if (from.apply(block)) {

View File

@ -24,7 +24,7 @@ public class OreGen extends Resource {
private double ONE_8 = 1 / 8F;
private double ONE_16 = 1 / 16F;
public int laced =0;
public int laced = 0;
public OreGen(Extent extent, Mask mask, Pattern pattern, int size, int minY, int maxY) {
this.maxSize = size;

View File

@ -29,19 +29,19 @@ public class MutableVector extends Vector {
}
public boolean equals(Object obj) {
if(!(obj instanceof Vector)) {
if (!(obj instanceof Vector)) {
return false;
} else {
Vector v = (Vector)obj;
Vector v = (Vector) obj;
return this.x == v.getX() && this.z == v.getZ() && this.y == v.getY();
}
}
public int hashCode() {
byte hash = 3;
int hash1 = 59 * hash + (int)(Double.doubleToLongBits(this.x) ^ Double.doubleToLongBits(this.x) >>> 32);
hash1 = 59 * hash1 + (int)(Double.doubleToLongBits(this.y) ^ Double.doubleToLongBits(this.y) >>> 32);
hash1 = 59 * hash1 + (int)(Double.doubleToLongBits(this.z) ^ Double.doubleToLongBits(this.z) >>> 32);
int hash1 = 59 * hash + (int) (Double.doubleToLongBits(this.x) ^ Double.doubleToLongBits(this.x) >>> 32);
hash1 = 59 * hash1 + (int) (Double.doubleToLongBits(this.y) ^ Double.doubleToLongBits(this.y) >>> 32);
hash1 = 59 * hash1 + (int) (Double.doubleToLongBits(this.z) ^ Double.doubleToLongBits(this.z) >>> 32);
return hash1;
}
}

View File

@ -10,7 +10,7 @@ import com.sk89q.worldedit.function.pattern.AbstractPattern;
public class DataAngleMask extends AbstractPattern {
public final Extent extent;
public final int maxY;
public final double factor = 1d/255;
public final double factor = 1d / 255;
public DataAngleMask(Extent extent) {
this.extent = extent;

View File

@ -16,7 +16,7 @@ import javax.annotation.Nullable;
public abstract class FaweChunk<T> implements Callable<FaweChunk> {
private FaweQueue parent;
private int x,z;
private int x, z;
public static int HEIGHT = 256;
private final ArrayDeque<Runnable> tasks = new ArrayDeque<Runnable>();
@ -33,6 +33,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* Change the chunk's location<br>
* - E.g. if you are cloning a chunk and want to set multiple
*
* @param parent
* @param x
* @param z
@ -45,6 +46,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* Get the parent queue this chunk belongs to
*
* @return
*/
public FaweQueue getParent() {
@ -61,6 +63,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* Get a unique hashcode for this chunk
*
* @return
*/
public long longHash() {
@ -69,6 +72,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* Get a hashcode; unique below abs(x/z) < Short.MAX_VALUE
*
* @return
*/
@Override
@ -85,6 +89,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* The modified sections
*
* @return
*/
public abstract int getBitMask();
@ -92,6 +97,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* Get the combined block id at a location<br>
* combined = (id <<<< 4) + data
*
* @param x
* @param y
* @param z
@ -127,10 +133,13 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* Get the combined id array at a layer or null if it does not exist
*
* @param layer
* @return char[] or null
*/
public @Nullable char[] getIdArray(int layer) {
public
@Nullable
char[] getIdArray(int layer) {
char[] ids = new char[4096];
int by = layer << 4;
int index = 0;
@ -187,6 +196,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* Fill this chunk with a block
*
* @param id
* @param data
*/
@ -196,6 +206,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* Fill a cuboid in this chunk with a block
*
* @param x1
* @param x2
* @param y1
@ -217,6 +228,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* Add a task to run when this chunk is dispatched
*
* @param run
*/
public void addNotifyTask(Runnable run) {
@ -238,6 +250,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* Get the underlying chunk object
*
* @return
*/
public abstract T getChunk();
@ -245,6 +258,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* Set a tile entity at a location<br>
* - May throw an error if an invalid block is at the location
*
* @param x
* @param y
* @param z
@ -266,6 +280,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* Get the UUID of entities being removed
*
* @return
*/
public abstract Set<UUID> getEntityRemoves();
@ -273,15 +288,17 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
/**
* Get the map of location to tile entity<br>
* - The byte pair represents the location in the chunk<br>
*
* @return
* @see com.boydti.fawe.util.MathMan#unpair16x (get0) => x
* @see com.boydti.fawe.util.MathMan#unpair16y (get0) => z
* get1 => y
* @return
*/
public abstract Map<Short, CompoundTag> getTiles();
/**
* Get the tile at a location
*
* @param x
* @param y
* @param z
@ -307,7 +324,8 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
* Spend time now so that the chunk can be more efficiently dispatched later<br>
* - Modifications after this call will be ignored
*/
public void optimize() {}
public void optimize() {
}
@Override
public boolean equals(final Object obj) {
@ -319,9 +337,15 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
public abstract FaweChunk<T> copy(boolean shallow);
public void start() {};
public void start() {
}
public void end() {};
;
public void end() {
}
;
@Override
public abstract FaweChunk call();

View File

@ -20,28 +20,34 @@ public class FaweLimit {
public static FaweLimit MAX;
static {
MAX = new FaweLimit() {
@Override
public boolean MAX_CHANGES() {
return true;
}
@Override
public boolean MAX_BLOCKSTATES() {
return true;
}
@Override
public boolean MAX_CHECKS() {
return true;
}
@Override
public boolean MAX_ENTITIES() {
return true;
}
@Override
public boolean MAX_FAILS() {
return true;
}
@Override
public boolean MAX_ITERATIONS() {
return true;

View File

@ -42,7 +42,7 @@ public class FaweOutputStream extends DataOutputStream {
if (nbtOut == null) {
nbtOut = new NBTOutputStream(parent);
}
nbtOut.writeNamedTag(name,tag);
nbtOut.writeNamedTag(name, tag);
}
@Override

View File

@ -59,6 +59,7 @@ public abstract class FawePlayer<T> extends Metadatable {
* - com.sk89q.worldedit.entity.Player
* - String (name)
* - UUID (player UUID)
*
* @param obj
* @param <V>
* @return
@ -86,14 +87,15 @@ public abstract class FawePlayer<T> extends Metadatable {
MainUtil.handleError(e);
return Fawe.imp().wrap(actor.getName());
}
} else if (obj instanceof PlayerWrapper){
} else if (obj instanceof PlayerWrapper) {
return wrap(((PlayerWrapper) obj).getParent());
} else {
try {
Field fieldPlayer = actor.getClass().getDeclaredField("player");
fieldPlayer.setAccessible(true);
return wrap(fieldPlayer.get(actor));
} catch (Throwable ignore) {}
} catch (Throwable ignore) {
}
}
}
if (obj instanceof Actor) {
@ -275,7 +277,8 @@ public abstract class FawePlayer<T> extends Metadatable {
if (session.getClipboard() != null) {
return;
}
} catch (EmptyClipboardException e) {}
} catch (EmptyClipboardException e) {
}
if (player != null && session != null) {
WorldData worldData = player.getWorld().getWorldData();
Clipboard clip = doc.toClipboard();
@ -295,6 +298,7 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Get the current World
*
* @return
*/
public World getWorld() {
@ -313,6 +317,7 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Load all the undo EditSession's from disk for a world <br>
* - Usually already called when necessary
*
* @param world
*/
public void loadSessionsFromDisk(final World world) {
@ -324,6 +329,7 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Send a title
*
* @param head
* @param sub
*/
@ -336,6 +342,7 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Get the player's limit
*
* @return
*/
public FaweLimit getLimit() {
@ -344,18 +351,21 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Get the player's name
*
* @return
*/
public abstract String getName();
/**
* Get the player's UUID
*
* @return
*/
public abstract UUID getUUID();
/**
* Check the player's permission
*
* @param perm
* @return
*/
@ -363,6 +373,7 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Set a permission (requires Vault)
*
* @param perm
* @param flag
*/
@ -370,24 +381,28 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Send a message to the player
*
* @param message
*/
public abstract void sendMessage(final String message);
/**
* Have the player execute a command
*
* @param substring
*/
public abstract void executeCommand(final String substring);
/**
* Get the player's location
*
* @return
*/
public abstract FaweLocation getLocation();
/**
* Get the WorldEdit player object
*
* @return
*/
public abstract Player toWorldEditPlayer();
@ -403,6 +418,7 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Get the player's current selection (or null)
*
* @return
*/
public Region getSelection() {
@ -415,6 +431,7 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Get the player's current LocalSession
*
* @return
*/
public LocalSession getSession() {
@ -423,6 +440,7 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Get the player's current allowed WorldEdit regions
*
* @return
*/
public RegionWrapper[] getCurrentRegions() {
@ -435,6 +453,7 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Set the player's WorldEdit selection to the following CuboidRegion
*
* @param region
*/
public void setSelection(final RegionWrapper region) {
@ -447,6 +466,7 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Set the player's WorldEdit selection
*
* @param selector
*/
public void setSelection(final RegionSelector selector) {
@ -455,6 +475,7 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Get the largest region in the player's allowed WorldEdit region
*
* @return
*/
public RegionWrapper getLargestRegion() {
@ -477,6 +498,7 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Check if the player has WorldEdit bypass enabled
*
* @return
*/
public boolean hasWorldEditBypass() {
@ -508,6 +530,7 @@ public abstract class FawePlayer<T> extends Metadatable {
/**
* Get the tracked EditSession(s) for this player<br>
* - Queued or autoqueued EditSessions are considered tracked
*
* @param requiredStage
* @return
*/

View File

@ -108,6 +108,7 @@ public abstract class FaweQueue implements HasFaweQueue {
* Add a progress task<br>
* - Progress type
* - Amount of type
*
* @param progressTask
*/
public void setProgressTracker(RunnableVal2<ProgressType, Integer> progressTask) {
@ -150,7 +151,8 @@ public abstract class FaweQueue implements HasFaweQueue {
return changeTask;
}
public void optimize() {}
public void optimize() {
}
public int setBlocks(CuboidRegion cuboid, final int id, final int data) {
RegionWrapper current = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
@ -295,9 +297,11 @@ public abstract class FaweQueue implements HasFaweQueue {
public abstract boolean regenerateChunk(int x, int z, @Nullable BaseBiome biome, @Nullable Long seed);
public void startSet(boolean parallel) {}
public void startSet(boolean parallel) {
}
public void endSet(boolean parallel) {}
public void endSet(boolean parallel) {
}
public int cancel() {
clear();
@ -321,6 +325,7 @@ public abstract class FaweQueue implements HasFaweQueue {
/**
* Gets the FaweChunk and sets the requested blocks
*
* @return
*/
public abstract boolean next(int amount, long time);

View File

@ -1,7 +1,7 @@
package com.boydti.fawe.object;
public class IntegerTrio {
public int x,y,z;
public int x, y, z;
public IntegerTrio(int x, int y, int z) {
this.x = x;
@ -15,7 +15,8 @@ public class IntegerTrio {
this.z = node.z;
}
public IntegerTrio() {}
public IntegerTrio() {
}
public final void set(int x, int y, int z) {
this.x = x;

View File

@ -8,6 +8,7 @@ public class Metadatable {
/**
* Set some session only metadata for the player
*
* @param key
* @param value
* @return previous value
@ -22,6 +23,7 @@ public class Metadatable {
/**
* Get the metadata for a key.
*
* @param <V>
* @param key
* @return
@ -35,6 +37,7 @@ public class Metadatable {
/**
* Get the metadata for a specific key (or return the default provided)
*
* @param key
* @param def
* @param <V>
@ -52,6 +55,7 @@ public class Metadatable {
* Delete the metadata for a key.
* - metadata is session only
* - deleting other plugin's metadata may cause issues
*
* @param key
*/
public <V> V deleteMeta(String key) {

View File

@ -3,7 +3,8 @@ package com.boydti.fawe.object;
public abstract class RunnableVal<T> implements Runnable {
public T value;
public RunnableVal() {}
public RunnableVal() {
}
public RunnableVal(T value) {
this.value = value;

View File

@ -4,7 +4,8 @@ public abstract class RunnableVal2<T, U> implements Runnable {
public T value1;
public U value2;
public RunnableVal2() {}
public RunnableVal2() {
}
public RunnableVal2(T value1, U value2) {
this.value1 = value1;

View File

@ -5,7 +5,8 @@ public abstract class RunnableVal3<T, U, V> implements Runnable {
public U value2;
public V value3;
public RunnableVal3() {}
public RunnableVal3() {
}
public RunnableVal3(T value1, U value2, V value3) {
this.value1 = value1;

View File

@ -6,7 +6,8 @@ public abstract class RunnableVal4<T, U, V, W> implements Runnable {
public V value3;
public W value4;
public RunnableVal4() {}
public RunnableVal4() {
}
public RunnableVal4(T value1, U value2, V value3, W value4) {
this.value1 = value1;

View File

@ -82,7 +82,8 @@ public class ScatterBrush implements Brush {
finish(editSession, placed, position, pattern, size);
}
public void finish(EditSession editSession, LocalBlockVectorSet placed, Vector pos, Pattern pattern, double size) {}
public void finish(EditSession editSession, LocalBlockVectorSet placed, Vector pos, Pattern pattern, double size) {
}
public boolean canApply(EditSession editSession, Vector pos) {
return mask.test(pos);

View File

@ -17,7 +17,7 @@ import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.util.Location;
import java.util.List;
public class ScatterCommand extends ScatterBrush{
public class ScatterCommand extends ScatterBrush {
private final String command;
public ScatterCommand(int count, int distance, String command) {

View File

@ -166,8 +166,12 @@ public class SplineBrush implements Brush {
}
// Calc full 3x3 covariance matrix, excluding symmetries:
double xx = 0.0; double xy = 0.0; double xz = 0.0;
double yy = 0.0; double yz = 0.0; double zz = 0.0;
double xx = 0.0;
double xy = 0.0;
double xz = 0.0;
double yy = 0.0;
double yz = 0.0;
double zz = 0.0;
Vector r = new Vector();
for (Vector p : points) {
@ -182,9 +186,9 @@ public class SplineBrush implements Brush {
zz += r.getZ() * r.getZ();
}
double det_x = yy*zz - yz*yz;
double det_y = xx*zz - xz*xz;
double det_z = xx*yy - xy*xy;
double det_x = yy * zz - yz * yz;
double det_y = xx * zz - xz * xz;
double det_z = xx * yy - xy * xy;
double det_max = Math.max(Math.max(det_x, det_y), det_z);
if (det_max <= 0.0) {
@ -194,18 +198,19 @@ public class SplineBrush implements Brush {
// Pick path with best conditioning:
Vector dir;
if (det_max == det_x) {
double a = (xz*yz - xy*zz) / det_x;
double b = (xy*yz - xz*yy) / det_x;
double a = (xz * yz - xy * zz) / det_x;
double b = (xy * yz - xz * yy) / det_x;
dir = new Vector(1.0, a, b);
} else if (det_max == det_y) {
double a = (yz*xz - xy*zz) / det_y;
double b = (xy*xz - yz*xx) / det_y;
double a = (yz * xz - xy * zz) / det_y;
double b = (xy * xz - yz * xx) / det_y;
dir = new Vector(a, 1.0, b);
} else {
double a = (yz*xy - xz*yy) / det_z;
double b = (xz*xy - yz*xx) / det_z;
double a = (yz * xy - xz * yy) / det_z;
double b = (xz * xy - yz * xx) / det_z;
dir = new Vector(a, b, 1.0);
};
}
;
return dir.normalize();
}
}

View File

@ -15,7 +15,7 @@ import java.util.ArrayList;
import java.util.List;
public class SurfaceSpline implements Brush {
final double tension, bias,continuity, quality;
final double tension, bias, continuity, quality;
public SurfaceSpline(final double tension, final double bias, final double continuity, final double quality) {
this.tension = tension;

View File

@ -1,8 +1,8 @@
package com.boydti.fawe.object.brush;
public enum TargetMode {
TARGET_BLOCK_RANGE,
FOWARD_POINT_PITCH,
TARGET_POINT_HEIGHT,
TARGET_FACE_RANGE,
TARGET_BLOCK_RANGE,
FOWARD_POINT_PITCH,
TARGET_POINT_HEIGHT,
TARGET_FACE_RANGE,
}

View File

@ -6,7 +6,7 @@ public class ArrayHeightMap extends ScalableHeightMap {
// The height map width/length
private final int width, length;
// The size to width/length ratio
private double rx,rz;
private double rx, rz;
public ArrayHeightMap(byte[][] height) {
setSize(5);

View File

@ -16,6 +16,7 @@ public class AverageHeightMapFilter {
this.maxY = maxY;
this.buffer = new int[inData.length];
}
public int[] filter(int iterations) {
for (int j = 0; j < iterations; j++) {
int a = -width;

View File

@ -157,6 +157,6 @@ public interface HeightMap {
}
}
}
return new int[][] {oldData, newData};
return new int[][]{oldData, newData};
}
}

View File

@ -14,7 +14,7 @@ import java.io.InputStream;
import java.util.HashSet;
import javax.imageio.ImageIO;
public class ScalableHeightMap implements com.boydti.fawe.object.brush.heightmap.HeightMap{
public class ScalableHeightMap implements com.boydti.fawe.object.brush.heightmap.HeightMap {
public int size2;
public int size;
@ -97,8 +97,8 @@ public class ScalableHeightMap implements com.boydti.fawe.object.brush.heightmap
int length = heightFile.getHeight();
Raster data = heightFile.getData();
byte[][] array = new byte[width][length];
double third = 1/3.0;
double alphaInverse = 1/255.0;
double third = 1 / 3.0;
double alphaInverse = 1 / 255.0;
for (int x = 0; x < width; x++) {
for (int z = 0; z < length; z++) {
int pixel = heightFile.getRGB(x, z);

View File

@ -11,6 +11,7 @@ public class MutableBiomeChange implements Change {
private MutableBlockVector2D mutable = new MutableBlockVector2D();
private BaseBiome from;
private BaseBiome to;
public MutableBiomeChange() {
this.from = new BaseBiome(0);
this.to = new BaseBiome(0);

View File

@ -30,7 +30,8 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet {
*
* @return a block bag, which may be null if none is used
*/
public @Nullable
public
@Nullable
BlockBag getBlockBag() {
return blockBag;
}
@ -79,7 +80,8 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet {
if (combinedFrom != 0) {
try {
blockBag.storeDroppedBlock(FaweCache.getId(combinedFrom), FaweCache.getData(combinedFrom));
} catch (BlockBagException ignored) {}
} catch (BlockBagException ignored) {
}
}
}
super.add(x, y, z, combinedFrom, combinedTo);

View File

@ -127,16 +127,25 @@ public abstract class FaweChangeSet implements ChangeSet {
}
public abstract void addTileCreate(CompoundTag tag);
public abstract void addTileRemove(CompoundTag tag);
public abstract void addEntityRemove(CompoundTag tag);
public abstract void addEntityCreate(CompoundTag tag);
public abstract void addBiomeChange(int x, int z, BaseBiome from, BaseBiome to);
public Iterator<Change> getIterator(BlockBag blockBag, int mode, boolean redo) {
return getIterator(redo);
}
public abstract Iterator<Change> getIterator(boolean redo);
public void delete() {};
public void delete() {
}
;
public EditSession toEditSession(FawePlayer player) {
return toEditSession(player, null);

View File

@ -70,14 +70,19 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
public interface FaweStreamPositionDelegate {
void write(OutputStream out, int x, int y, int z) throws IOException;
int readX(FaweInputStream in) throws IOException;
int readY(FaweInputStream in) throws IOException;
int readZ(FaweInputStream in) throws IOException;
}
public interface FaweStreamIdDelegate {
void writeChange(OutputStream out, int from, int to) throws IOException;
void readCombined(FaweInputStream in, MutableBlockChange change, boolean dir) throws IOException;
void readCombined(FaweInputStream in, MutableFullBlockChange change, boolean dir) throws IOException;
}
@ -141,7 +146,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
}
if (mode == 1 || mode == 4) { // small
posDel = new FaweStreamPositionDelegate() {
int lx,ly,lz;
int lx, ly, lz;
@Override
public void write(OutputStream out, int x, int y, int z) throws IOException {
int rx = -lx + (lx = x);
@ -180,7 +186,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
} else {
posDel = new FaweStreamPositionDelegate() {
byte[] buffer = new byte[5];
int lx,ly,lz;
int lx, ly, lz;
@Override
public void write(OutputStream stream, int x, int y, int z) throws IOException {
int rx = -lx + (lx = x);
@ -268,17 +275,27 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
}
public abstract OutputStream getBlockOS(int x, int y, int z) throws IOException;
public abstract OutputStream getBiomeOS() throws IOException;
public abstract NBTOutputStream getEntityCreateOS() throws IOException;
public abstract NBTOutputStream getEntityRemoveOS() throws IOException;
public abstract NBTOutputStream getTileCreateOS() throws IOException;
public abstract NBTOutputStream getTileRemoveOS() throws IOException;
public abstract FaweInputStream getBlockIS() throws IOException;
public abstract FaweInputStream getBiomeIS() throws IOException;
public abstract NBTInputStream getEntityCreateIS() throws IOException;
public abstract NBTInputStream getEntityRemoveIS() throws IOException;
public abstract NBTInputStream getTileCreateIS() throws IOException;
public abstract NBTInputStream getTileRemoveIS() throws IOException;
private int blockSize;
@ -310,8 +327,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
//x
posDel.write(stream, x - originX, y, z - originZ);
idDel.writeChange(stream, combinedFrom, combinedTo);
}
catch (Throwable e) {
} catch (Throwable e) {
MainUtil.handleError(e);
}
}
@ -331,8 +347,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
os.write((byte) (z));
os.write(from.getId());
os.write(to.getId());
}
catch (Throwable e) {
} catch (Throwable e) {
MainUtil.handleError(e);
}
}
@ -397,6 +412,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
final MutableBlockChange change = new MutableBlockChange(0, 0, 0, (short) 0, (byte) 0);
return new Iterator<MutableBlockChange>() {
private MutableBlockChange last = read();
public MutableBlockChange read() {
try {
change.x = posDel.readX(is) + originX;
@ -447,6 +463,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
final MutableBiomeChange change = new MutableBiomeChange();
return new Iterator<MutableBiomeChange>() {
private MutableBiomeChange last = new MutableBiomeChange();
public MutableBiomeChange read() {
try {
int int1 = is.read();
@ -513,6 +530,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
final MutableFullBlockChange change = new MutableFullBlockChange(blockBag, inventory, dir);
return new Iterator<MutableFullBlockChange>() {
private MutableFullBlockChange last = read();
public MutableFullBlockChange read() {
try {
change.x = posDel.readX(is) + originX;
@ -569,7 +587,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
CompoundTag tag = (CompoundTag) is.readTag();
change.tag = tag;
return change;
} catch (Exception ignoreOEF) {}
} catch (Exception ignoreOEF) {
}
try {
is.close();
} catch (IOException e) {
@ -618,7 +637,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
CompoundTag tag = (CompoundTag) is.readTag();
change.tag = tag;
return change;
} catch (Exception ignoreOEF) {}
} catch (Exception ignoreOEF) {
}
try {
is.close();
} catch (IOException e) {

View File

@ -37,7 +37,6 @@ import java.util.UUID;
* A clipboard with disk backed storage. (lower memory + loads on crash)
* - Uses an auto closable RandomAccessFile for getting / setting id / data
* - I don't know how to reduce nbt / entities to O(2) complexity, so it is stored in memory.
*
*/
public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
@ -201,7 +200,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
}
private void closeDirectBuffer(ByteBuffer cb) {
if (cb==null || !cb.isDirect()) return;
if (cb == null || !cb.isDirect()) return;
// we could use this type cast and call functions without reflection code,
// but static import from sun.* package is risky for non-SUN virtual machine.
@ -212,7 +211,8 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
Method clean = Class.forName("sun.misc.Cleaner").getMethod("clean");
clean.setAccessible(true);
clean.invoke(cleaner.invoke(cb));
} catch(Exception ex) { }
} catch (Exception ex) {
}
cb = null;
}

View File

@ -21,7 +21,8 @@ public class EmptyClipboard implements Clipboard {
public static final EmptyClipboard INSTANCE = new EmptyClipboard();
private EmptyClipboard() {}
private EmptyClipboard() {
}
@Override
public Region getRegion() {
@ -39,7 +40,8 @@ public class EmptyClipboard implements Clipboard {
}
@Override
public void setOrigin(Vector origin) {}
public void setOrigin(Vector origin) {
}
@Override
public Vector getMinimumPoint() {

View File

@ -38,7 +38,8 @@ public abstract class FaweClipboard {
public abstract boolean remove(ClipboardEntity clipboardEntity);
public void setOrigin(Vector offset) {} // Do nothing
public void setOrigin(Vector offset) {
} // Do nothing
public abstract void setDimensions(Vector dimensions);
@ -46,6 +47,7 @@ public abstract class FaweClipboard {
/**
* The locations provided are relative to the clipboard min
*
* @param task
* @param air
*/
@ -58,6 +60,7 @@ public abstract class FaweClipboard {
public void streamIds(final NBTStreamer.ByteReader task) {
forEach(new BlockReader() {
private int index = 0;
@Override
public void run(int x, int y, int z, BaseBlock block) {
task.run(index++, block.getId());
@ -68,6 +71,7 @@ public abstract class FaweClipboard {
public void streamDatas(final NBTStreamer.ByteReader task) {
forEach(new BlockReader() {
private int index = 0;
@Override
public void run(int x, int y, int z, BaseBlock block) {
task.run(index++, block.getData());
@ -79,6 +83,7 @@ public abstract class FaweClipboard {
final List<CompoundTag> tiles = new ArrayList<>();
forEach(new BlockReader() {
private int index = 0;
@Override
public void run(int x, int y, int z, BaseBlock block) {
CompoundTag tag = block.getNbtData();
@ -94,9 +99,11 @@ public abstract class FaweClipboard {
return tiles;
}
public void close() {}
public void close() {
}
public void flush() {}
public void flush() {
}
/**
* Stores entity data.
@ -104,8 +111,8 @@ public abstract class FaweClipboard {
public class ClipboardEntity implements Entity {
private final BaseEntity entity;
private final Extent world;
private final double x,y,z;
private final float yaw,pitch;
private final double x, y, z;
private final float yaw, pitch;
public ClipboardEntity(Extent world, double x, double y, double z, float yaw, float pitch, BaseEntity entity) {
checkNotNull(entity);

View File

@ -11,6 +11,7 @@ import java.util.Set;
public interface IClipboardFormat {
/**
* Returns the name of this format.
*
* @return The name of the format
*/
String getName();
@ -43,6 +44,7 @@ public interface IClipboardFormat {
/**
* Get the default extension
*
* @return
*/
String getExtension();

View File

@ -1,12 +1,12 @@
package com.boydti.fawe.object.clipboard;
import com.boydti.fawe.object.PseudoRandom;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.registry.WorldData;
import com.boydti.fawe.object.PseudoRandom;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.registry.WorldData;
public class MultiClipboardHolder extends ClipboardHolder{
public class MultiClipboardHolder extends ClipboardHolder {
private final ClipboardHolder[] holders;
private ClipboardHolder holder;
@ -18,7 +18,6 @@ public class MultiClipboardHolder extends ClipboardHolder{
}
@Override
public Clipboard getClipboard() {
holder = holders[PseudoRandom.random.nextInt(holders.length)];

View File

@ -36,8 +36,7 @@ public class ResizableClipboardBuilder extends MemoryOptimizedHistory {
maxX = x;
}
minX = x;
}
else if (x > maxX) {
} else if (x > maxX) {
maxX = x;
}
if (y < minY) {
@ -45,8 +44,7 @@ public class ResizableClipboardBuilder extends MemoryOptimizedHistory {
maxY = y;
}
minY = y;
}
else if (y > maxY) {
} else if (y > maxY) {
maxY = y;
}
if (z < minZ) {
@ -54,8 +52,7 @@ public class ResizableClipboardBuilder extends MemoryOptimizedHistory {
maxZ = z;
}
minZ = z;
}
else if (z > maxZ) {
} else if (z > maxZ) {
maxZ = z;
}
}

View File

@ -19,7 +19,7 @@ import java.util.Map;
public class WorldCopyClipboard extends ReadOnlyClipboard {
public final int mx,my,mz;
public final int mx, my, mz;
public final EditSession editSession;
public WorldCopyClipboard(EditSession editSession, Region region) {

View File

@ -1,8 +1,6 @@
package com.boydti.fawe.object.clipboard;
import com.boydti.fawe.object.RunnableVal2;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.regions.Region;

View File

@ -152,7 +152,6 @@ public class BlockVectorSet extends AbstractCollection<Vector> implements Set<Ve
}
@Override
public boolean remove(Object o) {
if (o instanceof Vector) {
@ -205,7 +204,6 @@ public class BlockVectorSet extends AbstractCollection<Vector> implements Set<Ve
}
@Override
public void clear() {
localSets.clear();

View File

@ -9,7 +9,8 @@ public abstract class IterableThreadLocal<T> extends ThreadLocal<T> implements I
private ThreadLocal<T> flag;
private ConcurrentLinkedDeque<T> allValues = new ConcurrentLinkedDeque<T>();
public IterableThreadLocal() { }
public IterableThreadLocal() {
}
@Override
protected final T initialValue() {
@ -25,7 +26,9 @@ public abstract class IterableThreadLocal<T> extends ThreadLocal<T> implements I
return getAll().iterator();
}
public T init() { return null; }
public T init() {
return null;
}
public final Collection<T> getAll() {
return Collections.unmodifiableCollection(allValues);

View File

@ -112,14 +112,17 @@ public class LocalBlockVector2DSet implements Set<Vector2D> {
return new Iterator<Vector2D>() {
int index = set.nextSetBit(0);
int previous = -1;
@Override
public void remove() {
set.clear(previous);
}
@Override
public boolean hasNext() {
return index != -1;
}
@Override
public Vector2D next() {
if (index != -1) {

View File

@ -70,7 +70,7 @@ public class LocalBlockVectorSet implements Set<Vector> {
while ((index = set.nextSetBit(index + 1)) != -1) {
int b1 = (index & 0xFF);
int b2 = ((byte) (index >> 8)) & 0x7F;
int b3 = ((byte)(index >> 15)) & 0xFF;
int b3 = ((byte) (index >> 15)) & 0xFF;
int b4 = ((byte) (index >> 23)) & 0xFF;
if (Math.abs((offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21)) - x) <= radius && Math.abs((offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21)) - z) <= radius && Math.abs((b1) - y) <= radius) {
return true;
@ -112,7 +112,7 @@ public class LocalBlockVectorSet implements Set<Vector> {
if (index != -1) {
int b1 = (index & 0xFF);
int b2 = ((byte) (index >> 8)) & 0x7F;
int b3 = ((byte)(index >> 15)) & 0xFF;
int b3 = ((byte) (index >> 15)) & 0xFF;
int b4 = ((byte) (index >> 23)) & 0xFF;
int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21);
int y = b1;
@ -128,20 +128,23 @@ public class LocalBlockVectorSet implements Set<Vector> {
int index = set.nextSetBit(0);
int previous = -1;
MutableBlockVector mutable = new MutableBlockVector(0, 0, 0);
@Override
public void remove() {
set.clear(previous);
}
@Override
public boolean hasNext() {
return index != -1;
}
@Override
public BlockVector next() {
if (index != -1) {
int b1 = (index & 0xFF);
int b2 = ((byte) (index >> 8)) & 0x7F;
int b3 = ((byte)(index >> 15)) & 0xFF;
int b3 = ((byte) (index >> 15)) & 0xFF;
int b4 = ((byte) (index >> 23)) & 0xFF;
mutable.mutX(offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21));
mutable.mutY(b1);
@ -171,7 +174,7 @@ public class LocalBlockVectorSet implements Set<Vector> {
index = set.nextSetBit(index);
int b1 = (index & 0xFF);
int b2 = ((byte) (index >> 8)) & 0x7F;
int b3 = ((byte)(index >> 15)) & 0xFF;
int b3 = ((byte) (index >> 15)) & 0xFF;
int b4 = ((byte) (index >> 23)) & 0xFF;
int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21);
int y = b1;
@ -282,7 +285,7 @@ public class LocalBlockVectorSet implements Set<Vector> {
index = set.nextSetBit(index + 1);
int b1 = (index & 0xFF);
int b2 = ((byte) (index >> 8)) & 0x7F;
int b3 = ((byte)(index >> 15)) & 0xFF;
int b3 = ((byte) (index >> 15)) & 0xFF;
int b4 = ((byte) (index >> 23)) & 0xFF;
mVec.mutX(offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21));
mVec.mutY(b1);
@ -312,7 +315,7 @@ public class LocalBlockVectorSet implements Set<Vector> {
index = set.nextSetBit(index + 1);
int b1 = (index & 0xFF);
int b2 = ((byte) (index >> 8)) & 0x7F;
int b3 = ((byte)(index >> 15)) & 0xFF;
int b3 = ((byte) (index >> 15)) & 0xFF;
int b4 = ((byte) (index >> 23)) & 0xFF;
int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21);
int y = b1;

View File

@ -26,7 +26,7 @@ public class PrimitiveList<T> extends AbstractList<T> {
Class<T> boxed;
if (type.isPrimitive()) {
this.primitive = type;
boxed = (Class<T>) Array.get(Array.newInstance(primitive,1),0).getClass();
boxed = (Class<T>) Array.get(Array.newInstance(primitive, 1), 0).getClass();
} else {
this.primitive = (Class<?>) type.getField("TYPE").get(null);
boxed = type;

View File

@ -1,4 +1,5 @@
package com.boydti.fawe.object.collection;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
@ -30,9 +31,9 @@ import java.util.concurrent.locks.ReentrantLock;
* <p/>
* This implementation is thread-safe and usable in concurrent environments.
*
* @since 0.8
* @see SoftReference
* @see <a href="http://shiro.apache.org">Apache Shiro</a>
* @since 0.8
*/
public class SoftHashMap<K, V> implements Map<K, V> {

View File

@ -18,15 +18,15 @@ public class SummedAreaTable {
this.length = buffer.length / width;
this.radius = radius;
this.area = MathMan.sqr(radius * 2 + 1);
this.areaInverse = 1f/area;
this.areaInverse = 1f / area;
}
public void processSummedAreaTable() {
int rowSize = source.length / width;
int colSize = width;
int index = 0;
for (int i=0; i<rowSize; i++) {
for (int j=0; j<colSize; j++, index++) {
for (int i = 0; i < rowSize; i++) {
for (int j = 0; j < colSize; j++, index++) {
summed[index] = getVal(i, j, index, source[index]);
}
}
@ -79,11 +79,10 @@ public class SummedAreaTable {
return curr + leftSum;
}
/* left-most column */
else if (row !=0 && col == 0) {
else if (row != 0 && col == 0) {
topSum = summed[index - width];
return curr + topSum;
}
else {
} else {
leftSum = summed[index - 1];
topSum = summed[index - width];
topLeftSum = summed[index - width - 1]; // overlap between leftSum and topSum

View File

@ -43,6 +43,7 @@ public class FaweException extends RuntimeException {
/**
* Faster exception throwing if you don't fill the stacktrace
*
* @return
*/
@Override

View File

@ -10,7 +10,7 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.world.biome.BaseBiome;
public class BlockTranslateExtent extends AbstractDelegateExtent {
private final int dx,dy,dz;
private final int dx, dy, dz;
private MutableBlockVector mutable = new MutableBlockVector();
public BlockTranslateExtent(Extent extent, int dx, int dy, int dz) {

View File

@ -4,8 +4,12 @@ import com.sk89q.worldedit.extent.Extent;
public interface LightingExtent extends Extent {
int getLight(int x, int y, int z);
int getSkyLight(int x, int y, int z);
int getBlockLight(int x, int y, int z);
int getOpacity(int x, int y, int z);
int getBrightness(int x, int y, int z);
}

View File

@ -28,6 +28,7 @@ public class MultiTransform extends RandomTransform {
super.add(extent, chance);
this.extents = getExtents().toArray(new ResettableExtent[getExtents().size()]);
}
@Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
boolean result = false;

View File

@ -59,7 +59,7 @@ public class RandomTransform extends SelectTransform {
/**
* Add a pattern to the weight list of patterns.
*
* <p>
* <p>The probability for the pattern added is chance / max where max is
* the sum of the probabilities of all added patterns.</p>
*

View File

@ -17,7 +17,7 @@ public class ScaleTransform extends ResettableExtent {
private transient int maxy;
private transient Vector min;
private final double dx,dy,dz;
private final double dx, dy, dz;
public ScaleTransform(Extent parent, double dx, double dy, double dz) {

View File

@ -6,7 +6,8 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.*;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BaseBiome;
@ -18,11 +19,13 @@ public abstract class SelectTransform extends ResettableExtent {
}
public abstract AbstractDelegateExtent getExtent(int x, int y, int z);
public abstract AbstractDelegateExtent getExtent(int x, int z);
public Extent getExtent(Vector pos) {
return getExtent(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
}
public Extent getExtent(Vector2D pos) {
return getExtent(pos.getBlockX(), pos.getBlockZ());
}

View File

@ -6,7 +6,7 @@ import com.sk89q.worldedit.extent.Extent;
import java.util.Arrays;
import java.util.Collection;
public class SingleRegionExtent extends FaweRegionExtent{
public class SingleRegionExtent extends FaweRegionExtent {
private final RegionWrapper region;

View File

@ -39,6 +39,7 @@ public class SourceMaskExtent extends TemporalExtent {
checkNotNull(mask);
this.mask = mask;
}
@Override
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
set(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);

View File

@ -11,10 +11,10 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.registry.BundledBlockData;
public class TemporalExtent extends AbstractDelegateExtent {
private int x,y,z = Integer.MAX_VALUE;
private int x, y, z = Integer.MAX_VALUE;
private BaseBlock block = EditSession.nullBlock;
private int bx,bz = Integer.MAX_VALUE;
private int bx, bz = Integer.MAX_VALUE;
private BaseBiome biome = EditSession.nullBiome;
/**

View File

@ -9,15 +9,14 @@ import java.util.concurrent.ConcurrentLinkedDeque;
* BufferedOutputStream that asynchronously flushes to disk, so callers don't
* have to wait until the flush happens. Buffers are put into a queue that is
* written asynchronously to disk once it is really available.
*
* <p>
* This class is thread-safe.
*
* <p>
* The error handling (as all stream ops are done asynchronously) is done during
* write and close. Exceptions on the asynchronous thread will be thrown to the
* caller either while writing or closing this stream.
*
* @author thomas.jungblut
*
*/
public final class AsyncBufferedOutputStream extends FilterOutputStream {
@ -62,7 +61,7 @@ public final class AsyncBufferedOutputStream extends FilterOutputStream {
* Writes the specified byte to this buffered output stream.
*
* @param b the byte to be written.
* @exception IOException if an I/O error occurs.
* @throws IOException if an I/O error occurs.
*/
@Override
public synchronized void write(int b) throws IOException {
@ -83,7 +82,7 @@ public final class AsyncBufferedOutputStream extends FilterOutputStream {
* @param b the data.
* @param off the start offset in the data.
* @param len the number of bytes to write.
* @exception IOException if an I/O error occurs.
* @throws IOException if an I/O error occurs.
*/
@Override
public synchronized void write(byte[] b, int off, int len) throws IOException {
@ -107,7 +106,7 @@ public final class AsyncBufferedOutputStream extends FilterOutputStream {
* Flushes this buffered output stream. It will enforce that the current
* buffer will be queue for asynchronous flushing no matter what size it has.
*
* @exception IOException if an I/O error occurs.
* @throws IOException if an I/O error occurs.
*/
@Override
public synchronized void flush() throws IOException {

View File

@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -18,7 +18,10 @@
package com.boydti.fawe.object.io;
import java.io.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Arrays;
@ -35,8 +38,7 @@ import java.util.Arrays;
* Author : Avinash Lakshman ( alakshman@facebook.com) & Prashant Malik ( pmalik@facebook.com )
*/
public class BufferedRandomAccessFile extends RandomAccessFile
{
public class BufferedRandomAccessFile extends RandomAccessFile {
static final int LogBuffSz_ = 16; // 64K buffer
public static final int BuffSz_ = (1 << LogBuffSz_);
static final long BuffMask_ = ~(((long) BuffSz_) - 1L);
@ -112,14 +114,12 @@ public class BufferedRandomAccessFile extends RandomAccessFile
* in mode <code>mode</code>, which should be "r" for reading only, or
* "rw" for reading and writing.
*/
public BufferedRandomAccessFile(File file, String mode) throws IOException
{
public BufferedRandomAccessFile(File file, String mode) throws IOException {
super(file, mode);
this.init(0);
}
public BufferedRandomAccessFile(File file, String mode, int size) throws IOException
{
public BufferedRandomAccessFile(File file, String mode, int size) throws IOException {
super(file, mode);
this.init(size);
}
@ -129,20 +129,17 @@ public class BufferedRandomAccessFile extends RandomAccessFile
* <code>name</code> in mode <code>mode</code>, which should be "r" for
* reading only, or "rw" for reading and writing.
*/
public BufferedRandomAccessFile(String name, String mode) throws IOException
{
public BufferedRandomAccessFile(String name, String mode) throws IOException {
super(name, mode);
this.init(0);
}
public BufferedRandomAccessFile(String name, String mode, int size) throws FileNotFoundException
{
public BufferedRandomAccessFile(String name, String mode, int size) throws FileNotFoundException {
super(name, mode);
this.init(size);
}
public BufferedRandomAccessFile(File file, String mode, byte[] buf) throws FileNotFoundException
{
public BufferedRandomAccessFile(File file, String mode, byte[] buf) throws FileNotFoundException {
super(file, mode);
this.dirty_ = this.closed_ = false;
this.lo_ = this.curr_ = this.hi_ = 0;
@ -152,8 +149,7 @@ public class BufferedRandomAccessFile extends RandomAccessFile
this.diskPos_ = 0L;
}
private void init(int size)
{
private void init(int size) {
this.dirty_ = this.closed_ = false;
this.lo_ = this.curr_ = this.hi_ = 0;
this.buff_ = (size > BuffSz_) ? new byte[size] : new byte[BuffSz_];
@ -163,8 +159,7 @@ public class BufferedRandomAccessFile extends RandomAccessFile
}
@Override
public void close() throws IOException
{
public void close() throws IOException {
this.flush();
this.closed_ = true;
super.close();
@ -174,16 +169,13 @@ public class BufferedRandomAccessFile extends RandomAccessFile
* Flush any bytes in the file's buffer that have not yet been written to
* disk. If the file was created read-only, this method is a no-op.
*/
public void flush() throws IOException
{
public void flush() throws IOException {
this.flushBuffer();
}
/* Flush any dirty bytes in the buffer to disk. */
private void flushBuffer() throws IOException
{
if (this.dirty_)
{
private void flushBuffer() throws IOException {
if (this.dirty_) {
if (this.diskPos_ != this.lo_)
super.seek(this.lo_);
int len = (int) (this.curr_ - this.lo_);
@ -198,20 +190,17 @@ public class BufferedRandomAccessFile extends RandomAccessFile
* number of bytes read. If the return result is less than
* "this.buff.length", then EOF was read.
*/
private int fillBuffer() throws IOException
{
private int fillBuffer() throws IOException {
int cnt = 0;
int rem = this.buff_.length;
while (rem > 0)
{
while (rem > 0) {
int n = super.read(this.buff_, cnt, rem);
if (n < 0)
break;
cnt += n;
rem -= n;
}
if ( (cnt < 0) && (this.hitEOF_ = (cnt < this.buff_.length)) )
{
if ((cnt < 0) && (this.hitEOF_ = (cnt < this.buff_.length))) {
// make sure buffer that wasn't read is initialized with -1
Arrays.fill(this.buff_, cnt, this.buff_.length, (byte) 0xff);
}
@ -229,27 +218,21 @@ public class BufferedRandomAccessFile extends RandomAccessFile
* opened in read-only mode.
*/
@Override
public void seek(long pos) throws IOException
{
if (pos >= this.hi_ || pos < this.lo_)
{
public void seek(long pos) throws IOException {
if (pos >= this.hi_ || pos < this.lo_) {
// seeking outside of current buffer -- flush and read
this.flushBuffer();
this.lo_ = pos & BuffMask_; // start at BuffSz boundary
this.maxHi_ = this.lo_ + (long) this.buff_.length;
if (this.diskPos_ != this.lo_)
{
if (this.diskPos_ != this.lo_) {
super.seek(this.lo_);
this.diskPos_ = this.lo_;
}
int n = this.fillBuffer();
this.hi_ = this.lo_ + (long) n;
}
else
{
} else {
// seeking inside current buffer -- no read required
if (pos < this.curr_)
{
if (pos < this.curr_) {
// if seeking backwards, we must flush to maintain V4
this.flushBuffer();
}
@ -263,16 +246,13 @@ public class BufferedRandomAccessFile extends RandomAccessFile
* @param pos
* @throws IOException
*/
public void seekUnsafe(long pos) throws IOException
{
if (pos >= this.hi_ || pos < this.lo_)
{
public void seekUnsafe(long pos) throws IOException {
if (pos >= this.hi_ || pos < this.lo_) {
// seeking outside of current buffer -- flush and read
this.flushBuffer();
this.lo_ = pos & BuffMask_; // start at BuffSz boundary
this.maxHi_ = this.lo_ + (long) this.buff_.length;
if (this.diskPos_ != this.lo_)
{
if (this.diskPos_ != this.lo_) {
super.seek(this.lo_);
this.diskPos_ = this.lo_;
}
@ -283,22 +263,18 @@ public class BufferedRandomAccessFile extends RandomAccessFile
}
@Override
public long getFilePointer()
{
public long getFilePointer() {
return this.curr_;
}
@Override
public long length() throws IOException
{
public long length() throws IOException {
return Math.max(this.curr_, super.length());
}
@Override
public int read() throws IOException
{
if (this.curr_ >= this.hi_)
{
public int read() throws IOException {
if (this.curr_ >= this.hi_) {
// test for EOF
// if (this.hi < this.maxHi) return -1;
if (this.hitEOF_)
@ -315,8 +291,7 @@ public class BufferedRandomAccessFile extends RandomAccessFile
}
public byte read1() throws IOException {
if (this.curr_ >= this.hi_)
{
if (this.curr_ >= this.hi_) {
// test for EOF
// if (this.hi < this.maxHi) return -1;
if (this.hitEOF_)
@ -333,16 +308,13 @@ public class BufferedRandomAccessFile extends RandomAccessFile
}
@Override
public int read(byte[] b) throws IOException
{
public int read(byte[] b) throws IOException {
return this.read(b, 0, b.length);
}
@Override
public int read(byte[] b, int off, int len) throws IOException
{
if (this.curr_ >= this.hi_)
{
public int read(byte[] b, int off, int len) throws IOException {
if (this.curr_ >= this.hi_) {
// test for EOF
// if (this.hi < this.maxHi) return -1;
if (this.hitEOF_)
@ -361,8 +333,7 @@ public class BufferedRandomAccessFile extends RandomAccessFile
}
public byte readCurrent() throws IOException {
if (this.curr_ >= this.hi_)
{
if (this.curr_ >= this.hi_) {
// test for EOF
// if (this.hi < this.maxHi) return -1;
if (this.hitEOF_)
@ -378,19 +349,14 @@ public class BufferedRandomAccessFile extends RandomAccessFile
}
public void writeCurrent(byte b) throws IOException {
if (this.curr_ >= this.hi_)
{
if (this.hitEOF_ && this.hi_ < this.maxHi_)
{
if (this.curr_ >= this.hi_) {
if (this.hitEOF_ && this.hi_ < this.maxHi_) {
// at EOF -- bump "hi"
this.hi_++;
}
else
{
} else {
// slow path -- write current buffer; read next one
this.seek(this.curr_);
if (this.curr_ == this.hi_)
{
if (this.curr_ == this.hi_) {
// appending to EOF -- bump "hi"
this.hi_++;
}
@ -400,29 +366,22 @@ public class BufferedRandomAccessFile extends RandomAccessFile
this.dirty_ = true;
}
public void writeUnsafe(int b) throws IOException
{
public void writeUnsafe(int b) throws IOException {
this.buff_[(int) (this.curr_ - this.lo_)] = (byte) b;
this.curr_++;
this.dirty_ = true;
}
@Override
public void write(int b) throws IOException
{
if (this.curr_ >= this.hi_)
{
if (this.hitEOF_ && this.hi_ < this.maxHi_)
{
public void write(int b) throws IOException {
if (this.curr_ >= this.hi_) {
if (this.hitEOF_ && this.hi_ < this.maxHi_) {
// at EOF -- bump "hi"
this.hi_++;
}
else
{
} else {
// slow path -- write current buffer; read next one
this.seek(this.curr_);
if (this.curr_ == this.hi_)
{
if (this.curr_ == this.hi_) {
// appending to EOF -- bump "hi"
this.hi_++;
}
@ -434,16 +393,13 @@ public class BufferedRandomAccessFile extends RandomAccessFile
}
@Override
public void write(byte[] b) throws IOException
{
public void write(byte[] b) throws IOException {
this.write(b, 0, b.length);
}
@Override
public void write(byte[] b, int off, int len) throws IOException
{
while (len > 0)
{
public void write(byte[] b, int off, int len) throws IOException {
while (len > 0) {
int n = this.writeAtMost(b, off, len);
off += n;
len -= n;
@ -455,21 +411,15 @@ public class BufferedRandomAccessFile extends RandomAccessFile
* Write at most "len" bytes to "b" starting at position "off", and return
* the number of bytes written.
*/
private int writeAtMost(byte[] b, int off, int len) throws IOException
{
if (this.curr_ >= this.hi_)
{
if (this.hitEOF_ && this.hi_ < this.maxHi_)
{
private int writeAtMost(byte[] b, int off, int len) throws IOException {
if (this.curr_ >= this.hi_) {
if (this.hitEOF_ && this.hi_ < this.maxHi_) {
// at EOF -- bump "hi"
this.hi_ = this.maxHi_;
}
else
{
} else {
// slow path -- write current buffer; read next one
this.seek(this.curr_);
if (this.curr_ == this.hi_)
{
if (this.curr_ == this.hi_) {
// appending to EOF -- bump "hi"
this.hi_ = this.maxHi_;
}

Some files were not shown because too many files have changed in this diff Show More