mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Upstream merges and a few code cleanups
This commit is contained in:
@ -4,18 +4,13 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FaweCommand;
|
||||
import com.boydti.fawe.object.FaweLocation;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.object.*;
|
||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -137,8 +132,8 @@ public class Rollback extends FaweCommand {
|
||||
UUID user = null;
|
||||
int radius = Integer.MAX_VALUE;
|
||||
long time = Long.MAX_VALUE;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String[] split = args[i].split(":");
|
||||
for (String arg : args) {
|
||||
String[] split = arg.split(":");
|
||||
if (split.length != 2) {
|
||||
BBC.COMMAND_SYNTAX.send(player, "/frb <info|undo> u:<uuid> r:<radius> t:<time>");
|
||||
return;
|
||||
|
@ -84,16 +84,16 @@ public abstract class IntFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
|
||||
public int getTotalCount() {
|
||||
int total = 0;
|
||||
for (int i = 0; i < count.length; i++) {
|
||||
total += Math.min(4096, this.count[i]);
|
||||
for (short value : count) {
|
||||
total += Math.min(4096, value);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int getTotalAir() {
|
||||
int total = 0;
|
||||
for (int i = 0; i < air.length; i++) {
|
||||
total += Math.min(4096, this.air[i]);
|
||||
for (short value : air) {
|
||||
total += Math.min(4096, value);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
@ -293,8 +293,7 @@ public class CorruptSchematicStreamer {
|
||||
int vx = 0, vy = 0, vz = 0;
|
||||
for (int x = 0; x < factors.size(); x++) {
|
||||
int xValue = factors.get(x);
|
||||
for (int y = 0; y < factors.size(); y++) {
|
||||
int yValue = factors.get(y);
|
||||
for (int yValue : factors) {
|
||||
long area = xValue * yValue;
|
||||
if (volume % area == 0) {
|
||||
int z = (int) (volume / area);
|
||||
|
@ -108,8 +108,8 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
out.writeNamedTagName("Sections", NBTConstants.TYPE_LIST);
|
||||
nbtOut.getOutputStream().writeByte(NBTConstants.TYPE_COMPOUND);
|
||||
int len = 0;
|
||||
for (int layer = 0; layer < ids.length; layer++) {
|
||||
if (ids[layer] != null) len++;
|
||||
for (int[] id : ids) {
|
||||
if (id != null) len++;
|
||||
}
|
||||
nbtOut.getOutputStream().writeInt(len);
|
||||
for (int layer = 0; layer < ids.length; layer++) {
|
||||
|
@ -165,8 +165,7 @@ public abstract class MCAWriter {
|
||||
pool.submit(() -> {
|
||||
try {
|
||||
int totalLength = 8192;
|
||||
for (int i = 0; i < compressed.length; i++) {
|
||||
byte[] compressedBytes = compressed[i];
|
||||
for (byte[] compressedBytes : compressed) {
|
||||
if (compressedBytes != null) {
|
||||
int blocks = ((4095 + compressedBytes.length + 5) / 4096) * 4096;
|
||||
totalLength += blocks;
|
||||
|
@ -112,8 +112,8 @@ public class WritableMCAChunk extends FaweChunk<Void> {
|
||||
out.writeNamedTag("Biomes", biomes);
|
||||
}
|
||||
int len = 0;
|
||||
for (int layer = 0; layer < hasSections.length; layer++) {
|
||||
if (hasSections[layer]) len++;
|
||||
for (boolean hasSection : hasSections) {
|
||||
if (hasSection) len++;
|
||||
}
|
||||
out.writeNamedTagName("Sections", NBTConstants.TYPE_LIST);
|
||||
nbtOut.writeByte(NBTConstants.TYPE_COMPOUND);
|
||||
|
@ -47,8 +47,8 @@ public class FaweOutputStream extends DataOutputStream {
|
||||
public void write(long[] data) throws IOException {
|
||||
this.writeVarInt(data.length);
|
||||
|
||||
for(int j = 0; j < data.length; ++j) {
|
||||
this.writeLong(data[j]);
|
||||
for (long datum : data) {
|
||||
this.writeLong(datum);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -507,8 +507,8 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
|
||||
public int getSize() {
|
||||
int count = 0;
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
count += blocks[i];
|
||||
for (int block : blocks) {
|
||||
count += block;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
@ -71,12 +71,7 @@ public class MainUtil {
|
||||
if (suggestions.getClass() != ArrayList.class) {
|
||||
suggestions = new ArrayList<>(suggestions);
|
||||
}
|
||||
Iterator<String> iter = suggestions.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (!iter.next().startsWith(prefix)) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
suggestions.removeIf(s -> !s.startsWith(prefix));
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
@ -917,11 +912,11 @@ public class MainUtil {
|
||||
if (directory.exists()) {
|
||||
File[] files = directory.listFiles();
|
||||
if (null != files) {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].isDirectory()) {
|
||||
iterateFiles(files[i], task);
|
||||
for (File file : files) {
|
||||
if (file.isDirectory()) {
|
||||
iterateFiles(file, task);
|
||||
} else {
|
||||
task.accept(files[i]);
|
||||
task.accept(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user