mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 12:36:40 +00:00
Javadoc and Formatting fixes. (#619)
Javadoc and Formatting fixes. Also, extremely minor code changes which have been tested. This commit is only part one of two commits that aim to fix problems with formatting in our project. In part two I will modify the Google Java Style Guide (since it closely matches our code style) for our project so there is guidance on how to format and document. * Updated PlotSquared URL * Removed plugin acronyms * Fixed a typo * Fixed grammar * Use modern block id's * Update YouTube video URL
This commit is contained in:
@ -390,7 +390,9 @@ public class CompoundTag extends Tag {
|
||||
@Override
|
||||
public Map<String, Object> toRaw() {
|
||||
HashMap<String, Object> raw = new HashMap<>();
|
||||
if (this.getValue().isEmpty()) return raw;
|
||||
if (this.getValue().isEmpty()) {
|
||||
return raw;
|
||||
}
|
||||
for (Map.Entry<String, Tag> entry : getValue().entrySet()) {
|
||||
raw.put(entry.getKey(), entry.getValue().toRaw());
|
||||
}
|
||||
|
@ -16,7 +16,9 @@ public abstract class CompressedCompoundTag<T> extends CompoundTag {
|
||||
|
||||
@Override
|
||||
public Map<String, Tag> getValue() {
|
||||
if (in != null) decompress();
|
||||
if (in != null) {
|
||||
decompress();
|
||||
}
|
||||
return super.getValue();
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,9 @@ public final class NBTInputStream implements Closeable {
|
||||
return;
|
||||
case NBTConstants.TYPE_BYTE: {
|
||||
ValueReader value = scope.getValueReader();
|
||||
if (value == null) value = scope.getElemReader();
|
||||
if (value == null) {
|
||||
value = scope.getElemReader();
|
||||
}
|
||||
if (value != null) {
|
||||
value.applyInt(0, is.readByte());
|
||||
} else {
|
||||
@ -197,7 +199,9 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
case NBTConstants.TYPE_SHORT: {
|
||||
ValueReader value = scope.getValueReader();
|
||||
if (value == null) value = scope.getElemReader();
|
||||
if (value == null) {
|
||||
value = scope.getElemReader();
|
||||
}
|
||||
if (value != null) {
|
||||
value.applyInt(0, is.readShort());
|
||||
} else {
|
||||
@ -207,7 +211,9 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
case NBTConstants.TYPE_INT: {
|
||||
ValueReader value = scope.getValueReader();
|
||||
if (value == null) value = scope.getElemReader();
|
||||
if (value == null) {
|
||||
value = scope.getElemReader();
|
||||
}
|
||||
if (value != null) {
|
||||
value.applyInt(0, is.readInt());
|
||||
} else {
|
||||
@ -217,7 +223,9 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
case NBTConstants.TYPE_LONG: {
|
||||
ValueReader value = scope.getValueReader();
|
||||
if (value == null) value = scope.getElemReader();
|
||||
if (value == null) {
|
||||
value = scope.getElemReader();
|
||||
}
|
||||
if (value != null) {
|
||||
value.applyLong(0, is.readLong());
|
||||
} else {
|
||||
@ -227,7 +235,9 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
case NBTConstants.TYPE_FLOAT: {
|
||||
ValueReader value = scope.getValueReader();
|
||||
if (value == null) value = scope.getElemReader();
|
||||
if (value == null) {
|
||||
value = scope.getElemReader();
|
||||
}
|
||||
if (value != null) {
|
||||
value.applyFloat(0, is.readFloat());
|
||||
} else {
|
||||
@ -237,7 +247,9 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
case NBTConstants.TYPE_DOUBLE: {
|
||||
ValueReader value = scope.getValueReader();
|
||||
if (value == null) value = scope.getElemReader();
|
||||
if (value == null) {
|
||||
value = scope.getElemReader();
|
||||
}
|
||||
if (value != null) {
|
||||
value.applyDouble(0, is.readDouble());
|
||||
} else {
|
||||
@ -247,7 +259,9 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
case NBTConstants.TYPE_STRING: {
|
||||
ValueReader value = scope.getValueReader();
|
||||
if (value == null) value = scope.getElemReader();
|
||||
if (value == null) {
|
||||
value = scope.getElemReader();
|
||||
}
|
||||
int length = is.readShort() & 0xFFFF;
|
||||
if (value != null) {
|
||||
byte[] bytes = new byte[length];
|
||||
@ -325,7 +339,9 @@ public final class NBTInputStream implements Closeable {
|
||||
case NBTConstants.TYPE_BYTE_ARRAY: {
|
||||
int length = is.readInt();
|
||||
scope.acceptInfo(length, NBTConstants.TYPE_BYTE);
|
||||
if (scope.acceptLazy(length, this)) return;
|
||||
if (scope.acceptLazy(length, this)) {
|
||||
return;
|
||||
}
|
||||
ValueReader valueReader = scope.getValueReader();
|
||||
if (valueReader != null) {
|
||||
byte[] arr = new byte[length];
|
||||
@ -360,7 +376,9 @@ public final class NBTInputStream implements Closeable {
|
||||
case NBTConstants.TYPE_INT_ARRAY: {
|
||||
int length = is.readInt();
|
||||
scope.acceptInfo(length, NBTConstants.TYPE_INT);
|
||||
if (scope.acceptLazy(length, this)) return;
|
||||
if (scope.acceptLazy(length, this)) {
|
||||
return;
|
||||
}
|
||||
ValueReader valueReader = scope.getValueReader();
|
||||
if (valueReader != null) {
|
||||
valueReader.apply(0, readIntArrayRaw(length));
|
||||
@ -379,7 +397,9 @@ public final class NBTInputStream implements Closeable {
|
||||
case NBTConstants.TYPE_LONG_ARRAY: {
|
||||
int length = is.readInt();
|
||||
scope.acceptInfo(length, NBTConstants.TYPE_LONG);
|
||||
if (scope.acceptLazy(length, this)) return;
|
||||
if (scope.acceptLazy(length, this)) {
|
||||
return;
|
||||
}
|
||||
ValueReader valueReader = scope.getValueReader();
|
||||
if (valueReader != null) {
|
||||
valueReader.apply(0, readLongArrayRaw(length));
|
||||
|
@ -126,7 +126,9 @@ public class CommandContext {
|
||||
for (endIndex = i; endIndex < args.length; ++endIndex) {
|
||||
final String arg2 = args[endIndex];
|
||||
if (arg2.charAt(arg2.length() - 1) == quotedChar && arg2.length() > 1) {
|
||||
if (endIndex != i) build.append(' ');
|
||||
if (endIndex != i) {
|
||||
build.append(' ');
|
||||
}
|
||||
build.append(arg2.substring(endIndex == i ? 1 : 0, arg2.length() - 1));
|
||||
break;
|
||||
} else if (endIndex == i) {
|
||||
|
@ -28,10 +28,11 @@ public final class ReflectionUtil {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getField(Object from, String name) {
|
||||
if (from instanceof Class)
|
||||
if (from instanceof Class) {
|
||||
return getField((Class) from, null, name);
|
||||
else
|
||||
} else {
|
||||
return getField(from.getClass(), from, name);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -258,8 +258,7 @@ public final class StringUtil {
|
||||
|
||||
for (i = 1; i <= n; ++i) {
|
||||
cost = s.charAt(i - 1) == tj ? 0 : 1;
|
||||
// minimum of cell to the left+1, to the top+1, diagonally left
|
||||
// and up +cost
|
||||
// minimum of cell to the left+1, to the top+1, diagonally left and up +cost
|
||||
d[i] = Math.min(Math.min(d[i - 1] + 1, p[i] + 1), p[i - 1]
|
||||
+ cost);
|
||||
}
|
||||
|
@ -43,6 +43,57 @@ public class YAMLNode {
|
||||
this.writeDefaults = writeDefaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts a value to an integer. May return null.
|
||||
*
|
||||
* @param o the object
|
||||
* @return an integer or null
|
||||
*/
|
||||
@Nullable
|
||||
private static Integer castInt(Object o) {
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else if (o instanceof Number) {
|
||||
return ((Number) o).intValue();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts a value to a double. May return null.
|
||||
*
|
||||
* @param o the object
|
||||
* @return a double or null
|
||||
*/
|
||||
@Nullable
|
||||
private static Double castDouble(Object o) {
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else if (o instanceof Number) {
|
||||
return ((Number) o).doubleValue();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts a value to a boolean. May return null.
|
||||
*
|
||||
* @param o the object
|
||||
* @return a boolean or null
|
||||
*/
|
||||
@Nullable
|
||||
private static Boolean castBoolean(Object o) {
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else if (o instanceof Boolean) {
|
||||
return (Boolean) o;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the underlying map.
|
||||
*
|
||||
@ -262,8 +313,8 @@ public class YAMLNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string at a location. This will either return a Vector
|
||||
* or the default value. If the object at the particular location is not
|
||||
* Gets a string at a location. This will either return a Vector, or
|
||||
* the default value. If the object at the particular location is not
|
||||
* actually a string, it will be converted to its string representation.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
@ -282,8 +333,8 @@ public class YAMLNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string at a location. This will either return a String
|
||||
* or the default value. If the object at the particular location is not
|
||||
* Gets a string at a location. This will either return a String, or
|
||||
* the default value. If the object at the particular location is not
|
||||
* actually a string, it will be converted to its string representation.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
@ -302,13 +353,13 @@ public class YAMLNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an integer at a location. This will either return an integer
|
||||
* or null. If the object at the particular location is not
|
||||
* actually a integer, the default value will be returned. However, other
|
||||
* number types will be casted to an integer.
|
||||
* Gets an integer at a location. This will either return an Integer, or
|
||||
* null. If the object at the particular location is not
|
||||
* actually an Integer, the default value will be returned. However, other
|
||||
* number types will be casted to an Integer.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @return integer or null
|
||||
* @return Integer or null
|
||||
*/
|
||||
public Integer getInt(String path) {
|
||||
Integer o = castInt(getProperty(path));
|
||||
@ -320,14 +371,14 @@ public class YAMLNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an integer at a location. This will either return an integer
|
||||
* or the default value. If the object at the particular location is not
|
||||
* actually a integer, the default value will be returned. However, other
|
||||
* Gets an integer at a location. This will either return an Integer, or
|
||||
* the default value. If the object at the particular location is not
|
||||
* actually an Integer, the default value will be returned. However, other
|
||||
* number types will be casted to an integer.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @param def default value
|
||||
* @return int or default
|
||||
* @return Integer or default
|
||||
*/
|
||||
public int getInt(String path, int def) {
|
||||
Integer o = castInt(getProperty(path));
|
||||
@ -342,13 +393,13 @@ public class YAMLNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a double at a location. This will either return a double
|
||||
* or null. If the object at the particular location is not
|
||||
* actually a double, the default value will be returned. However, other
|
||||
* number types will be casted to a double.
|
||||
* Gets a double at a location. This will either return a Double, or
|
||||
* null. If the object at the particular location is not
|
||||
* actually a Double, the default value will be returned. However, other
|
||||
* number types will be casted to a Double.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @return double or null
|
||||
* @return Double or null
|
||||
*/
|
||||
public Double getDouble(String path) {
|
||||
Double o = castDouble(getProperty(path));
|
||||
@ -360,14 +411,14 @@ public class YAMLNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a double at a location. This will either return a double
|
||||
* or the default value. If the object at the particular location is not
|
||||
* actually a double, the default value will be returned. However, other
|
||||
* number types will be casted to a double.
|
||||
* Gets a double at a location. This will either return a Double, or
|
||||
* the default value. If the object at the particular location is not
|
||||
* actually a Double, the default value will be returned. However, other
|
||||
* number types will be casted to a Double.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @param def default value
|
||||
* @return double or default
|
||||
* @return Double or default
|
||||
*/
|
||||
public double getDouble(String path, double def) {
|
||||
Double o = castDouble(getProperty(path));
|
||||
@ -382,12 +433,12 @@ public class YAMLNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a boolean at a location. This will either return a boolean
|
||||
* or null. If the object at the particular location is not
|
||||
* actually a boolean, the default value will be returned.
|
||||
* Gets a Boolean at a location. This will either return a Boolean, or
|
||||
* null. If the object at the particular location is not
|
||||
* actually a Boolean, the default value will be returned.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @return boolean or null
|
||||
* @return Boolean or null
|
||||
*/
|
||||
public Boolean getBoolean(String path) {
|
||||
Boolean o = castBoolean(getProperty(path));
|
||||
@ -399,13 +450,13 @@ public class YAMLNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a boolean at a location. This will either return a boolean
|
||||
* or the default value. If the object at the particular location is not
|
||||
* actually a boolean, the default value will be returned.
|
||||
* Gets a Boolean at a location. This will either return a Boolean, or
|
||||
* the default value. If the object at the particular location is not
|
||||
* actually a Boolean, the default value will be returned.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @param def default value
|
||||
* @return boolean or default
|
||||
* @return Boolean or default
|
||||
*/
|
||||
public boolean getBoolean(String path, boolean def) {
|
||||
Boolean o = castBoolean(getProperty(path));
|
||||
@ -421,7 +472,7 @@ public class YAMLNode {
|
||||
|
||||
/**
|
||||
* Get a list of keys at a location. If the map at the particular location
|
||||
* does not exist or it is not a map, null will be returned.
|
||||
* does not exist, or it is not a map, null will be returned.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @return list of keys
|
||||
@ -461,16 +512,16 @@ public class YAMLNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of strings. Non-valid entries will not be in the list.
|
||||
* Gets a list of Strings. Non-valid entries will not be in the list.
|
||||
* There will be no null slots. If the list is not defined, the
|
||||
* default will be returned. 'null' can be passed for the default
|
||||
* and an empty list will be returned instead. If an item in the list
|
||||
* is not a string, it will be converted to a string. The node must be
|
||||
* an actual list and not just a string.
|
||||
* default will be returned. 'null' can be passed for the default, and
|
||||
* an empty list will be returned instead. If an item in the list
|
||||
* is not a String, it will be converted to a string. The node must be
|
||||
* an actual list and not just a String.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @param def default value or null for an empty list as default
|
||||
* @return list of strings
|
||||
* @return list of Strings
|
||||
*/
|
||||
public List<String> getStringList(String path, List<String> def) {
|
||||
List<Object> raw = getList(path);
|
||||
@ -496,13 +547,13 @@ public class YAMLNode {
|
||||
/**
|
||||
* Gets a list of integers. Non-valid entries will not be in the list.
|
||||
* There will be no null slots. If the list is not defined, the
|
||||
* default will be returned. 'null' can be passed for the default
|
||||
* and an empty list will be returned instead. The node must be
|
||||
* default will be returned. 'null' can be passed for the default, and
|
||||
* an empty list will be returned instead. The node must be
|
||||
* an actual list and not just an integer.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @param def default value or null for an empty list as default
|
||||
* @return list of integers
|
||||
* @return list of Integers
|
||||
*/
|
||||
public List<Integer> getIntList(String path, List<Integer> def) {
|
||||
List<Object> raw = getList(path);
|
||||
@ -525,15 +576,15 @@ public class YAMLNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of doubles. Non-valid entries will not be in the list.
|
||||
* Gets a list of Doubles. Non-valid entries will not be in the list.
|
||||
* There will be no null slots. If the list is not defined, the
|
||||
* default will be returned. 'null' can be passed for the default
|
||||
* and an empty list will be returned instead. The node must be
|
||||
* an actual list and cannot be just a double.
|
||||
* default will be returned. 'null' can be passed for the default, and
|
||||
* an empty list will be returned instead. The node must be
|
||||
* an actual list and cannot be just a Double.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @param def default value or null for an empty list as default
|
||||
* @return list of integers
|
||||
* @return list of Doubles
|
||||
*/
|
||||
public List<Double> getDoubleList(String path, List<Double> def) {
|
||||
List<Object> raw = getList(path);
|
||||
@ -556,15 +607,15 @@ public class YAMLNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of booleans. Non-valid entries will not be in the list.
|
||||
* Gets a list of Booleans. Non-valid entries will not be in the list.
|
||||
* There will be no null slots. If the list is not defined, the
|
||||
* default will be returned. 'null' can be passed for the default
|
||||
* and an empty list will be returned instead. The node must be
|
||||
* an actual list and cannot be just a boolean,
|
||||
* default will be returned. 'null' can be passed for the default, and
|
||||
* an empty list will be returned instead. The node must be
|
||||
* an actual list and cannot be just a Boolean.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @param def default value or null for an empty list as default
|
||||
* @return list of integers
|
||||
* @return list of Booleans
|
||||
*/
|
||||
public List<Boolean> getBooleanList(String path, List<Boolean> def) {
|
||||
List<Object> raw = getList(path);
|
||||
@ -589,13 +640,13 @@ public class YAMLNode {
|
||||
/**
|
||||
* Gets a list of vectors. Non-valid entries will not be in the list.
|
||||
* There will be no null slots. If the list is not defined, the
|
||||
* default will be returned. 'null' can be passed for the default
|
||||
* and an empty list will be returned instead. The node must be
|
||||
* an actual node and cannot be just a vector,
|
||||
* default will be returned. 'null' can be passed for the default, and
|
||||
* an empty list will be returned instead. The node must be
|
||||
* an actual node and cannot be just a vector.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @param def default value or null for an empty list as default
|
||||
* @return list of integers
|
||||
* @return list of vectors
|
||||
*/
|
||||
public List<Vector3> getVectorList(String path, List<Vector3> def) {
|
||||
List<YAMLNode> raw = getNodeList(path, null);
|
||||
@ -619,13 +670,13 @@ public class YAMLNode {
|
||||
/**
|
||||
* Gets a list of 2D vectors. Non-valid entries will not be in the list.
|
||||
* There will be no null slots. If the list is not defined, the
|
||||
* default will be returned. 'null' can be passed for the default
|
||||
* and an empty list will be returned instead. The node must be
|
||||
* an actual node and cannot be just a vector,
|
||||
* default will be returned. 'null' can be passed for the default, and
|
||||
* an empty list will be returned instead. The node must be
|
||||
* an actual node and cannot be just a vector.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @param def default value or null for an empty list as default
|
||||
* @return list of integers
|
||||
* @return list of vectors
|
||||
*/
|
||||
public List<Vector2> getVector2List(String path, List<Vector2> def) {
|
||||
|
||||
@ -649,13 +700,13 @@ public class YAMLNode {
|
||||
/**
|
||||
* Gets a list of 2D vectors. Non-valid entries will not be in the list.
|
||||
* There will be no null slots. If the list is not defined, the
|
||||
* default will be returned. 'null' can be passed for the default
|
||||
* and an empty list will be returned instead. The node must be
|
||||
* an actual node and cannot be just a vector,
|
||||
* default will be returned. 'null' can be passed for the default, and
|
||||
* an empty list will be returned instead. The node must be
|
||||
* an actual node and cannot be just a vector.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @param def default value or null for an empty list as default
|
||||
* @return list of integers
|
||||
* @return list of vectors
|
||||
*/
|
||||
public List<BlockVector2> getBlockVector2List(String path, List<BlockVector2> def) {
|
||||
|
||||
@ -679,13 +730,13 @@ public class YAMLNode {
|
||||
/**
|
||||
* Gets a list of nodes. Non-valid entries will not be in the list.
|
||||
* There will be no null slots. If the list is not defined, the
|
||||
* default will be returned. 'null' can be passed for the default
|
||||
* and an empty list will be returned instead. The node must be
|
||||
* an actual node and cannot be just a boolean,
|
||||
* default will be returned. 'null' can be passed for the default, and
|
||||
* an empty list will be returned instead. The node must be
|
||||
* an actual node and cannot be just a {@code YAMLNode}.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @param def default value or null for an empty list as default
|
||||
* @return list of integers
|
||||
* @return list of nodes
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<YAMLNode> getNodeList(String path, List<YAMLNode> def) {
|
||||
@ -708,7 +759,7 @@ public class YAMLNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration node at a path. If the node doesn't exist or the
|
||||
* Get a configuration node at a path. If the node doesn't exist, or the
|
||||
* path does not lead to a node, null will be returned. A node has
|
||||
* key/value mappings.
|
||||
*
|
||||
@ -728,7 +779,7 @@ public class YAMLNode {
|
||||
|
||||
/**
|
||||
* Get a list of nodes at a location. If the map at the particular location
|
||||
* does not exist or it is not a map, null will be returned.
|
||||
* does not exist, or it is not a map, null will be returned.
|
||||
*
|
||||
* @param path path to node (dot notation)
|
||||
* @return map of nodes
|
||||
@ -755,57 +806,6 @@ public class YAMLNode {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts a value to an integer. May return null.
|
||||
*
|
||||
* @param o the object
|
||||
* @return an integer or null
|
||||
*/
|
||||
@Nullable
|
||||
private static Integer castInt(Object o) {
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else if (o instanceof Number) {
|
||||
return ((Number) o).intValue();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts a value to a double. May return null.
|
||||
*
|
||||
* @param o the object
|
||||
* @return a double or null
|
||||
*/
|
||||
@Nullable
|
||||
private static Double castDouble(Object o) {
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else if (o instanceof Number) {
|
||||
return ((Number) o).doubleValue();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts a value to a boolean. May return null.
|
||||
*
|
||||
* @param o the object
|
||||
* @return a boolean or null
|
||||
*/
|
||||
@Nullable
|
||||
private static Boolean castBoolean(Object o) {
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else if (o instanceof Boolean) {
|
||||
return (Boolean) o;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the property at a location. This will override existing
|
||||
* configuration data to have it conform to key/value mappings.
|
||||
|
@ -176,12 +176,13 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reorder mode for {@link EditSession#setReorderMode(ReorderMode)}.
|
||||
* NOT FUNCTIONAL IN FAWE AS OF June 3,2019
|
||||
* Reorder mode for {@link EditSession#setReorderMode(ReorderMode)}. NOT FUNCTIONAL IN FAWE
|
||||
*
|
||||
* <p>
|
||||
* MULTI_STAGE = Multi stage reorder, may not be great with mods.
|
||||
* FAST = Use the fast mode. Good for mods.
|
||||
* NONE = Place blocks without worrying about placement order.
|
||||
* </p>
|
||||
*/
|
||||
public enum ReorderMode {
|
||||
MULTI_STAGE("multi"),
|
||||
@ -256,7 +257,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* The limit for this specific edit (blocks etc)
|
||||
* The limit for this specific edit (blocks etc).
|
||||
*
|
||||
* @return The limit
|
||||
*/
|
||||
@ -273,7 +274,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new limit representing how much of this edit's limit has been used so far
|
||||
* Returns a new limit representing how much of this edit's limit has been used so far.
|
||||
*
|
||||
* @return Limit remaining
|
||||
*/
|
||||
@ -291,7 +292,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the remaining limits
|
||||
* Returns the remaining limits.
|
||||
*
|
||||
* @return remaining limits
|
||||
*/
|
||||
@ -300,7 +301,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* The region extent restricts block placements to allowmaxYed regions
|
||||
* The region extent restricts block placements to allow max Y regions.
|
||||
* TODO This doc needs to be rewritten because it may not actually describe what it does.
|
||||
*
|
||||
* @return FaweRegionExtent (may be null)
|
||||
*/
|
||||
@ -312,6 +314,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
public Extent getBypassAll() {
|
||||
return bypassAll;
|
||||
}
|
||||
|
||||
public Extent getBypassHistory() {
|
||||
return bypassHistory;
|
||||
}
|
||||
@ -321,7 +324,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Player or null
|
||||
* Get the Player or null.
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
@ -436,9 +439,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue certain types of block for better reproduction of those blocks.
|
||||
* Queue certain types of block for better reproduction of those blocks. Uses
|
||||
* {@link ReorderMode#MULTI_STAGE}.
|
||||
*
|
||||
* Uses {@link ReorderMode#MULTI_STAGE}
|
||||
* @deprecated Use {@link EditSession#setReorderMode(ReorderMode)} with MULTI_STAGE instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ -480,7 +483,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
new ExtentTraverser(this).setNext(transform);
|
||||
}
|
||||
|
||||
public @Nullable ResettableExtent getTransform() {
|
||||
@Nullable
|
||||
public ResettableExtent getTransform() {
|
||||
ExtentTraverser<ResettableExtent> traverser = new ExtentTraverser<>(getExtent()).find(ResettableExtent.class);
|
||||
if (traverser != null) {
|
||||
return traverser.get();
|
||||
@ -710,8 +714,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable chunk batching. Disabling will
|
||||
* {@linkplain #flushSession() flush the session}.
|
||||
* Enable or disable chunk batching. Disabling will flush the session.
|
||||
*
|
||||
* @param batchingChunks {@code true} to enable, {@code false} to disable
|
||||
*/
|
||||
@ -895,7 +898,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override @Deprecated
|
||||
@Override
|
||||
@Deprecated
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block) throws MaxChangedBlocksException {
|
||||
if (position.getBlockY() < 0 || position.getBlockY() > 255) {
|
||||
return false;
|
||||
@ -971,6 +975,16 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
||||
return this.changes = super.setBlocks(region, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
return this.changes = super.setBlocks(region, pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores all blocks to their initial state.
|
||||
*
|
||||
@ -1023,7 +1037,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Closing an EditSession {@linkplain #flushSession() flushes its buffers}.
|
||||
* Closing an EditSession flushes its buffers to the world, and performs other
|
||||
* cleanup tasks.
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
@ -1033,7 +1048,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
/**
|
||||
* Communicate to the EditSession that all block changes are complete,
|
||||
* and that it should apply them to the world.
|
||||
*
|
||||
* @deprecated Replace with {@link #close()} for proper cleanup behavior.
|
||||
*/
|
||||
@Deprecated
|
||||
public void flushSession() {
|
||||
flushQueue();
|
||||
}
|
||||
@ -1048,7 +1066,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
if (used.MAX_FAILS > 0) {
|
||||
if (used.MAX_CHANGES > 0 || used.MAX_ENTITIES > 0) {
|
||||
player.print(Caption.of("fawe.error.worldedit.some.fails", used.MAX_FAILS));
|
||||
} else if (new ExtentTraverser<>(getExtent()).findAndGet(FaweRegionExtent.class) != null){
|
||||
} else if (new ExtentTraverser<>(getExtent()).findAndGet(FaweRegionExtent.class) != null) {
|
||||
player.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.region"));
|
||||
} else {
|
||||
player.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.level"));
|
||||
@ -1096,21 +1114,11 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
});
|
||||
Operations.completeBlindly(visitor);
|
||||
return this.changes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
||||
return this.changes = super.setBlocks(region, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
return this.changes = super.setBlocks(region, pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
|
||||
return this.changes = super.replaceBlocks(region, filter, replacement);
|
||||
@ -1198,6 +1206,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
Math.max(origin.getBlockY() - depth + 1, getMinimumPoint().getBlockY()),
|
||||
Math.min(getMaxY(), origin.getBlockY())),
|
||||
Masks.negate(new ExistingBlockMask(this)));
|
||||
|
||||
// Want to replace blocks
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
|
||||
@ -1313,7 +1322,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @param block the block to place
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
* @deprecated Use {@link EditSession#makeCuboidFaces(Region, Pattern)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public <B extends BlockStateHolder<B>> int makeCuboidFaces(Region region, B block) throws MaxChangedBlocksException {
|
||||
return makeCuboidFaces(region, block);
|
||||
}
|
||||
@ -1420,7 +1431,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @param block the placed block
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
* @deprecated Use {@link EditSession#overlayCuboidBlocks(Region, Pattern)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public <B extends BlockStateHolder<B>> int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException {
|
||||
checkNotNull(block);
|
||||
|
||||
@ -1573,7 +1586,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, this, to);
|
||||
|
||||
if (replacement == null) replacement = BlockTypes.AIR.getDefaultState();
|
||||
if (replacement == null) {
|
||||
replacement = BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
BlockReplace remove = replacement instanceof ExistingPattern ? null : new BlockReplace(this, replacement);
|
||||
copy.setSourceFunction(remove); // Remove
|
||||
|
||||
@ -1649,8 +1664,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
Mask liquidMask;
|
||||
if (plants) {
|
||||
liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER,
|
||||
BlockTypes.KELP_PLANT, BlockTypes.KELP, BlockTypes.SEAGRASS, BlockTypes.TALL_SEAGRASS);
|
||||
liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER,
|
||||
BlockTypes.KELP_PLANT, BlockTypes.KELP, BlockTypes.SEAGRASS, BlockTypes.TALL_SEAGRASS);
|
||||
} else {
|
||||
liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
|
||||
}
|
||||
@ -1660,9 +1675,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
liquidMask = new MaskUnion(liquidMask, new BlockStateMask(this, stateMap, true));
|
||||
}
|
||||
Mask mask = new MaskIntersection(
|
||||
new BoundedHeightMask(0, getWorld().getMaxY()),
|
||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||
liquidMask);
|
||||
new BoundedHeightMask(0, getWorld().getMaxY()),
|
||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||
liquidMask);
|
||||
BlockReplace replace;
|
||||
if (waterlogged) {
|
||||
replace = new BlockReplace(this, new WaterloggedRemover(this));
|
||||
@ -1708,6 +1723,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||
blockMask
|
||||
);
|
||||
|
||||
BlockReplace replace = new BlockReplace(this, fluid.getDefaultState());
|
||||
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
||||
|
||||
@ -1787,7 +1803,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
final int ceilRadiusX = (int) Math.ceil(radiusX);
|
||||
final int ceilRadiusZ = (int) Math.ceil(radiusZ);
|
||||
|
||||
double xSqr, zSqr;
|
||||
double xSqr;
|
||||
double zSqr;
|
||||
double distanceSq;
|
||||
double nextXn = 0;
|
||||
|
||||
@ -1910,7 +1927,11 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
LocalBlockVectorSet set = new LocalBlockVectorSet();
|
||||
|
||||
double nextXn = 0;
|
||||
double dx, dy, dz, dxy, dxyz;
|
||||
double dx;
|
||||
double dy;
|
||||
double dz;
|
||||
double dxy;
|
||||
double dxyz;
|
||||
forX:
|
||||
for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
final double xn = nextXn;
|
||||
@ -1945,22 +1966,30 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
if (Math.abs((x) * nx + (y) * ny + (z) * nz) < threshold)
|
||||
if (Math.abs((x) * nx + (y) * ny + (z) * nz) < threshold) {
|
||||
setBlock(mutable.setComponents(px + x, py + y, pz + z), block);
|
||||
if (Math.abs((-x) * nx + (y) * ny + (z) * nz) < threshold)
|
||||
}
|
||||
if (Math.abs((-x) * nx + (y) * ny + (z) * nz) < threshold) {
|
||||
setBlock(mutable.setComponents(px - x, py + y, pz + z), block);
|
||||
if (Math.abs((x) * nx + (-y) * ny + (z) * nz) < threshold)
|
||||
}
|
||||
if (Math.abs((x) * nx + (-y) * ny + (z) * nz) < threshold) {
|
||||
setBlock(mutable.setComponents(px + x, py - y, pz + z), block);
|
||||
if (Math.abs((x) * nx + (y) * ny + (-z) * nz) < threshold)
|
||||
}
|
||||
if (Math.abs((x) * nx + (y) * ny + (-z) * nz) < threshold) {
|
||||
setBlock(mutable.setComponents(px + x, py + y, pz - z), block);
|
||||
if (Math.abs((-x) * nx + (-y) * ny + (z) * nz) < threshold)
|
||||
}
|
||||
if (Math.abs((-x) * nx + (-y) * ny + (z) * nz) < threshold) {
|
||||
setBlock(mutable.setComponents(px - x, py - y, pz + z), block);
|
||||
if (Math.abs((x) * nx + (-y) * ny + (-z) * nz) < threshold)
|
||||
}
|
||||
if (Math.abs((x) * nx + (-y) * ny + (-z) * nz) < threshold) {
|
||||
setBlock(mutable.setComponents(px + x, py - y, pz - z), block);
|
||||
if (Math.abs((-x) * nx + (y) * ny + (-z) * nz) < threshold)
|
||||
}
|
||||
if (Math.abs((-x) * nx + (y) * ny + (-z) * nz) < threshold) {
|
||||
setBlock(mutable.setComponents(px - x, py + y, pz - z), block);
|
||||
if (Math.abs((-x) * nx + (-y) * ny + (-z) * nz) < threshold)
|
||||
}
|
||||
if (Math.abs((-x) * nx + (-y) * ny + (-z) * nz) < threshold) {
|
||||
setBlock(mutable.setComponents(px - x, py - y, pz - z), block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2050,18 +2079,26 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
yy = py + y;
|
||||
if (yy <= maxY) {
|
||||
this.setBlock(px + x, py + y, pz + z, block);
|
||||
if (x != 0) this.setBlock(px - x, py + y, pz + z, block);
|
||||
if (x != 0) {
|
||||
this.setBlock(px - x, py + y, pz + z, block);
|
||||
}
|
||||
if (z != 0) {
|
||||
this.setBlock(px + x, py + y, pz - z, block);
|
||||
if (x != 0) this.setBlock(px - x, py + y, pz - z, block);
|
||||
if (x != 0) {
|
||||
this.setBlock(px - x, py + y, pz - z, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (y != 0 && (yy = py - y) >= 0) {
|
||||
this.setBlock(px + x, yy, pz + z, block);
|
||||
if (x != 0) this.setBlock(px - x, yy, pz + z, block);
|
||||
if (x != 0) {
|
||||
this.setBlock(px - x, yy, pz + z, block);
|
||||
}
|
||||
if (z != 0) {
|
||||
this.setBlock(px + x, yy, pz - z, block);
|
||||
if (x != 0) this.setBlock(px - x, yy, pz - z, block);
|
||||
if (x != 0) {
|
||||
this.setBlock(px - x, yy, pz - z, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2114,8 +2151,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@Deprecated
|
||||
public int thaw(BlockVector3 position, double radius)
|
||||
throws MaxChangedBlocksException {
|
||||
throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
double radiusSq = radius * radius;
|
||||
|
||||
@ -2164,6 +2202,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@Deprecated
|
||||
public int simulateSnow(BlockVector3 position, double radius) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
double radiusSq = radius * radius;
|
||||
@ -2257,7 +2296,11 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
final BlockType block = getBlockType(x, y, z);
|
||||
switch (block.getInternalId()) {
|
||||
case BlockID.COARSE_DIRT:
|
||||
if (onlyNormalDirt) break loop;
|
||||
if (onlyNormalDirt) {
|
||||
break loop;
|
||||
}
|
||||
this.setBlock(x, y, z, grass);
|
||||
break loop;
|
||||
case BlockID.DIRT:
|
||||
this.setBlock(x, y, z, grass);
|
||||
break loop;
|
||||
@ -2344,7 +2387,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @return the results
|
||||
*/
|
||||
public List<Countable<BlockState>> getBlockDistribution(Region region, boolean separateStates) {
|
||||
if (separateStates) return getBlockDistributionWithData(region);
|
||||
if (separateStates) {
|
||||
return getBlockDistributionWithData(region);
|
||||
}
|
||||
List<Countable<BlockType>> normalDistr = getBlockDistribution(region);
|
||||
List<Countable<BlockState>> distribution = new ArrayList<>();
|
||||
for (Countable<BlockType> count : normalDistr) {
|
||||
@ -2363,8 +2408,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @param expressionString the expression defining the shape
|
||||
* @param hollow whether the shape should be hollow
|
||||
* @return number of blocks changed
|
||||
* @throws ExpressionException Thrown when there's a problem during any stage of the expression compilation or evaluation.
|
||||
* @throws MaxChangedBlocksException Thrown when the block limit has been reached
|
||||
* @throws ExpressionException if there is a problem with the expression
|
||||
* @throws MaxChangedBlocksException if the maximum block change limit is exceeded
|
||||
*/
|
||||
public int makeShape(final Region region, final Vector3 zero, final Vector3 unit,
|
||||
final Pattern pattern, final String expressionString, final boolean hollow)
|
||||
@ -2383,11 +2428,11 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @param hollow whether the shape should be hollow
|
||||
* @param timeout the time, in milliseconds, to wait for each expression evaluation before halting it. -1 to disable
|
||||
* @return number of blocks changed
|
||||
* @throws ExpressionException Thrown when there's a problem during any stage of the expression compilation or evaluation.
|
||||
* @throws MaxChangedBlocksException Thrown when the block limit has been reached
|
||||
* @throws ExpressionException if there is a problem with the expression
|
||||
* @throws MaxChangedBlocksException if the maximum block change limit is exceeded
|
||||
*/
|
||||
public int makeShape(final Region region, final Vector3 zero, final Vector3 unit,
|
||||
final Pattern pattern, final String expressionString, final boolean hollow, final int timeout)
|
||||
final Pattern pattern, final String expressionString, final boolean hollow, final int timeout)
|
||||
throws ExpressionException, MaxChangedBlocksException {
|
||||
final Expression expression = Expression.compile(expressionString, "x", "y", "z", "type", "data");
|
||||
expression.optimize();
|
||||
@ -2548,63 +2593,64 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
public int hollowOutRegion(Region region, int thickness, Pattern pattern, Mask mask) {
|
||||
try {
|
||||
final Set<BlockVector3> outside = new LocalBlockVectorSet();
|
||||
final Set<BlockVector3> outside = new LocalBlockVectorSet();
|
||||
|
||||
final BlockVector3 min = region.getMinimumPoint();
|
||||
final BlockVector3 max = region.getMaximumPoint();
|
||||
final BlockVector3 min = region.getMinimumPoint();
|
||||
final BlockVector3 max = region.getMaximumPoint();
|
||||
|
||||
final int minX = min.getBlockX();
|
||||
final int minY = min.getBlockY();
|
||||
final int minZ = min.getBlockZ();
|
||||
final int maxX = max.getBlockX();
|
||||
final int maxY = max.getBlockY();
|
||||
final int maxZ = max.getBlockZ();
|
||||
final int minX = min.getBlockX();
|
||||
final int minY = min.getBlockY();
|
||||
final int minZ = min.getBlockZ();
|
||||
final int maxX = max.getBlockX();
|
||||
final int maxY = max.getBlockY();
|
||||
final int maxZ = max.getBlockZ();
|
||||
|
||||
for (int x = minX; x <= maxX; ++x) {
|
||||
for (int y = minY; y <= maxY; ++y) {
|
||||
recurseHollow(region, BlockVector3.at(x, y, minZ), outside, mask);
|
||||
recurseHollow(region, BlockVector3.at(x, y, maxZ), outside, mask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = minY; y <= maxY; ++y) {
|
||||
for (int z = minZ; z <= maxZ; ++z) {
|
||||
recurseHollow(region, BlockVector3.at(minX, y, z), outside, mask);
|
||||
recurseHollow(region, BlockVector3.at(maxX, y, z), outside, mask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int z = minZ; z <= maxZ; ++z) {
|
||||
for (int x = minX; x <= maxX; ++x) {
|
||||
recurseHollow(region, BlockVector3.at(x, minY, z), outside, mask);
|
||||
recurseHollow(region, BlockVector3.at(x, maxY, z), outside, mask);
|
||||
for (int y = minY; y <= maxY; ++y) {
|
||||
recurseHollow(region, BlockVector3.at(x, y, minZ), outside, mask);
|
||||
recurseHollow(region, BlockVector3.at(x, y, maxZ), outside, mask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = minY; y <= maxY; ++y) {
|
||||
for (int z = minZ; z <= maxZ; ++z) {
|
||||
recurseHollow(region, BlockVector3.at(minX, y, z), outside, mask);
|
||||
recurseHollow(region, BlockVector3.at(maxX, y, z), outside, mask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int z = minZ; z <= maxZ; ++z) {
|
||||
for (int x = minX; x <= maxX; ++x) {
|
||||
recurseHollow(region, BlockVector3.at(x, minY, z), outside, mask);
|
||||
recurseHollow(region, BlockVector3.at(x, maxY, z), outside, mask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < thickness; ++i) {
|
||||
final Set<BlockVector3> newOutside = new LocalBlockVectorSet();
|
||||
outer: for (BlockVector3 position : region) {
|
||||
for (BlockVector3 recurseDirection : recurseDirections) {
|
||||
BlockVector3 neighbor = position.add(recurseDirection);
|
||||
|
||||
if (outside.contains(neighbor)) {
|
||||
newOutside.add(position);
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outside.addAll(newOutside);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < thickness; ++i) {
|
||||
final Set<BlockVector3> newOutside = new LocalBlockVectorSet();
|
||||
outer: for (BlockVector3 position : region) {
|
||||
for (BlockVector3 recurseDirection : recurseDirections) {
|
||||
BlockVector3 neighbor = position.add(recurseDirection);
|
||||
|
||||
if (outside.contains(neighbor)) {
|
||||
newOutside.add(position);
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outside.addAll(newOutside);
|
||||
}
|
||||
|
||||
outer: for (BlockVector3 position : region) {
|
||||
for (BlockVector3 recurseDirection : recurseDirections) {
|
||||
BlockVector3 neighbor = position.add(recurseDirection);
|
||||
if (outside.contains(neighbor)) {
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
this.changes++;
|
||||
this.changes++;
|
||||
pattern.apply(getExtent(), position, position);
|
||||
}
|
||||
} catch (WorldEditException e) {
|
||||
@ -2632,15 +2678,23 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @see #drawLine(Pattern, List, double, boolean)
|
||||
*/
|
||||
public int drawLine(Pattern pattern, BlockVector3 pos1, BlockVector3 pos2, double radius, boolean filled, boolean flat)
|
||||
throws MaxChangedBlocksException {
|
||||
throws MaxChangedBlocksException {
|
||||
|
||||
LocalBlockVectorSet vset = new LocalBlockVectorSet();
|
||||
boolean notdrawn = true;
|
||||
|
||||
int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ();
|
||||
int x2 = pos2.getBlockX(), y2 = pos2.getBlockY(), z2 = pos2.getBlockZ();
|
||||
int tipx = x1, tipy = y1, tipz = z1;
|
||||
int dx = Math.abs(x2 - x1), dy = Math.abs(y2 - y1), dz = Math.abs(z2 - z1);
|
||||
int x1 = pos1.getBlockX();
|
||||
int y1 = pos1.getBlockY();
|
||||
int z1 = pos1.getBlockZ();
|
||||
int x2 = pos2.getBlockX();
|
||||
int y2 = pos2.getBlockY();
|
||||
int z2 = pos2.getBlockZ();
|
||||
int tipx = x1;
|
||||
int tipy = y1;
|
||||
int tipz = z1;
|
||||
int dx = Math.abs(x2 - x1);
|
||||
int dy = Math.abs(y2 - y1);
|
||||
int dz = Math.abs(z2 - z1);
|
||||
|
||||
if (dx + dy + dz == 0) {
|
||||
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
||||
@ -2667,8 +2721,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
} else if (dMax == dz && notdrawn) {
|
||||
for (int domstep = 0; domstep <= dz; domstep++) {
|
||||
tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1);
|
||||
tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dz * (y2-y1>0 ? 1 : -1));
|
||||
tipx = (int) Math.round(x1 + domstep * (double) dx / (double) dz * (x2-x1>0 ? 1 : -1));
|
||||
tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dz * (y2 - y1 > 0 ? 1 : -1));
|
||||
tipx = (int) Math.round(x1 + domstep * (double) dx / (double) dz * (x2 - x1 > 0 ? 1 : -1));
|
||||
|
||||
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
||||
}
|
||||
@ -2708,10 +2762,18 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
BlockVector3 pos1 = vectors.get(i);
|
||||
BlockVector3 pos2 = vectors.get(i + 1);
|
||||
|
||||
int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ();
|
||||
int x2 = pos2.getBlockX(), y2 = pos2.getBlockY(), z2 = pos2.getBlockZ();
|
||||
int tipx = x1, tipy = y1, tipz = z1;
|
||||
int dx = Math.abs(x2 - x1), dy = Math.abs(y2 - y1), dz = Math.abs(z2 - z1);
|
||||
int x1 = pos1.getBlockX();
|
||||
int y1 = pos1.getBlockY();
|
||||
int z1 = pos1.getBlockZ();
|
||||
int x2 = pos2.getBlockX();
|
||||
int y2 = pos2.getBlockY();
|
||||
int z2 = pos2.getBlockZ();
|
||||
int tipx = x1;
|
||||
int tipy = y1;
|
||||
int tipz = z1;
|
||||
int dx = Math.abs(x2 - x1);
|
||||
int dy = Math.abs(y2 - y1);
|
||||
int dz = Math.abs(z2 - z1);
|
||||
|
||||
if (dx + dy + dz == 0) {
|
||||
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
||||
@ -2738,8 +2800,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
} else /* if (dMax == dz) */ {
|
||||
for (int domstep = 0; domstep <= dz; domstep++) {
|
||||
tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1);
|
||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2-y1>0 ? 1 : -1));
|
||||
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2-x1>0 ? 1 : -1));
|
||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2 - y1 > 0 ? 1 : -1));
|
||||
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2 - x1 > 0 ? 1 : -1));
|
||||
|
||||
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
||||
}
|
||||
@ -2815,7 +2877,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
int ceilrad = (int) Math.ceil(radius);
|
||||
|
||||
for (BlockVector3 v : vset) {
|
||||
int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
|
||||
int tipx = v.getBlockX();
|
||||
int tipy = v.getBlockY();
|
||||
int tipz = v.getBlockZ();
|
||||
|
||||
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
|
||||
for (int loopy = tipy - ceilrad; loopy <= tipy + ceilrad; loopy++) {
|
||||
@ -2837,7 +2901,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
final LocalBlockVectorSet returnset = new LocalBlockVectorSet();
|
||||
final int ceilrad = (int) Math.ceil(radius);
|
||||
for (BlockVector3 v : vset) {
|
||||
final int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
|
||||
final int tipx = v.getBlockX();
|
||||
final int tipy = v.getBlockY();
|
||||
final int tipz = v.getBlockZ();
|
||||
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
|
||||
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
|
||||
if (MathMan.hypot(loopx - tipx, 0, loopz - tipz) <= radius) {
|
||||
@ -2854,11 +2920,13 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
final LocalBlockVectorSet newset = new LocalBlockVectorSet();
|
||||
newset.addAll(vset);
|
||||
for (BlockVector3 v : newset) {
|
||||
final int x = v.getX(), y = v.getY(), z = v.getZ();
|
||||
if (!(newset.contains(x + 1, y, z) &&
|
||||
newset.contains(x - 1, y, z) &&
|
||||
newset.contains(x, y, z + 1) &&
|
||||
newset.contains(x, y, z - 1))) {
|
||||
final int x = v.getX();
|
||||
final int y = v.getY();
|
||||
final int z = v.getZ();
|
||||
if (!(newset.contains(x + 1, y, z)
|
||||
&& newset.contains(x - 1, y, z)
|
||||
&& newset.contains(x, y, z + 1)
|
||||
&& newset.contains(x, y, z - 1))) {
|
||||
returnset.add(v);
|
||||
}
|
||||
}
|
||||
@ -2870,13 +2938,15 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
final LocalBlockVectorSet newset = new LocalBlockVectorSet();
|
||||
newset.addAll(vset);
|
||||
for (BlockVector3 v : newset) {
|
||||
final int x = v.getX(), y = v.getY(), z = v.getZ();
|
||||
if (!(newset.contains(x + 1, y, z) &&
|
||||
newset.contains(x - 1, y, z) &&
|
||||
newset.contains(x, y + 1, z) &&
|
||||
newset.contains(x, y - 1, z) &&
|
||||
newset.contains(x, y, z + 1) &&
|
||||
newset.contains(x, y, z - 1))) {
|
||||
final int x = v.getX();
|
||||
final int y = v.getY();
|
||||
final int z = v.getZ();
|
||||
if (!(newset.contains(x + 1, y, z)
|
||||
&& newset.contains(x - 1, y, z)
|
||||
&& newset.contains(x, y + 1, z)
|
||||
&& newset.contains(x, y - 1, z)
|
||||
&& newset.contains(x, y, z + 1)
|
||||
&& newset.contains(x, y, z - 1))) {
|
||||
returnset.add(v);
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ public class LocalSession implements TextureHolder {
|
||||
private transient final Object clipboardLock = new Object();
|
||||
private transient boolean superPickaxe = false;
|
||||
private transient BlockTool pickaxeMode = new SinglePickaxe();
|
||||
private transient final Int2ObjectOpenHashMap<Tool> tools = new Int2ObjectOpenHashMap<>(0);
|
||||
private final transient Int2ObjectOpenHashMap<Tool> tools = new Int2ObjectOpenHashMap<>(0);
|
||||
private transient int maxBlocksChanged = -1;
|
||||
private transient int maxTimeoutTime;
|
||||
private transient boolean useInventory;
|
||||
@ -245,9 +245,13 @@ public class LocalSession implements TextureHolder {
|
||||
|
||||
} else {
|
||||
int i = name.lastIndexOf('.');
|
||||
if (i != -1) val = StringMan.toInteger(name, 0, i);
|
||||
if (i != -1) {
|
||||
val = StringMan.toInteger(name, 0, i);
|
||||
}
|
||||
}
|
||||
if (val != null) {
|
||||
set.set(val);
|
||||
}
|
||||
if (val != null) set.set(val);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
@ -402,7 +406,9 @@ public class LocalSession implements TextureHolder {
|
||||
checkNotNull(editSession);
|
||||
|
||||
// Don't store anything if no changes were made
|
||||
if (editSession.size() == 0) return;
|
||||
if (editSession.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = editSession.getPlayer();
|
||||
int limit = player == null ? Integer.MAX_VALUE : player.getLimit().MAX_HISTORY;
|
||||
@ -721,7 +727,8 @@ public class LocalSession implements TextureHolder {
|
||||
return selector.getRegion();
|
||||
}
|
||||
|
||||
public @Nullable VirtualWorld getVirtualWorld() {
|
||||
@Nullable
|
||||
public VirtualWorld getVirtualWorld() {
|
||||
synchronized (dirty) {
|
||||
return virtual;
|
||||
}
|
||||
@ -814,8 +821,9 @@ public class LocalSession implements TextureHolder {
|
||||
*/
|
||||
public void setClipboard(@Nullable ClipboardHolder clipboard) {
|
||||
synchronized (clipboardLock) {
|
||||
if (this.clipboard == clipboard)
|
||||
if (this.clipboard == clipboard) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.clipboard != null) {
|
||||
if (clipboard == null || !clipboard.contains(this.clipboard.getClipboard())) {
|
||||
@ -990,7 +998,8 @@ public class LocalSession implements TextureHolder {
|
||||
*
|
||||
* @return the snapshot
|
||||
*/
|
||||
public @Nullable Snapshot getSnapshotExperimental() {
|
||||
@Nullable
|
||||
public Snapshot getSnapshotExperimental() {
|
||||
return snapshotExperimental;
|
||||
}
|
||||
|
||||
@ -1051,7 +1060,9 @@ public class LocalSession implements TextureHolder {
|
||||
public Tool getTool(BaseItem item, Player player) {
|
||||
if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) {
|
||||
BrushTool tool = BrushCache.getTool(player, this, item);
|
||||
if (tool != null) return tool;
|
||||
if (tool != null) {
|
||||
return tool;
|
||||
}
|
||||
}
|
||||
loadDefaults(player, false);
|
||||
return getTool(item.getType());
|
||||
@ -1244,7 +1255,9 @@ public class LocalSession implements TextureHolder {
|
||||
* @param actor the actor
|
||||
*/
|
||||
public void tellVersion(Actor actor) {
|
||||
if (hasBeenToldVersion) return;
|
||||
if (hasBeenToldVersion) {
|
||||
return;
|
||||
}
|
||||
hasBeenToldVersion = true;
|
||||
actor.sendAnnouncements();
|
||||
}
|
||||
|
@ -42,7 +42,8 @@ public class WorldEditManifest {
|
||||
);
|
||||
}
|
||||
|
||||
private static @Nullable Attributes readAttributes() {
|
||||
@Nullable
|
||||
private static Attributes readAttributes() {
|
||||
Class<WorldEditManifest> clazz = WorldEditManifest.class;
|
||||
String className = clazz.getSimpleName() + ".class";
|
||||
String classPath = clazz.getResource(className).toString();
|
||||
|
@ -62,7 +62,8 @@ public class BaseItem implements NbtValued {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public @Nullable Object getNativeItem() {
|
||||
@Nullable
|
||||
public Object getNativeItem() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -62,12 +62,12 @@ import static org.enginehub.piston.part.CommandParts.arg;
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class ApplyBrushCommands {
|
||||
|
||||
private static final CommandArgument REGION_FACTORY = arg(TranslatableComponent.of("shape") , TranslatableComponent.of("worldedit.brush.apply.shape"))
|
||||
private static final CommandArgument REGION_FACTORY = arg(TranslatableComponent.of("shape"), TranslatableComponent.of("worldedit.brush.apply.shape"))
|
||||
.defaultsTo(ImmutableList.of())
|
||||
.ofTypes(ImmutableList.of(Key.of(RegionFactory.class)))
|
||||
.build();
|
||||
|
||||
private static final CommandArgument RADIUS = arg(TranslatableComponent.of("radius") , TranslatableComponent.of("worldedit.brush.apply.radius"))
|
||||
private static final CommandArgument RADIUS = arg(TranslatableComponent.of("radius"), TranslatableComponent.of("worldedit.brush.apply.radius"))
|
||||
.defaultsTo(ImmutableList.of("5"))
|
||||
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
||||
.build();
|
||||
@ -86,7 +86,7 @@ public class ApplyBrushCommands {
|
||||
|
||||
builder.condition(new PermissionCondition(ImmutableSet.of("worldedit.brush.apply")));
|
||||
builder.addParts(REGION_FACTORY, RADIUS);
|
||||
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type") , TranslatableComponent.of("worldedit.brush.apply.type"))
|
||||
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TranslatableComponent.of("worldedit.brush.apply.type"))
|
||||
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
|
||||
.required()
|
||||
.build());
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -133,7 +133,7 @@ public class ClipboardCommands {
|
||||
session.setClipboard(null);
|
||||
|
||||
Clipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId());
|
||||
|
||||
|
||||
clipboard.setOrigin(centerClipboard ? region.getCenter().toBlockPoint() : session.getPlacementPosition(actor));
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||
copy.setCopyingEntities(copyEntities);
|
||||
@ -156,16 +156,15 @@ public class ClipboardCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/lazycopy",
|
||||
desc = "Lazily copy the selection to the clipboard"
|
||||
name = "/lazycopy",
|
||||
desc = "Lazily copy the selection to the clipboard"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.lazycopy")
|
||||
public void lazyCopy(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
public void lazyCopy(Actor actor, LocalSession session, EditSession editSession, @Selection Region region,
|
||||
@Switch(name = 'e', desc = "Skip copy entities")
|
||||
boolean skipEntities,
|
||||
boolean skipEntities,
|
||||
@Switch(name = 'b', desc = "Also copy biomes")
|
||||
boolean copyBiomes) throws WorldEditException {
|
||||
boolean copyBiomes) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
@ -178,39 +177,40 @@ public class ClipboardCommands {
|
||||
|
||||
lazyClipboard.setOrigin(session.getPlacementPosition(actor));
|
||||
session.setClipboard(new ClipboardHolder(lazyClipboard));
|
||||
actor.print(Caption.of("fawe.worldedit.copy.command.copy" , region.getVolume()));
|
||||
actor.print(Caption.of("fawe.worldedit.copy.command.copy", region.getVolume()));
|
||||
}
|
||||
|
||||
// @Command(
|
||||
// name = "/lazycut",
|
||||
// desc = "Lazily cut the selection to the clipboard"
|
||||
// )
|
||||
// @CommandPermissions("worldedit.clipboard.lazycut")
|
||||
// public void lazyCut(Actor actor, LocalSession session, EditSession editSession,
|
||||
// @Selection final Region region,
|
||||
// @Switch(name = 'e', desc = "Skip copy entities")
|
||||
// boolean skipEntities,
|
||||
// @ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
|
||||
// Mask maskOpt,
|
||||
// @Switch(name = 'b', desc = "Also copy biomes")
|
||||
// boolean copyBiomes) throws WorldEditException {
|
||||
// BlockVector3 min = region.getMinimumPoint();
|
||||
// BlockVector3 max = region.getMaximumPoint();
|
||||
// long volume = ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1);
|
||||
// FaweLimit limit = actor.getLimit();
|
||||
// if (volume >= limit.MAX_CHECKS) {
|
||||
// throw FaweCache.MAX_CHECKS;
|
||||
// }
|
||||
// if (volume >= limit.MAX_CHANGES) {
|
||||
// throw FaweCache.MAX_CHANGES;
|
||||
// }
|
||||
// session.setClipboard(null);
|
||||
//
|
||||
// ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes);
|
||||
// clipboard.setOrigin(session.getPlacementPosition(actor));
|
||||
// session.setClipboard(new ClipboardHolder(lazyClipboard));
|
||||
// actor.print(TranslatableComponent.of("fawe.worldedit.cut.command.cut.lazy" , region.getArea()));
|
||||
// }
|
||||
/*
|
||||
@Command(
|
||||
name = "/lazycut",
|
||||
desc = "Lazily cut the selection to the clipboard"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.lazycut")
|
||||
public void lazyCut(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Selection final Region region,
|
||||
@Switch(name = 'e', desc = "Skip copy entities")
|
||||
boolean skipEntities,
|
||||
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
|
||||
Mask maskOpt,
|
||||
@Switch(name = 'b', desc = "Also copy biomes")
|
||||
boolean copyBiomes) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long volume = ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1);
|
||||
FaweLimit limit = actor.getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw FaweCache.MAX_CHECKS;
|
||||
}
|
||||
if (volume >= limit.MAX_CHANGES) {
|
||||
throw FaweCache.MAX_CHANGES;
|
||||
}
|
||||
session.setClipboard(null);
|
||||
|
||||
ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes);
|
||||
clipboard.setOrigin(session.getPlacementPosition(actor));
|
||||
session.setClipboard(new ClipboardHolder(lazyClipboard));
|
||||
actor.print(TranslatableComponent.of("fawe.worldedit.cut.command.cut.lazy", region.getArea()));
|
||||
}*/
|
||||
|
||||
@Command(
|
||||
name = "/cut",
|
||||
@ -267,24 +267,24 @@ public class ClipboardCommands {
|
||||
if (!actor.hasPermission("fawe.tips")) {
|
||||
actor.print(TranslatableComponent.of("fawe.tips.tip.lazycut"));
|
||||
}
|
||||
copy.getStatusMessages().forEach(actor::print);
|
||||
copy.getStatusMessages().forEach(actor::print);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "download",
|
||||
aliases = { "/download" },
|
||||
desc = "Downloads your clipboard through the configured web interface"
|
||||
name = "download",
|
||||
aliases = { "/download" },
|
||||
desc = "Downloads your clipboard through the configured web interface"
|
||||
)
|
||||
@Deprecated
|
||||
@CommandPermissions({"worldedit.clipboard.download"})
|
||||
public void download(final Player player, final LocalSession session, @Arg(name = "format", desc = "String", def = "schem") final String formatName) throws WorldEditException {
|
||||
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||
if (format == null) {
|
||||
player.print(Caption.of("fawe.worldedit.clipboard.clipboard.invalid.format" , formatName));
|
||||
player.print(Caption.of("fawe.worldedit.clipboard.clipboard.invalid.format", formatName));
|
||||
return;
|
||||
}
|
||||
|
||||
player.print(Caption.of("fawe.web.generating.link" , formatName));
|
||||
player.print(Caption.of("fawe.web.generating.link", formatName));
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
|
||||
URL url;
|
||||
@ -370,7 +370,7 @@ public class ClipboardCommands {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
player.print(Caption.of("fawe.web.download.link" , urlText).clickEvent(ClickEvent.openUrl(urlText)));
|
||||
player.print(Caption.of("fawe.web.download.link", urlText).clickEvent(ClickEvent.openUrl(urlText)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -412,9 +412,13 @@ public class ClipboardCommands {
|
||||
checkPaste(actor, editSession, to, holder, clipboard);
|
||||
|
||||
if (!onlySelect) {
|
||||
Operation operation =
|
||||
holder.createPaste(editSession).to(to).ignoreAirBlocks(ignoreAirBlocks)
|
||||
.copyBiomes(pasteBiomes).copyEntities(pasteEntities).maskSource(sourceMask)
|
||||
Operation operation = holder
|
||||
.createPaste(editSession)
|
||||
.to(to)
|
||||
.ignoreAirBlocks(ignoreAirBlocks)
|
||||
.copyBiomes(pasteBiomes)
|
||||
.copyEntities(pasteEntities)
|
||||
.maskSource(sourceMask)
|
||||
.build();
|
||||
Operations.completeLegacy(operation);
|
||||
messages.addAll(Lists.newArrayList(operation.getStatusMessages()));
|
||||
@ -451,23 +455,22 @@ public class ClipboardCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/place",
|
||||
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)"
|
||||
)
|
||||
|
||||
name = "/place",
|
||||
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.place")
|
||||
@Logging(PLACEMENT)
|
||||
public void place(Actor actor, World world, LocalSession session, final EditSession editSession,
|
||||
@Switch(name = 'a', desc = "Skip air blocks")
|
||||
boolean ignoreAirBlocks,
|
||||
boolean ignoreAirBlocks,
|
||||
@Switch(name = 'o', desc = "Paste at the original position")
|
||||
boolean atOrigin,
|
||||
boolean atOrigin,
|
||||
@Switch(name = 's', desc = "Select the region after pasting")
|
||||
boolean selectPasted,
|
||||
boolean selectPasted,
|
||||
@Switch(name = 'e', desc = "Paste entities if available")
|
||||
boolean pasteEntities,
|
||||
boolean pasteEntities,
|
||||
@Switch(name = 'b', desc = "Paste biomes if available")
|
||||
boolean pasteBiomes) throws WorldEditException {
|
||||
boolean pasteBiomes) throws WorldEditException {
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
final Clipboard clipboard = holder.getClipboard();
|
||||
final BlockVector3 origin = clipboard.getOrigin();
|
||||
@ -486,7 +489,7 @@ public class ClipboardCommands {
|
||||
selector.learnChanges();
|
||||
selector.explainRegionAdjust(actor, session);
|
||||
}
|
||||
actor.print(Caption.of("fawe.worldedit.paste.command.paste" , to));
|
||||
actor.print(Caption.of("fawe.worldedit.paste.command.paste", to));
|
||||
|
||||
if (!actor.hasPermission("fawe.tips")) {
|
||||
actor.print(TranslatableComponent.of("fawe.tips.tip.copypaste"));
|
||||
@ -496,23 +499,23 @@ public class ClipboardCommands {
|
||||
@Command(
|
||||
name = "/rotate",
|
||||
desc = "Rotate the contents of the clipboard",
|
||||
descFooter = "Non-destructively rotate the contents of the clipboard.\n" +
|
||||
"Angles are provided in degrees and a positive angle will result in a clockwise rotation. " +
|
||||
"Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.\n"
|
||||
descFooter = "Non-destructively rotate the contents of the clipboard.\n"
|
||||
+ "Angles are provided in degrees and a positive angle will result in a clockwise rotation. "
|
||||
+ "Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.\n"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.rotate")
|
||||
public void rotate(Actor actor, LocalSession session,
|
||||
@Arg(desc = "Amount to rotate on the y-axis")
|
||||
double yRotate,
|
||||
double rotateY,
|
||||
@Arg(desc = "Amount to rotate on the x-axis", def = "0")
|
||||
double xRotate,
|
||||
double rotateX,
|
||||
@Arg(desc = "Amount to rotate on the z-axis", def = "0")
|
||||
double zRotate) throws WorldEditException {
|
||||
double rotateZ) throws WorldEditException {
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
AffineTransform transform = new AffineTransform();
|
||||
transform = transform.rotateY(-yRotate);
|
||||
transform = transform.rotateX(-xRotate);
|
||||
transform = transform.rotateZ(-zRotate);
|
||||
transform = transform.rotateY(-rotateY);
|
||||
transform = transform.rotateX(-rotateX);
|
||||
transform = transform.rotateZ(-rotateZ);
|
||||
holder.setTransform(holder.getTransform().combine(transform));
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.rotate.rotated"));
|
||||
}
|
||||
|
@ -113,7 +113,9 @@ public class FlattenedClipboardTransform {
|
||||
*/
|
||||
public Operation copyTo(Extent target) {
|
||||
Extent extent = original;
|
||||
if (transform != null && !transform.isIdentity()) extent = new BlockTransformExtent(original, transform);
|
||||
if (transform != null && !transform.isIdentity()) {
|
||||
extent = new BlockTransformExtent(original, transform);
|
||||
}
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(extent, original.getRegion(), original.getOrigin(), target, original.getOrigin());
|
||||
copy.setTransform(transform);
|
||||
if (original.hasBiomes()) {
|
||||
|
@ -409,12 +409,18 @@ public class GeneralCommands {
|
||||
// complexity
|
||||
int min = Integer.parseInt(arguments.get(0));
|
||||
int max = Integer.parseInt(arguments.get(1));
|
||||
if (min < 0 || max > 100) throw new InputParseException("Complexity must be in the range 0-100");
|
||||
if (min != 0 || max != 100) util = new CleanTextureUtil(util, min, max);
|
||||
if (min < 0 || max > 100) {
|
||||
throw new InputParseException("Complexity must be in the range 0-100");
|
||||
}
|
||||
if (min != 0 || max != 100) {
|
||||
util = new CleanTextureUtil(util, min, max);
|
||||
}
|
||||
|
||||
randomIndex = 2;
|
||||
} else if (arguments.size() == 1 && argLower.equals("true") || argLower.equals("false")) {
|
||||
if (argLower.equals("true")) util = new RandomTextureUtil(util);
|
||||
if (argLower.equals("true")) {
|
||||
util = new RandomTextureUtil(util);
|
||||
}
|
||||
checkRandomization = false;
|
||||
} else {
|
||||
if (argLower.equals("#copy") || argLower.equals("#clipboard")) {
|
||||
@ -435,20 +441,24 @@ public class GeneralCommands {
|
||||
if (checkRandomization) {
|
||||
if (arguments.size() > randomIndex) {
|
||||
boolean random = Boolean.parseBoolean(arguments.get(randomIndex));
|
||||
if (random) util = new RandomTextureUtil(util);
|
||||
if (random) {
|
||||
util = new RandomTextureUtil(util);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(util instanceof CachedTextureUtil)) util = new CachedTextureUtil(util);
|
||||
if (!(util instanceof CachedTextureUtil)) {
|
||||
util = new CachedTextureUtil(util);
|
||||
}
|
||||
session.setTextureUtil(util);
|
||||
player.print(Caption.of("fawe.worldedit.general.texture.set" , StringMan.join(arguments, " ")));
|
||||
player.print(Caption.of("fawe.worldedit.general.texture.set", StringMan.join(arguments, " ")));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/gsmask",
|
||||
aliases = {"gsmask", "globalsourcemask", "/globalsourcemask"},
|
||||
desc = "Set the global source mask",
|
||||
descFooter = "The global source mask applies to all edits you do and masks based on the source blocks (e.g., the blocks in your clipboard)"
|
||||
name = "/gsmask",
|
||||
aliases = {"gsmask", "globalsourcemask", "/globalsourcemask"},
|
||||
desc = "Set the global source mask",
|
||||
descFooter = "The global source mask applies to all edits you do and masks based on the source blocks (e.g., the blocks in your clipboard)"
|
||||
)
|
||||
@CommandPermissions({"worldedit.global-mask", "worldedit.mask.global"})
|
||||
public void gsmask(Player player, LocalSession session, EditSession editSession, @Arg(desc = "The mask to set", def = "") Mask maskOpt) throws WorldEditException {
|
||||
@ -462,9 +472,9 @@ public class GeneralCommands {
|
||||
|
||||
|
||||
@Command(
|
||||
name = "/gtransform",
|
||||
aliases = {"gtransform"},
|
||||
desc = "Set the global transform"
|
||||
name = "/gtransform",
|
||||
aliases = {"gtransform"},
|
||||
desc = "Set the global transform"
|
||||
)
|
||||
@CommandPermissions({"worldedit.global-transform", "worldedit.transform.global"})
|
||||
public void gtransform(Player player, EditSession editSession, LocalSession session, ResettableExtent transform) throws WorldEditException {
|
||||
@ -477,9 +487,9 @@ public class GeneralCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/tips",
|
||||
aliases = {"tips"},
|
||||
desc = "Toggle FAWE tips"
|
||||
name = "/tips",
|
||||
aliases = {"tips"},
|
||||
desc = "Toggle FAWE tips"
|
||||
)
|
||||
@CommandPermissions("fawe.tips")
|
||||
public void tips(Player player, LocalSession session) throws WorldEditException {
|
||||
|
@ -108,26 +108,26 @@ public class GenerationCommands {
|
||||
@Arg(name = "pocketMax", desc = "TODO", def = "3") int pocketMaxOpt) throws WorldEditException {
|
||||
CavesGen gen = new CavesGen(sizeOpt, frequencyOpt, rarityOpt, minYOpt, maxYOpt, systemFrequencyOpt, individualRarityOpt, pocketChanceOpt, pocketMinOpt, pocketMaxOpt);
|
||||
editSession.generate(region, gen);
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount()));
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
name = "/ores",
|
||||
desc = "Generates ores"
|
||||
name = "/ores",
|
||||
desc = "Generates ores"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.ore")
|
||||
@Logging(PLACEMENT)
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
public void ores(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask) throws WorldEditException {
|
||||
editSession.addOres(region, mask);
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount()));
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/img",
|
||||
aliases = { "/image", "image" },
|
||||
desc = "Generate an image"
|
||||
name = "/img",
|
||||
aliases = { "/image", "image" },
|
||||
desc = "Generate an image"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.image")
|
||||
@Logging(PLACEMENT)
|
||||
@ -155,7 +155,9 @@ public class GenerationCommands {
|
||||
int color = finalImage.getRGB(x, z);
|
||||
BlockType block = tu.getNearestBlock(color);
|
||||
count[0]++;
|
||||
if (block != null) return editSession.setBlock(pos, block.getDefaultState());
|
||||
if (block != null) {
|
||||
return editSession.setBlock(pos, block.getDefaultState());
|
||||
}
|
||||
return false;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
@ -163,19 +165,19 @@ public class GenerationCommands {
|
||||
return false;
|
||||
});
|
||||
Operations.completeBlindly(visitor);
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount()));
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/ore",
|
||||
desc = "Generates ores"
|
||||
name = "/ore",
|
||||
desc = "Generates ores"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.ore")
|
||||
@Logging(PLACEMENT)
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
public void ore(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask, @Arg(desc = "Pattern") Pattern material, @Arg(desc="Ore vein size") @Range(from = 0, to=Integer.MAX_VALUE) int size, int freq, @Range(from=0, to=100) int rarity, @Range(from=0, to=255) int minY, @Range(from=0, to=255) int maxY) throws WorldEditException {
|
||||
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount()));
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -211,7 +213,8 @@ public class GenerationCommands {
|
||||
int height,
|
||||
@Switch(name = 'h', desc = "Make a hollow cylinder")
|
||||
boolean hollow) throws WorldEditException {
|
||||
final double radiusX, radiusZ;
|
||||
final double radiusX;
|
||||
final double radiusZ;
|
||||
switch (radii.size()) {
|
||||
case 1:
|
||||
radiusX = radiusZ = Math.max(1, radii.get(0));
|
||||
@ -270,7 +273,9 @@ public class GenerationCommands {
|
||||
boolean raised,
|
||||
@Switch(name = 'h', desc = "Make a hollow sphere")
|
||||
boolean hollow) throws WorldEditException {
|
||||
final double radiusX, radiusY, radiusZ;
|
||||
final double radiusX;
|
||||
final double radiusY;
|
||||
final double radiusZ;
|
||||
switch (radii.size()) {
|
||||
case 1:
|
||||
radiusX = radiusY = radiusZ = Math.max(0, radii.get(0));
|
||||
@ -427,9 +432,15 @@ public class GenerationCommands {
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit = unit.withX(1.0);
|
||||
if (unit.getY() == 0) unit = unit.withY(1.0);
|
||||
if (unit.getZ() == 0) unit = unit.withZ(1.0);
|
||||
if (unit.getX() == 0) {
|
||||
unit = unit.withX(1.0);
|
||||
}
|
||||
if (unit.getY() == 0) {
|
||||
unit = unit.withY(1.0);
|
||||
}
|
||||
if (unit.getZ() == 0) {
|
||||
unit = unit.withZ(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
final Vector3 unit1 = unit;
|
||||
@ -451,9 +462,9 @@ public class GenerationCommands {
|
||||
name = "/generatebiome",
|
||||
aliases = { "/genbiome", "/gb" },
|
||||
desc = "Sets biome according to a formula.",
|
||||
descFooter = "Formula must return positive numbers (true) if the point is inside the shape\n" +
|
||||
"Sets the biome of blocks in that shape.\n"
|
||||
+"See also https://tinyurl.com/weexpr."
|
||||
descFooter = "Formula must return positive numbers (true) if the point is inside the shape\n"
|
||||
+ "Sets the biome of blocks in that shape.\n"
|
||||
+ "See also https://tinyurl.com/weexpr."
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.shape.biome")
|
||||
@Logging(ALL)
|
||||
@ -494,9 +505,15 @@ public class GenerationCommands {
|
||||
zero = max.add(min).multiply(0.5);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit = unit.withX(1.0);
|
||||
if (unit.getY() == 0) unit = unit.withY(1.0);
|
||||
if (unit.getZ() == 0) unit = unit.withZ(1.0);
|
||||
if (unit.getX() == 0) {
|
||||
unit = unit.withX(1.0);
|
||||
}
|
||||
if (unit.getY() == 0) {
|
||||
unit = unit.withY(1.0);
|
||||
}
|
||||
if (unit.getZ() == 0) {
|
||||
unit = unit.withZ(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
final Vector3 unit1 = unit;
|
||||
|
@ -70,50 +70,62 @@ public class HistorySubCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "restore",
|
||||
aliases = {"rerun"},
|
||||
desc = "Rerun edits" +
|
||||
" - The time uses s, m, h, d, y.\n" +
|
||||
" - Import from disk: /history import"
|
||||
name = "restore",
|
||||
aliases = {"rerun"},
|
||||
desc = "Rerun edits"
|
||||
+ " - The time uses s, m, h, d, y.\n"
|
||||
+ " - Import from disk: /history import"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.redo")
|
||||
@Confirm
|
||||
public synchronized void rerun(Player player, World world, RollbackDatabase database,
|
||||
@AllowedRegion Region[] allowedRegions,
|
||||
@ArgFlag(name = 'u', desc = "String user", def="me") UUID other,
|
||||
@ArgFlag(name = 'u', desc = "String user", def = "me")
|
||||
UUID other,
|
||||
@ArgFlag(name = 'r', def = "0", desc = "radius")
|
||||
@Range(from = 0, to = Integer.MAX_VALUE) int radius,
|
||||
@Range(from = 0, to = Integer.MAX_VALUE)
|
||||
int radius,
|
||||
@ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0")
|
||||
@Time long timeDiff) throws WorldEditException {
|
||||
@Time
|
||||
long timeDiff) throws WorldEditException {
|
||||
rollback(player, world, database, allowedRegions, other, radius, timeDiff, true);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "rollback",
|
||||
desc = "Undo a specific edit. " +
|
||||
" - The time uses s, m, h, d, y."
|
||||
name = "rollback",
|
||||
desc = "Undo a specific edit. "
|
||||
+ " - The time uses s, m, h, d, y."
|
||||
)
|
||||
@CommandPermissions("worldedit.history.undo")
|
||||
@Confirm
|
||||
public synchronized void rollback(Player player, World world, RollbackDatabase database,
|
||||
@AllowedRegion Region[] allowedRegions,
|
||||
@ArgFlag(name = 'u', desc = "String user", def = "") UUID other,
|
||||
@ArgFlag(name = 'u', desc = "String user", def = "")
|
||||
UUID other,
|
||||
@ArgFlag(name = 'r', def = "0", desc = "radius")
|
||||
@Range(from = 0, to = Integer.MAX_VALUE) int radius,
|
||||
@ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0") @Time long timeDiff,
|
||||
@Switch(name = 'f', desc = "Restore instead of rollback") boolean restore) throws WorldEditException {
|
||||
@Range(from = 0, to = Integer.MAX_VALUE)
|
||||
int radius,
|
||||
@ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0")
|
||||
@Time
|
||||
long timeDiff,
|
||||
@Switch(name = 'f', desc = "Restore instead of rollback")
|
||||
boolean restore) throws WorldEditException {
|
||||
if (!Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
player.print(Caption.of("fawe.error.setting.disable" , "history.use-database (Import with /history import )"));
|
||||
player.print(Caption.of("fawe.error.setting.disable", "history.use-database (Import with /history import )"));
|
||||
return;
|
||||
}
|
||||
checkCommandArgument(radius > 0, "Radius must be >= 0");
|
||||
checkCommandArgument(timeDiff > 0, "Time must be >= 0");
|
||||
|
||||
if (other == null) other = player.getUniqueId();
|
||||
if (other == null) {
|
||||
other = player.getUniqueId();
|
||||
}
|
||||
if (!other.equals(player.getUniqueId())) {
|
||||
player.checkPermission("worldedit.history.undo.other");
|
||||
}
|
||||
if (other == Identifiable.EVERYONE) other = null;
|
||||
if (other == Identifiable.EVERYONE) {
|
||||
other = null;
|
||||
}
|
||||
Location origin = player.getLocation();
|
||||
BlockVector3 bot = origin.toBlockPoint().subtract(radius, radius, radius);
|
||||
BlockVector3 top = origin.toBlockPoint().add(radius, radius, radius);
|
||||
@ -121,11 +133,11 @@ public class HistorySubCommands {
|
||||
top = top.clampY(0, world.getMaxY());
|
||||
// TODO mask the regions bot / top to the bottom and top coord in the allowedRegions
|
||||
// TODO: then mask the edit to the bot / top
|
||||
// if (allowedRegions.length != 1 || !allowedRegions[0].isGlobal()) {
|
||||
// finalQueue = new MaskedIQueueExtent(SetQueue.IMP.getNewQueue(fp.getWorld(), true, false), allowedRegions);
|
||||
// } else {
|
||||
// finalQueue = SetQueue.IMP.getNewQueue(fp.getWorld(), true, false);
|
||||
// }
|
||||
// if (allowedRegions.length != 1 || !allowedRegions[0].isGlobal()) {
|
||||
// finalQueue = new MaskedIQueueExtent(SetQueue.IMP.getNewQueue(fp.getWorld(), true, false), allowedRegions);
|
||||
// } else {
|
||||
// finalQueue = SetQueue.IMP.getNewQueue(fp.getWorld(), true, false);
|
||||
// }
|
||||
int count = 0;
|
||||
UUID finalOther = other;
|
||||
long minTime = System.currentTimeMillis() - timeDiff;
|
||||
@ -136,14 +148,14 @@ public class HistorySubCommands {
|
||||
String path = edit.getWorld().getName() + "/" + finalOther + "-" + edit.getIndex();
|
||||
player.print(Caption.of("fawe.worldedit.rollback.rollback.element", path));
|
||||
}
|
||||
player.print(Caption.of("fawe.worldedit.tool.tool.inspect.info.footer" , count));
|
||||
player.print(Caption.of("fawe.worldedit.tool.tool.inspect.info.footer", count));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "import",
|
||||
desc = "Import history into the database" +
|
||||
" - The time uses s, m, h, d, y.\n" +
|
||||
" - Import from disk: /history import"
|
||||
name = "import",
|
||||
desc = "Import history into the database"
|
||||
+ " - The time uses s, m, h, d, y.\n"
|
||||
+ " - Import from disk: /history import"
|
||||
)
|
||||
@CommandPermissions("fawe.rollback.import")
|
||||
@Confirm
|
||||
@ -197,14 +209,16 @@ public class HistorySubCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "info",
|
||||
aliases = {"summary", "summarize"},
|
||||
desc = "Summarize an edit"
|
||||
name = "info",
|
||||
aliases = {"summary", "summarize"},
|
||||
desc = "Summarize an edit"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.info")
|
||||
public synchronized void summary(Player player, RollbackDatabase database, Arguments arguments,
|
||||
@Arg(desc = "Player uuid/name") UUID other,
|
||||
@Arg(desc = "edit index") Integer index) throws WorldEditException, ExecutionException, InterruptedException {
|
||||
@Arg(desc = "Player uuid/name")
|
||||
UUID other,
|
||||
@Arg(desc = "edit index")
|
||||
Integer index) throws WorldEditException, ExecutionException, InterruptedException {
|
||||
RollbackOptimizedHistory edit = database.getEdit(other, index).get();
|
||||
if (edit == null) {
|
||||
player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.none"));
|
||||
@ -238,11 +252,21 @@ public class HistorySubCommands {
|
||||
|
||||
String sizeStr = StringMan.humanReadableByteCountBin(edit.getSizeOnDisk());
|
||||
String extra = "";
|
||||
if (biomes) extra += "biomes, ";
|
||||
if (createdEnts) extra += "+entity, ";
|
||||
if (removedEnts) extra += "-entity, ";
|
||||
if (createdTiles) extra += "+tile, ";
|
||||
if (removedTiles) extra += "-tile, ";
|
||||
if (biomes) {
|
||||
extra += "biomes, ";
|
||||
}
|
||||
if (createdEnts) {
|
||||
extra += "+entity, ";
|
||||
}
|
||||
if (removedEnts) {
|
||||
extra += "-entity, ";
|
||||
}
|
||||
if (createdTiles) {
|
||||
extra += "+tile, ";
|
||||
}
|
||||
if (removedTiles) {
|
||||
extra += "-tile, ";
|
||||
}
|
||||
|
||||
TranslatableComponent body = Caption.of("fawe.worldedit.history.find.element.more", size, edit.getMinimumPoint(), edit.getMaximumPoint(), extra.trim(), sizeStr);
|
||||
Component distr = TextComponent.of("/history distr").clickEvent(ClickEvent.suggestCommand("//history distr " + other + " " + index));
|
||||
@ -296,23 +320,29 @@ public class HistorySubCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "find",
|
||||
aliases = {"inspect", "search", "near"},
|
||||
desc = "Find nearby edits"
|
||||
name = "find",
|
||||
aliases = {"inspect", "search", "near"},
|
||||
desc = "Find nearby edits"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.find")
|
||||
public synchronized void find(Player player, World world, RollbackDatabase database, Arguments arguments,
|
||||
@ArgFlag(name = 'u', def="", desc = "String user") UUID other,
|
||||
@ArgFlag(name = 'u', def = "", desc = "String user")
|
||||
UUID other,
|
||||
@ArgFlag(name = 'r', def = "0", desc = "radius")
|
||||
@Range(from = 0, to = Integer.MAX_VALUE) Integer radius,
|
||||
@Range(from = 0, to = Integer.MAX_VALUE)
|
||||
Integer radius,
|
||||
@ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0")
|
||||
@Time Long timeDiff,
|
||||
@ArgFlag(name = 'p', desc = "Page to view.", def = "") Integer page) throws WorldEditException {
|
||||
@Time
|
||||
Long timeDiff,
|
||||
@ArgFlag(name = 'p', desc = "Page to view.", def = "")
|
||||
Integer page) throws WorldEditException {
|
||||
if (!Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
player.print(Caption.of("fawe.error.setting.disable" , "history.use-database (Import with //history import )"));
|
||||
player.print(Caption.of("fawe.error.setting.disable", "history.use-database (Import with //history import )"));
|
||||
return;
|
||||
}
|
||||
if (other == null && radius == 0 && timeDiff == 0) throw new InsufficientArgumentsException("User must be provided");
|
||||
if (other == null && radius == 0 && timeDiff == 0) {
|
||||
throw new InsufficientArgumentsException("User must be provided");
|
||||
}
|
||||
checkCommandArgument(radius > 0, "Radius must be >= 0");
|
||||
checkCommandArgument(timeDiff > 0, "Time must be >= 0");
|
||||
|
||||
@ -322,11 +352,15 @@ public class HistorySubCommands {
|
||||
List<Supplier<? extends ChangeSet>> history = cached == null ? null : cached.get();
|
||||
|
||||
if (page == null || history == null) {
|
||||
if (other == null) other = player.getUniqueId();
|
||||
if (other == null) {
|
||||
other = player.getUniqueId();
|
||||
}
|
||||
if (!other.equals(player.getUniqueId())) {
|
||||
player.checkPermission("worldedit.history.undo.other");
|
||||
}
|
||||
if (other == Identifiable.EVERYONE) other = null;
|
||||
if (other == Identifiable.EVERYONE) {
|
||||
other = null;
|
||||
}
|
||||
|
||||
BlockVector3 bot = origin.toBlockPoint().subtract(radius, radius, radius);
|
||||
BlockVector3 top = origin.toBlockPoint().add(radius, radius, radius);
|
||||
@ -345,15 +379,18 @@ public class HistorySubCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "distr",
|
||||
aliases = {"distribution"},
|
||||
desc = "View block distribution for an edit"
|
||||
name = "distr",
|
||||
aliases = {"distribution"},
|
||||
desc = "View block distribution for an edit"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.distr")
|
||||
public void distr(Player player, LocalSession session, RollbackDatabase database, Arguments arguments,
|
||||
@Arg(desc = "Player uuid/name") UUID other,
|
||||
@Arg(desc = "edit index") Integer index,
|
||||
@ArgFlag(name = 'p', desc = "Page to view.", def = "") Integer page) throws ExecutionException, InterruptedException {
|
||||
@Arg(desc = "Player uuid/name")
|
||||
UUID other,
|
||||
@Arg(desc = "edit index")
|
||||
Integer index,
|
||||
@ArgFlag(name = 'p', desc = "Page to view.", def = "")
|
||||
Integer page) throws ExecutionException, InterruptedException {
|
||||
String pageCommand = "/" + arguments.get().replaceAll("-p [0-9]+", "").trim();
|
||||
Reference<PaginationBox> cached = player.getMeta(pageCommand);
|
||||
PaginationBox pages = cached == null ? null : cached.get();
|
||||
@ -372,13 +409,15 @@ public class HistorySubCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "list",
|
||||
desc = "List your history"
|
||||
name = "list",
|
||||
desc = "List your history"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.list")
|
||||
public void list(Player player, LocalSession session, RollbackDatabase database, Arguments arguments,
|
||||
@Arg(desc = "Player uuid/name") UUID other,
|
||||
@ArgFlag(name = 'p', desc = "Page to view.", def = "") Integer page) {
|
||||
@Arg(desc = "Player uuid/name")
|
||||
UUID other,
|
||||
@ArgFlag(name = 'p', desc = "Page to view.", def = "")
|
||||
Integer page) {
|
||||
int index = session.getHistoryIndex();
|
||||
List<Supplier<? extends ChangeSet>> history = Lists.transform(session.getHistory(), (Function<ChangeSet, Supplier<ChangeSet>>) input -> () -> input);
|
||||
Location origin = player.getLocation();
|
||||
@ -393,8 +432,8 @@ public class HistorySubCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "clear",
|
||||
desc = "Clear your history"
|
||||
name = "clear",
|
||||
desc = "Clear your history"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.clear")
|
||||
public void clearHistory(Actor actor, LocalSession session) {
|
||||
|
@ -88,13 +88,17 @@ public class ListFilters {
|
||||
@Override
|
||||
public File getPath(File root) {
|
||||
File newRoot = new File(root, finalArg);
|
||||
if (newRoot.exists()) return newRoot;
|
||||
if (newRoot.exists()) {
|
||||
return newRoot;
|
||||
}
|
||||
String firstArg = finalArg.substring(0, finalArg.length() - File.separator.length());
|
||||
if (firstArg.length() > 3 && firstArg.length() <= 16) {
|
||||
UUID fromName = Fawe.imp().getUUID(finalArg);
|
||||
if (fromName != null) {
|
||||
newRoot = new File(root, finalArg);
|
||||
if (newRoot.exists()) return newRoot;
|
||||
if (newRoot.exists()) {
|
||||
return newRoot;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new StopExecutionException(TextComponent.of("Cannot find path: " + finalArg));
|
||||
@ -105,7 +109,7 @@ public class ListFilters {
|
||||
Pattern pattern;
|
||||
try {
|
||||
pattern = Pattern.compile(argLower);
|
||||
} catch (PatternSyntaxException ignore) {
|
||||
} catch (PatternSyntaxException ignored) {
|
||||
pattern = Pattern.compile(Pattern.quote(argLower));
|
||||
}
|
||||
Pattern finalPattern = pattern;
|
||||
|
@ -9,7 +9,9 @@ import java.util.Optional;
|
||||
public class MethodCommands {
|
||||
|
||||
public static String getArguments(InjectedValueAccess context) {
|
||||
if (context == null) return null;
|
||||
if (context == null) {
|
||||
return null;
|
||||
}
|
||||
Optional<Arguments> arguments = context.injectedValue(Key.of(Arguments.class));
|
||||
return arguments.map(Arguments::get).orElse(null);
|
||||
}
|
||||
|
@ -115,9 +115,9 @@ public class RegionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/air",
|
||||
aliases = {"/0"},
|
||||
desc = "Sets all the blocks in the region to air"
|
||||
name = "/air",
|
||||
aliases = {"/0"},
|
||||
desc = "Sets all the blocks in the region to air"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.set")
|
||||
@Logging(REGION)
|
||||
@ -126,18 +126,19 @@ public class RegionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/test",
|
||||
desc = "test region"
|
||||
name = "/test",
|
||||
desc = "test region"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.test")
|
||||
@Logging(REGION)
|
||||
public void test(Player player, EditSession editSession, @Arg(desc = "test") double testValue) throws WorldEditException {
|
||||
public void test(Player player, EditSession editSession,
|
||||
@Arg(desc = "test") double testValue) throws WorldEditException {
|
||||
player.print(TextComponent.of(testValue));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/fixlighting",
|
||||
desc = "Get the light at a position"
|
||||
name = "/fixlighting",
|
||||
desc = "Get the light at a position"
|
||||
)
|
||||
@CommandPermissions("worldedit.light.fix")
|
||||
public void fixLighting(Player player) throws WorldEditException {
|
||||
@ -148,25 +149,25 @@ public class RegionCommands {
|
||||
final int cz = loc.getBlockZ() >> 4;
|
||||
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
|
||||
}
|
||||
int count = FaweAPI.fixLighting(player.getWorld(), selection,null, RelightMode.ALL);
|
||||
player.print(Caption.of("fawe.info.lighting.propagate.selection" , count));
|
||||
int count = FaweAPI.fixLighting(player.getWorld(), selection, null, RelightMode.ALL);
|
||||
player.print(Caption.of("fawe.info.lighting.propagate.selection", count));
|
||||
}
|
||||
|
||||
// @Command(
|
||||
// name = "/getlighting",
|
||||
// desc = "Get the light at a position"
|
||||
// )
|
||||
// @CommandPermissions("worldedit.light.fix")
|
||||
// public void getLighting(Player player, EditSession editSession) throws WorldEditException {
|
||||
// final Location loc = player.getLocation();
|
||||
// int block = editSession.getBlockLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
// int sky = editSession.getSkyLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
// player.print(TextComponent.of("Light: " + block + " | " + sky));
|
||||
// }
|
||||
// @Command(
|
||||
// name = "/getlighting",
|
||||
// desc = "Get the light at a position"
|
||||
// )
|
||||
// @CommandPermissions("worldedit.light.fix")
|
||||
// public void getLighting(Player player, EditSession editSession) throws WorldEditException {
|
||||
// final Location loc = player.getLocation();
|
||||
// int block = editSession.getBlockLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
// int sky = editSession.getSkyLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
// player.print(TextComponent.of("Light: " + block + " | " + sky));
|
||||
// }
|
||||
|
||||
@Command(
|
||||
name = "/removelighting",
|
||||
desc = "Removing lighting in a selection"
|
||||
name = "/removelighting",
|
||||
desc = "Removing lighting in a selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.light.remove")
|
||||
public void removeLighting(Player player) {
|
||||
@ -177,13 +178,13 @@ public class RegionCommands {
|
||||
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
|
||||
}
|
||||
int count = FaweAPI.fixLighting(player.getWorld(), selection, null, RelightMode.NONE);
|
||||
player.print(Caption.of("fawe.info.updated.lighting.selection" , count));
|
||||
player.print(Caption.of("fawe.info.updated.lighting.selection", count));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/nbtinfo",
|
||||
aliases = "/nbt",
|
||||
desc = "View nbt info for a block"
|
||||
name = "/nbtinfo",
|
||||
aliases = "/nbt",
|
||||
desc = "View nbt info for a block"
|
||||
)
|
||||
@CommandPermissions("worldedit.nbtinfo")
|
||||
public void nbtinfo(Player player, EditSession editSession) {
|
||||
@ -201,8 +202,8 @@ public class RegionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/setblocklight",
|
||||
desc = "Set block lighting in a selection"
|
||||
name = "/setblocklight",
|
||||
desc = "Set block lighting in a selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.light.set")
|
||||
public void setlighting(Player player, EditSession editSession, @Selection Region region) {
|
||||
@ -210,8 +211,8 @@ public class RegionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/setskylight",
|
||||
desc = "Set sky lighting in a selection"
|
||||
name = "/setskylight",
|
||||
desc = "Set sky lighting in a selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.light.set")
|
||||
public void setskylighting(Player player, @Selection Region region) {
|
||||
@ -316,9 +317,9 @@ public class RegionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/lay",
|
||||
desc = "Set the top block in the region"
|
||||
)
|
||||
name = "/lay",
|
||||
desc = "Set the top block in the region"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.overlay")
|
||||
@Logging(REGION)
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
@ -337,7 +338,7 @@ public class RegionCommands {
|
||||
editSession.setBlock(x, y, z, patternArg);
|
||||
affected++;
|
||||
}
|
||||
player.print(Caption.of("fawe.worldedit.visitor.visitor.block" , affected));
|
||||
player.print(Caption.of("fawe.worldedit.visitor.visitor.block", affected));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -412,7 +413,8 @@ public class RegionCommands {
|
||||
int iterations,
|
||||
@Arg(desc = "The mask of blocks to use as the height map", def = "")
|
||||
Mask mask,
|
||||
@Switch(name = 's', desc = "TODO") boolean snow) throws WorldEditException {
|
||||
@Switch(name = 's', desc = "The flag makes it only consider snow")
|
||||
boolean snow) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
@ -433,10 +435,10 @@ public class RegionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/wea",
|
||||
aliases = {"wea", "worldeditanywhere", "/worldeditanywhere", "/weanywhere"},
|
||||
desc = "Bypass region restrictions",
|
||||
descFooter = "Bypass region restrictions"
|
||||
name = "/wea",
|
||||
aliases = {"wea", "worldeditanywhere", "/worldeditanywhere", "/weanywhere"},
|
||||
desc = "Bypass region restrictions",
|
||||
descFooter = "Bypass region restrictions"
|
||||
)
|
||||
@CommandPermissions("fawe.admin")
|
||||
public void wea(Actor actor) throws WorldEditException {
|
||||
@ -448,10 +450,10 @@ public class RegionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/wer",
|
||||
aliases = {"wer", "worldeditregion", "/worldeditregion", "select", "/select"},
|
||||
desc = "Select your current allowed region",
|
||||
descFooter = "Select your current allowed region"
|
||||
name = "/wer",
|
||||
aliases = {"wer", "worldeditregion", "/worldeditregion", "select", "/select"},
|
||||
desc = "Select your current allowed region",
|
||||
descFooter = "Select your current allowed region"
|
||||
)
|
||||
@CommandPermissions("fawe.worldeditregion")
|
||||
public void wer(Player player) throws WorldEditException {
|
||||
@ -523,20 +525,21 @@ public class RegionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/fall",
|
||||
desc = "Have the blocks in the selection fall",
|
||||
descFooter = "Make the blocks in the selection fall\n" +
|
||||
"The -m flag will only fall within the vertical selection."
|
||||
)
|
||||
name = "/fall",
|
||||
desc = "Have the blocks in the selection fall",
|
||||
descFooter = "Make the blocks in the selection fall\n"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.fall")
|
||||
@Logging(ORIENTATION_REGION)
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
public void fall(Player player, EditSession editSession, LocalSession session,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "BlockStateHolder", def = "air") BlockStateHolder replace,
|
||||
@Switch(name = 'm', desc = "TODO") boolean notFullHeight) throws WorldEditException {
|
||||
@Arg(desc = "BlockStateHolder", def = "air")
|
||||
BlockStateHolder replace,
|
||||
@Switch(name = 'm', desc = "Only fall within the vertical selection")
|
||||
boolean notFullHeight) throws WorldEditException {
|
||||
int affected = editSession.fall(region, !notFullHeight, replace);
|
||||
player.print(Caption.of("fawe.worldedit.visitor.visitor.block" , affected));
|
||||
player.print(Caption.of("fawe.worldedit.visitor.visitor.block", affected));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -598,14 +601,14 @@ public class RegionCommands {
|
||||
@Command(
|
||||
name = "/regen",
|
||||
desc = "Regenerates the contents of the selection",
|
||||
descFooter = "This command might affect things outside the selection,\n" +
|
||||
"if they are within the same chunk."
|
||||
descFooter = "This command might affect things outside the selection,\n"
|
||||
+ "if they are within the same chunk."
|
||||
)
|
||||
@CommandPermissions("worldedit.regen")
|
||||
@Logging(REGION)
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
public void regenerateChunk(Actor actor, World world, LocalSession session,
|
||||
EditSession editSession, @Selection Region region) throws WorldEditException {
|
||||
public void regenerateChunk(Actor actor, World world, LocalSession session, EditSession editSession,
|
||||
@Selection Region region) throws WorldEditException {
|
||||
Mask mask = session.getMask();
|
||||
boolean success;
|
||||
try {
|
||||
@ -626,9 +629,9 @@ public class RegionCommands {
|
||||
@Command(
|
||||
name = "/deform",
|
||||
desc = "Deforms a selected region with an expression",
|
||||
descFooter = "The expression is executed for each block and is expected\n" +
|
||||
"to modify the variables x, y and z to point to a new block\n" +
|
||||
"to fetch. See also https://tinyurl.com/weexpr"
|
||||
descFooter = "The expression is executed for each block and is expected\n"
|
||||
+ "to modify the variables x, y and z to point to a new block\n"
|
||||
+ "to fetch. See also https://tinyurl.com/weexpr"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.deform")
|
||||
@Logging(ALL)
|
||||
@ -665,9 +668,15 @@ public class RegionCommands {
|
||||
zero = max.add(min).divide(2);
|
||||
unit = max.subtract(zero);
|
||||
|
||||
if (unit.getX() == 0) unit = unit.withX(1.0);
|
||||
if (unit.getY() == 0) unit = unit.withY(1.0);
|
||||
if (unit.getZ() == 0) unit = unit.withZ(1.0);
|
||||
if (unit.getX() == 0) {
|
||||
unit = unit.withX(1.0);
|
||||
}
|
||||
if (unit.getY() == 0) {
|
||||
unit = unit.withY(1.0);
|
||||
}
|
||||
if (unit.getZ() == 0) {
|
||||
unit = unit.withZ(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
final Vector3 unit1 = unit;
|
||||
@ -687,10 +696,9 @@ public class RegionCommands {
|
||||
@Command(
|
||||
name = "/hollow",
|
||||
desc = "Hollows out the object contained in this selection",
|
||||
descFooter = "Hollows out the object contained in this selection.\n" +
|
||||
"Optionally fills the hollowed out part with the given block.\n" +
|
||||
"Thickness is measured in manhattan distance."
|
||||
|
||||
descFooter = "Hollows out the object contained in this selection.\n"
|
||||
+ "Optionally fills the hollowed out part with the given block.\n"
|
||||
+ "Thickness is measured in manhattan distance."
|
||||
)
|
||||
@CommandPermissions("worldedit.region.hollow")
|
||||
@Logging(REGION)
|
||||
@ -701,7 +709,8 @@ public class RegionCommands {
|
||||
int thickness,
|
||||
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
|
||||
Pattern pattern,
|
||||
@ArgFlag(name = 'm', desc = "Mask to hollow with") Mask mask) throws WorldEditException {
|
||||
@ArgFlag(name = 'm', desc = "Mask to hollow with")
|
||||
Mask mask) throws WorldEditException {
|
||||
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
|
||||
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
|
||||
|
||||
|
@ -116,8 +116,8 @@ public class SchematicCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "loadall",
|
||||
desc = "Load multiple clipboards (paste will randomly choose one)"
|
||||
name = "loadall",
|
||||
desc = "Load multiple clipboards (paste will randomly choose one)"
|
||||
)
|
||||
@Deprecated
|
||||
@CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.load.web", "worldedit.schematic.load.asset"})
|
||||
@ -130,14 +130,14 @@ public class SchematicCommands {
|
||||
boolean randomRotate) throws FilenameException {
|
||||
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||
if (format == null) {
|
||||
player.print(Caption.of("fawe.worldedit.clipboard.clipboard.invalid.format" , formatName));
|
||||
player.print(Caption.of("fawe.worldedit.clipboard.clipboard.invalid.format", formatName));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
MultiClipboardHolder all = ClipboardFormats.loadAllFromInput(player, filename, null, true);
|
||||
if (all != null) {
|
||||
session.addClipboard(all);
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.loaded" , filename));
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.loaded", filename));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -145,8 +145,8 @@ public class SchematicCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "clear",
|
||||
desc = "Clear your clipboard"
|
||||
name = "clear",
|
||||
desc = "Clear your clipboard"
|
||||
)
|
||||
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
|
||||
public void clear(Player player, LocalSession session) throws WorldEditException {
|
||||
@ -155,8 +155,8 @@ public class SchematicCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "unload",
|
||||
desc = "Remove a clipboard from your multi-clipboard"
|
||||
name = "unload",
|
||||
desc = "Remove a clipboard from your multi-clipboard"
|
||||
)
|
||||
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
|
||||
public void unload(Player player, LocalSession session, String fileName) throws WorldEditException {
|
||||
@ -177,7 +177,9 @@ public class SchematicCommands {
|
||||
if (identifiable instanceof MultiClipboardHolder) {
|
||||
MultiClipboardHolder multi = (MultiClipboardHolder) identifiable;
|
||||
multi.remove(uri);
|
||||
if (multi.getHolders().isEmpty()) session.setClipboard(null);
|
||||
if (multi.getHolders().isEmpty()) {
|
||||
session.setClipboard(null);
|
||||
}
|
||||
} else {
|
||||
session.setClipboard(null);
|
||||
}
|
||||
@ -185,7 +187,7 @@ public class SchematicCommands {
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.print(Caption.of("fawe.worldedit.clipboard.clipboard.uri.not.found" , fileName));
|
||||
player.print(Caption.of("fawe.worldedit.clipboard.clipboard.uri.not.found", fileName));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -272,7 +274,7 @@ public class SchematicCommands {
|
||||
uri = file.toURI();
|
||||
}
|
||||
format.hold(actor, uri, in);
|
||||
actor.print(Caption.of("fawe.worldedit.schematic.schematic.loaded" , filename));
|
||||
actor.print(Caption.of("fawe.worldedit.schematic.schematic.loaded", filename));
|
||||
} catch (IllegalArgumentException e) {
|
||||
actor.printError("Unknown filename: " + filename);
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
@ -301,8 +303,7 @@ public class SchematicCommands {
|
||||
@Switch(name = 'f', desc = "Overwrite an existing file.")
|
||||
boolean allowOverwrite,
|
||||
@Switch(name = 'g', desc = "//TODO")
|
||||
boolean global
|
||||
) throws WorldEditException {
|
||||
boolean global) throws WorldEditException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
||||
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
@ -401,7 +402,7 @@ public class SchematicCommands {
|
||||
for (File source : sources) {
|
||||
File destFile = new File(destDir, source.getName());
|
||||
if (destFile.exists()) {
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.exists" , destFile));
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.exists", destFile));
|
||||
continue;
|
||||
}
|
||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory(dir, destFile) || !MainUtil.isInSubDirectory(dir, source)) && !player.hasPermission("worldedit.schematic.delete.other")) {
|
||||
@ -412,8 +413,10 @@ public class SchematicCommands {
|
||||
try {
|
||||
File cached = new File(source.getParentFile(), "." + source.getName() + ".cached");
|
||||
Files.move(source.toPath(), destFile.toPath());
|
||||
if (cached.exists()) Files.move(cached.toPath(), destFile.toPath());
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.success" , source, destFile));
|
||||
if (cached.exists()) {
|
||||
Files.move(cached.toPath(), destFile.toPath());
|
||||
}
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.success", source, destFile));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@ -428,7 +431,9 @@ public class SchematicCommands {
|
||||
List<File> files = new ArrayList<>();
|
||||
for (URI uri : uris) {
|
||||
File file = new File(uri);
|
||||
if (file.exists()) files.add(file);
|
||||
if (file.exists()) {
|
||||
files.add(file);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
@ -475,9 +480,7 @@ public class SchematicCommands {
|
||||
@ArgFlag(name = 'f', desc = "Restricts by format.", def = "")
|
||||
String formatName,
|
||||
@Arg(name = "filter", desc = "Filter for schematics", def = "all")
|
||||
String filter,
|
||||
Arguments arguments
|
||||
) throws WorldEditException {
|
||||
String filter, Arguments arguments) throws WorldEditException {
|
||||
if (oldFirst && newFirst) {
|
||||
throw new StopExecutionException(TextComponent.of("Cannot sort by oldest and newest."));
|
||||
}
|
||||
@ -633,7 +636,7 @@ public class SchematicCommands {
|
||||
writer.write(target);
|
||||
}
|
||||
log.info(actor.getName() + " saved " + file.getCanonicalPath());
|
||||
actor.print(Caption.of("fawe.worldedit.schematic.schematic.saved" , file.getName()));
|
||||
actor.print(Caption.of("fawe.worldedit.schematic.schematic.saved", file.getName()));
|
||||
} else {
|
||||
actor.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual"));
|
||||
}
|
||||
@ -686,7 +689,9 @@ public class SchematicCommands {
|
||||
}
|
||||
} else {
|
||||
res = Long.compare(f1.lastModified(), f2.lastModified()); // use date if there is a flag
|
||||
if (sortType == 1) res = -res; // flip date for newest first instead of oldest first
|
||||
if (sortType == 1) {
|
||||
res = -res; // flip date for newest first instead of oldest first
|
||||
}
|
||||
}
|
||||
return res;
|
||||
});
|
||||
@ -699,7 +704,9 @@ public class SchematicCommands {
|
||||
//TODO filtering for directories, global, and private scheamtics needs to be reimplemented here
|
||||
private static List<File> getFiles(File root, String filter, ClipboardFormat format) {
|
||||
File[] files = root.listFiles();
|
||||
if (files == null) return null;
|
||||
if (files == null) {
|
||||
return null;
|
||||
}
|
||||
//Only get the files that match the format parameter
|
||||
if (format != null) {
|
||||
files = Arrays.stream(files).filter(format::isFormat).toArray(File[]::new);
|
||||
@ -708,7 +715,9 @@ public class SchematicCommands {
|
||||
for (File f : files) {
|
||||
if (f.isDirectory()) {
|
||||
List<File> subFiles = getFiles(f, filter, format);
|
||||
if (subFiles == null) continue; // empty subdir
|
||||
if (subFiles == null) {
|
||||
continue; // empty subdir
|
||||
}
|
||||
fileList.addAll(subFiles);
|
||||
} else {
|
||||
fileList.add(f);
|
||||
@ -723,8 +732,7 @@ public class SchematicCommands {
|
||||
desc = "Delete a saved schematic"
|
||||
)
|
||||
@CommandPermissions("worldedit.schematic.delete")
|
||||
public void delete(Actor actor,
|
||||
LocalSession session,
|
||||
public void delete(Actor actor, LocalSession session,
|
||||
@Arg(desc = "File name.")
|
||||
String filename) throws WorldEditException, IOException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
@ -756,7 +764,7 @@ public class SchematicCommands {
|
||||
actor.printError(TranslatableComponent.of("worldedit.schematic.delete.failed", TextComponent.of(filename)));
|
||||
continue;
|
||||
}
|
||||
actor.print(Caption.of("worldedit.schematic.delete.deleted" , filename));
|
||||
actor.print(Caption.of("worldedit.schematic.delete.deleted", filename));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -559,7 +559,9 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
BlockDistributionResult res = new BlockDistributionResult(distribution, separateStates);
|
||||
if (!actor.isPlayer()) res.formatForConsole();
|
||||
if (!actor.isPlayer()) {
|
||||
res.formatForConsole();
|
||||
}
|
||||
actor.print(res.create(page));
|
||||
}
|
||||
|
||||
|
@ -88,8 +88,8 @@ public class ToolCommands {
|
||||
).build();
|
||||
}
|
||||
commandManager.register(CommandUtil.deprecate(
|
||||
command, "Global tool names cause conflicts " +
|
||||
"and will be removed in WorldEdit 8", ToolCommands::asNonGlobal
|
||||
command, "Global tool names cause conflicts "
|
||||
+ "and will be removed in WorldEdit 8", ToolCommands::asNonGlobal
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ import org.enginehub.piston.annotation.param.Switch;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Tool commands.
|
||||
@ -64,18 +65,16 @@ public class ToolUtilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "mask",
|
||||
aliases = "/mask",
|
||||
desc = "Set the brush destination mask"
|
||||
name = "mask",
|
||||
aliases = "/mask",
|
||||
desc = "Set the brush destination mask"
|
||||
)
|
||||
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
|
||||
public void mask(Player player, LocalSession session,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
|
||||
boolean offHand,
|
||||
@Arg(desc = "The destination mask", def = "")
|
||||
Mask maskOpt,
|
||||
Arguments arguments)
|
||||
throws WorldEditException {
|
||||
Mask maskOpt, Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
|
||||
@ -96,32 +95,31 @@ public class ToolUtilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "material",
|
||||
aliases = {"mat", "/material", "pattern"},
|
||||
desc = "Set the brush material"
|
||||
name = "material",
|
||||
aliases = {"mat", "/material", "pattern"},
|
||||
desc = "Set the brush material"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.material")
|
||||
public void material(Player player, LocalSession session,
|
||||
@Arg(desc = "The pattern of blocks to use")
|
||||
Pattern pattern,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
Arguments arguments) throws WorldEditException {
|
||||
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
|
||||
boolean offHand, Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.printInfo(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (pattern == null) {
|
||||
tool.setFill(null);
|
||||
} else {
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
settings.setFill(pattern);
|
||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
|
||||
tool.update();
|
||||
}
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.material.set"));
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
settings.setFill(pattern);
|
||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
|
||||
tool.update();
|
||||
}
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.material.set"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -169,9 +167,9 @@ public class ToolUtilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/superpickaxe",
|
||||
aliases = {",", "/sp", "/pickaxe", "/"},
|
||||
desc = "Toggle the super pickaxe function"
|
||||
name = "/superpickaxe",
|
||||
aliases = {",", "/sp", "/pickaxe", "/"},
|
||||
desc = "Toggle the super pickaxe function"
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe")
|
||||
public void togglePickaxe(Player player, LocalSession session,
|
||||
@ -180,8 +178,8 @@ public class ToolUtilCommands {
|
||||
boolean hasSuperPickAxe = session.hasSuperPickAxe();
|
||||
if (superPickaxe != null && superPickaxe == hasSuperPickAxe) {
|
||||
player.printError(TranslatableComponent.of(superPickaxe ? "worldedit.tool.superpickaxe.enabled.already" : "worldedit.tool.superpickaxe.disabled.already"));
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (hasSuperPickAxe) {
|
||||
session.disableSuperPickAxe();
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.disabled"));
|
||||
@ -192,10 +190,10 @@ public class ToolUtilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "primary",
|
||||
aliases = { "/primary" },
|
||||
desc = "Set the right click brush",
|
||||
descFooter = "Set the right click brush"
|
||||
name = "primary",
|
||||
aliases = { "/primary" },
|
||||
desc = "Set the right click brush",
|
||||
descFooter = "Set the right click brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.primary")
|
||||
public void primary(Player player, LocalSession session,
|
||||
@ -213,15 +211,15 @@ public class ToolUtilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "secondary",
|
||||
aliases = { "/secondary" },
|
||||
desc = "Set the left click brush",
|
||||
descFooter = "Set the left click brush"
|
||||
name = "secondary",
|
||||
aliases = { "/secondary" },
|
||||
desc = "Set the left click brush",
|
||||
descFooter = "Set the left click brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.secondary")
|
||||
public void secondary(Player player, LocalSession session,
|
||||
@Arg(desc = "The brush command", variable = true) List<String> commandStr)
|
||||
throws WorldEditException {
|
||||
@Arg(desc = "The brush command", variable = true)
|
||||
List<String> commandStr) throws WorldEditException {
|
||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
session.setTool(item, null, player);
|
||||
@ -235,19 +233,19 @@ public class ToolUtilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "visualize",
|
||||
aliases = {"visual", "vis", "/visualize", "/visual", "/vis"},
|
||||
desc = "Toggle between different visualization modes",
|
||||
descFooter = "Toggle between different visualization modes\n" +
|
||||
"0 = No visualization\n" +
|
||||
"1 = Single block at target position\n" +
|
||||
"2 = Glass showing what blocks will be changed"
|
||||
name = "visualize",
|
||||
aliases = {"visual", "vis", "/visualize", "/visual", "/vis"},
|
||||
desc = "Toggle between different visualization modes",
|
||||
descFooter = "Toggle between different visualization modes\n"
|
||||
+ "0 = No visualization\n"
|
||||
+ "1 = Single block at target position\n"
|
||||
+ "2 = Glass showing what blocks will be changed"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.visualize")
|
||||
public void visual(Player player, LocalSession session,
|
||||
@Arg(name = "mode", desc = "int", def = "0") @Range(from = 0, to = 2)
|
||||
int mode)
|
||||
throws WorldEditException {
|
||||
@Arg(name = "mode", desc = "int", def = "0")
|
||||
@Range(from = 0, to = 2)
|
||||
int mode) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
|
||||
@ -256,17 +254,18 @@ public class ToolUtilCommands {
|
||||
VisualMode[] modes = VisualMode.values();
|
||||
VisualMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
|
||||
tool.setVisualMode(player, newMode);
|
||||
player.print(Caption.of("fawe.worldedit.brush.brush.visual.mode.set" , newMode));
|
||||
player.print(Caption.of("fawe.worldedit.brush.brush.visual.mode.set", newMode));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "target",
|
||||
aliases = {"tar", "/target", "/tar"},
|
||||
desc = "Toggle between different target modes"
|
||||
name = "target",
|
||||
aliases = {"tar", "/target", "/tar"},
|
||||
desc = "Toggle between different target modes"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.target")
|
||||
public void target(Player player, LocalSession session,
|
||||
@Arg(name = "mode", desc = "int", def = "0") int mode) throws WorldEditException {
|
||||
@Arg(name = "mode", desc = "int", def = "0")
|
||||
int mode) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
|
||||
@ -275,13 +274,13 @@ public class ToolUtilCommands {
|
||||
TargetMode[] modes = TargetMode.values();
|
||||
TargetMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
|
||||
tool.setTargetMode(newMode);
|
||||
player.print(Caption.of("fawe.worldedit.brush.brush.target.mode.set" , newMode));
|
||||
player.print(Caption.of("fawe.worldedit.brush.brush.target.mode.set", newMode));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "targetoffset",
|
||||
aliases = {"to"},
|
||||
desc = "Set the targeting mask"
|
||||
name = "targetoffset",
|
||||
aliases = {"to"},
|
||||
desc = "Set the targeting mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.targetoffset")
|
||||
public void targetOffset(Player player, EditSession editSession, LocalSession session,
|
||||
@ -292,21 +291,21 @@ public class ToolUtilCommands {
|
||||
return;
|
||||
}
|
||||
tool.setTargetOffset(offset);
|
||||
player.print(Caption.of("fawe.worldedit.brush.brush.target.offset.set" , offset));
|
||||
player.print(Caption.of("fawe.worldedit.brush.brush.target.offset.set", offset));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "scroll",
|
||||
desc = "Toggle between different target modes"
|
||||
name = "scroll",
|
||||
desc = "Toggle between different target modes"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.scroll")
|
||||
public void scroll(Player player, EditSession editSession, LocalSession session,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
|
||||
boolean offHand,
|
||||
@Arg(desc = "Target Modes", def = "none")
|
||||
Scroll.Action mode,
|
||||
Scroll.Action mode,
|
||||
@Arg(desc = "The scroll action", variable = true)
|
||||
List<String> commandStr) throws WorldEditException {
|
||||
List<String> commandStr) throws WorldEditException {
|
||||
BrushTool bt = session.getBrushTool(player, false);
|
||||
if (bt == null) {
|
||||
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
|
||||
@ -319,9 +318,9 @@ public class ToolUtilCommands {
|
||||
if (mode == Scroll.Action.NONE) {
|
||||
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.scroll.action.unset"));
|
||||
} else if (action != null) {
|
||||
String full = (mode.name().toLowerCase() + " " + StringMan.join(commandStr, " ")).trim();
|
||||
String full = (mode.name().toLowerCase(Locale.ROOT) + " " + StringMan.join(commandStr, " ")).trim();
|
||||
settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, full);
|
||||
player.print(Caption.of("fawe.worldedit.brush.brush.scroll.action.set" , mode));
|
||||
player.print(Caption.of("fawe.worldedit.brush.brush.scroll.action.set", mode));
|
||||
}
|
||||
bt.update();
|
||||
}
|
||||
@ -329,17 +328,17 @@ public class ToolUtilCommands {
|
||||
|
||||
|
||||
@Command(
|
||||
name = "smask",
|
||||
aliases = {"/smask", "/sourcemask", "sourcemask"},
|
||||
desc = "Set the brush source mask",
|
||||
descFooter = "Set the brush source mask"
|
||||
name = "smask",
|
||||
aliases = {"/smask", "/sourcemask", "sourcemask"},
|
||||
desc = "Set the brush source mask",
|
||||
descFooter = "Set the brush source mask"
|
||||
)
|
||||
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
|
||||
public void smask(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The destination mask", def = "")
|
||||
Mask maskArg,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
Mask maskArg,
|
||||
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
|
||||
boolean offHand,
|
||||
Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
@ -367,7 +366,7 @@ public class ToolUtilCommands {
|
||||
// @CommandPermissions({"worldedit.brush.options.transform", "worldedit.transform.brush"})
|
||||
// public void transform(Player player, LocalSession session, EditSession editSession,
|
||||
// @Arg(desc = "The transform", def = "") ResettableExtent transform,
|
||||
// @Switch(name = 'h', desc = "TODO")
|
||||
// @Switch(name = 'h', desc = "Whether the offhand should be considered or not")
|
||||
// boolean offHand,
|
||||
// Arguments arguments) throws WorldEditException {
|
||||
// BrushTool tool = session.getBrushTool(player, false);
|
||||
|
@ -101,7 +101,7 @@ import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
|
||||
/**
|
||||
* Utility commands.
|
||||
*/
|
||||
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class})
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class UtilityCommands {
|
||||
|
||||
private final WorldEdit we;
|
||||
@ -111,8 +111,8 @@ public class UtilityCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/macro",
|
||||
desc = "Generate or run a macro"
|
||||
name = "/macro",
|
||||
desc = "Generate or run a macro"
|
||||
)
|
||||
@CommandPermissions("worldedit.macro")
|
||||
public void macro(Player player, LocalSession session, String name, String argument) throws IOException {
|
||||
@ -120,9 +120,9 @@ public class UtilityCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/heightmapinterface",
|
||||
name = "/heightmapinterface",
|
||||
aliases = { "/hmi", "hmi" },
|
||||
desc = "Generate the heightmap interface: https://github.com/boy0001/HeightMap"
|
||||
desc = "Generate the heightmap interface: https://github.com/boy0001/HeightMap"
|
||||
)
|
||||
@CommandPermissions("fawe.admin")
|
||||
public void heightmapInterface(Player player, @Arg(name = "min", desc = "int", def = "100") int min, @Arg(name = "max", desc = "int", def = "200") int max) throws IOException {
|
||||
@ -135,7 +135,7 @@ public class UtilityCommands {
|
||||
final int sub = srcFolder.getAbsolutePath().length();
|
||||
List<String> images = new ArrayList<>();
|
||||
MainUtil.iterateFiles(srcFolder, file -> {
|
||||
switch (file.getName().substring(file.getName().lastIndexOf('.')).toLowerCase()) {
|
||||
switch (file.getName().substring(file.getName().lastIndexOf('.')).toLowerCase(Locale.ROOT)) {
|
||||
case ".png":
|
||||
case ".jpeg":
|
||||
break;
|
||||
@ -144,7 +144,9 @@ public class UtilityCommands {
|
||||
}
|
||||
try {
|
||||
String name = file.getAbsolutePath().substring(sub);
|
||||
if (name.startsWith(File.separator)) name = name.replaceFirst(java.util.regex.Pattern.quote(File.separator), "");
|
||||
if (name.startsWith(File.separator)) {
|
||||
name = name.replaceFirst(java.util.regex.Pattern.quote(File.separator), "");
|
||||
}
|
||||
BufferedImage img = MainUtil.readImage(file);
|
||||
BufferedImage minImg = ImageUtil.getScaledInstance(img, min, min, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
|
||||
BufferedImage maxImg = max == -1 ? img : ImageUtil.getScaledInstance(img, max, max, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
|
||||
@ -173,20 +175,20 @@ public class UtilityCommands {
|
||||
config.append("// The local source for the image (used in commands)\n");
|
||||
config.append("var src_local = \"file://\";\n");
|
||||
File configFile = new File(webSrc, "config.js");
|
||||
player.print(TextComponent.of(String.format("Writing %s",configFile)));
|
||||
player.print(TextComponent.of(String.format("Writing %s", configFile)));
|
||||
Files.write(configFile.toPath(), config.toString().getBytes());
|
||||
player.print(TextComponent.of("Done! See: `FastAsyncWorldEdit/web/heightmap`"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/cancel",
|
||||
aliases= {"fcancel"},
|
||||
desc = "Cancel your current command"
|
||||
name = "/cancel",
|
||||
aliases = {"fcancel"},
|
||||
desc = "Cancel your current command"
|
||||
)
|
||||
@CommandPermissions(value = "fawe.cancel", queued = false)
|
||||
public void cancel(Player player) {
|
||||
int cancelled = player.cancel(false);
|
||||
player.print(Caption.of("fawe.cancel.worldedit.cancel.count" , cancelled));
|
||||
player.print(Caption.of("fawe.cancel.worldedit.cancel.count", cancelled));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -702,8 +704,8 @@ public class UtilityCommands {
|
||||
|
||||
|
||||
@Command(
|
||||
name = "/confirm",
|
||||
desc = "Confirm a command"
|
||||
name = "/confirm",
|
||||
desc = "Confirm a command"
|
||||
)
|
||||
@CommandPermissions(value = "fawe.confirm", queued = false)
|
||||
public void confirm(Player player) throws WorldEditException {
|
||||
@ -746,15 +748,16 @@ public class UtilityCommands {
|
||||
if (file.isDirectory()) {
|
||||
type = URIType.DIRECTORY;
|
||||
} else {
|
||||
if (name.indexOf('.') != -1)
|
||||
if (name.indexOf('.') != -1) {
|
||||
name = name.substring(0, name.lastIndexOf('.'));
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (!MainUtil.isInSubDirectory(root, file)) {
|
||||
throw new RuntimeException(
|
||||
new StopExecutionException(TextComponent.of("Invalid path")));
|
||||
}
|
||||
} catch (IOException ignore) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
} else if (uriStr.startsWith("http://") || uriStr.startsWith("https://")) {
|
||||
type = URIType.URL;
|
||||
@ -780,8 +783,9 @@ public class UtilityCommands {
|
||||
fileList.sort((f1, f2) -> {
|
||||
boolean dir1 = f1.isDirectory();
|
||||
boolean dir2 = f2.isDirectory();
|
||||
if (dir1 != dir2)
|
||||
if (dir1 != dir2) {
|
||||
return dir1 ? -1 : 1;
|
||||
}
|
||||
int res;
|
||||
if (sortType == 0) { // use name by default
|
||||
int p = f1.getParent().compareTo(f2.getParent());
|
||||
@ -792,8 +796,9 @@ public class UtilityCommands {
|
||||
}
|
||||
} else {
|
||||
res = Long.compare(f1.lastModified(), f2.lastModified()); // use date if there is a flag
|
||||
if (sortType == 1)
|
||||
if (sortType == 1) {
|
||||
res = -res; // flip date for newest first instead of oldest first
|
||||
}
|
||||
}
|
||||
return res;
|
||||
});
|
||||
@ -814,7 +819,7 @@ public class UtilityCommands {
|
||||
boolean listGlobal = !Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS;
|
||||
if (len > 0) {
|
||||
for (String arg : args) {
|
||||
switch (arg.toLowerCase()) {
|
||||
switch (arg.toLowerCase(Locale.ROOT)) {
|
||||
case "me":
|
||||
case "mine":
|
||||
case "local":
|
||||
@ -874,21 +879,27 @@ public class UtilityCommands {
|
||||
forEachFile = new DelegateConsumer<File>(forEachFile) {
|
||||
@Override
|
||||
public void accept(File file) {
|
||||
if (cf.isFormat(file)) super.accept(file);
|
||||
if (cf.isFormat(file)) {
|
||||
super.accept(file);
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
forEachFile = new DelegateConsumer<File>(forEachFile) {
|
||||
@Override
|
||||
public void accept(File file) {
|
||||
if (!file.toString().endsWith(".cached")) super.accept(file);
|
||||
if (!file.toString().endsWith(".cached")) {
|
||||
super.accept(file);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
if (playerFolder) {
|
||||
if (listMine) {
|
||||
File playerDir = MainUtil.resolveRelative(new File(dir, actor.getUniqueId() + dirFilter));
|
||||
if (playerDir.exists()) allFiles(playerDir.listFiles(), false, forEachFile);
|
||||
if (playerDir.exists()) {
|
||||
allFiles(playerDir.listFiles(), false, forEachFile);
|
||||
}
|
||||
}
|
||||
if (listGlobal) {
|
||||
File rel = MainUtil.resolveRelative(new File(dir, dirFilter));
|
||||
@ -905,37 +916,51 @@ public class UtilityCommands {
|
||||
super.accept(f);
|
||||
}
|
||||
};
|
||||
if (rel.exists()) allFiles(rel.listFiles(), false, forEachFile);
|
||||
if (rel.exists()) {
|
||||
allFiles(rel.listFiles(), false, forEachFile);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
File rel = MainUtil.resolveRelative(new File(dir, dirFilter));
|
||||
if (rel.exists()) allFiles(rel.listFiles(), false, forEachFile);
|
||||
if (rel.exists()) {
|
||||
allFiles(rel.listFiles(), false, forEachFile);
|
||||
}
|
||||
}
|
||||
if (!filters.isEmpty() && !toFilter.isEmpty()) {
|
||||
List<File> result = filter(toFilter, filters);
|
||||
for (File file : result) rootFunction.accept(file);
|
||||
for (File file : result) {
|
||||
rootFunction.accept(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<File> filter(List<File> fileList, List<String> filters) {
|
||||
String[] normalizedNames = new String[fileList.size()];
|
||||
for (int i = 0; i < fileList.size(); i++) {
|
||||
String normalized = fileList.get(i).getName().toLowerCase();
|
||||
if (normalized.startsWith("../")) normalized = normalized.substring(3);
|
||||
String normalized = fileList.get(i).getName().toLowerCase(Locale.ROOT);
|
||||
if (normalized.startsWith("../")) {
|
||||
normalized = normalized.substring(3);
|
||||
}
|
||||
normalizedNames[i] = normalized.replace("/", File.separator);
|
||||
}
|
||||
|
||||
for (String filter : filters) {
|
||||
if (fileList.isEmpty()) return fileList;
|
||||
String lowerFilter = filter.toLowerCase().replace("/", File.separator);
|
||||
if (fileList.isEmpty()) {
|
||||
return fileList;
|
||||
}
|
||||
String lowerFilter = filter.toLowerCase(Locale.ROOT).replace("/", File.separator);
|
||||
List<File> newList = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < normalizedNames.length; i++) {
|
||||
if (normalizedNames[i].startsWith(lowerFilter)) newList.add(fileList.get(i));
|
||||
if (normalizedNames[i].startsWith(lowerFilter)) {
|
||||
newList.add(fileList.get(i));
|
||||
}
|
||||
}
|
||||
if (newList.isEmpty()) {
|
||||
for (int i = 0; i < normalizedNames.length; i++) {
|
||||
if (normalizedNames[i].contains(lowerFilter)) newList.add(fileList.get(i));
|
||||
if (normalizedNames[i].contains(lowerFilter)) {
|
||||
newList.add(fileList.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (newList.isEmpty()) {
|
||||
@ -943,9 +968,11 @@ public class UtilityCommands {
|
||||
if (checkName.length() > 3 && checkName.length() <= 16) {
|
||||
UUID fromName = Fawe.imp().getUUID(checkName);
|
||||
if (fromName != null) {
|
||||
lowerFilter = filter.replaceFirst(checkName, fromName.toString()).toLowerCase();
|
||||
lowerFilter = filter.replaceFirst(checkName, fromName.toString()).toLowerCase(Locale.ROOT);
|
||||
for (int i = 0; i < normalizedNames.length; i++) {
|
||||
if (normalizedNames[i].startsWith(lowerFilter)) newList.add(fileList.get(i));
|
||||
if (normalizedNames[i].startsWith(lowerFilter)) {
|
||||
newList.add(fileList.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -957,7 +984,9 @@ public class UtilityCommands {
|
||||
}
|
||||
|
||||
public static void allFiles(File[] files, boolean recursive, Consumer<File> task) {
|
||||
if (files == null || files.length == 0) return;
|
||||
if (files == null || files.length == 0) {
|
||||
return;
|
||||
}
|
||||
for (File f : files) {
|
||||
if (f.isDirectory()) {
|
||||
if (recursive) {
|
||||
|
@ -78,22 +78,22 @@ public class WorldEditCommands {
|
||||
FaweVersion fVer = Fawe.get().getVersion();
|
||||
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
|
||||
actor.print(TextComponent.of("FastAsyncWorldEdit" + fVerStr + " created by Empire92, MattBDev, IronApollo, dordsor21 and NotMyFault"));
|
||||
|
||||
|
||||
if (fVer != null) {
|
||||
FaweVersion version = Fawe.get().getVersion();
|
||||
Date date = new GregorianCalendar(2000 + version.year, version.month - 1, version.day)
|
||||
.getTime();
|
||||
|
||||
TextComponent dateArg = TextComponent.of(date.toLocaleString());
|
||||
TextComponent commitArg = TextComponent.of(Integer.toHexString(version.hash));
|
||||
TextComponent buildArg = TextComponent.of(version.build);
|
||||
TextComponent platformArg = TextComponent.of(Settings.IMP.PLATFORM);
|
||||
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.version.version", dateArg, commitArg, buildArg, platformArg));
|
||||
|
||||
TextComponent dateArg = TextComponent.of(date.toLocaleString());
|
||||
TextComponent commitArg = TextComponent.of(Integer.toHexString(version.hash));
|
||||
TextComponent buildArg = TextComponent.of(version.build);
|
||||
TextComponent platformArg = TextComponent.of(Settings.IMP.PLATFORM);
|
||||
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.version.version", dateArg, commitArg, buildArg, platformArg));
|
||||
}
|
||||
|
||||
actor.printInfo(TextComponent.of("Wiki: https://wiki.intellectualsites.com/FastAsyncWorldEdit/index"));
|
||||
|
||||
|
||||
actor.printInfo(TextComponent.of("Wiki: https://wiki.intellectualsites.com/FastAsyncWorldEdit/index"));
|
||||
|
||||
PlatformManager pm = we.getPlatformManager();
|
||||
|
||||
TextComponentProducer producer = new TextComponentProducer();
|
||||
@ -104,19 +104,19 @@ public class WorldEditCommands {
|
||||
.append(TextComponent.of("(" + platform.getPlatformVersion() + ")"))
|
||||
).newline();
|
||||
}
|
||||
actor.print(new MessageBox("Platforms", producer, TextColor.GRAY).create());
|
||||
|
||||
producer.reset();
|
||||
for (Capability capability : Capability.values()) {
|
||||
actor.print(new MessageBox("Platforms", producer, TextColor.GRAY).create());
|
||||
|
||||
producer.reset();
|
||||
for (Capability capability : Capability.values()) {
|
||||
Platform platform = pm.queryCapability(capability);
|
||||
producer.append(
|
||||
TextComponent.of(capability.name(), TextColor.GRAY)
|
||||
TextComponent.of(capability.name(), TextColor.GRAY)
|
||||
.append(TextComponent.of(": ")
|
||||
.append(TextComponent.of(platform != null ? platform.getPlatformName() : "NONE")))
|
||||
).newline();
|
||||
}
|
||||
actor.print(new MessageBox("Capabilities", producer, TextColor.GRAY).create());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -67,7 +67,7 @@ public class AreaPickaxe implements BlockTool {
|
||||
|
||||
try {
|
||||
for (int x = ox - range; x <= ox + range; ++x) {
|
||||
for (int y = oy - range; y <= oy + range; ++y) {
|
||||
for (int y = oy - range; y <= oy + range; ++y) {
|
||||
for (int z = oz - range; z <= oz + range; ++z) {
|
||||
if (!initialType.equals(editSession.getBlock(x, y, z).getBlockType())) {
|
||||
continue;
|
||||
|
@ -280,7 +280,7 @@ public class BrushTool
|
||||
/**
|
||||
* Set the brush.
|
||||
*
|
||||
* @param brush tbe brush
|
||||
* @param brush the brush
|
||||
* @param permission the permission
|
||||
*/
|
||||
public void setBrush(Brush brush, String permission) {
|
||||
|
@ -33,7 +33,7 @@ public enum NavigationWand implements DoubleActionTraceTool {
|
||||
@Override
|
||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||
if (!player.hasPermission("worldedit.navigation.jumpto.tool")) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
final int maxDist = config.navigationWandMaxDistance;
|
||||
if (maxDist <= 0) {
|
||||
|
@ -55,7 +55,7 @@ import java.io.File;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a player
|
||||
* Represents a player.
|
||||
*/
|
||||
public interface Player extends Entity, Actor {
|
||||
|
||||
@ -356,30 +356,29 @@ public interface Player extends Entity, Actor {
|
||||
void setSelection(Region region);
|
||||
|
||||
/**
|
||||
* Get the player's current selection (or null)
|
||||
* Get the player's selection region. If the selection is defined in
|
||||
* a different world, the {@code IncompleteRegionException}
|
||||
* exception will be thrown.
|
||||
*
|
||||
* @return
|
||||
* @return a region
|
||||
* @throws IncompleteRegionException if no region is selected
|
||||
*/
|
||||
default Region getSelection() {
|
||||
try {
|
||||
return getSession().getSelection(getWorld());
|
||||
} catch (IncompleteRegionException e) {
|
||||
return null;
|
||||
}
|
||||
default Region getSelection() throws IncompleteRegionException {
|
||||
return getSession().getSelection(getWorld());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the player's WorldEdit selection
|
||||
* Set the player's WorldEdit selection.
|
||||
*
|
||||
* @param selector
|
||||
* @param selector the selector
|
||||
*/
|
||||
default void setSelection(RegionSelector selector) {
|
||||
getSession().setRegionSelector(getWorld(), selector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the World the player is editing in (may not match the world they are in)<br/> - e.g., If
|
||||
* they are editing a CFI world.<br/>
|
||||
* Get the world the player is editing in. The world may or may not match the world they are in.
|
||||
* For example, if they are editing a CFI world.
|
||||
*
|
||||
* @return Editing world
|
||||
*/
|
||||
@ -396,7 +395,7 @@ public interface Player extends Entity, Actor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this player (deletes all metadata etc) - Usually called on logout
|
||||
* Unregister this player, deleting all data stored during the logon session.
|
||||
*/
|
||||
default void unregister() {
|
||||
cancel(true);
|
||||
@ -410,7 +409,7 @@ public interface Player extends Entity, Actor {
|
||||
void sendTitle(Component title, Component sub);
|
||||
|
||||
/**
|
||||
* Loads any history items from disk: - Should already be called if history on disk is enabled
|
||||
* Loads any history items from disk: - Should already be called if history on disk is enabled.
|
||||
*/
|
||||
default void loadClipboardFromDisk() {
|
||||
File file = MainUtil.getFile(Fawe.imp().getDirectory(),
|
||||
|
@ -89,7 +89,8 @@ public class EditSessionEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return the actor, which may be null if unavailable
|
||||
*/
|
||||
public @Nullable Actor getActor() {
|
||||
@Nullable
|
||||
public Actor getActor() {
|
||||
return actor;
|
||||
}
|
||||
|
||||
@ -98,7 +99,8 @@ public class EditSessionEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return the world
|
||||
*/
|
||||
public @Nullable World getWorld() {
|
||||
@Nullable
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
stateString = blockAndExtraData[0].substring(stateStart + 1, blockAndExtraData[0].length() - 1);
|
||||
}
|
||||
String[] stateProperties = EMPTY_STRING_ARRAY;
|
||||
if(stateString != null) {
|
||||
if (stateString != null) {
|
||||
stateProperties = stateString.split(",");
|
||||
}
|
||||
if (typeString.isEmpty()) {
|
||||
|
@ -55,8 +55,12 @@ public abstract class RichParser<E> extends InputParser<E> {
|
||||
|
||||
@Override
|
||||
public E parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||
if (!input.startsWith(this.prefix)) return null;
|
||||
if (input.length() < this.prefix.length()) return null;
|
||||
if (!input.startsWith(this.prefix)) {
|
||||
return null;
|
||||
}
|
||||
if (input.length() < this.prefix.length()) {
|
||||
return null;
|
||||
}
|
||||
String[] arguments = extractArguments(input.substring(prefix.length()), true);
|
||||
return parseFromInput(arguments, context);
|
||||
}
|
||||
|
@ -29,14 +29,18 @@ public class AdjacentMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length == 0) return null;
|
||||
if (arguments.length == 0) {
|
||||
return null;
|
||||
}
|
||||
Mask subMask = worldEdit.getMaskFactory().parseFromInput(arguments[0], context);
|
||||
int min = arguments.length > 1 ? Integer.parseInt(arguments[1]) : -1;
|
||||
int max = arguments.length > 2 ? Integer.parseInt(arguments[2]) : -1;
|
||||
if (min == -1 && max == -1) {
|
||||
min = 1;
|
||||
max = 8;
|
||||
} else if (max == -1) max = min;
|
||||
} else if (max == -1) {
|
||||
max = min;
|
||||
}
|
||||
if (max >= 8 && min == 1) {
|
||||
return new AdjacentAnyMask(subMask);
|
||||
}
|
||||
|
@ -30,14 +30,15 @@ public class AngleMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) return null;
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) {
|
||||
return null;
|
||||
}
|
||||
String minArg = arguments[0];
|
||||
String maxArg = arguments[1];
|
||||
boolean degree = minArg.endsWith("d");
|
||||
if (degree ^ maxArg.endsWith("d")) {
|
||||
throw new InputParseException("Cannot combine degree with block-step");
|
||||
}
|
||||
double min, max;
|
||||
boolean overlay = false;
|
||||
if (arguments.length > 2) {
|
||||
for (int index = 2; index < 2 + flags.length; index++) {
|
||||
@ -49,6 +50,8 @@ public class AngleMaskParser extends RichParser<Mask> {
|
||||
}
|
||||
}
|
||||
}
|
||||
double min;
|
||||
double max;
|
||||
if (degree) {
|
||||
double minDeg = Double.parseDouble(minArg.substring(0, minArg.length() - 1));
|
||||
double maxDeg = Double.parseDouble(maxArg.substring(0, maxArg.length() - 1));
|
||||
|
@ -118,7 +118,7 @@
|
||||
//// () -> {
|
||||
//// if (full.length() == 1) return new ArrayList<>(dispatcher.getPrimaryAliases());
|
||||
//// return dispatcher.getAliases().stream().filter(
|
||||
//// s -> s.startsWith(command.toLowerCase())
|
||||
//// s -> s.startsWith(command.toLowerCase(Locale.ROOT))
|
||||
//// ).collect(Collectors.toList());
|
||||
//// }
|
||||
//// );
|
||||
@ -147,7 +147,7 @@
|
||||
// input = input.substring(input.indexOf(char0) + 1);
|
||||
// mask = parseFromInput(char0 + "[" + input + "]", context);
|
||||
// if (actor != null) {
|
||||
// actor.print(Caption.of("fawe.worldedit.help.command.clarifying.bracket" , char0 + "[" + input + "]"));
|
||||
// actor.print(Caption.of("fawe.worldedit.help.command.clarifying.bracket", char0 + "[" + input + "]"));
|
||||
// }
|
||||
// return mask;
|
||||
// }
|
||||
@ -164,7 +164,7 @@
|
||||
// {
|
||||
// try {
|
||||
// builder.addRegex(full);
|
||||
// } catch (InputParseException ignore) {}
|
||||
// } catch (InputParseException ignored) {}
|
||||
// }
|
||||
// if (mask == null) {
|
||||
// context.setPreferringWildcard(false);
|
||||
|
@ -30,14 +30,17 @@ public class ExtremaMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) return null;
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) {
|
||||
return null;
|
||||
}
|
||||
String minArg = arguments[0];
|
||||
String maxArg = arguments[1];
|
||||
boolean degree = minArg.endsWith("d");
|
||||
if (degree ^ maxArg.endsWith("d")) {
|
||||
throw new InputParseException("Cannot combine degree with block-step");
|
||||
}
|
||||
double min, max;
|
||||
double min;
|
||||
double max;
|
||||
boolean overlay = false;
|
||||
if (arguments.length > 2) {
|
||||
for (int index = 2; index < 2 + flags.length; index++) {
|
||||
|
@ -30,14 +30,17 @@ public class ROCAngleMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) return null;
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) {
|
||||
return null;
|
||||
}
|
||||
String minArg = arguments[0];
|
||||
String maxArg = arguments[1];
|
||||
boolean degree = minArg.endsWith("d");
|
||||
if (degree ^ maxArg.endsWith("d")) {
|
||||
throw new InputParseException("Cannot combine degree with block-step");
|
||||
}
|
||||
double min, max;
|
||||
double min;
|
||||
double max;
|
||||
boolean overlay = false;
|
||||
if (arguments.length > 2) {
|
||||
for (int index = 2; index < 2 + flags.length; index++) {
|
||||
|
@ -26,7 +26,9 @@ public class RadiusMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2) return null;
|
||||
if (arguments.length < 2) {
|
||||
return null;
|
||||
}
|
||||
int min = Integer.parseInt(arguments[0]);
|
||||
int max = Integer.parseInt(arguments[1]);
|
||||
return new RadiusMask(min, max);
|
||||
|
@ -27,7 +27,9 @@ public class SimplexMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length != 3) return null;
|
||||
if (arguments.length != 3) {
|
||||
return null;
|
||||
}
|
||||
double scale = Double.parseDouble(arguments[0]);
|
||||
double min = Double.parseDouble(arguments[1]);
|
||||
double max = Double.parseDouble(arguments[2]);
|
||||
|
@ -5,7 +5,10 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.*;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
|
@ -26,6 +26,8 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
@ -79,7 +81,7 @@ public class RandomPatternParser extends InputParser<Pattern> {
|
||||
String[] p = token.split("%", 2);
|
||||
|
||||
if (p.length < 2) {
|
||||
throw new InputParseException("Missing the type after the % symbol for '" + input + "'");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.missing-random-type", TextComponent.of(input)));
|
||||
} else {
|
||||
chance = Double.parseDouble(p[0]);
|
||||
innerPattern = worldEdit.getPatternFactory().parseFromInput(p[1], context);
|
||||
|
@ -30,6 +30,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.StateApplyingPattern;
|
||||
import com.sk89q.worldedit.function.pattern.TypeApplyingPattern;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -82,19 +84,29 @@ public class TypeOrStateApplyingPatternParser extends InputParser<Pattern> {
|
||||
worldEdit.getBlockFactory().parseFromInput(type, context).getBlockType().getDefaultState());
|
||||
} else {
|
||||
// states given
|
||||
if (!parts[1].endsWith("]")) throw new InputParseException("State is missing trailing ']'");
|
||||
if (!parts[1].endsWith("]")) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.missing-rbracket"));
|
||||
}
|
||||
final String[] states = parts[1].substring(0, parts[1].length() - 1).split(",");
|
||||
Map<String, String> statesToSet = new HashMap<>();
|
||||
for (String state : states) {
|
||||
if (state.isEmpty()) throw new InputParseException("Empty part in state");
|
||||
if (state.isEmpty()) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.empty-state"));
|
||||
}
|
||||
String[] propVal = state.split("=", 2);
|
||||
if (propVal.length != 2) throw new InputParseException("Missing '=' separator");
|
||||
if (propVal.length != 2) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.missing-equals-separator"));
|
||||
}
|
||||
final String prop = propVal[0];
|
||||
if (prop.isEmpty()) throw new InputParseException("Empty property in state");
|
||||
if (prop.isEmpty()) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.empty-property"));
|
||||
}
|
||||
final String value = propVal[1];
|
||||
if (value.isEmpty()) throw new InputParseException("Empty value in state");
|
||||
if (value.isEmpty()) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.empty-value"));
|
||||
}
|
||||
if (statesToSet.put(prop, value) != null) {
|
||||
throw new InputParseException("Duplicate properties in state");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.duplicate-property", TextComponent.of(prop)));
|
||||
}
|
||||
}
|
||||
if (type.isEmpty()) {
|
||||
|
@ -36,10 +36,14 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public class ParserContext {
|
||||
|
||||
private @Nullable Extent extent;
|
||||
private @Nullable LocalSession session;
|
||||
private @Nullable World world;
|
||||
private @Nullable Actor actor;
|
||||
@Nullable
|
||||
private Extent extent;
|
||||
@Nullable
|
||||
private LocalSession session;
|
||||
@Nullable
|
||||
private World world;
|
||||
@Nullable
|
||||
private Actor actor;
|
||||
private boolean restricted = true;
|
||||
private boolean tryLegacy = true;
|
||||
private boolean preferringWildcard;
|
||||
@ -71,7 +75,8 @@ public class ParserContext {
|
||||
*
|
||||
* @return an extent
|
||||
*/
|
||||
public @Nullable Extent getExtent() {
|
||||
@Nullable
|
||||
public Extent getExtent() {
|
||||
return extent;
|
||||
}
|
||||
|
||||
@ -89,7 +94,8 @@ public class ParserContext {
|
||||
*
|
||||
* @return a session
|
||||
*/
|
||||
public @Nullable LocalSession getSession() {
|
||||
@Nullable
|
||||
public LocalSession getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
@ -107,7 +113,8 @@ public class ParserContext {
|
||||
*
|
||||
* @return a world
|
||||
*/
|
||||
public @Nullable World getWorld() {
|
||||
@Nullable
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@ -126,7 +133,8 @@ public class ParserContext {
|
||||
*
|
||||
* @return an actor, or null
|
||||
*/
|
||||
public @Nullable Actor getActor() {
|
||||
@Nullable
|
||||
public Actor getActor() {
|
||||
return actor;
|
||||
}
|
||||
|
||||
|
@ -76,22 +76,8 @@ import javax.annotation.Nullable;
|
||||
* players that make use of WorldEdit.
|
||||
*/
|
||||
public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
private final Map<String, Object> meta;
|
||||
|
||||
public AbstractPlayerActor(Map<String, Object> meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public AbstractPlayerActor() {
|
||||
this(new ConcurrentHashMap<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRawMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
// Queue for async tasks
|
||||
private AtomicInteger runningCount = new AtomicInteger();
|
||||
private AsyncNotifyQueue asyncNotifyQueue = new AsyncNotifyQueue(
|
||||
@ -111,6 +97,14 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
}
|
||||
});
|
||||
|
||||
public AbstractPlayerActor(Map<String, Object> meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public AbstractPlayerActor() {
|
||||
this(new ConcurrentHashMap<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Extent getExtent() {
|
||||
return getWorld();
|
||||
@ -146,6 +140,11 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRawMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHoldingPickAxe() {
|
||||
ItemType item = getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
@ -250,7 +249,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
return false;
|
||||
}
|
||||
return getWorld().getBlock(location.add(0, -1, 0)).getBlockType().getMaterial()
|
||||
.isMovementBlocker();
|
||||
.isMovementBlocker();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -522,6 +521,52 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
return getCardinalDirection(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player's current allowed WorldEdit regions.
|
||||
*
|
||||
* @return an array of allowed regions
|
||||
*/
|
||||
public Region[] getCurrentRegions() {
|
||||
return getCurrentRegions(FaweMaskManager.MaskType.MEMBER);
|
||||
}
|
||||
|
||||
public Region[] getCurrentRegions(FaweMaskManager.MaskType type) {
|
||||
return WEManager.IMP.getMask(this, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the largest region in the player's allowed WorldEdit region.
|
||||
*/
|
||||
public Region getLargestRegion() {
|
||||
long area = 0;
|
||||
Region max = null;
|
||||
for (Region region : this.getCurrentRegions()) {
|
||||
final long tmp = region.getVolume();
|
||||
if (tmp > area) {
|
||||
area = tmp;
|
||||
max = region;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public void setSelection(Region region) {
|
||||
RegionSelector selector;
|
||||
if (region instanceof ConvexPolyhedralRegion) {
|
||||
selector = new ConvexPolyhedralRegionSelector((ConvexPolyhedralRegion) region);
|
||||
} else if (region instanceof CylinderRegion) {
|
||||
selector = new CylinderRegionSelector((CylinderRegion) region);
|
||||
} else if (region instanceof Polygonal2DRegion) {
|
||||
selector = new Polygonal2DRegionSelector((Polygonal2DRegion) region);
|
||||
} else {
|
||||
selector = new CuboidRegionSelector(null, region.getMinimumPoint(),
|
||||
region.getMaximumPoint());
|
||||
}
|
||||
selector.setWorld(region.getWorld());
|
||||
|
||||
getSession().setRegionSelector(getWorld(), selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getCardinalDirection(int yawOffset) {
|
||||
final Location location = getLocation();
|
||||
@ -631,6 +676,36 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a task either async, or on the current thread.
|
||||
*
|
||||
* @param ifFree the task to run if free
|
||||
* @param checkFree Whether to first check if a task is running
|
||||
* @param async TODO description
|
||||
* @return false if the task was ran or queued
|
||||
*/
|
||||
public boolean runAction(Runnable ifFree, boolean checkFree, boolean async) {
|
||||
if (checkFree) {
|
||||
if (runningCount.get() != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Runnable wrapped = () -> {
|
||||
try {
|
||||
runningCount.addAndGet(1);
|
||||
ifFree.run();
|
||||
} finally {
|
||||
runningCount.decrementAndGet();
|
||||
}
|
||||
};
|
||||
if (async) {
|
||||
asyncNotifyQueue.run(wrapped);
|
||||
} else {
|
||||
TaskManager.IMP.taskNow(wrapped, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDestroyBedrock() {
|
||||
return hasPermission("worldedit.override.bedrock");
|
||||
@ -690,84 +765,4 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a task either async, or on the current thread.
|
||||
*
|
||||
* @param ifFree the task to run if free
|
||||
* @param checkFree Whether to first check if a task is running
|
||||
* @param async TODO description
|
||||
* @return false if the task was ran or queued
|
||||
*/
|
||||
public boolean runAction(Runnable ifFree, boolean checkFree, boolean async) {
|
||||
if (checkFree) {
|
||||
if (runningCount.get() != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Runnable wrapped = () -> {
|
||||
try {
|
||||
runningCount.addAndGet(1);
|
||||
ifFree.run();
|
||||
} finally {
|
||||
runningCount.decrementAndGet();
|
||||
}
|
||||
};
|
||||
if (async) {
|
||||
asyncNotifyQueue.run(wrapped);
|
||||
} else {
|
||||
TaskManager.IMP.taskNow(wrapped, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the player's current allowed WorldEdit regions.
|
||||
*
|
||||
* @return an array of allowed regions
|
||||
*/
|
||||
public Region[] getCurrentRegions() {
|
||||
return getCurrentRegions(FaweMaskManager.MaskType.MEMBER);
|
||||
}
|
||||
|
||||
public Region[] getCurrentRegions(FaweMaskManager.MaskType type) {
|
||||
return WEManager.IMP.getMask(this, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the largest region in the player's allowed WorldEdit region.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Region getLargestRegion() {
|
||||
long area = 0;
|
||||
Region max = null;
|
||||
for (Region region : this.getCurrentRegions()) {
|
||||
final long tmp = region.getVolume();
|
||||
if (tmp > area) {
|
||||
area = tmp;
|
||||
max = region;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public void setSelection(Region region) {
|
||||
RegionSelector selector;
|
||||
if (region instanceof ConvexPolyhedralRegion) {
|
||||
selector = new ConvexPolyhedralRegionSelector((ConvexPolyhedralRegion) region);
|
||||
} else if (region instanceof CylinderRegion) {
|
||||
selector = new CylinderRegionSelector((CylinderRegion) region);
|
||||
} else if (region instanceof Polygonal2DRegion) {
|
||||
selector = new Polygonal2DRegionSelector((Polygonal2DRegion) region);
|
||||
} else {
|
||||
selector = new CuboidRegionSelector(null, region.getMinimumPoint(),
|
||||
region.getMaximumPoint());
|
||||
}
|
||||
selector.setWorld(region.getWorld());
|
||||
|
||||
getSession().setRegionSelector(getWorld(), selector);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -98,7 +98,8 @@ public interface Platform {
|
||||
*
|
||||
* @return the watchdog service, or {@code null} if none
|
||||
*/
|
||||
default @Nullable Watchdog getWatchdog() {
|
||||
@Nullable
|
||||
default Watchdog getWatchdog() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -620,7 +620,9 @@ public final class PlatformCommandManager {
|
||||
}
|
||||
|
||||
public int parseCommand(String args, InjectedValueAccess access) {
|
||||
if (args.isEmpty()) return 0;
|
||||
if (args.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
String[] split = parseArgs(args)
|
||||
.map(Substring::getSubstring)
|
||||
.toArray(String[]::new);
|
||||
@ -841,6 +843,7 @@ public final class PlatformCommandManager {
|
||||
}
|
||||
throw t;
|
||||
}
|
||||
|
||||
event.setSuggestions(suggestions.stream()
|
||||
.map(suggestion -> {
|
||||
int noSlashLength = arguments.length() - 1;
|
||||
|
@ -77,7 +77,8 @@ public class PlatformManager {
|
||||
private final PlatformCommandManager platformCommandManager;
|
||||
private final List<Platform> platforms = new ArrayList<>();
|
||||
private final Map<Capability, Platform> preferences = new EnumMap<>(Capability.class);
|
||||
private @Nullable String firstSeenVersion;
|
||||
@Nullable
|
||||
private String firstSeenVersion;
|
||||
private final AtomicBoolean initialized = new AtomicBoolean();
|
||||
private final AtomicBoolean configured = new AtomicBoolean();
|
||||
|
||||
@ -112,9 +113,8 @@ public class PlatformManager {
|
||||
// Make sure that versions are in sync
|
||||
if (firstSeenVersion != null) {
|
||||
if (!firstSeenVersion.equals(platform.getVersion())) {
|
||||
logger.warn("Multiple ports of WorldEdit are installed but they report different versions ({} and {}). " +
|
||||
"If these two versions are truly different, then you may run into unexpected crashes and errors.",
|
||||
new Object[]{ firstSeenVersion, platform.getVersion() });
|
||||
logger.warn("Multiple ports of WorldEdit are installed but they report different versions ({} and {}). "
|
||||
+ "If these two versions are truly different, then you may run into unexpected crashes and errors.", firstSeenVersion, platform.getVersion());
|
||||
}
|
||||
} else {
|
||||
firstSeenVersion = platform.getVersion();
|
||||
@ -209,7 +209,8 @@ public class PlatformManager {
|
||||
* @param capability the capability
|
||||
* @return the most preferred platform, or null if no platform was found
|
||||
*/
|
||||
private synchronized @Nullable Platform findMostPreferred(Capability capability) {
|
||||
@Nullable
|
||||
private synchronized Platform findMostPreferred(Capability capability) {
|
||||
Platform preferred = null;
|
||||
Preference highest = null;
|
||||
|
||||
@ -352,7 +353,9 @@ public class PlatformManager {
|
||||
}
|
||||
|
||||
virtual.handleBlockInteract(player, vector.toBlockPoint(), event);
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getType() == Interaction.HIT) {
|
||||
@ -363,8 +366,8 @@ public class PlatformManager {
|
||||
if (superPickaxe != null && superPickaxe.canUse(player)) {
|
||||
player.runAction(() -> reset(superPickaxe)
|
||||
.actPrimary(queryCapability(Capability.WORLD_EDITING),
|
||||
getConfiguration(), player, session, location), false, true);
|
||||
event.setCancelled(true);
|
||||
getConfiguration(), player, session, location), false, true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -373,11 +376,11 @@ public class PlatformManager {
|
||||
if (tool instanceof DoubleActionBlockTool && tool.canUse(player)) {
|
||||
player.runAction(() -> reset((DoubleActionBlockTool) tool)
|
||||
.actSecondary(queryCapability(Capability.WORLD_EDITING),
|
||||
getConfiguration(), player, session, location), false, true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
getConfiguration(), player, session, location), false, true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
} else if (event.getType() == Interaction.OPEN) {
|
||||
} else if (event.getType() == Interaction.OPEN) {
|
||||
Tool tool = session.getTool(player);
|
||||
if (tool instanceof BlockTool && tool.canUse(player)) {
|
||||
if (player.checkAction()) {
|
||||
@ -385,14 +388,14 @@ public class PlatformManager {
|
||||
BlockTool blockTool = (BlockTool) tool;
|
||||
if (!(tool instanceof BrushTool)) {
|
||||
blockTool = reset(blockTool);
|
||||
}
|
||||
}
|
||||
blockTool.actPrimary(queryCapability(Capability.WORLD_EDITING),
|
||||
getConfiguration(), player, session, location);
|
||||
getConfiguration(), player, session, location);
|
||||
}, false, true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
handleThrowable(e, actor);
|
||||
} finally {
|
||||
@ -403,7 +406,7 @@ public class PlatformManager {
|
||||
public void handleThrowable(Throwable e, Actor actor) {
|
||||
FaweException faweException = FaweException.get(e);
|
||||
if (faweException != null) {
|
||||
actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason" , faweException.getComponent()));
|
||||
actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason", faweException.getComponent()));
|
||||
} else {
|
||||
actor.printError("Please report this error: [See console]");
|
||||
actor.printRaw(e.getClass().getName() + ": " + e.getMessage());
|
||||
@ -423,7 +426,9 @@ public class PlatformManager {
|
||||
logger.info("virtualWorld was not null in handlePlayerInput()");
|
||||
}
|
||||
virtual.handlePlayerInput(player, event);
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@ -432,10 +437,10 @@ public class PlatformManager {
|
||||
Tool tool = session.getTool(player);
|
||||
if (tool instanceof DoubleActionTraceTool && tool.canUse(player)) {
|
||||
player.runAsyncIfFree(() -> reset((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING),
|
||||
getConfiguration(), player, session));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
getConfiguration(), player, session));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@ -445,10 +450,10 @@ public class PlatformManager {
|
||||
if (tool instanceof TraceTool && tool.canUse(player)) {
|
||||
//todo this needs to be fixed so the event is canceled after actPrimary is used and returns true
|
||||
player.runAction(() -> reset((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING),
|
||||
getConfiguration(), player, session), false, true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
getConfiguration(), player, session), false, true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@ -456,7 +461,7 @@ public class PlatformManager {
|
||||
} catch (Throwable e) {
|
||||
FaweException faweException = FaweException.get(e);
|
||||
if (faweException != null) {
|
||||
player.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason" , faweException.getComponent()));
|
||||
player.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason", faweException.getComponent()));
|
||||
} else {
|
||||
player.printError("Please report this error: [See console]");
|
||||
player.printRaw(e.getClass().getName() + ": " + e.getMessage());
|
||||
|
@ -41,7 +41,9 @@ public class Bindings {
|
||||
private boolean register(Method method, InjectedValueStore store, CommandManager manager) {
|
||||
// Check that it has the binding
|
||||
Binding binding = method.getAnnotation(Binding.class);
|
||||
if (binding == null) return false;
|
||||
if (binding == null) {
|
||||
return false;
|
||||
}
|
||||
Annotation[] annotations = method.getAnnotations();
|
||||
|
||||
// Get the key
|
||||
@ -49,7 +51,7 @@ public class Bindings {
|
||||
Key key;
|
||||
if ( annotations.length == 1) {
|
||||
key = Key.of(ret);
|
||||
}else if (annotations.length == 2) {
|
||||
} else if (annotations.length == 2) {
|
||||
Annotation annotation = annotations[0] == binding ? annotations[1] : annotations[0];
|
||||
key = Key.of(ret, annotation);
|
||||
} else {
|
||||
|
@ -124,7 +124,7 @@ public class ConsumeBindings extends Bindings {
|
||||
uuid = Fawe.imp().getUUID(argument);
|
||||
}
|
||||
if (uuid == null) {
|
||||
throw new InputParseException(Caption.toString(Caption.of("fawe.error.player.not.found" , argument)));
|
||||
throw new InputParseException(Caption.toString(Caption.of("fawe.error.player.not.found", argument)));
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
@ -202,7 +202,9 @@ public class ConsumeBindings extends Bindings {
|
||||
public BiomeType getBiomeType(String argument) throws WorldEditException {
|
||||
if (argument != null) {
|
||||
|
||||
if (MathMan.isInteger(argument)) return BiomeTypes.getLegacy(Integer.parseInt(argument));
|
||||
if (MathMan.isInteger(argument)) {
|
||||
return BiomeTypes.getLegacy(Integer.parseInt(argument));
|
||||
}
|
||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
Collection<BiomeType> knownBiomes = BiomeType.REGISTRY.values();
|
||||
|
@ -103,7 +103,9 @@ public class PrimitiveBindings extends Bindings {
|
||||
@Binding
|
||||
public Vector3 getVector3(String argument) {
|
||||
String[] radii = argument.split(",");
|
||||
final double radiusX, radiusY, radiusZ;
|
||||
final double radiusX;
|
||||
final double radiusY;
|
||||
final double radiusZ;
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]);
|
||||
@ -133,7 +135,8 @@ public class PrimitiveBindings extends Bindings {
|
||||
public Vector2 getVector2(String argument) {
|
||||
String radiusString = argument;
|
||||
String[] radii = radiusString.split(",");
|
||||
final double radiusX, radiusZ;
|
||||
final double radiusX;
|
||||
final double radiusZ;
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]);
|
||||
@ -161,7 +164,9 @@ public class PrimitiveBindings extends Bindings {
|
||||
public BlockVector3 getBlockVector3(String argument) {
|
||||
String radiusString = argument;
|
||||
String[] radii = radiusString.split(",");
|
||||
final double radiusX, radiusY, radiusZ;
|
||||
final double radiusX;
|
||||
final double radiusY;
|
||||
final double radiusZ;
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]);
|
||||
@ -190,7 +195,8 @@ public class PrimitiveBindings extends Bindings {
|
||||
@Binding
|
||||
public BlockVector2 getBlockVector2(String argument) {
|
||||
String[] radii = argument.split(",");
|
||||
final double radiusX, radiusZ;
|
||||
final double radiusX;
|
||||
final double radiusZ;
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusZ = parseNumericInput(radii[0]);
|
||||
@ -214,7 +220,8 @@ public class PrimitiveBindings extends Bindings {
|
||||
* @return a number
|
||||
* @throws InputParseException thrown on parse error
|
||||
*/
|
||||
public static @Nullable Double parseNumericInput(@Nullable String input) {
|
||||
@Nullable
|
||||
public static Double parseNumericInput(@Nullable String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -85,8 +85,8 @@ public class AbstractDelegateExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||
return extent.getFullBlock(x, y, z);
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
return extent.getBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,39 +100,38 @@ public class AbstractDelegateExtent implements Extent {
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean isQueueEnabled() {
|
||||
return extent.isQueueEnabled();
|
||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||
return extent.getFullBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableQueue() {
|
||||
try {
|
||||
if (!(extent instanceof ForgetfulExtentBuffer)) { // placeholder
|
||||
extent.disableQueue();
|
||||
}
|
||||
} catch (FaweException ignored) {
|
||||
}
|
||||
if (extent instanceof AbstractDelegateExtent) {
|
||||
Extent next = ((AbstractDelegateExtent) extent).getExtent();
|
||||
new ExtentTraverser(this).setNext(next);
|
||||
} else {
|
||||
getLogger(AbstractDelegateExtent.class).debug("Cannot disable queue");
|
||||
}
|
||||
public BiomeType getBiomeType(int x, int y, int z) {
|
||||
return extent.getBiomeType(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableQueue() {
|
||||
try {
|
||||
extent.enableQueue();
|
||||
} catch (FaweException enableQueue) {
|
||||
// TODO NOT IMPLEMENTED - THIS IS IMPORTANT (ForgetfulExtentBuffer is just a placeholder for now, it won't work)
|
||||
new ExtentTraverser<>(this).setNext(new ForgetfulExtentBuffer(extent));
|
||||
}
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
return extent.getBiome(position);
|
||||
}
|
||||
/*
|
||||
History
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int getEmmittedLight(int x, int y, int z) {
|
||||
return extent.getEmmittedLight(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSkyLight(int x, int y, int z) {
|
||||
return extent.getSkyLight(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBrightness(int x, int y, int z) {
|
||||
return extent.getBrightness(x, y, z);
|
||||
}
|
||||
|
||||
public void setChangeSet(AbstractChangeSet changeSet) {
|
||||
if (extent instanceof HistoryExtent) {
|
||||
HistoryExtent history = ((HistoryExtent) extent);
|
||||
@ -148,57 +147,6 @@ public class AbstractDelegateExtent implements Extent {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxY() {
|
||||
return extent.getMaxY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
return extent.getBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
return extent.createEntity(location, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntity(int x, int y, int z, UUID uuid) {
|
||||
extent.removeEntity(x, y, z, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities() {
|
||||
return extent.getEntities();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
return extent.getEntities(region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fullySupports3DBiomes() {
|
||||
return extent.fullySupports3DBiomes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
return extent.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiomeType(int x, int y, int z) {
|
||||
return extent.getBiomeType(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return extent.setBiome(x, y, z, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block)
|
||||
throws WorldEditException {
|
||||
@ -216,49 +164,29 @@ public class AbstractDelegateExtent implements Extent {
|
||||
return setBlock(x, y, z, getBlock(x, y, z).toBaseBlock(tile));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fullySupports3DBiomes() {
|
||||
return extent.fullySupports3DBiomes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return extent.setBiome(x, y, z, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
return extent.setBiome(position.getX(), position.getY(), position.getZ(), biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean relight(int x, int y, int z) {
|
||||
return extent.relight(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean relightBlock(int x, int y, int z) {
|
||||
return extent.relightBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean relightSky(int x, int y, int z) {
|
||||
return extent.relightSky(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkyLight(int x, int y, int z, int value) {
|
||||
extent.setSkyLight(x, y, z, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockLight(int x, int y, int z, int value) {
|
||||
extent.setSkyLight(x, y, z, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSkyLight(int x, int y, int z) {
|
||||
return extent.getSkyLight(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEmmittedLight(int x, int y, int z) {
|
||||
return extent.getEmmittedLight(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBrightness(int x, int y, int z) {
|
||||
return extent.getBrightness(x, y, z);
|
||||
public void setSkyLight(int x, int y, int z, int value) {
|
||||
extent.setSkyLight(x, y, z, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -276,13 +204,61 @@ public class AbstractDelegateExtent implements Extent {
|
||||
return extent.getMaximumPoint();
|
||||
}
|
||||
|
||||
protected Operation commitBefore() {
|
||||
return null;
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
return extent.getEntities(region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable
|
||||
Operation commit() {
|
||||
public List<? extends Entity> getEntities() {
|
||||
return extent.getEntities();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
return extent.createEntity(location, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntity(int x, int y, int z, UUID uuid) {
|
||||
extent.removeEntity(x, y, z, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQueueEnabled() {
|
||||
return extent.isQueueEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableQueue() {
|
||||
try {
|
||||
extent.enableQueue();
|
||||
} catch (FaweException enableQueue) {
|
||||
// TODO NOT IMPLEMENTED - THIS IS IMPORTANT (ForgetfulExtentBuffer is just a placeholder for now, it won't work)
|
||||
new ExtentTraverser<>(this).setNext(new ForgetfulExtentBuffer(extent));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableQueue() {
|
||||
try {
|
||||
if (!(extent instanceof ForgetfulExtentBuffer)) { // placeholder
|
||||
extent.disableQueue();
|
||||
}
|
||||
} catch (FaweException ignored) {
|
||||
}
|
||||
if (extent instanceof AbstractDelegateExtent) {
|
||||
Extent next = ((AbstractDelegateExtent) extent).getExtent();
|
||||
new ExtentTraverser(this).setNext(next);
|
||||
} else {
|
||||
getLogger(AbstractDelegateExtent.class).debug("Cannot disable queue");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Operation commit() {
|
||||
Operation ours = commitBefore();
|
||||
Operation other = null;
|
||||
if (extent != this) {
|
||||
@ -299,6 +275,26 @@ public class AbstractDelegateExtent implements Extent {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxY() {
|
||||
return extent.getMaxY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean relight(int x, int y, int z) {
|
||||
return extent.relight(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean relightBlock(int x, int y, int z) {
|
||||
return extent.relightBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean relightSky(int x, int y, int z) {
|
||||
return extent.relightSky(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Extent addProcessor(IBatchProcessor processor) {
|
||||
if (Settings.IMP.EXPERIMENTAL.OTHER) {
|
||||
@ -343,4 +339,8 @@ public class AbstractDelegateExtent implements Extent {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
protected Operation commitBefore() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,8 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
* @param location the location
|
||||
* @return a reference to the created entity, or null if the entity could not be created
|
||||
*/
|
||||
default @Nullable Entity createEntity(Location location, BaseEntity entity) {
|
||||
@Nullable
|
||||
default Entity createEntity(Location location, BaseEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -164,11 +165,15 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
}
|
||||
|
||||
default void enableQueue() {
|
||||
if (!isQueueEnabled()) throw FaweException._enableQueue;
|
||||
if (!isQueueEnabled()) {
|
||||
throw FaweException._enableQueue;
|
||||
}
|
||||
}
|
||||
|
||||
default void disableQueue() {
|
||||
if (isQueueEnabled()) throw FaweException._disableQueue;
|
||||
if (isQueueEnabled()) {
|
||||
throw FaweException._disableQueue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -281,18 +286,26 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
int offset = state ? 0 : 1;
|
||||
for (int d = 0; d <= clearance; d++) {
|
||||
int y1 = y + d;
|
||||
if (mask.test(MutableBlockVector3.get(x, y1, z)) != state) return y1 - offset;
|
||||
if (mask.test(MutableBlockVector3.get(x, y1, z)) != state) {
|
||||
return y1 - offset;
|
||||
}
|
||||
int y2 = y - d;
|
||||
if (mask.test(MutableBlockVector3.get(x, y2, z)) != state) return y2 + offset;
|
||||
if (mask.test(MutableBlockVector3.get(x, y2, z)) != state) {
|
||||
return y2 + offset;
|
||||
}
|
||||
}
|
||||
if (clearanceAbove != clearanceBelow) {
|
||||
if (clearanceAbove < clearanceBelow) {
|
||||
for (int layer = y - clearance - 1; layer >= minY; layer--) {
|
||||
if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) return layer + offset;
|
||||
if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) {
|
||||
return layer + offset;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int layer = y + clearance + 1; layer <= maxY; layer++) {
|
||||
if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) return layer - offset;
|
||||
if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) {
|
||||
return layer - offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -310,26 +323,34 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
for (int d = 0; d <= clearance; d++) {
|
||||
int y1 = y + d;
|
||||
block = getBlock(x, y1, z);
|
||||
if (block.getMaterial().isMovementBlocker() == state && block.getBlockType() != BlockTypes.__RESERVED__) return y1 - offset;
|
||||
if (block.getMaterial().isMovementBlocker() == state && block.getBlockType() != BlockTypes.__RESERVED__) {
|
||||
return y1 - offset;
|
||||
}
|
||||
int y2 = y - d;
|
||||
block = getBlock(x, y2, z);
|
||||
if (block.getMaterial().isMovementBlocker() == state && block.getBlockType() != BlockTypes.__RESERVED__) return y2 + offset;
|
||||
if (block.getMaterial().isMovementBlocker() == state && block.getBlockType() != BlockTypes.__RESERVED__) {
|
||||
return y2 + offset;
|
||||
}
|
||||
}
|
||||
if (clearanceAbove != clearanceBelow) {
|
||||
if (clearanceAbove < clearanceBelow) {
|
||||
for (int layer = y - clearance - 1; layer >= minY; layer--) {
|
||||
block = getBlock(x, layer, z);
|
||||
if (block.getMaterial().isMovementBlocker() == state && block.getBlockType() != BlockTypes.__RESERVED__) return layer + offset;
|
||||
if (block.getMaterial().isMovementBlocker() == state && block.getBlockType() != BlockTypes.__RESERVED__) {
|
||||
return layer + offset;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int layer = y + clearance + 1; layer <= maxY; layer++) {
|
||||
block = getBlock(x, layer, z);
|
||||
if (block.getMaterial().isMovementBlocker() == state && block.getBlockType() != BlockTypes.__RESERVED__) return layer - offset;
|
||||
if (block.getMaterial().isMovementBlocker() == state && block.getBlockType() != BlockTypes.__RESERVED__) {
|
||||
return layer - offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int result = state ? failedMin : failedMax;
|
||||
if(result > 0 && !ignoreAir) {
|
||||
if (result > 0 && !ignoreAir) {
|
||||
block = getBlock(x, result, z);
|
||||
return block.getBlockType().getMaterial().isAir() ? -1 : result;
|
||||
}
|
||||
@ -464,7 +485,9 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
ExtentTraverser<Extent> next = traverser.next();
|
||||
if (next != null) {
|
||||
Extent child = next.get();
|
||||
if (child instanceof NullExtent) return true;
|
||||
if (child instanceof NullExtent) {
|
||||
return true;
|
||||
}
|
||||
traverser.setNext(nullExtent);
|
||||
child.cancel();
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public interface InputExtent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a immutable snapshot of the block at the given location.
|
||||
* Get an immutable snapshot of the block at the given location.
|
||||
*
|
||||
* @param position position of the block
|
||||
* @return the block
|
||||
|
@ -124,7 +124,9 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
|
||||
|
||||
@Override
|
||||
public Extent construct(Extent child) {
|
||||
if (child == getExtent()) return this;
|
||||
if (child == getExtent()) {
|
||||
return this;
|
||||
}
|
||||
return new MaskingExtent(child, this.mask.copy(), this.threadIdToFilter);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,6 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
|
||||
@Override
|
||||
public void setOrigin(BlockVector3 origin) {
|
||||
// this.origin = origin;
|
||||
getParent().setOrigin(origin.subtract(region.getMinimumPoint()));
|
||||
}
|
||||
|
||||
@ -117,9 +116,9 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
@Override
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
if (region.contains(position)) {
|
||||
int x = position.getBlockX()- origin.getX();
|
||||
int y = position.getBlockY()- origin.getY();
|
||||
int z = position.getBlockZ()- origin.getZ();
|
||||
int x = position.getBlockX() - origin.getX();
|
||||
int y = position.getBlockY() - origin.getY();
|
||||
int z = position.getBlockZ() - origin.getZ();
|
||||
return getParent().getBlock(x, y, z);
|
||||
}
|
||||
|
||||
@ -128,10 +127,10 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
if(region.contains(position)) {
|
||||
int x = position.getBlockX()- origin.getX();
|
||||
int y = position.getBlockY()- origin.getY();
|
||||
int z = position.getBlockZ()- origin.getZ();
|
||||
if (region.contains(position)) {
|
||||
int x = position.getBlockX() - origin.getX();
|
||||
int y = position.getBlockY() - origin.getY();
|
||||
int z = position.getBlockZ() - origin.getZ();
|
||||
return getParent().getFullBlock(x, y, z);
|
||||
}
|
||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
@ -320,8 +319,11 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
public static class ClipboardEntity implements Entity {
|
||||
private final BaseEntity entity;
|
||||
private final Clipboard clipboard;
|
||||
private final double x, y, z;
|
||||
private final float yaw, pitch;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final float yaw;
|
||||
private final float pitch;
|
||||
|
||||
public ClipboardEntity(Location loc, BaseEntity entity) {
|
||||
this((Clipboard) loc.getExtent(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), entity);
|
||||
|
@ -129,7 +129,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove entity from clipboard
|
||||
* Remove entity from clipboard.
|
||||
*/
|
||||
void removeEntity(Entity entity);
|
||||
|
||||
@ -184,7 +184,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Forwards to paste(world, to, true, true, null)
|
||||
* Forwards to {@link #paste(World, BlockVector3, boolean, boolean, Transform)}.
|
||||
*/
|
||||
default EditSession paste(World world, BlockVector3 to) {
|
||||
return paste(world, to, true, true, null);
|
||||
@ -204,7 +204,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Save this schematic to a stream
|
||||
* Save this schematic to a stream.
|
||||
*/
|
||||
default void save(OutputStream stream, ClipboardFormat format) throws IOException {
|
||||
checkNotNull(stream);
|
||||
@ -220,7 +220,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Paste this schematic in a world
|
||||
* Paste this schematic in a world.
|
||||
*/
|
||||
default EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir,
|
||||
boolean copyEntities, @Nullable Transform transform) {
|
||||
|
@ -34,6 +34,7 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
@ -72,7 +73,7 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
|
||||
|
||||
@Override
|
||||
public boolean isFormat(File file) {
|
||||
String name = file.getName().toLowerCase();
|
||||
String name = file.getName().toLowerCase(Locale.ROOT);
|
||||
return name.endsWith(".schematic") || name.endsWith(".mcedit") || name.endsWith(".mce");
|
||||
}
|
||||
},
|
||||
@ -108,7 +109,7 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
|
||||
|
||||
@Override
|
||||
public boolean isFormat(File file) {
|
||||
String name = file.getName().toLowerCase();
|
||||
String name = file.getName().toLowerCase(Locale.ROOT);
|
||||
return name.endsWith(".schem") || name.endsWith(".sponge");
|
||||
}
|
||||
|
||||
@ -141,13 +142,13 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
|
||||
|
||||
@Override
|
||||
public boolean isFormat(File file) {
|
||||
String name = file.getName().toLowerCase();
|
||||
String name = file.getName().toLowerCase(Locale.ROOT);
|
||||
return name.endsWith(".nbt");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Isometric PNG writer
|
||||
* Isometric PNG writer.
|
||||
*/
|
||||
PNG("png", "image") {
|
||||
|
||||
|
@ -101,7 +101,7 @@ public interface ClipboardFormat {
|
||||
|
||||
/**
|
||||
* Sets the actor's clipboard.
|
||||
* @param actor
|
||||
* @param actor the actor
|
||||
* @param uri the URI of the schematic to hold
|
||||
* @param inputStream the input stream
|
||||
* @throws IOException thrown on I/O error
|
||||
|
@ -126,7 +126,7 @@ public class ClipboardFormats {
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect the format using the given extension
|
||||
* Detect the format using the given extension.
|
||||
*
|
||||
* @param extension the extension
|
||||
* @return the format, otherwise null if one cannot be detected
|
||||
@ -195,8 +195,8 @@ public class ClipboardFormats {
|
||||
return null;
|
||||
}
|
||||
File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ?
|
||||
new File(working, player.getUniqueId().toString()) : working;
|
||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS
|
||||
? new File(working, player.getUniqueId().toString()) : working;
|
||||
File f;
|
||||
if (input.startsWith("#")) {
|
||||
String[] extensions;
|
||||
|
@ -80,9 +80,14 @@ public class FastSchematicReader extends NBTSchematicReader {
|
||||
private List<Map<String, Object>> tiles;
|
||||
private List<Map<String, Object>> entities;
|
||||
|
||||
private int width, height, length;
|
||||
private int offsetX, offsetY, offsetZ;
|
||||
private char[] palette, biomePalette;
|
||||
private int width;
|
||||
private int height;
|
||||
private int length;
|
||||
private int offsetX;
|
||||
private int offsetY;
|
||||
private int offsetZ;
|
||||
private char[] palette;
|
||||
private char[] biomePalette;
|
||||
private BlockVector3 min = BlockVector3.ZERO;
|
||||
|
||||
|
||||
@ -97,22 +102,30 @@ public class FastSchematicReader extends NBTSchematicReader {
|
||||
}
|
||||
|
||||
private String fix(String palettePart) {
|
||||
if (fixer == null || dataVersion == -1) return palettePart;
|
||||
if (fixer == null || dataVersion == -1) {
|
||||
return palettePart;
|
||||
}
|
||||
return fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, palettePart, dataVersion);
|
||||
}
|
||||
|
||||
private CompoundTag fixBlockEntity(CompoundTag tag) {
|
||||
if (fixer == null || dataVersion == -1) return tag;
|
||||
if (fixer == null || dataVersion == -1) {
|
||||
return tag;
|
||||
}
|
||||
return fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY, tag, dataVersion);
|
||||
}
|
||||
|
||||
private CompoundTag fixEntity(CompoundTag tag) {
|
||||
if (fixer == null || dataVersion == -1) return tag;
|
||||
if (fixer == null || dataVersion == -1) {
|
||||
return tag;
|
||||
}
|
||||
return fixer.fixUp(DataFixer.FixTypes.ENTITY, tag, dataVersion);
|
||||
}
|
||||
|
||||
private String fixBiome(String biomePalettePart) {
|
||||
if(fixer == null || dataVersion == -1) return biomePalettePart;
|
||||
if (fixer == null || dataVersion == -1) {
|
||||
return biomePalettePart;
|
||||
}
|
||||
return fixer.fixUp(DataFixer.FixTypes.BIOME, biomePalettePart, dataVersion);
|
||||
}
|
||||
|
||||
@ -208,8 +221,12 @@ public class FastSchematicReader extends NBTSchematicReader {
|
||||
throw new IOException("This schematic version is currently not supported");
|
||||
}
|
||||
|
||||
if (blocks != null) blocks.close();
|
||||
if (biomes != null) biomes.close();
|
||||
if (blocks != null) {
|
||||
blocks.close();
|
||||
}
|
||||
if (biomes != null) {
|
||||
biomes.close();
|
||||
}
|
||||
blocks = null;
|
||||
biomes = null;
|
||||
|
||||
@ -285,7 +302,9 @@ public class FastSchematicReader extends NBTSchematicReader {
|
||||
CompoundTag tile = FaweCache.IMP.asTag(tileRaw);
|
||||
|
||||
int[] pos = tile.getIntArray("Pos");
|
||||
int x,y,z;
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
if (pos.length != 3) {
|
||||
if (!tile.containsKey("x") || !tile.containsKey("y") || !tile.containsKey("z")) {
|
||||
return null;
|
||||
|
@ -190,7 +190,9 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
Map<BlockVector3, BlockState> blockStates = new HashMap<>();
|
||||
|
||||
for (Tag tag : tileEntities) {
|
||||
if (!(tag instanceof CompoundTag)) continue;
|
||||
if (!(tag instanceof CompoundTag)) {
|
||||
continue;
|
||||
}
|
||||
CompoundTag t = (CompoundTag) tag;
|
||||
Map<String, Tag> values = new HashMap<>(t.getValue());
|
||||
String id = t.getString("id");
|
||||
|
@ -95,7 +95,7 @@ public class SchematicReader implements ClipboardReader {
|
||||
private NBTInputStream inputStream;
|
||||
private InputStream rootStream;
|
||||
|
||||
// private final DataFixer fixer; TODO
|
||||
// private final DataFixer fixer; TODO
|
||||
|
||||
private FastByteArrayOutputStream idOut = new FastByteArrayOutputStream();
|
||||
private FastByteArrayOutputStream dataOut = new FastByteArrayOutputStream();
|
||||
@ -110,9 +110,15 @@ public class SchematicReader implements ClipboardReader {
|
||||
private List<Map<String, Object>> tiles;
|
||||
private List<Map<String, Object>> entities;
|
||||
|
||||
private int width, height, length;
|
||||
private int offsetX, offsetY, offsetZ;
|
||||
private int originX, originY, originZ;
|
||||
private int width;
|
||||
private int height;
|
||||
private int length;
|
||||
private int offsetX;
|
||||
private int offsetY;
|
||||
private int offsetZ;
|
||||
private int originX;
|
||||
private int originY;
|
||||
private int originZ;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -249,10 +255,18 @@ public class SchematicReader implements ClipboardReader {
|
||||
StreamDelegate root = createDelegate();
|
||||
inputStream.readNamedTagLazy(root);
|
||||
|
||||
if (ids != null) ids.close();
|
||||
if (datas != null) datas.close();
|
||||
if (adds != null) adds.close();
|
||||
if (biomes != null) biomes.close();
|
||||
if (ids != null) {
|
||||
ids.close();
|
||||
}
|
||||
if (datas != null) {
|
||||
datas.close();
|
||||
}
|
||||
if (adds != null) {
|
||||
adds.close();
|
||||
}
|
||||
if (biomes != null) {
|
||||
biomes.close();
|
||||
}
|
||||
ids = null;
|
||||
datas = null;
|
||||
adds = null;
|
||||
@ -265,7 +279,7 @@ public class SchematicReader implements ClipboardReader {
|
||||
}
|
||||
|
||||
Clipboard clipboard = createOutput.apply(dimensions);
|
||||
try (InputStream dataIn = new LZ4BlockInputStream(new FastByteArraysInputStream(dataOut.toByteArrays()));InputStream idIn = new LZ4BlockInputStream(new FastByteArraysInputStream(idOut.toByteArrays()))) {
|
||||
try (InputStream dataIn = new LZ4BlockInputStream(new FastByteArraysInputStream(dataOut.toByteArrays())); InputStream idIn = new LZ4BlockInputStream(new FastByteArraysInputStream(idOut.toByteArrays()))) {
|
||||
if (addOut != null) {
|
||||
try (FaweInputStream addIn = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(addOut.toByteArrays())))) {
|
||||
if (clipboard instanceof LinearClipboard) {
|
||||
@ -368,7 +382,9 @@ public class SchematicReader implements ClipboardReader {
|
||||
private void fixStates(Clipboard fc) {
|
||||
for (BlockVector3 pos : fc) {
|
||||
BlockState block = pos.getBlock(fc);
|
||||
if (block.getMaterial().isAir()) continue;
|
||||
if (block.getMaterial().isAir()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
@ -425,13 +441,23 @@ public class SchematicReader implements ClipboardReader {
|
||||
}
|
||||
} else {
|
||||
int group = group(type);
|
||||
if (group == -1) return;
|
||||
if (group == -1) {
|
||||
return;
|
||||
}
|
||||
BlockState set = block;
|
||||
|
||||
if (set.getState(PropertyKey.NORTH) == Boolean.FALSE && merge(fc, group, x, y, z - 1)) set = set.with(PropertyKey.NORTH, true);
|
||||
if (set.getState(PropertyKey.EAST) == Boolean.FALSE && merge(fc, group, x + 1, y, z)) set = set.with(PropertyKey.EAST, true);
|
||||
if (set.getState(PropertyKey.SOUTH) == Boolean.FALSE && merge(fc, group, x, y, z + 1)) set = set.with(PropertyKey.SOUTH, true);
|
||||
if (set.getState(PropertyKey.WEST) == Boolean.FALSE && merge(fc, group, x - 1, y, z)) set = set.with(PropertyKey.WEST, true);
|
||||
if (set.getState(PropertyKey.NORTH) == Boolean.FALSE && merge(fc, group, x, y, z - 1)) {
|
||||
set = set.with(PropertyKey.NORTH, true);
|
||||
}
|
||||
if (set.getState(PropertyKey.EAST) == Boolean.FALSE && merge(fc, group, x + 1, y, z)) {
|
||||
set = set.with(PropertyKey.EAST, true);
|
||||
}
|
||||
if (set.getState(PropertyKey.SOUTH) == Boolean.FALSE && merge(fc, group, x, y, z + 1)) {
|
||||
set = set.with(PropertyKey.SOUTH, true);
|
||||
}
|
||||
if (set.getState(PropertyKey.WEST) == Boolean.FALSE && merge(fc, group, x - 1, y, z)) {
|
||||
set = set.with(PropertyKey.WEST, true);
|
||||
}
|
||||
|
||||
if (group == 2) {
|
||||
int ns = (set.getState(PropertyKey.NORTH) ? 1 : 0) + ((Boolean) set.getState(PropertyKey.SOUTH) ? 1 : 0);
|
||||
@ -441,7 +467,9 @@ public class SchematicReader implements ClipboardReader {
|
||||
}
|
||||
}
|
||||
|
||||
if (set != block) pos.setBlock(fc, set);
|
||||
if (set != block) {
|
||||
pos.setBlock(fc, set);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,5 +24,6 @@ import com.sk89q.worldedit.world.entity.EntityType;
|
||||
|
||||
public interface EntityNBTCompatibilityHandler {
|
||||
boolean isAffectedEntity(EntityType type, CompoundTag entityTag);
|
||||
|
||||
CompoundTag updateNBT(EntityType type, CompoundTag entityTag);
|
||||
}
|
||||
|
@ -35,8 +35,12 @@ public abstract class BlockBag {
|
||||
*/
|
||||
public void storeDroppedBlock(BlockState blockState) throws BlockBagException {
|
||||
BlockState dropped = blockState; // TODO BlockType.getBlockBagItem(id, data);
|
||||
if (dropped == null) return;
|
||||
if (dropped.getBlockType().getMaterial().isAir()) return;
|
||||
if (dropped == null) {
|
||||
return;
|
||||
}
|
||||
if (dropped.getBlockType().getMaterial().isAir()) {
|
||||
return;
|
||||
}
|
||||
|
||||
storeBlock(dropped);
|
||||
}
|
||||
@ -55,8 +59,10 @@ public abstract class BlockBag {
|
||||
}
|
||||
fetchBlock(blockState);
|
||||
} catch (OutOfBlocksException e) {
|
||||
BlockState placed = blockState;// TODO BlockType.getBlockBagItem(id, data);
|
||||
if (placed == null || placed.getBlockType().getMaterial().isAir()) throw e; // TODO: check
|
||||
BlockState placed = blockState; // TODO BlockType.getBlockBagItem(id, data);
|
||||
if (placed == null || placed.getBlockType().getMaterial().isAir()) {
|
||||
throw e; // TODO: check
|
||||
}
|
||||
|
||||
fetchBlock(placed);
|
||||
}
|
||||
|
@ -64,7 +64,8 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
||||
*
|
||||
* @return a block bag, which may be null if none is used
|
||||
*/
|
||||
public @Nullable BlockBag getBlockBag() {
|
||||
@Nullable
|
||||
public BlockBag getBlockBag() {
|
||||
return blockBag;
|
||||
}
|
||||
|
||||
@ -76,6 +77,7 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
||||
public void setBlockBag(@Nullable BlockBag blockBag) {
|
||||
this.blockBag = blockBag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of missing blocks and clears the list for the next
|
||||
* operation.
|
||||
@ -122,6 +124,7 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.setBlock(x, y, z, block);
|
||||
}
|
||||
}
|
||||
|
@ -291,7 +291,9 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newIndex != null) return newIndex;
|
||||
if (newIndex != null) {
|
||||
return newIndex;
|
||||
}
|
||||
}
|
||||
return newIndex;
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class RegionMaskTestFunction implements RegionFunction {
|
||||
|
||||
private final RegionFunction pass,fail;
|
||||
private final RegionFunction pass;
|
||||
private final RegionFunction fail;
|
||||
private Mask mask;
|
||||
|
||||
/**
|
||||
|
@ -80,9 +80,9 @@ public class CavesGen extends GenBase {
|
||||
y += f4;
|
||||
z += MathMan.sinInexact(paramdouble2) * f3;
|
||||
|
||||
if (k != 0)
|
||||
if (k != 0) {
|
||||
paramdouble3 *= 0.92F;
|
||||
else {
|
||||
} else {
|
||||
paramdouble3 *= 0.7F;
|
||||
}
|
||||
paramdouble3 += f2 * 0.1F;
|
||||
@ -117,8 +117,9 @@ public class CavesGen extends GenBase {
|
||||
|
||||
//Boundaries check.
|
||||
if (x < real_x - 16.0D - d3 * 2.0D || z < real_z - 16.0D - d3 * 2.0D
|
||||
|| x > real_x + 16.0D + d3 * 2.0D || z > real_z + 16.0D + d3 * 2.0D)
|
||||
|| x > real_x + 16.0D + d3 * 2.0D || z > real_z + 16.0D + d3 * 2.0D) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
int m = (int) (x - d3) - bx - 1;
|
||||
@ -130,20 +131,25 @@ public class CavesGen extends GenBase {
|
||||
int i3 = (int) (z - d3) - bz - 1;
|
||||
int i4 = (int) (z + d3) - bz + 1;
|
||||
|
||||
if (m < 0)
|
||||
if (m < 0) {
|
||||
m = 0;
|
||||
if (n > 16)
|
||||
}
|
||||
if (n > 16) {
|
||||
n = 16;
|
||||
}
|
||||
|
||||
if (i1 < 1)
|
||||
if (i1 < 1) {
|
||||
i1 = 1;
|
||||
}
|
||||
if (i2 > 256 - 8) {
|
||||
i2 = 256 - 8;
|
||||
}
|
||||
if (i3 < 0)
|
||||
if (i3 < 0) {
|
||||
i3 = 0;
|
||||
if (i4 > 16)
|
||||
}
|
||||
if (i4 > 16) {
|
||||
i4 = 16;
|
||||
}
|
||||
|
||||
// Search for water
|
||||
boolean waterFound = false;
|
||||
@ -156,8 +162,9 @@ public class CavesGen extends GenBase {
|
||||
waterFound = true;
|
||||
}
|
||||
if (local_y != i1 - 1 && local_x != m && local_x != n - 1 && local_z != i3
|
||||
&& local_z != i4 - 1)
|
||||
&& local_z != i4 - 1) {
|
||||
local_y = i1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -206,8 +213,9 @@ public class CavesGen extends GenBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isLargeCave)
|
||||
if (isLargeCave) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,19 +237,21 @@ public class CavesGen extends GenBase {
|
||||
public void generateChunk(int chunkX, int chunkZ, BlockVector2 originChunk, Extent chunk) throws WorldEditException {
|
||||
int i = ThreadLocalRandom.current().nextInt(ThreadLocalRandom.current()
|
||||
.nextInt(ThreadLocalRandom.current().nextInt(this.caveFrequency) + 1) + 1);
|
||||
if (this.evenCaveDistribution)
|
||||
if (this.evenCaveDistribution) {
|
||||
i = this.caveFrequency;
|
||||
if (ThreadLocalRandom.current().nextInt(100) >= this.caveRarity)
|
||||
}
|
||||
if (ThreadLocalRandom.current().nextInt(100) >= this.caveRarity) {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
for (int j = 0; j < i; j++) {
|
||||
double x = (chunkX << 4) + ThreadLocalRandom.current().nextInt(16);
|
||||
|
||||
double y;
|
||||
|
||||
if (this.evenCaveDistribution)
|
||||
if (this.evenCaveDistribution) {
|
||||
y = ThreadLocalRandom.current().nextInt(this.caveMinAltitude, this.caveMaxAltitude);
|
||||
else {
|
||||
} else {
|
||||
y = ThreadLocalRandom.current()
|
||||
.nextInt(ThreadLocalRandom.current()
|
||||
.nextInt(this.caveMaxAltitude - this.caveMinAltitude + 1) + 1) + this.caveMinAltitude;
|
||||
|
@ -84,8 +84,12 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
* @param pos the vine position
|
||||
*/
|
||||
private void placeVine(BlockVector3 basePos, BlockVector3 pos) throws MaxChangedBlocksException {
|
||||
if (pos.distance(basePos) > 4) return;
|
||||
if (!editSession.getBlock(pos).getBlockType().getMaterial().isAir()) return;
|
||||
if (pos.distance(basePos) > 4) {
|
||||
return;
|
||||
}
|
||||
if (!editSession.getBlock(pos).getBlockType().getMaterial().isAir()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = -1; i > -3; --i) {
|
||||
BlockVector3 testPos = pos.add(0, i, 0);
|
||||
|
@ -10,7 +10,8 @@ public abstract class GenBase {
|
||||
|
||||
private final int checkAreaSize;
|
||||
private final long seed;
|
||||
private final long worldSeed1, worldSeed2;
|
||||
private final long worldSeed1;
|
||||
private final long worldSeed2;
|
||||
|
||||
public GenBase(int area) {
|
||||
this.checkAreaSize = area;
|
||||
|
@ -102,8 +102,9 @@ public class OreGen implements Resource {
|
||||
double dz = (zz + 0.5D - d9) * id11o2;
|
||||
double dxyz2 = dxy2 + dz * dz;
|
||||
if ((dxyz2 < 1)) {
|
||||
if (mask.test(mutable))
|
||||
if (mask.test(mutable)) {
|
||||
pattern.apply(extent, mutable, mutable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,9 @@ public class SchemGen implements Resource {
|
||||
mutable.mutX(x);
|
||||
mutable.mutZ(z);
|
||||
int y = extent.getNearestSurfaceTerrainBlock(x, z, mutable.getBlockY(), 0, 255);
|
||||
if (y == -1) return false;
|
||||
if (y == -1) {
|
||||
return false;
|
||||
}
|
||||
mutable.mutY(y);
|
||||
if (!mask.test(mutable)) {
|
||||
return false;
|
||||
|
@ -40,7 +40,6 @@ public abstract class AbstractExtentMask extends AbstractMask {
|
||||
setExtent(extent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the extent.
|
||||
*
|
||||
@ -60,6 +59,6 @@ public abstract class AbstractExtentMask extends AbstractMask {
|
||||
this.extent = extent;
|
||||
}
|
||||
|
||||
abstract public boolean test(Extent extent, BlockVector3 position);
|
||||
public abstract boolean test(Extent extent, BlockVector3 position);
|
||||
|
||||
}
|
||||
|
@ -35,4 +35,5 @@ public abstract class AbstractMask implements Mask {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -182,6 +182,7 @@ public class BlockMask extends ABlockMask {
|
||||
public Collection<BaseBlock> getBlocks() {
|
||||
return Collections.emptyList(); //TODO Not supported in FAWE yet
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(BlockState state) {
|
||||
return ordinals[state.getOrdinal()] || replacesAir() && state.getOrdinal() <= 3;
|
||||
@ -321,7 +322,7 @@ public class BlockMask extends ABlockMask {
|
||||
for (int i = 0; i < cloned.length; i++) {
|
||||
cloned[i] = !cloned[i];
|
||||
}
|
||||
if(replacesAir()){
|
||||
if (replacesAir()) {
|
||||
cloned[BlockTypes.AIR.getDefaultState().getOrdinal()] = false;
|
||||
cloned[BlockTypes.CAVE_AIR.getDefaultState().getOrdinal()] = false;
|
||||
cloned[BlockTypes.VOID_AIR.getDefaultState().getOrdinal()] = false;
|
||||
|
@ -39,7 +39,7 @@ public class BlockMaskBuilder {
|
||||
private static final Operator LESS_EQUAL = (a, b) -> a <= b;
|
||||
private static final Operator NOT = (a, b) -> a != b;
|
||||
|
||||
private final static long[] ALL = new long[0];
|
||||
private static final long[] ALL = new long[0];
|
||||
|
||||
private interface Operator {
|
||||
boolean test(int left, int right);
|
||||
@ -47,7 +47,9 @@ public class BlockMaskBuilder {
|
||||
|
||||
private boolean filterRegex(BlockType blockType, PropertyKey key, String regex) {
|
||||
Property<Object> property = blockType.getProperty(key);
|
||||
if (property == null) return false;
|
||||
if (property == null) {
|
||||
return false;
|
||||
}
|
||||
List<Object> values = property.getValues();
|
||||
boolean result = false;
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
@ -62,7 +64,9 @@ public class BlockMaskBuilder {
|
||||
|
||||
private boolean filterOperator(BlockType blockType, PropertyKey key, Operator operator, CharSequence value) {
|
||||
Property<Object> property = blockType.getProperty(key);
|
||||
if (property == null) return false;
|
||||
if (property == null) {
|
||||
return false;
|
||||
}
|
||||
int index = property.getIndexFor(value);
|
||||
List<Object> values = property.getValues();
|
||||
boolean result = false;
|
||||
@ -98,7 +102,9 @@ public class BlockMaskBuilder {
|
||||
public BlockMaskBuilder addRegex(String input) throws InputParseException {
|
||||
if (input.charAt(input.length() - 1) == ']') {
|
||||
int propStart = StringMan.findMatchingBracket(input, input.length() - 1);
|
||||
if (propStart == -1) return this;
|
||||
if (propStart == -1) {
|
||||
return this;
|
||||
}
|
||||
|
||||
MutableCharSequence charSequence = MutableCharSequence.getTemporal();
|
||||
charSequence.setString(input);
|
||||
@ -121,7 +127,9 @@ public class BlockMaskBuilder {
|
||||
if (blockTypeList.isEmpty()) {
|
||||
throw new InputParseException("No block found for " + input);
|
||||
}
|
||||
if (blockTypeList.size() == 1) type = blockTypeList.get(0);
|
||||
if (blockTypeList.size() == 1) {
|
||||
type = blockTypeList.get(0);
|
||||
}
|
||||
}
|
||||
// Empty string
|
||||
charSequence.setSubstring(0, 0);
|
||||
@ -137,18 +145,23 @@ public class BlockMaskBuilder {
|
||||
case '{':
|
||||
case '(':
|
||||
int next = StringMan.findMatchingBracket(input, i);
|
||||
if (next != -1) i = next;
|
||||
if (next != -1) {
|
||||
i = next;
|
||||
}
|
||||
break;
|
||||
case ']':
|
||||
case ',': {
|
||||
charSequence.setSubstring(last, i);
|
||||
if (key == null && PropertyKey.get(charSequence) == null) suggest(input, charSequence.toString(), type != null ? Collections.singleton(type) : blockTypeList);
|
||||
if (operator == null) throw new SuggestInputParseException("No operator for " + input, "", () -> Arrays.asList("=", "~", "!", "<", ">", "<=", ">="));
|
||||
if (key == null && PropertyKey.get(charSequence) == null) {
|
||||
suggest(input, charSequence.toString(), type != null ? Collections.singleton(type) : blockTypeList);
|
||||
}
|
||||
if (operator == null) {
|
||||
throw new SuggestInputParseException("No operator for " + input, "", () -> Arrays.asList("=", "~", "!", "<", ">", "<=", ">="));
|
||||
}
|
||||
boolean filtered = false;
|
||||
if (type != null) {
|
||||
filtered = filterRegexOrOperator(type, key, operator, charSequence);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for (BlockType myType : blockTypeList) {
|
||||
filtered |= filterRegexOrOperator(myType, key, operator, charSequence);
|
||||
}
|
||||
@ -164,8 +177,9 @@ public class BlockMaskBuilder {
|
||||
for (int j = 0; j < p.getValues().size(); j++) {
|
||||
if (has(t, p, j)) {
|
||||
String o = p.getValues().get(j).toString();
|
||||
if (o.startsWith(value))
|
||||
if (o.startsWith(value)) {
|
||||
values.add(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -185,7 +199,9 @@ public class BlockMaskBuilder {
|
||||
case '>': {
|
||||
charSequence.setSubstring(last, i);
|
||||
boolean extra = input.charAt(i + 1) == '=';
|
||||
if (extra) i++;
|
||||
if (extra) {
|
||||
i++;
|
||||
}
|
||||
switch (c) {
|
||||
case '~':
|
||||
operator = EQUAL_OR_NULL;
|
||||
@ -205,8 +221,9 @@ public class BlockMaskBuilder {
|
||||
}
|
||||
if (charSequence.length() > 0 || key == null) {
|
||||
key = PropertyKey.get(charSequence);
|
||||
if (key == null)
|
||||
if (key == null) {
|
||||
suggest(input, charSequence.toString(), type != null ? Collections.singleton(type) : blockTypeList);
|
||||
}
|
||||
}
|
||||
last = i + 1;
|
||||
break;
|
||||
@ -232,7 +249,9 @@ public class BlockMaskBuilder {
|
||||
private <T> boolean has(BlockType type, Property<T> property, int index) {
|
||||
AbstractProperty<T> prop = (AbstractProperty<T>) property;
|
||||
long[] states = bitSets[type.getInternalId()];
|
||||
if (states == null) return false;
|
||||
if (states == null) {
|
||||
return false;
|
||||
}
|
||||
int localI = index << prop.getBitOffset() >> BlockTypesCache.BIT_OFFSET;
|
||||
return (states == ALL || FastBitSet.get(states, localI));
|
||||
}
|
||||
@ -328,10 +347,11 @@ public class BlockMaskBuilder {
|
||||
set = FastBitSet.get(states, stateId);
|
||||
Arrays.fill(states, 0);
|
||||
}
|
||||
if (set)
|
||||
if (set) {
|
||||
FastBitSet.set(states, stateId);
|
||||
else
|
||||
} else {
|
||||
bitSets[i] = null;
|
||||
}
|
||||
reset(true);
|
||||
}
|
||||
return this;
|
||||
@ -350,7 +370,9 @@ public class BlockMaskBuilder {
|
||||
public <T> BlockMaskBuilder filter(Predicate<BlockType> typePredicate, BiPredicate<BlockType, Map.Entry<Property<T>, T>> allowed) {
|
||||
for (int i = 0; i < bitSets.length; i++) {
|
||||
long[] states = bitSets[i];
|
||||
if (states == null) continue;
|
||||
if (states == null) {
|
||||
continue;
|
||||
}
|
||||
BlockType type = BlockTypes.get(i);
|
||||
if (!typePredicate.test(type)) {
|
||||
bitSets[i] = null;
|
||||
@ -398,22 +420,30 @@ public class BlockMaskBuilder {
|
||||
}
|
||||
|
||||
public <T extends BlockStateHolder<T>> BlockMaskBuilder addBlocks(Collection<T> blocks) {
|
||||
for (BlockStateHolder<T> block : blocks) add(block);
|
||||
for (BlockStateHolder<T> block : blocks) {
|
||||
add(block);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlockMaskBuilder addTypes(Collection<BlockType> blocks) {
|
||||
for (BlockType block : blocks) add(block);
|
||||
for (BlockType block : blocks) {
|
||||
add(block);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public <T extends BlockStateHolder<T>> BlockMaskBuilder addBlocks(T... blocks) {
|
||||
for (BlockStateHolder<T> block : blocks) add(block);
|
||||
for (BlockStateHolder<T> block : blocks) {
|
||||
add(block);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlockMaskBuilder addTypes(BlockType... blocks) {
|
||||
for (BlockType block : blocks) add(block);
|
||||
for (BlockType block : blocks) {
|
||||
add(block);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -430,7 +460,9 @@ public class BlockMaskBuilder {
|
||||
public BlockMaskBuilder addAll(Predicate<BlockType> typePredicate, BiPredicate<BlockType, Map.Entry<Property<?>, ?>> propPredicate) {
|
||||
for (int i = 0; i < bitSets.length; i++) {
|
||||
long[] states = bitSets[i];
|
||||
if (states == ALL) continue;
|
||||
if (states == ALL) {
|
||||
continue;
|
||||
}
|
||||
BlockType type = BlockTypes.get(i);
|
||||
if (!typePredicate.test(type)) {
|
||||
continue;
|
||||
@ -457,7 +489,9 @@ public class BlockMaskBuilder {
|
||||
public <T> BlockMaskBuilder add(BlockType type, Property<T> property, int index) {
|
||||
AbstractProperty<T> prop = (AbstractProperty<T>) property;
|
||||
long[] states = bitSets[type.getInternalId()];
|
||||
if (states == ALL) return this;
|
||||
if (states == ALL) {
|
||||
return this;
|
||||
}
|
||||
|
||||
List<T> values = property.getValues();
|
||||
int localI = index << prop.getBitOffset() >> BlockTypesCache.BIT_OFFSET;
|
||||
@ -474,7 +508,9 @@ public class BlockMaskBuilder {
|
||||
public <T> BlockMaskBuilder filter(BlockType type, Property<T> property, int index) {
|
||||
AbstractProperty<T> prop = (AbstractProperty<T>) property;
|
||||
long[] states = bitSets[type.getInternalId()];
|
||||
if (states == null) return this;
|
||||
if (states == null) {
|
||||
return this;
|
||||
}
|
||||
List<T> values = property.getValues();
|
||||
int localI = index << prop.getBitOffset() >> BlockTypesCache.BIT_OFFSET;
|
||||
if (states == ALL || FastBitSet.get(states, localI)) {
|
||||
@ -499,8 +535,11 @@ public class BlockMaskBuilder {
|
||||
} else {
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
int index = current.modifyIndex(state, i) >> BlockTypesCache.BIT_OFFSET;
|
||||
if (set) FastBitSet.set(states, index);
|
||||
else FastBitSet.clear(states, index);
|
||||
if (set) {
|
||||
FastBitSet.set(states, index);
|
||||
} else {
|
||||
FastBitSet.clear(states, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -529,7 +568,9 @@ public class BlockMaskBuilder {
|
||||
if (!optimizedStates) {
|
||||
for (int i = 0; i < bitSets.length; i++) {
|
||||
long[] bitSet = bitSets[i];
|
||||
if (bitSet == null || bitSet == ALL) continue;
|
||||
if (bitSet == null || bitSet == ALL) {
|
||||
continue;
|
||||
}
|
||||
BlockType type = BlockTypes.get(i);
|
||||
int maxStateId = type.getMaxStateId();
|
||||
if (maxStateId == 0) {
|
||||
@ -547,12 +588,18 @@ public class BlockMaskBuilder {
|
||||
List<?> values = prop.getValues();
|
||||
for (int j = 0; j < values.size(); j++) {
|
||||
int localI = j << prop.getBitOffset() >> BlockTypesCache.BIT_OFFSET;
|
||||
if (FastBitSet.get(bitSet, localI)) set++;
|
||||
else clear++;
|
||||
if (FastBitSet.get(bitSet, localI)) {
|
||||
set++;
|
||||
} else {
|
||||
clear++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (set == 0) bitSets[i] = null;
|
||||
else if (clear == 0) bitSets[i] = ALL;
|
||||
if (set == 0) {
|
||||
bitSets[i] = null;
|
||||
} else if (clear == 0) {
|
||||
bitSets[i] = ALL;
|
||||
}
|
||||
}
|
||||
reset(true);
|
||||
}
|
||||
@ -564,7 +611,9 @@ public class BlockMaskBuilder {
|
||||
ordinals = new boolean[BlockTypesCache.states.length];
|
||||
for (int i = 0; i < BlockTypesCache.values.length; i++) {
|
||||
long[] bitSet = bitSets[i];
|
||||
if (bitSet == null) continue;
|
||||
if (bitSet == null) {
|
||||
continue;
|
||||
}
|
||||
BlockType type = BlockTypesCache.values[i];
|
||||
if (bitSet == ALL) {
|
||||
for (BlockState state : type.getAllStates()) {
|
||||
|
@ -110,7 +110,9 @@ public class BlockTypeMask extends AbstractExtentMask {
|
||||
public Collection<BlockType> getBlocks() {
|
||||
Set<BlockType> blocks = new HashSet<>();
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (types[i]) blocks.add(BlockTypes.get(i));
|
||||
if (types[i]) {
|
||||
blocks.add(BlockTypes.get(i));
|
||||
}
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
@ -112,7 +112,9 @@ public class MaskIntersection extends AbstractMask {
|
||||
// Optimize sub masks
|
||||
for (int i = 0; i < masksArray.length; i++) {
|
||||
Mask mask = masksArray[i];
|
||||
if (ignore.contains(mask)) continue;
|
||||
if (ignore.contains(mask)) {
|
||||
continue;
|
||||
}
|
||||
Mask newMask = mask.tryOptimize();
|
||||
if (newMask != null) {
|
||||
changed = true;
|
||||
@ -135,7 +137,9 @@ public class MaskIntersection extends AbstractMask {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (formArray) formArray();
|
||||
if (formArray) {
|
||||
formArray();
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
@ -146,9 +150,13 @@ public class MaskIntersection extends AbstractMask {
|
||||
Set<Map.Entry<Mask, Mask>> failedCombines = new HashSet<>();
|
||||
// Combine the masks
|
||||
boolean changed = false;
|
||||
while (combineMasks(pairingFunction(), failedCombines)) changed = true;
|
||||
while (combineMasks(pairingFunction(), failedCombines)) {
|
||||
changed = true;
|
||||
}
|
||||
// Optimize / combine
|
||||
do changed |= optimizeMasks(optimized);
|
||||
do {
|
||||
changed |= optimizeMasks(optimized);
|
||||
}
|
||||
while (combineMasks(pairingFunction(), failedCombines) && --maxIteration > 0);
|
||||
|
||||
if (maxIteration == 0) {
|
||||
@ -159,8 +167,12 @@ public class MaskIntersection extends AbstractMask {
|
||||
}
|
||||
// Return result
|
||||
formArray();
|
||||
if (masks.isEmpty()) return Masks.alwaysTrue();
|
||||
if (masks.size() == 1) return masks.iterator().next();
|
||||
if (masks.isEmpty()) {
|
||||
return Masks.alwaysTrue();
|
||||
}
|
||||
if (masks.size() == 1) {
|
||||
return masks.iterator().next();
|
||||
}
|
||||
return changed ? this : null;
|
||||
}
|
||||
|
||||
@ -171,9 +183,13 @@ public class MaskIntersection extends AbstractMask {
|
||||
outer:
|
||||
for (Mask mask : masks) {
|
||||
for (Mask other : masks) {
|
||||
if (mask == other) continue;
|
||||
if (mask == other) {
|
||||
continue;
|
||||
}
|
||||
AbstractMap.SimpleEntry<Mask, Mask> pair = new AbstractMap.SimpleEntry<>(mask, other);
|
||||
if (failedCombines.contains(pair)) continue;
|
||||
if (failedCombines.contains(pair)) {
|
||||
continue;
|
||||
}
|
||||
Mask combined = pairing.apply(pair);
|
||||
if (combined != null) {
|
||||
result = new Mask[]{combined, mask, other};
|
||||
@ -183,7 +199,9 @@ public class MaskIntersection extends AbstractMask {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result == null) break;
|
||||
if (result == null) {
|
||||
break;
|
||||
}
|
||||
masks.remove(result[1]);
|
||||
masks.remove(result[2]);
|
||||
masks.add(result[0]);
|
||||
|
@ -38,7 +38,7 @@ public class BackwardsExtentBlockCopy extends RegionVisitor implements Operation
|
||||
for (BlockVector3 pt : destRegion) {
|
||||
BlockVector3 copyFrom = transform(inverse, pt);
|
||||
if (region.contains(copyFrom)) {
|
||||
if(function.apply(pt)) {
|
||||
if (function.apply(pt)) {
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
|
@ -47,10 +47,10 @@ public class ChangeSetExecutor implements Operation {
|
||||
public void perform(Change change, UndoContext context) {
|
||||
change.redo(context);
|
||||
}
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
public void perform(Change change, UndoContext context) {}
|
||||
public void perform(Change change, UndoContext context) {
|
||||
}
|
||||
}
|
||||
|
||||
private final Iterator<Change> iterator;
|
||||
|
@ -367,8 +367,11 @@ public class ForwardExtentCopy implements Operation {
|
||||
copy = new IntersectRegionFunction(filterFunction, copy);
|
||||
}
|
||||
if (sourceMask != Masks.alwaysTrue()) {
|
||||
if (maskFunc != null) copy = new RegionMaskTestFunction(sourceMask, copy, maskFunc);
|
||||
else copy = new RegionMaskingFilter(source, sourceMask, copy);
|
||||
if (maskFunc != null) {
|
||||
copy = new RegionMaskTestFunction(sourceMask, copy, maskFunc);
|
||||
} else {
|
||||
copy = new RegionMaskingFilter(source, sourceMask, copy);
|
||||
}
|
||||
}
|
||||
if (copyingBiomes && (source.isWorld() || region instanceof FlatRegion)) {
|
||||
copy = CombinedRegionFunction.combine(copy, new BiomeCopy(source, finalDest));
|
||||
|
@ -77,7 +77,9 @@ public class RandomPattern extends AbstractPattern {
|
||||
public void add(Pattern pattern, double chance) {
|
||||
checkNotNull(pattern);
|
||||
Double existingWeight = weights.get(pattern);
|
||||
if (existingWeight != null) chance += existingWeight;
|
||||
if (existingWeight != null) {
|
||||
chance += existingWeight;
|
||||
}
|
||||
weights.put(pattern, chance);
|
||||
collection = RandomCollection.of(weights, random);
|
||||
this.patterns.add(pattern);
|
||||
|
@ -39,7 +39,9 @@ public class WaterloggedRemover extends AbstractExtentPattern {
|
||||
|
||||
private synchronized BlockState[] getRemap() {
|
||||
BlockState[] remap = cache.get();
|
||||
if (remap != null) return remap;
|
||||
if (remap != null) {
|
||||
return remap;
|
||||
}
|
||||
cache = new SoftReference<>(remap = new BlockState[BlockTypesCache.states.length]);
|
||||
|
||||
// init
|
||||
|
@ -236,7 +236,9 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
BlockVectorSet tempQueue = new BlockVectorSet();
|
||||
for (currentDepth = 0; !queue.isEmpty() && currentDepth <= maxDepth; currentDepth++) {
|
||||
for (BlockVector3 from : queue) {
|
||||
if (function.apply(from)) affected++;
|
||||
if (function.apply(from)) {
|
||||
affected++;
|
||||
}
|
||||
for (int i = 0, j = 0; i < dirs.length && j < maxBranch; i++) {
|
||||
BlockVector3 direction = dirs[i];
|
||||
int y = from.getBlockY() + direction.getY();
|
||||
|
@ -13,9 +13,9 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
* A chunk based search algorithm
|
||||
*/
|
||||
public class ScanChunk {
|
||||
private static final int MAX_QUEUE = 34816;
|
||||
public static final BlockVector3[] DEFAULT_DIRECTIONS = new BlockVector3[6];
|
||||
public static final BlockVector3[] DIAGONAL_DIRECTIONS;
|
||||
private static final int MAX_QUEUE = 34816;
|
||||
|
||||
static {
|
||||
DEFAULT_DIRECTIONS[0] = BlockVector3.at(0, -1, 0);
|
||||
@ -45,6 +45,7 @@ public class ScanChunk {
|
||||
private final BlockVector3[] directions;
|
||||
private final Long2ObjectOpenHashMap<long[][]> visits;
|
||||
private final Long2ObjectOpenHashMap<char[][]> queues;
|
||||
private ConcurrentLinkedQueue<char[]> queuePool = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public ScanChunk(RegionFunction function) {
|
||||
this.function = function;
|
||||
@ -63,10 +64,14 @@ public class ScanChunk {
|
||||
int Z = z >> 4;
|
||||
long pair = pairInt(X, Z);
|
||||
long[][] chunk = visits.get(pair);
|
||||
if (chunk == null) return false;
|
||||
if (chunk == null) {
|
||||
return false;
|
||||
}
|
||||
int layer = y >> 4;
|
||||
long[] section = chunk[layer];
|
||||
if (section == null) return false;
|
||||
if (section == null) {
|
||||
return false;
|
||||
}
|
||||
return get(section, getLocalIndex(x & 15, y & 15, z & 15));
|
||||
}
|
||||
|
||||
@ -134,23 +139,22 @@ public class ScanChunk {
|
||||
|
||||
public void process() {
|
||||
LongArraySet set = new LongArraySet();
|
||||
/*
|
||||
while (!queues.isEmpty()) {
|
||||
// ObjectIterator<Long2ObjectMap.Entry<char[][]>> iter = queues.long2ObjectEntrySet().fastIterator();
|
||||
// Long2ObjectMap.Entry<char[][]> entry = iter.next();
|
||||
// long index = entry.getLongKey();
|
||||
// int X = MathMan.unpairIntX(index);
|
||||
// int Z = MathMan.unpairIntY(index);
|
||||
// // check that adjacent chunks aren;t being processed
|
||||
//
|
||||
// char[] queue = entry.getValue();
|
||||
// long[][] visit = visits.get(index);
|
||||
// if (visit == null) {
|
||||
// visits.put(index, visit = new long[16][]);
|
||||
// }
|
||||
}
|
||||
}
|
||||
ObjectIterator<Long2ObjectMap.Entry<char[][]>> iter = queues.long2ObjectEntrySet().fastIterator();
|
||||
Long2ObjectMap.Entry<char[][]> entry = iter.next();
|
||||
long index = entry.getLongKey();
|
||||
int X = MathMan.unpairIntX(index);
|
||||
int Z = MathMan.unpairIntY(index);
|
||||
// check that adjacent chunks aren;t being processed
|
||||
|
||||
private ConcurrentLinkedQueue<char[]> queuePool = new ConcurrentLinkedQueue<>();
|
||||
char[] queue = entry.getValue();
|
||||
long[][] visit = visits.get(index);
|
||||
if (visit == null) {
|
||||
visits.put(index, visit = new long[16][]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private char[] newQueue() {
|
||||
char[] arr = queuePool.poll();
|
||||
@ -178,7 +182,7 @@ public class ScanChunk {
|
||||
|
||||
apply(xx + x, yy + y, zz + z);
|
||||
|
||||
int x1 = x, x2 = x;
|
||||
int x1 = x;
|
||||
|
||||
// find start of scan-line
|
||||
int i1 = index;
|
||||
@ -187,7 +191,9 @@ public class ScanChunk {
|
||||
// queue in west chunk
|
||||
break;
|
||||
}
|
||||
if (get(visit, i1)) break;
|
||||
if (get(visit, i1)) {
|
||||
break;
|
||||
}
|
||||
// visit
|
||||
set(visit, i1);
|
||||
|
||||
@ -199,12 +205,15 @@ public class ScanChunk {
|
||||
|
||||
// find end of scan-line
|
||||
int i2 = index;
|
||||
int x2 = x;
|
||||
while (true) {
|
||||
if (x2 > 15) {
|
||||
// queue in east chunk
|
||||
break;
|
||||
}
|
||||
if (get(visit, i2)) break;
|
||||
if (get(visit, i2)) {
|
||||
break;
|
||||
}
|
||||
set(visit, i2);
|
||||
i2++;
|
||||
x2++;
|
||||
@ -220,9 +229,9 @@ public class ScanChunk {
|
||||
|
||||
}
|
||||
|
||||
public void process4(int X, int Z, char[][] queues, long[][] visit) {
|
||||
int xx = X << 4;
|
||||
int zz = Z << 4;
|
||||
public void process4(int chunkX, int chunkZ, char[][] queues, long[][] visit) {
|
||||
int xx = chunkX << 4;
|
||||
int zz = chunkZ << 4;
|
||||
|
||||
// TODO fetch instead of create
|
||||
final BlockVector3[] dirs = directions;
|
||||
@ -231,7 +240,9 @@ public class ScanChunk {
|
||||
boolean empty = true;
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
char[] queue = queues[layer];
|
||||
if (queue == null) continue;
|
||||
if (queue == null) {
|
||||
continue;
|
||||
}
|
||||
char index;
|
||||
while ((index = queue[0]) != queue[1]) {
|
||||
queue[0]++;
|
||||
@ -246,73 +257,75 @@ public class ScanChunk {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty) break;
|
||||
if (empty) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// empty queues
|
||||
|
||||
// while (indexStart != indexEnd) {
|
||||
// char index = queue[indexStart++];
|
||||
// byte dirs = 0xF;
|
||||
// int x = index & 15;
|
||||
// int z = (index >> 4) & 15;
|
||||
// int y = index >> 8;
|
||||
//
|
||||
// int layer = y >> 4;
|
||||
// long[] visitBits = visit[layer];
|
||||
//
|
||||
// int x1 = x;
|
||||
// int x2 = x;
|
||||
//
|
||||
// // find start of scan-line
|
||||
// int i1 = index;
|
||||
// while (true) {
|
||||
// if (x1 < 0) {
|
||||
// // queue in adjacent chunk
|
||||
// break;
|
||||
// }
|
||||
// if (get(visitBits, i1--)) break;
|
||||
// x1--;
|
||||
// }
|
||||
// i1++;
|
||||
// x1++;
|
||||
//
|
||||
// // find end of scan-line
|
||||
// int i2 = index;
|
||||
// while (true) {
|
||||
// if (x2 > 15) {
|
||||
// // queue in adjacent chunk
|
||||
// break;
|
||||
// }
|
||||
// if (get(visitBits, i2++)) break;
|
||||
// x2++;
|
||||
// }
|
||||
// i2--;
|
||||
// x2--;
|
||||
//
|
||||
// boolean scanUp = false;
|
||||
// boolean scanDown = false;
|
||||
// boolean scanLeft = false;
|
||||
// boolean scanRight = false;
|
||||
//
|
||||
// for (int i = i1; i <= i2; i++) {
|
||||
// if (!scanDown && y > 0 && )
|
||||
// }
|
||||
//
|
||||
// for (int i=x1; i<=x2; i++) { // find scan-lines above this one
|
||||
// if (!inScanLine && y>0 && ip.getPixel(i,y-1)==color)
|
||||
// {push(i, y-1); inScanLine = true;}
|
||||
// else if (inScanLine && y>0 && ip.getPixel(i,y-1)!=color)
|
||||
// inScanLine = false;
|
||||
// }
|
||||
//
|
||||
// inScanLine = false;
|
||||
// for (int i=x1; i<=x2; i++) { // find scan-lines below this one
|
||||
// if (!inScanLine && y<height-1 && ip.getPixel(i,y+1)==color)
|
||||
// {push(i, y+1); inScanLine = true;}
|
||||
// else if (inScanLine && y<height-1 && ip.getPixel(i,y+1)!=color)
|
||||
// inScanLine = false;
|
||||
// }
|
||||
// }
|
||||
/* while (indexStart != indexEnd) {
|
||||
char index = queue[indexStart++];
|
||||
byte dirs = 0xF;
|
||||
int x = index & 15;
|
||||
int z = (index >> 4) & 15;
|
||||
int y = index >> 8;
|
||||
|
||||
int layer = y >> 4;
|
||||
long[] visitBits = visit[layer];
|
||||
|
||||
int x1 = x;
|
||||
int x2 = x;
|
||||
|
||||
// find start of scan-line
|
||||
int i1 = index;
|
||||
while (true) {
|
||||
if (x1 < 0) {
|
||||
// queue in adjacent chunk
|
||||
break;
|
||||
}
|
||||
if (get(visitBits, i1--)) break;
|
||||
x1--;
|
||||
}
|
||||
i1++;
|
||||
x1++;
|
||||
|
||||
// find end of scan-line
|
||||
int i2 = index;
|
||||
while (true) {
|
||||
if (x2 > 15) {
|
||||
// queue in adjacent chunk
|
||||
break;
|
||||
}
|
||||
if (get(visitBits, i2++)) break;
|
||||
x2++;
|
||||
}
|
||||
i2--;
|
||||
x2--;
|
||||
|
||||
boolean scanUp = false;
|
||||
boolean scanDown = false;
|
||||
boolean scanLeft = false;
|
||||
boolean scanRight = false;
|
||||
|
||||
for (int i = i1; i <= i2; i++) {
|
||||
if (!scanDown && y > 0 && )
|
||||
}
|
||||
|
||||
for (int i=x1; i<=x2; i++) { // find scan-lines above this one
|
||||
if (!inScanLine && y>0 && ip.getPixel(i,y-1)==color)
|
||||
{push(i, y-1); inScanLine = true;}
|
||||
else if (inScanLine && y>0 && ip.getPixel(i,y-1)!=color)
|
||||
inScanLine = false;
|
||||
}
|
||||
|
||||
inScanLine = false;
|
||||
for (int i=x1; i<=x2; i++) { // find scan-lines below this one
|
||||
if (!inScanLine && y<height-1 && ip.getPixel(i,y+1)==color)
|
||||
{push(i, y+1); inScanLine = true;}
|
||||
else if (inScanLine && y<height-1 && ip.getPixel(i,y+1)!=color)
|
||||
inScanLine = false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public void set(long[] bits, int i) {
|
||||
|
@ -39,7 +39,8 @@ public class UndoContext {
|
||||
*
|
||||
* @return an extent or null
|
||||
*/
|
||||
public @Nullable Extent getExtent() {
|
||||
@Nullable
|
||||
public Extent getExtent() {
|
||||
return extent;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.history.changeset;
|
||||
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
@ -81,24 +82,22 @@ public interface ChangeSet extends Closeable {
|
||||
int size();
|
||||
|
||||
/**
|
||||
* Close the changeset
|
||||
* Close the changeset.
|
||||
*/
|
||||
@Override
|
||||
default void close() throws IOException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the changeset (e.g. files on disk, or in a database)
|
||||
*/
|
||||
default void delete() {}
|
||||
default void delete() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a summary of this changeset (or null)
|
||||
* @param region
|
||||
* @param shallow
|
||||
* @return
|
||||
* Get a summary of this changeset.
|
||||
*/
|
||||
@Nullable
|
||||
default ChangeSetSummary summarize(Region region, boolean shallow) {
|
||||
return null;
|
||||
}
|
||||
|
@ -55,9 +55,10 @@ public final class ChunkDeleter {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ChunkDeleter.class);
|
||||
|
||||
private static final Comparator<BlockVector2> chunkSorter = Comparator.comparing(
|
||||
pos -> (pos.getBlockX() & 31) + (pos.getBlockZ() & 31) * 32);
|
||||
pos -> (pos.getBlockX() & 31) + (pos.getBlockZ() & 31) * 32
|
||||
);
|
||||
|
||||
private static Gson chunkDeleterGson = new GsonBuilder()
|
||||
private static final Gson chunkDeleterGson = new GsonBuilder()
|
||||
.registerTypeAdapter(BlockVector2.class, new BlockVector2Adapter())
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
@ -95,13 +96,13 @@ public final class ChunkDeleter {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
if (!deletedFile) {
|
||||
logger.warn("Chunk deletion file could not be cleaned up. This may have unintended consequences" +
|
||||
" on next startup, or if /delchunks is used again.");
|
||||
logger.warn("Chunk deletion file could not be cleaned up. This may have unintended consequences"
|
||||
+ " on next startup, or if /delchunks is used again.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.error("Error occurred while deleting chunks. " +
|
||||
"If world errors occur, stop the server and restore the *.bak backup files.");
|
||||
logger.error("Error occurred while deleting chunks. "
|
||||
+ "If world errors occur, stop the server and restore the *.bak backup files.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,7 +119,7 @@ public final class ChunkDeleter {
|
||||
}
|
||||
|
||||
private final ChunkDeletionInfo chunkDeletionInfo;
|
||||
private Set<Path> backedUpRegions = new HashSet<>();
|
||||
private final Set<Path> backedUpRegions = new HashSet<>();
|
||||
private boolean shouldPreload;
|
||||
private int debugRate = 100;
|
||||
private int totalChunksDeleted = 0;
|
||||
@ -139,7 +140,9 @@ public final class ChunkDeleter {
|
||||
|
||||
return regionToChunkList.entrySet().stream().allMatch(entry -> {
|
||||
Path regionPath = entry.getKey();
|
||||
if (!Files.exists(regionPath)) return true;
|
||||
if (!Files.exists(regionPath)) {
|
||||
return true;
|
||||
}
|
||||
if (chunkBatch.backup && !backedUpRegions.contains(regionPath)) {
|
||||
try {
|
||||
backupRegion(regionPath);
|
||||
@ -156,10 +159,10 @@ public final class ChunkDeleter {
|
||||
Path worldPath = Paths.get(chunkBatch.worldPath);
|
||||
if (chunkBatch.chunks != null) {
|
||||
return chunkBatch.chunks.stream()
|
||||
.collect(Collectors.groupingBy(RegionFilePos::new))
|
||||
.entrySet().stream().collect(Collectors.toMap(
|
||||
e -> worldPath.resolve("region").resolve(e.getKey().getFileName()),
|
||||
e -> e.getValue().stream().sorted(chunkSorter)));
|
||||
.collect(Collectors.groupingBy(RegionFilePos::new))
|
||||
.entrySet().stream().collect(Collectors.toMap(
|
||||
e -> worldPath.resolve("region").resolve(e.getKey().getFileName()),
|
||||
e -> e.getValue().stream().sorted(chunkSorter)));
|
||||
} else {
|
||||
final BlockVector2 minChunk = chunkBatch.minChunk;
|
||||
final BlockVector2 maxChunk = chunkBatch.maxChunk;
|
||||
@ -169,7 +172,9 @@ public final class ChunkDeleter {
|
||||
for (int regX = minRegion.getX(); regX <= maxRegion.getX(); regX++) {
|
||||
for (int regZ = minRegion.getZ(); regZ <= maxRegion.getZ(); regZ++) {
|
||||
final Path regionPath = worldPath.resolve("region").resolve(new RegionFilePos(regX, regZ).getFileName());
|
||||
if (!Files.exists(regionPath)) continue;
|
||||
if (!Files.exists(regionPath)) {
|
||||
continue;
|
||||
}
|
||||
int startX = regX << 5;
|
||||
int endX = (regX << 5) + 31;
|
||||
int startZ = regZ << 5;
|
||||
@ -180,17 +185,17 @@ public final class ChunkDeleter {
|
||||
int maxX = Math.min(Math.max(startX, endX), maxChunk.getBlockX());
|
||||
int maxZ = Math.min(Math.max(startZ, endZ), maxChunk.getBlockZ());
|
||||
Stream<BlockVector2> stream = Stream.iterate(BlockVector2.at(minX, minZ),
|
||||
bv2 -> {
|
||||
int nextX = bv2.getBlockX();
|
||||
int nextZ = bv2.getBlockZ();
|
||||
if (++nextX > maxX) {
|
||||
nextX = minX;
|
||||
if (++nextZ > maxZ) {
|
||||
return null;
|
||||
}
|
||||
bv2 -> {
|
||||
int nextX = bv2.getBlockX();
|
||||
int nextZ = bv2.getBlockZ();
|
||||
if (++nextX > maxX) {
|
||||
nextX = minX;
|
||||
if (++nextZ > maxZ) {
|
||||
return null;
|
||||
}
|
||||
return BlockVector2.at(nextX, nextZ);
|
||||
});
|
||||
}
|
||||
return BlockVector2.at(nextX, nextZ);
|
||||
});
|
||||
groupedChunks.put(regionPath, stream);
|
||||
}
|
||||
}
|
||||
@ -199,7 +204,9 @@ public final class ChunkDeleter {
|
||||
}
|
||||
|
||||
private BiPredicate<RegionAccess, BlockVector2> createPredicates(List<ChunkDeletionInfo.DeletionPredicate> deletionPredicates) {
|
||||
if (deletionPredicates == null) return (r, p) -> true;
|
||||
if (deletionPredicates == null) {
|
||||
return (r, p) -> true;
|
||||
}
|
||||
return deletionPredicates.stream()
|
||||
.map(this::createPredicate)
|
||||
.reduce(BiPredicate::and)
|
||||
@ -249,7 +256,9 @@ public final class ChunkDeleter {
|
||||
try (RegionAccess region = new RegionAccess(regionFile, shouldPreload)) {
|
||||
for (Iterator<BlockVector2> iterator = chunks.iterator(); iterator.hasNext();) {
|
||||
BlockVector2 chunk = iterator.next();
|
||||
if (chunk == null) break;
|
||||
if (chunk == null) {
|
||||
break;
|
||||
}
|
||||
if (deletionPredicate.test(region, chunk)) {
|
||||
region.deleteChunk(chunk);
|
||||
totalChunksDeleted++;
|
||||
@ -322,12 +331,18 @@ public final class ChunkDeleter {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RegionFilePos that = (RegionFilePos) o;
|
||||
|
||||
if (x != that.x) return false;
|
||||
if (x != that.x) {
|
||||
return false;
|
||||
}
|
||||
return z == that.z;
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,9 @@ public class ChunkDeletionInfo {
|
||||
public BlockVector2 maxChunk;
|
||||
|
||||
public int getChunkCount() {
|
||||
if (chunks != null) return chunks.size();
|
||||
if (chunks != null) {
|
||||
return chunks.size();
|
||||
}
|
||||
final BlockVector2 dist = maxChunk.subtract(minChunk).add(1, 1);
|
||||
return dist.getBlockX() * dist.getBlockZ();
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public final class BlockStateIdAccess {
|
||||
|
||||
public interface BlockStateInternalId {
|
||||
int getInternalId(BlockState blockState);
|
||||
|
||||
void setInternalId(BlockState blockState, int internalId);
|
||||
}
|
||||
|
||||
@ -52,6 +53,7 @@ public final class BlockStateIdAccess {
|
||||
}
|
||||
|
||||
/**
|
||||
* An invalid internal ID, for verification purposes.
|
||||
* @return an internal ID which is never valid
|
||||
*/
|
||||
public static int invalidId() {
|
||||
@ -67,7 +69,8 @@ public final class BlockStateIdAccess {
|
||||
//return blockStateInternalId.getInternalId(holder);
|
||||
}
|
||||
|
||||
public static @Nullable BlockState getBlockStateById(int id) {
|
||||
@Nullable
|
||||
public static BlockState getBlockStateById(int id) {
|
||||
return BlockState.getFromOrdinal(id);
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,9 @@ public class CommandArgParser {
|
||||
break;
|
||||
case QUOTE:
|
||||
handleQuote(nextPart);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (currentArg.size() > 0) {
|
||||
|
@ -23,43 +23,43 @@ import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
|
||||
public interface CUIRegion {
|
||||
|
||||
|
||||
/**
|
||||
* Sends CUI events describing the region for
|
||||
* versions of CUI equal to or greater than the
|
||||
* value supplied by getProtocolVersion().
|
||||
*
|
||||
*
|
||||
*/
|
||||
void describeCUI(LocalSession session, Actor player);
|
||||
|
||||
|
||||
/**
|
||||
* Sends CUI events describing the region for
|
||||
* versions of CUI smaller than the value
|
||||
* versions of CUI smaller than the value
|
||||
* supplied by getProtocolVersion().
|
||||
*
|
||||
*
|
||||
*/
|
||||
void describeLegacyCUI(LocalSession session, Actor player);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the CUI version that is required to send
|
||||
* up-to-date data. If the CUI version is smaller than
|
||||
* this value, the legacy methods will be called.
|
||||
*
|
||||
*
|
||||
* @return the protocol version
|
||||
*/
|
||||
int getProtocolVersion();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the type ID to send to CUI in the selection event.
|
||||
*
|
||||
* @return the type ID
|
||||
*/
|
||||
String getTypeID();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the type ID to send to CUI in the selection
|
||||
* event if the CUI is in legacy mode.
|
||||
*
|
||||
*
|
||||
* @return the legacy type ID
|
||||
*/
|
||||
String getLegacyTypeID();
|
||||
|
@ -63,8 +63,12 @@ public class ServerCUIHandler {
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(player);
|
||||
RegionSelector regionSelector = session.getRegionSelector(player.getWorld());
|
||||
|
||||
int posX, posY, posZ;
|
||||
int width, height, length;
|
||||
int posX;
|
||||
int posY;
|
||||
int posZ;
|
||||
int width;
|
||||
int height;
|
||||
int length;
|
||||
|
||||
if (regionSelector instanceof CuboidRegionSelector) {
|
||||
if (regionSelector.isDefined()) {
|
||||
|
@ -25,10 +25,15 @@ package com.sk89q.worldedit.internal.expression;
|
||||
public interface ExpressionEnvironment {
|
||||
|
||||
int getBlockType(double x, double y, double z);
|
||||
|
||||
int getBlockData(double x, double y, double z);
|
||||
|
||||
int getBlockTypeAbs(double x, double y, double z);
|
||||
|
||||
int getBlockDataAbs(double x, double y, double z);
|
||||
|
||||
int getBlockTypeRel(double x, double y, double z);
|
||||
|
||||
int getBlockDataRel(double x, double y, double z);
|
||||
|
||||
}
|
||||
|
@ -84,9 +84,8 @@ public class ExpressionHelper {
|
||||
? (mh.type().parameterCount() - 1) + "+"
|
||||
: String.valueOf(mh.type().parameterCount()))
|
||||
.collect(Collectors.joining("/"));
|
||||
throw evalException(ctx, "Incorrect number of arguments for function '" + fnName + "', " +
|
||||
"expected " + possibleCounts + ", " +
|
||||
"got " + ctx.args.size());
|
||||
throw evalException(ctx, "Incorrect number of arguments for function '" + fnName + "', "
|
||||
+ "expected " + possibleCounts + ", " + "got " + ctx.args.size());
|
||||
}
|
||||
|
||||
// Special argument handle names
|
||||
|
@ -267,10 +267,10 @@ public final class Functions {
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
double currentX = getBufferItem(megabuf, index) - x;
|
||||
double currentY = getBufferItem(megabuf, index+1) - y;
|
||||
double currentZ = getBufferItem(megabuf, index+2) - z;
|
||||
double currentY = getBufferItem(megabuf, index + 1) - y;
|
||||
double currentZ = getBufferItem(megabuf, index + 2) - z;
|
||||
|
||||
double currentDistanceSquared = currentX*currentX + currentY*currentY + currentZ*currentZ;
|
||||
double currentDistanceSquared = currentX * currentX + currentY * currentY + currentZ * currentZ;
|
||||
|
||||
if (currentDistanceSquared < minDistanceSquared) {
|
||||
minDistanceSquared = currentDistanceSquared;
|
||||
|
@ -475,11 +475,15 @@ class CompilingVisitor extends ExpressionBaseVisitor<MethodHandle> {
|
||||
|
||||
long aLong = Double.doubleToRawLongBits(a);
|
||||
// Make aLong lexicographically ordered as a twos-complement long
|
||||
if (aLong < 0) aLong = 0x8000000000000000L - aLong;
|
||||
if (aLong < 0) {
|
||||
aLong = 0x8000000000000000L - aLong;
|
||||
}
|
||||
|
||||
long bLong = Double.doubleToRawLongBits(b);
|
||||
// Make bLong lexicographically ordered as a twos-complement long
|
||||
if (bLong < 0) bLong = 0x8000000000000000L - bLong;
|
||||
if (bLong < 0) {
|
||||
bLong = 0x8000000000000000L - bLong;
|
||||
}
|
||||
|
||||
final long longDiff = Math.abs(aLong - bLong);
|
||||
return longDiff <= 450359963L;
|
||||
@ -555,8 +559,8 @@ class CompilingVisitor extends ExpressionBaseVisitor<MethodHandle> {
|
||||
value -= arg;
|
||||
break;
|
||||
default:
|
||||
throw ExpressionHelper.evalException(ctx, "Invalid text for assign expr: " +
|
||||
ctx.assignmentOperator().getText());
|
||||
throw ExpressionHelper.evalException(ctx, "Invalid text for assign expr: "
|
||||
+ ctx.assignmentOperator().getText());
|
||||
}
|
||||
}
|
||||
variable.setValue(value);
|
||||
|
@ -23,6 +23,8 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -79,7 +81,7 @@ public abstract class AbstractFactory<E> {
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoMatchException("No match for '" + input + "'");
|
||||
throw new NoMatchException(TranslatableComponent.of("worldedit.error.no-match", TextComponent.of(input)));
|
||||
}
|
||||
|
||||
public List<String> getSuggestions(String input) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user