mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
A lot of small changes
This commit is contained in:
@ -207,8 +207,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(ChunkHolder chunk, int x, int y, int z,
|
||||
BlockStateHolder block) {
|
||||
public boolean setBlock(ChunkHolder chunk, int x, int y, int z, BlockStateHolder block) {
|
||||
return chunk.chunkSet.setBlock(x, y, z, block);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class RollbackDatabase extends AsyncNotifyQueue {
|
||||
private @Language("SQLite") String GET_EDITS_USER = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` DESC, `id` DESC";
|
||||
private @Language("SQLite") String GET_EDITS_USER_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` ASC, `id` ASC";
|
||||
private @Language("SQLite") String GET_EDITS = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` DESC, `id` DESC";
|
||||
private @Language("SQLite") String GET_EDITS_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` ASC, `id` ASC";
|
||||
private @Language("SQLite") String GET_EDITS_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` , `id` ";
|
||||
private @Language("SQLite") String GET_EDIT_USER = "SELECT * FROM `{0}edits` WHERE `player`=? AND `id`=?";
|
||||
|
||||
private @Language("SQLite") String DELETE_EDITS_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `time`>? AND `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=?";
|
||||
|
@ -15,10 +15,12 @@ import com.sk89q.jnbt.ShortTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class JSON2NBT {
|
||||
private static final Pattern INT_ARRAY_MATCHER = Pattern.compile("\\[[-+\\d|,\\s]+\\]");
|
||||
@ -40,7 +42,7 @@ public class JSON2NBT {
|
||||
public static int topTagsCount(String str) throws NBTException {
|
||||
int i = 0;
|
||||
boolean flag = false;
|
||||
Stack stack = new Stack();
|
||||
Stack<Character> stack = new Stack<>();
|
||||
|
||||
for (int j = 0; j < str.length(); ++j) {
|
||||
char c0 = str.charAt(j);
|
||||
@ -54,11 +56,11 @@ public class JSON2NBT {
|
||||
}
|
||||
} else if (!flag) {
|
||||
if (c0 != 123 && c0 != 91) {
|
||||
if (c0 == 125 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 123)) {
|
||||
if (c0 == 125 && (stack.isEmpty() || stack.pop() != 123)) {
|
||||
throw new NBTException("Unbalanced curly brackets {}: " + str);
|
||||
}
|
||||
|
||||
if (c0 == 93 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 91)) {
|
||||
if (c0 == 93 && (stack.isEmpty() || stack.pop() != 91)) {
|
||||
throw new NBTException("Unbalanced square brackets []: " + str);
|
||||
}
|
||||
} else {
|
||||
@ -66,7 +68,7 @@ public class JSON2NBT {
|
||||
++i;
|
||||
}
|
||||
|
||||
stack.push(Character.valueOf(c0));
|
||||
stack.push(c0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,7 +93,6 @@ public class JSON2NBT {
|
||||
private static JSON2NBT.Any nameValueToNBT(String key, String value) throws NBTException {
|
||||
value = value.trim();
|
||||
String s;
|
||||
boolean c0;
|
||||
char c01;
|
||||
if (value.startsWith("{")) {
|
||||
value = value.substring(1, value.length() - 1);
|
||||
@ -100,7 +101,6 @@ public class JSON2NBT {
|
||||
for (JSON2NBT$list1 = new JSON2NBT.Compound(key); value.length() > 0; value = value.substring(s.length() + 1)) {
|
||||
s = nextNameValuePair(value, true);
|
||||
if (s.length() > 0) {
|
||||
c0 = false;
|
||||
JSON2NBT$list1.tagList.add(getTagFromNameValue(s, false));
|
||||
}
|
||||
|
||||
@ -122,7 +122,6 @@ public class JSON2NBT {
|
||||
for (JSON2NBT$list = new JSON2NBT.List(key); value.length() > 0; value = value.substring(s.length() + 1)) {
|
||||
s = nextNameValuePair(value, false);
|
||||
if (s.length() > 0) {
|
||||
c0 = true;
|
||||
JSON2NBT$list.tagList.add(getTagFromNameValue(s, true));
|
||||
}
|
||||
|
||||
@ -145,7 +144,7 @@ public class JSON2NBT {
|
||||
private static JSON2NBT.Any getTagFromNameValue(String str, boolean isArray) throws NBTException {
|
||||
String s = locateName(str, isArray);
|
||||
String s1 = locateValue(str, isArray);
|
||||
return joinStrToNBT(new String[]{s, s1});
|
||||
return joinStrToNBT(s, s1);
|
||||
}
|
||||
|
||||
private static String nextNameValuePair(String str, boolean isCompound) throws NBTException {
|
||||
@ -167,7 +166,7 @@ public class JSON2NBT {
|
||||
}
|
||||
|
||||
private static String locateValueAt(String str, int index) throws NBTException {
|
||||
Stack stack = new Stack();
|
||||
Stack<Character> stack = new Stack<>();
|
||||
int i = index + 1;
|
||||
boolean flag = false;
|
||||
boolean flag1 = false;
|
||||
@ -192,11 +191,11 @@ public class JSON2NBT {
|
||||
}
|
||||
} else if (!flag) {
|
||||
if (c0 != 123 && c0 != 91) {
|
||||
if (c0 == 125 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 123)) {
|
||||
if (c0 == 125 && (stack.isEmpty() || stack.pop() != 123)) {
|
||||
throw new NBTException("Unbalanced curly brackets {}: " + str);
|
||||
}
|
||||
|
||||
if (c0 == 93 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 91)) {
|
||||
if (c0 == 93 && (stack.isEmpty() || stack.pop() != 91)) {
|
||||
throw new NBTException("Unbalanced square brackets []: " + str);
|
||||
}
|
||||
|
||||
@ -204,7 +203,7 @@ public class JSON2NBT {
|
||||
return str.substring(0, i);
|
||||
}
|
||||
} else {
|
||||
stack.push(Character.valueOf(c0));
|
||||
stack.push(c0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,14 +342,11 @@ public class JSON2NBT {
|
||||
|
||||
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 = Iterables.toArray(SPLITTER.split(var7), String.class);
|
||||
|
||||
try {
|
||||
int[] var5 = new int[var8.length];
|
||||
|
||||
for (int j = 0; j < var8.length; ++j) {
|
||||
var5[j] = Integer.parseInt(var8[j].trim());
|
||||
}
|
||||
int[] var5 = Arrays.stream(var8).mapToInt(s -> Integer.parseInt(s.trim()))
|
||||
.toArray();
|
||||
|
||||
return new IntArrayTag(var5);
|
||||
} catch (NumberFormatException var51) {
|
||||
@ -379,27 +375,23 @@ public class JSON2NBT {
|
||||
}
|
||||
|
||||
private static class List extends JSON2NBT.Any {
|
||||
protected java.util.List<JSON2NBT.Any> tagList = Lists.newArrayList();
|
||||
protected List<JSON2NBT.Any> tagList = Lists.newArrayList();
|
||||
|
||||
public List(String json) {
|
||||
this.json = json;
|
||||
}
|
||||
|
||||
public Tag parse() throws NBTException {
|
||||
ArrayList<Tag> list = new ArrayList<>();
|
||||
Iterator var2 = this.tagList.iterator();
|
||||
ArrayList<Tag> list = this.tagList.stream().map(Any::parse)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
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();
|
||||
return new ListTag(tagType, list);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Compound extends JSON2NBT.Any {
|
||||
protected java.util.List<JSON2NBT.Any> tagList = Lists.newArrayList();
|
||||
protected List<JSON2NBT.Any> tagList = Lists.newArrayList();
|
||||
|
||||
public Compound(String jsonIn) {
|
||||
this.json = jsonIn;
|
||||
@ -407,10 +399,8 @@ public class JSON2NBT {
|
||||
|
||||
public Tag parse() throws NBTException {
|
||||
HashMap<String, Tag> map = new HashMap<>();
|
||||
Iterator var2 = this.tagList.iterator();
|
||||
|
||||
while (var2.hasNext()) {
|
||||
JSON2NBT.Any JSON2NBT$any = (JSON2NBT.Any) var2.next();
|
||||
for (Any JSON2NBT$any : this.tagList) {
|
||||
map.put(JSON2NBT$any.json, JSON2NBT$any.parse());
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class MCAChunk implements IChunk {
|
||||
|
||||
public final char[] blocks = new char[65536];
|
||||
|
||||
public final BlockVector3ChunkMap<CompoundTag> tiles = new BlockVector3ChunkMap<CompoundTag>();
|
||||
public final BlockVector3ChunkMap<CompoundTag> tiles = new BlockVector3ChunkMap<>();
|
||||
public final Map<UUID, CompoundTag> entities = new HashMap<>();
|
||||
public long inhabitedTime = System.currentTimeMillis();
|
||||
public long lastUpdate;
|
||||
|
@ -7,8 +7,8 @@ import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.IBlocks;
|
||||
import com.boydti.fawe.beta.IChunkGet;
|
||||
import com.boydti.fawe.beta.IChunkSet;
|
||||
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
||||
import com.boydti.fawe.beta.implementation.blocks.FallbackChunkGet;
|
||||
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAChunk;
|
||||
import com.boydti.fawe.object.FaweInputStream;
|
||||
import com.boydti.fawe.object.FaweOutputStream;
|
||||
@ -46,7 +46,6 @@ import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.Identifiable;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -60,7 +59,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -1556,9 +1554,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
|
||||
public void setHeights(int value) {
|
||||
heights.record(() -> {
|
||||
Arrays.fill(heights.get(), (byte) value);
|
||||
});
|
||||
heights.record(() -> Arrays.fill(heights.get(), (byte) value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,6 +17,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import java.io.Closeable;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Best used when clipboard selections are small, or using legacy formats
|
||||
@ -46,6 +47,7 @@ public abstract class LinearClipboard extends SimpleClipboard implements Clipboa
|
||||
|
||||
public abstract Collection<CompoundTag> getTileEntities();
|
||||
|
||||
@Override
|
||||
public void close() {}
|
||||
|
||||
public void flush() {}
|
||||
@ -55,6 +57,7 @@ public abstract class LinearClipboard extends SimpleClipboard implements Clipboa
|
||||
close();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
return iterator(Order.YZX);
|
||||
|
@ -9,8 +9,6 @@ import java.util.Spliterator;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,6 @@ import java.io.RandomAccessFile;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
/**
|
||||
@ -156,10 +155,8 @@ public class FastByteArrayOutputStream extends OutputStream {
|
||||
public void writeTo(OutputStream out) throws IOException {
|
||||
// Check if we have a list of buffers
|
||||
if (buffers != null) {
|
||||
Iterator iter = buffers.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
byte[] bytes = (byte[]) iter.next();
|
||||
for (byte[] bytes : buffers) {
|
||||
out.write(bytes, 0, blockSize);
|
||||
}
|
||||
}
|
||||
@ -171,10 +168,8 @@ public class FastByteArrayOutputStream extends OutputStream {
|
||||
public void writeTo(RandomAccessFile out) throws IOException {
|
||||
// Check if we have a list of buffers
|
||||
if (buffers != null) {
|
||||
Iterator iter = buffers.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
byte[] bytes = (byte[]) iter.next();
|
||||
for (byte[] bytes : buffers) {
|
||||
out.write(bytes, 0, blockSize);
|
||||
}
|
||||
}
|
||||
@ -231,4 +226,4 @@ public class FastByteArrayOutputStream extends OutputStream {
|
||||
size = 0;
|
||||
buffers.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,9 @@
|
||||
package com.boydti.fawe.object.task;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Supplier;
|
||||
|
@ -52,7 +52,7 @@ public class ReflectionUtils {
|
||||
|
||||
// 2. Copy it
|
||||
T[] previousValues = (T[]) valuesField.get(enumType);
|
||||
List values = new ArrayList(Arrays.asList(previousValues));
|
||||
List<T> values = new ArrayList<>(Arrays.asList(previousValues));
|
||||
|
||||
// 3. build new enum
|
||||
T newValue = (T) makeEnum(enumType, // The target enum class
|
||||
@ -176,7 +176,7 @@ public class ReflectionUtils {
|
||||
|
||||
public static <T> List<T> getList(List<T> list) {
|
||||
try {
|
||||
Class<? extends List> clazz = (Class<? extends List>) Class.forName("java.util.Collections$UnmodifiableList");
|
||||
Class<? extends List<T>> clazz = (Class<? extends List<T>>) Class.forName("java.util.Collections$UnmodifiableList");
|
||||
if (!clazz.isInstance(list)) return list;
|
||||
Field m = clazz.getDeclaredField("list");
|
||||
m.setAccessible(true);
|
||||
@ -566,10 +566,10 @@ public class ReflectionUtils {
|
||||
* @throws RuntimeException if constructor not found
|
||||
*/
|
||||
public RefConstructor findConstructor(int number) {
|
||||
final List<Constructor> constructors = new ArrayList<>();
|
||||
final List<Constructor<?>> constructors = new ArrayList<>();
|
||||
Collections.addAll(constructors, this.clazz.getConstructors());
|
||||
Collections.addAll(constructors, this.clazz.getDeclaredConstructors());
|
||||
for (Constructor m : constructors) {
|
||||
for (Constructor<?> m : constructors) {
|
||||
if (m.getParameterTypes().length == number) {
|
||||
return new RefConstructor(m);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class ReflectionUtils9 {
|
||||
|
||||
// 2. Copy it
|
||||
T[] previousValues = (T[]) valuesField.get(enumType);
|
||||
List values = new ArrayList<>(Arrays.asList(previousValues));
|
||||
List<T> values = new ArrayList<>(Arrays.asList(previousValues));
|
||||
|
||||
// 3. build new enum
|
||||
T newValue = (T) makeEnum(enumType, // The target enum class
|
||||
|
Reference in New Issue
Block a user