mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
cleanup
This commit is contained in:
parent
7f8749239f
commit
c8c9247dfe
@ -3,6 +3,7 @@ package com.dfsek.terra.api.structures.parser.exceptions;
|
||||
import com.dfsek.terra.api.structures.tokenizer.Position;
|
||||
|
||||
public class ParseException extends Exception {
|
||||
private static final long serialVersionUID = 6744390543046766386L;
|
||||
private final Position position;
|
||||
|
||||
public ParseException(String message, Position position) {
|
||||
|
@ -4,6 +4,8 @@ import com.dfsek.terra.api.structures.tokenizer.Position;
|
||||
|
||||
public class EOFException extends TokenizerException {
|
||||
|
||||
private static final long serialVersionUID = 3980047409902809440L;
|
||||
|
||||
public EOFException(String message, Position position) {
|
||||
super(message, position);
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import com.dfsek.terra.api.structures.tokenizer.Position;
|
||||
|
||||
public class FormatException extends TokenizerException {
|
||||
|
||||
private static final long serialVersionUID = -791308012940744455L;
|
||||
|
||||
public FormatException(String message, Position position) {
|
||||
super(message, position);
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import com.dfsek.terra.api.structures.tokenizer.Position;
|
||||
|
||||
public abstract class TokenizerException extends ParseException {
|
||||
|
||||
private static final long serialVersionUID = 2792384010083575420L;
|
||||
|
||||
public TokenizerException(String message, Position position) {
|
||||
super(message, position);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.dfsek.terra.api.util.GlueList;
|
||||
import java.util.List;
|
||||
|
||||
public class AttemptsFailedException extends RuntimeException {
|
||||
private static final long serialVersionUID = -1160459550006067137L;
|
||||
private final List<Throwable> causes;
|
||||
|
||||
public AttemptsFailedException(String message, List<Throwable> causes) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.dfsek.terra.api.transform;
|
||||
|
||||
public class TransformException extends Exception {
|
||||
private static final long serialVersionUID = -6661338369581162084L;
|
||||
|
||||
public TransformException() {
|
||||
super();
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class Transformer<F, T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Transformer<F, T> build() {
|
||||
public Transformer<F, T> build() {
|
||||
return new Transformer<>(transforms);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import java.util.SplittableRandom;
|
||||
|
||||
public class FastRandom extends Random {
|
||||
|
||||
private static final long serialVersionUID = 4571946470190183260L;
|
||||
private XoRoShiRo128PlusPlus random;
|
||||
|
||||
public FastRandom() {
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.dfsek.terra.api.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
@ -76,14 +78,16 @@ import static net.jafama.FastMath.*;
|
||||
* @see ArrayList
|
||||
* @param <T> the type of elements held in this collection
|
||||
*/
|
||||
@SuppressWarnings({"ManualMinMaxCalculation", "ConstantConditions", "ManualArrayToCollectionCopy"})
|
||||
public class GlueList<T> extends AbstractList<T> implements List<T>, Cloneable, Serializable {
|
||||
|
||||
transient Node<T> first;
|
||||
transient Node<T> last;
|
||||
private static final long serialVersionUID = -4339173882660322249L;
|
||||
private transient Node<T> first;
|
||||
private transient Node<T> last;
|
||||
|
||||
int size;
|
||||
private int size;
|
||||
|
||||
int initialCapacity;
|
||||
private int initialCapacity;
|
||||
|
||||
private static final int DEFAULT_CAPACITY = 10;
|
||||
|
||||
@ -236,7 +240,7 @@ public class GlueList<T> extends AbstractList<T> implements List<T>, Cloneable,
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends T> c) {
|
||||
public boolean addAll(@NotNull Collection<? extends T> c) {
|
||||
|
||||
Objects.requireNonNull(c);
|
||||
|
||||
@ -426,7 +430,6 @@ public class GlueList<T> extends AbstractList<T> implements List<T>, Cloneable,
|
||||
return indexOf(o) != -1;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public T remove(int index) {
|
||||
|
||||
@ -499,7 +502,7 @@ public class GlueList<T> extends AbstractList<T> implements List<T>, Cloneable,
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
public boolean removeAll(@NotNull Collection<?> c) {
|
||||
|
||||
Objects.requireNonNull(c);
|
||||
|
||||
@ -518,7 +521,7 @@ public class GlueList<T> extends AbstractList<T> implements List<T>, Cloneable,
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
public boolean retainAll(@NotNull Collection<?> c) {
|
||||
|
||||
Objects.requireNonNull(c);
|
||||
|
||||
@ -663,7 +666,7 @@ public class GlueList<T> extends AbstractList<T> implements List<T>, Cloneable,
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> subList(int fromIndex, int toIndex) {
|
||||
public @NotNull List<T> subList(int fromIndex, int toIndex) {
|
||||
return super.subList(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
@ -689,8 +692,8 @@ public class GlueList<T> extends AbstractList<T> implements List<T>, Cloneable,
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a) {
|
||||
return (T[]) Arrays.copyOf(toArray(), size, a.getClass());
|
||||
public <E> E[] toArray(E[] a) {
|
||||
return (E[]) Arrays.copyOf(toArray(), size, a.getClass());
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
@ -698,7 +701,7 @@ public class GlueList<T> extends AbstractList<T> implements List<T>, Cloneable,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
public @NotNull Iterator<T> iterator() {
|
||||
return new Itr();
|
||||
}
|
||||
|
||||
@ -736,7 +739,7 @@ public class GlueList<T> extends AbstractList<T> implements List<T>, Cloneable,
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<T> listIterator(int index) {
|
||||
public @NotNull ListIterator<T> listIterator(int index) {
|
||||
|
||||
checkPositionIndex(index);
|
||||
|
||||
@ -751,89 +754,65 @@ public class GlueList<T> extends AbstractList<T> implements List<T>, Cloneable,
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<T> listIterator() {
|
||||
public @NotNull ListIterator<T> listIterator() {
|
||||
return new ListItr(0);
|
||||
}
|
||||
|
||||
private class Itr implements Iterator<T> {
|
||||
protected static class Node<T> {
|
||||
|
||||
Node<T> node = first;
|
||||
protected Node<T> pre;
|
||||
protected Node<T> next;
|
||||
|
||||
int i = 0;//inner-array index
|
||||
int j = 0;//total index -> cursor
|
||||
protected int listSize;
|
||||
|
||||
int lastReturn = -1;
|
||||
protected int startingIndex;
|
||||
protected int endingIndex;
|
||||
|
||||
int expectedModCount = modCount;
|
||||
int elementDataPointer = node.elementDataPointer;
|
||||
protected T[] elementData;
|
||||
protected int elementDataPointer;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return j != size;
|
||||
@SuppressWarnings("unchecked")
|
||||
Node(Node<T> pre, Node<T> next, int listSize) {
|
||||
this.pre = pre;
|
||||
this.next = next;
|
||||
this.listSize = listSize;
|
||||
this.elementData = (T[]) new Object[listSize >>> 1];
|
||||
this.startingIndex = listSize;
|
||||
this.endingIndex = listSize + elementData.length - 1;
|
||||
}
|
||||
|
||||
Node(Node<T> pre, Node<T> next, int listSize, int initialCapacity) {
|
||||
this.pre = pre;
|
||||
this.next = next;
|
||||
this.listSize = listSize;
|
||||
this.elementData = createElementData(initialCapacity);
|
||||
this.startingIndex = listSize;
|
||||
this.endingIndex = listSize + elementData.length - 1;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
T[] createElementData(int capacity) {
|
||||
|
||||
if(capacity == 0 || capacity == 1) {
|
||||
return (T[]) new Object[DEFAULT_CAPACITY];
|
||||
} else if(capacity > 1) {
|
||||
return (T[]) new Object[capacity];
|
||||
} else {
|
||||
throw new IllegalArgumentException("Illegal Capacity: " + capacity);
|
||||
}
|
||||
}
|
||||
|
||||
boolean isAddable() {
|
||||
return elementDataPointer < elementData.length;
|
||||
}
|
||||
|
||||
void add(T element) {
|
||||
elementData[elementDataPointer++] = element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
|
||||
checkForComodification();
|
||||
|
||||
if (j >= size) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
if (j >= last.endingIndex + 1) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
|
||||
if (j == 0) {// it's for listIterator.when node becomes null.
|
||||
node = first;
|
||||
elementDataPointer = node.elementDataPointer;
|
||||
i = 0;
|
||||
}
|
||||
|
||||
T val = node.elementData[i++];
|
||||
|
||||
if (i >= elementDataPointer) {
|
||||
node = node.next;
|
||||
i = 0;
|
||||
elementDataPointer = (node != null) ? node.elementDataPointer : 0;
|
||||
}
|
||||
|
||||
lastReturn = j++;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
|
||||
if (lastReturn < 0) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
checkForComodification();
|
||||
|
||||
try {
|
||||
com.dfsek.terra.api.util.GlueList.this.remove(lastReturn);
|
||||
|
||||
j = lastReturn;
|
||||
|
||||
lastReturn = -1;
|
||||
|
||||
i = (--i < 0) ? 0 : i;
|
||||
|
||||
elementDataPointer = (node != null) ? node.elementDataPointer : 0;
|
||||
|
||||
expectedModCount = modCount;
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
}
|
||||
|
||||
void checkForComodification() {
|
||||
if (modCount != expectedModCount) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
public String toString() {
|
||||
return String.format("[sIndex: %d - eIndex: %d | elementDataPointer: %d | elementDataLength: %d]", startingIndex, endingIndex, elementDataPointer, elementData.length);
|
||||
}
|
||||
}
|
||||
|
||||
@ -988,61 +967,85 @@ public class GlueList<T> extends AbstractList<T> implements List<T>, Cloneable,
|
||||
}
|
||||
}
|
||||
|
||||
static class Node<T> {
|
||||
private class Itr implements Iterator<T> {
|
||||
|
||||
Node<T> pre;
|
||||
Node<T> next;
|
||||
protected Node<T> node = first;
|
||||
|
||||
int listSize;
|
||||
protected int i = 0;//inner-array index
|
||||
protected int j = 0;//total index -> cursor
|
||||
|
||||
int startingIndex;
|
||||
int endingIndex;
|
||||
protected int lastReturn = -1;
|
||||
|
||||
T[] elementData;
|
||||
int elementDataPointer;
|
||||
protected int expectedModCount = modCount;
|
||||
protected int elementDataPointer = node.elementDataPointer;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Node(Node<T> pre, Node<T> next, int listSize) {
|
||||
this.pre = pre;
|
||||
this.next = next;
|
||||
this.listSize = listSize;
|
||||
this.elementData = (T[]) new Object[listSize >>> 1];
|
||||
this.startingIndex = listSize;
|
||||
this.endingIndex = listSize + elementData.length - 1;
|
||||
}
|
||||
|
||||
Node(Node<T> pre, Node<T> next, int listSize, int initialCapacity) {
|
||||
this.pre = pre;
|
||||
this.next = next;
|
||||
this.listSize = listSize;
|
||||
this.elementData = createElementData(initialCapacity);
|
||||
this.startingIndex = listSize;
|
||||
this.endingIndex = listSize + elementData.length - 1;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
T[] createElementData(int capacity) {
|
||||
|
||||
if (capacity == 0 || capacity == 1) {
|
||||
return (T[]) new Object[DEFAULT_CAPACITY];
|
||||
} else if (capacity > 1) {
|
||||
return (T[]) new Object[capacity];
|
||||
} else {
|
||||
throw new IllegalArgumentException("Illegal Capacity: " + capacity);
|
||||
}
|
||||
}
|
||||
|
||||
boolean isAddable() {
|
||||
return elementDataPointer < elementData.length;
|
||||
}
|
||||
|
||||
void add(T element) {
|
||||
elementData[elementDataPointer++] = element;
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return j != size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[sIndex: %d - eIndex: %d | elementDataPointer: %d | elementDataLength: %d]", startingIndex, endingIndex, elementDataPointer, elementData.length);
|
||||
public T next() {
|
||||
|
||||
checkForComodification();
|
||||
|
||||
if(j >= size) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
if(j >= last.endingIndex + 1) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
|
||||
if(j == 0) {// it's for listIterator.when node becomes null.
|
||||
node = first;
|
||||
elementDataPointer = node.elementDataPointer;
|
||||
i = 0;
|
||||
}
|
||||
|
||||
T val = node.elementData[i++];
|
||||
|
||||
if(i >= elementDataPointer) {
|
||||
node = node.next;
|
||||
i = 0;
|
||||
elementDataPointer = (node != null) ? node.elementDataPointer : 0;
|
||||
}
|
||||
|
||||
lastReturn = j++;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
|
||||
if(lastReturn < 0) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
checkForComodification();
|
||||
|
||||
try {
|
||||
com.dfsek.terra.api.util.GlueList.this.remove(lastReturn);
|
||||
|
||||
j = lastReturn;
|
||||
|
||||
lastReturn = -1;
|
||||
|
||||
i = (--i < 0) ? 0 : i;
|
||||
|
||||
elementDataPointer = (node != null) ? node.elementDataPointer : 0;
|
||||
|
||||
expectedModCount = modCount;
|
||||
} catch(IndexOutOfBoundsException e) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
}
|
||||
|
||||
void checkForComodification() {
|
||||
if(modCount != expectedModCount) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package com.dfsek.terra.api.util.mutable;
|
||||
|
||||
public class MutableDouble extends MutableNumber<Double> {
|
||||
private static final long serialVersionUID = -2218110876763640053L;
|
||||
|
||||
public MutableDouble(Double value) {
|
||||
super(value);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.dfsek.terra.api.util.mutable;
|
||||
|
||||
public class MutableInteger extends MutableNumber<Integer> {
|
||||
private static final long serialVersionUID = -4427935901819632745L;
|
||||
|
||||
public MutableInteger(Integer value) {
|
||||
super(value);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.dfsek.terra.api.util.mutable;
|
||||
|
||||
public abstract class MutableNumber<T extends Number> extends Number implements MutablePrimitive<T> {
|
||||
|
||||
private static final long serialVersionUID = 8619508342781664393L;
|
||||
protected T value;
|
||||
|
||||
public MutableNumber(T value) {
|
||||
|
@ -9,6 +9,7 @@ import java.lang.reflect.Type;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class LinkedHashMapLoader implements TypeLoader<LinkedHashMap<Object, Object>> {
|
||||
@Override
|
||||
public LinkedHashMap<Object, Object> load(Type t, Object c, ConfigLoader loader) throws LoadException {
|
||||
|
@ -7,6 +7,7 @@ import com.dfsek.terra.api.math.noise.samplers.noise.CellularSampler;
|
||||
import com.dfsek.terra.api.math.noise.samplers.noise.simplex.OpenSimplex2Sampler;
|
||||
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
public class CellularNoiseTemplate extends NoiseTemplate<CellularSampler> {
|
||||
@Value("distance")
|
||||
@Default
|
||||
|
@ -25,6 +25,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BiomeLocateCommand extends WorldCommand {
|
||||
public BiomeLocateCommand(com.dfsek.terra.bukkit.command.Command parent) {
|
||||
super(parent);
|
||||
|
@ -11,7 +11,7 @@ import java.io.ObjectStreamClass;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class SerializationUtil {
|
||||
public final class SerializationUtil {
|
||||
public static Object fromFile(File f) throws IOException, ClassNotFoundException {
|
||||
ObjectInputStream ois = new MovedObjectInputStream(new FileInputStream(f), "com.dfsek.terra.api.world.generation.population", "com.dfsek.terra.bukkit.population"); // Backwards compat with old Gaea location
|
||||
Object o = ois.readObject();
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.dfsek.terra.bukkit.structure;
|
||||
|
||||
public class WorldEditNotFoundException extends RuntimeException {
|
||||
private static final long serialVersionUID = 3678822468346338227L;
|
||||
|
||||
public WorldEditNotFoundException() {
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.dfsek.terra.api.platform.world.BiomeGrid;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BukkitBiomeGrid implements BiomeGrid {
|
||||
private final ChunkGenerator.BiomeGrid delegate;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user