mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-24 22:04:23 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
6b208b98bc
commit
a309488cdf
214 files changed
+9283
-9265
No files matched your search
@@ -110,11 +110,9 @@ public class DataByteArray implements IData {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("[");
|
||||
boolean first = true;
|
||||
for(byte value : data) {
|
||||
if(first)
|
||||
first = false;
|
||||
else
|
||||
result.append(", ");
|
||||
for (byte value : data) {
|
||||
if (first) first = false;
|
||||
else result.append(", ");
|
||||
|
||||
result.append(value);
|
||||
}
|
||||
@@ -125,7 +123,7 @@ public class DataByteArray implements IData {
|
||||
@Override
|
||||
public List<IData> asList() {
|
||||
List<IData> result = new ArrayList<IData>();
|
||||
for(byte value : data) {
|
||||
for (byte value : data) {
|
||||
result.add(new DataByte(value));
|
||||
}
|
||||
return result;
|
||||
@@ -144,7 +142,7 @@ public class DataByteArray implements IData {
|
||||
@Override
|
||||
public int[] asIntArray() {
|
||||
int[] result = new int[data.length];
|
||||
for(int i = 0; i < result.length; i++) {
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = data[i];
|
||||
}
|
||||
return result;
|
||||
@@ -157,7 +155,7 @@ public class DataByteArray implements IData {
|
||||
|
||||
@Override
|
||||
public void setAt(int i, IData value) {
|
||||
if(immutable) {
|
||||
if (immutable) {
|
||||
throw new UnsupportedOperationException("Cannot modify this byte array");
|
||||
} else {
|
||||
data[i] = value.asByte();
|
||||
@@ -196,7 +194,7 @@ public class DataByteArray implements IData {
|
||||
|
||||
@Override
|
||||
public IData immutable() {
|
||||
if(immutable) {
|
||||
if (immutable) {
|
||||
return this;
|
||||
} else {
|
||||
return new DataByteArray(Arrays.copyOf(this.data, this.data.length), true);
|
||||
|
||||
@@ -110,8 +110,8 @@ public class DataIntArray implements IData {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append('[');
|
||||
boolean first = true;
|
||||
for(int value : data) {
|
||||
if(first) {
|
||||
for (int value : data) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
result.append(", ");
|
||||
@@ -125,7 +125,7 @@ public class DataIntArray implements IData {
|
||||
@Override
|
||||
public List<IData> asList() {
|
||||
List<IData> result = new ArrayList<>();
|
||||
for(int value : data) {
|
||||
for (int value : data) {
|
||||
result.add(new DataInt(value));
|
||||
}
|
||||
return result;
|
||||
@@ -139,7 +139,7 @@ public class DataIntArray implements IData {
|
||||
@Override
|
||||
public byte[] asByteArray() {
|
||||
byte[] result = new byte[data.length];
|
||||
for(int i = 0; i < result.length; i++) {
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = (byte) data[i];
|
||||
}
|
||||
return result;
|
||||
@@ -157,7 +157,7 @@ public class DataIntArray implements IData {
|
||||
|
||||
@Override
|
||||
public void setAt(int i, IData value) {
|
||||
if(immutable) {
|
||||
if (immutable) {
|
||||
throw new UnsupportedOperationException("Cannot modify this byte array");
|
||||
} else {
|
||||
data[i] = value.asInt();
|
||||
@@ -196,7 +196,7 @@ public class DataIntArray implements IData {
|
||||
|
||||
@Override
|
||||
public IData immutable() {
|
||||
if(immutable) {
|
||||
if (immutable) {
|
||||
return this;
|
||||
} else {
|
||||
return new DataIntArray(Arrays.copyOf(this.data, this.data.length), true);
|
||||
|
||||
@@ -54,7 +54,7 @@ public class DataList implements IData {
|
||||
|
||||
@Override
|
||||
public List<IData> asList() {
|
||||
if(immutable) {
|
||||
if (immutable) {
|
||||
return Collections.unmodifiableList(values);
|
||||
} else {
|
||||
return values;
|
||||
@@ -71,8 +71,8 @@ public class DataList implements IData {
|
||||
StringBuilder output = new StringBuilder();
|
||||
output.append('[');
|
||||
boolean first = true;
|
||||
for(IData value : values) {
|
||||
if(first) {
|
||||
for (IData value : values) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
output.append(", ");
|
||||
@@ -87,11 +87,11 @@ public class DataList implements IData {
|
||||
public byte[] asByteArray() {
|
||||
try {
|
||||
byte[] result = new byte[values.size()];
|
||||
for(int i = 0; i < values.size(); i++) {
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
result[i] = values.get(i).asByte();
|
||||
}
|
||||
return result;
|
||||
} catch(IllegalDataException ex) {
|
||||
} catch (IllegalDataException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -100,11 +100,11 @@ public class DataList implements IData {
|
||||
public int[] asIntArray() {
|
||||
try {
|
||||
int[] result = new int[values.size()];
|
||||
for(int i = 0; i < values.size(); i++) {
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
result[i] = values.get(i).asInt();
|
||||
}
|
||||
return result;
|
||||
} catch(IllegalDataException ex) {
|
||||
} catch (IllegalDataException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class DataList implements IData {
|
||||
|
||||
@Override
|
||||
public void setAt(int i, IData value) {
|
||||
if(immutable) {
|
||||
if (immutable) {
|
||||
throw new UnsupportedOperationException("this list is immutable");
|
||||
} else {
|
||||
values.set(i, value);
|
||||
@@ -141,23 +141,19 @@ public class DataList implements IData {
|
||||
@Override
|
||||
public boolean contains(IData data) {
|
||||
List<IData> dataValues = data.asList();
|
||||
if(dataValues != null && containsList(dataValues))
|
||||
return true;
|
||||
if (dataValues != null && containsList(dataValues)) return true;
|
||||
|
||||
for(IData value : values) {
|
||||
if(value.contains(data))
|
||||
return true;
|
||||
for (IData value : values) {
|
||||
if (value.contains(data)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean containsList(List<IData> dataValues) {
|
||||
outer:
|
||||
for(IData dataValue : dataValues) {
|
||||
for(IData value : values) {
|
||||
if(value.contains(dataValue))
|
||||
continue outer;
|
||||
outer: for (IData dataValue : dataValues) {
|
||||
for (IData value : values) {
|
||||
if (value.contains(dataValue)) continue outer;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -169,12 +165,10 @@ public class DataList implements IData {
|
||||
@Override
|
||||
public boolean equals(IData data) {
|
||||
List<IData> otherValues = data.asList();
|
||||
if(otherValues.size() != values.size())
|
||||
return false;
|
||||
if (otherValues.size() != values.size()) return false;
|
||||
|
||||
for(int i = 0; i < values.size(); i++) {
|
||||
if(!values.get(i).equals(otherValues.get(i)))
|
||||
return false;
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
if (!values.get(i).equals(otherValues.get(i))) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -187,11 +181,11 @@ public class DataList implements IData {
|
||||
|
||||
@Override
|
||||
public IData immutable() {
|
||||
if(immutable) {
|
||||
if (immutable) {
|
||||
return this;
|
||||
} else {
|
||||
List<IData> copy = new ArrayList<>();
|
||||
for(IData value : values) {
|
||||
for (IData value : values) {
|
||||
copy.add(value.immutable());
|
||||
}
|
||||
return new DataList(copy, true);
|
||||
@@ -200,8 +194,7 @@ public class DataList implements IData {
|
||||
|
||||
@Override
|
||||
public IData update(IData data) {
|
||||
if(immutable)
|
||||
data = data.immutable();
|
||||
if (immutable) data = data.immutable();
|
||||
|
||||
List<IData> result = new ArrayList<>();
|
||||
result.addAll(values);
|
||||
|
||||
@@ -24,10 +24,10 @@ public class DataMap implements IData {
|
||||
Map<String, IData> result = new HashMap<>();
|
||||
Map<String, IData> otherMap = other.asMap();
|
||||
|
||||
for(Map.Entry<String, IData> entry : data.entrySet()) {
|
||||
for (Map.Entry<String, IData> entry : data.entrySet()) {
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
for(Map.Entry<String, IData> entry : otherMap.entrySet()) {
|
||||
for (Map.Entry<String, IData> entry : otherMap.entrySet()) {
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
@@ -39,10 +39,10 @@ public class DataMap implements IData {
|
||||
Map<String, IData> result = new HashMap<>();
|
||||
Map<String, IData> otherMap = other.asMap();
|
||||
|
||||
for(Map.Entry<String, IData> entry : data.entrySet()) {
|
||||
for (Map.Entry<String, IData> entry : data.entrySet()) {
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
for(String key : otherMap.keySet()) {
|
||||
for (String key : otherMap.keySet()) {
|
||||
result.remove(key);
|
||||
}
|
||||
|
||||
@@ -129,14 +129,14 @@ public class DataMap implements IData {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append('{');
|
||||
boolean first = true;
|
||||
for(Map.Entry<String, IData> entry : data.entrySet()) {
|
||||
if(first) {
|
||||
for (Map.Entry<String, IData> entry : data.entrySet()) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
result.append(", ");
|
||||
}
|
||||
|
||||
if(isValidIdentifier(entry.getKey())) {
|
||||
if (isValidIdentifier(entry.getKey())) {
|
||||
result.append(entry.getKey());
|
||||
} else {
|
||||
result.append("\"").append(entry.getKey()).append("\"");
|
||||
@@ -156,7 +156,7 @@ public class DataMap implements IData {
|
||||
|
||||
@Override
|
||||
public Map<String, IData> asMap() {
|
||||
if(immutable) {
|
||||
if (immutable) {
|
||||
return Collections.unmodifiableMap(data);
|
||||
} else {
|
||||
return data;
|
||||
@@ -190,7 +190,7 @@ public class DataMap implements IData {
|
||||
|
||||
@Override
|
||||
public void memberSet(String name, IData data) {
|
||||
if(immutable) {
|
||||
if (immutable) {
|
||||
throw new UnsupportedOperationException("this map is not modifiable");
|
||||
} else {
|
||||
this.data.put(name, data);
|
||||
@@ -204,18 +204,17 @@ public class DataMap implements IData {
|
||||
|
||||
@Override
|
||||
public boolean contains(IData data) {
|
||||
if(data instanceof DataString) {
|
||||
if (data instanceof DataString) {
|
||||
return this.data.containsKey(data.asString());
|
||||
}
|
||||
|
||||
Map<String, IData> dataMap = data.asMap();
|
||||
if(dataMap == null)
|
||||
return false;
|
||||
if (dataMap == null) return false;
|
||||
|
||||
for(Map.Entry<String, IData> dataEntry : dataMap.entrySet()) {
|
||||
if(!this.data.containsKey(dataEntry.getKey())) {
|
||||
for (Map.Entry<String, IData> dataEntry : dataMap.entrySet()) {
|
||||
if (!this.data.containsKey(dataEntry.getKey())) {
|
||||
return false;
|
||||
} else if(!this.data.get(dataEntry.getKey()).contains(dataEntry.getValue())) {
|
||||
} else if (!this.data.get(dataEntry.getKey()).contains(dataEntry.getValue())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -230,17 +229,15 @@ public class DataMap implements IData {
|
||||
|
||||
@Override
|
||||
public boolean equals(IData data) {
|
||||
if(this == data)
|
||||
return true;
|
||||
if (this == data) return true;
|
||||
|
||||
Map<String, IData> dataMap = data.asMap();
|
||||
if(dataMap.size() != this.data.size())
|
||||
return false;
|
||||
if (dataMap.size() != this.data.size()) return false;
|
||||
|
||||
for(Map.Entry<String, IData> dataEntry : this.data.entrySet()) {
|
||||
if(!dataMap.containsKey(dataEntry.getKey())) {
|
||||
for (Map.Entry<String, IData> dataEntry : this.data.entrySet()) {
|
||||
if (!dataMap.containsKey(dataEntry.getKey())) {
|
||||
return false;
|
||||
} else if(!dataMap.get(dataEntry.getKey()).equals(dataEntry.getValue())) {
|
||||
} else if (!dataMap.get(dataEntry.getKey()).equals(dataEntry.getValue())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -250,11 +247,11 @@ public class DataMap implements IData {
|
||||
|
||||
@Override
|
||||
public IData immutable() {
|
||||
if(immutable) {
|
||||
if (immutable) {
|
||||
return this;
|
||||
} else {
|
||||
Map<String, IData> result = new HashMap<>();
|
||||
for(Map.Entry<String, IData> entry : this.data.entrySet()) {
|
||||
for (Map.Entry<String, IData> entry : this.data.entrySet()) {
|
||||
result.put(entry.getKey(), entry.getValue().immutable());
|
||||
}
|
||||
return new DataMap(result, true);
|
||||
@@ -263,14 +260,13 @@ public class DataMap implements IData {
|
||||
|
||||
@Override
|
||||
public IData update(IData data) {
|
||||
if(immutable)
|
||||
data = data.immutable();
|
||||
if (immutable) data = data.immutable();
|
||||
|
||||
Map<String, IData> result = new HashMap<>();
|
||||
for(Map.Entry<String, IData> entry : this.data.entrySet()) {
|
||||
for (Map.Entry<String, IData> entry : this.data.entrySet()) {
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
for(Map.Entry<String, IData> entry : data.asMap().entrySet()) {
|
||||
for (Map.Entry<String, IData> entry : data.asMap().entrySet()) {
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return new DataMap(result, immutable);
|
||||
@@ -287,12 +283,10 @@ public class DataMap implements IData {
|
||||
}
|
||||
|
||||
private boolean isValidIdentifier(String str) {
|
||||
if(!Character.isJavaIdentifierStart(str.charAt(0)))
|
||||
return false;
|
||||
if (!Character.isJavaIdentifierStart(str.charAt(0))) return false;
|
||||
|
||||
for(int i = 1; i < str.length(); i++) {
|
||||
if(!Character.isJavaIdentifierPart(str.charAt(i)))
|
||||
return false;
|
||||
for (int i = 1; i < str.length(); i++) {
|
||||
if (!Character.isJavaIdentifierPart(str.charAt(i))) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class DataString implements IData {
|
||||
|
||||
@Override
|
||||
public IData memberGet(String name) {
|
||||
if(name.equals("length")) {
|
||||
if (name.equals("length")) {
|
||||
return new DataInt(value.length());
|
||||
} else {
|
||||
throw new UnsupportedOperationException("no such member: " + name);
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package minetweaker.api.data;
|
||||
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
|
||||
/**
|
||||
* Generic data interface. A data element may contain any kind of basic data
|
||||
* element (bool, byte, short, int, long, float, double, string, list, map, int
|
||||
* array or byte array). Used to store data with stacks, blocks, world, ...
|
||||
* Generic data interface. A data element may contain any kind of basic data element (bool, byte, short, int, long,
|
||||
* float, double, string, list, map, int array or byte array). Used to store data with stacks, blocks, world, ...
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@@ -69,8 +68,7 @@ public interface IData {
|
||||
String asString();
|
||||
|
||||
/**
|
||||
* Attempts to convert this value to a List. Returns null if this value
|
||||
* cannot be converted to a list.
|
||||
* Attempts to convert this value to a List. Returns null if this value cannot be converted to a list.
|
||||
*
|
||||
* @return list data of this value, if any
|
||||
*/
|
||||
@@ -78,8 +76,7 @@ public interface IData {
|
||||
List<IData> asList();
|
||||
|
||||
/**
|
||||
* Attempts to convert this value to a Map. Returns null if this value
|
||||
* cannot be converted to a map.
|
||||
* Attempts to convert this value to a Map. Returns null if this value cannot be converted to a map.
|
||||
*
|
||||
* @return map data of this value, if any
|
||||
*/
|
||||
@@ -87,8 +84,7 @@ public interface IData {
|
||||
Map<String, IData> asMap();
|
||||
|
||||
/**
|
||||
* Attempts to convert this value to a byte array. Returns null if this
|
||||
* value cannot be converted to a byte array.
|
||||
* Attempts to convert this value to a byte array. Returns null if this value cannot be converted to a byte array.
|
||||
*
|
||||
* @return byte array data of this value, if any
|
||||
*/
|
||||
@@ -96,8 +92,7 @@ public interface IData {
|
||||
byte[] asByteArray();
|
||||
|
||||
/**
|
||||
* Attempts to convert this value to an int array. Returns null if this
|
||||
* value cannot be converted to an int array.
|
||||
* Attempts to convert this value to an int array. Returns null if this value cannot be converted to an int array.
|
||||
*
|
||||
* @return int array data of this value, if any
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
* This file is part of MineTweaker API, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 MineTweaker <http://minetweaker3.powerofbytes.com>
|
||||
* This file is part of MineTweaker API, licensed under the MIT License (MIT). Copyright (c) 2014 MineTweaker
|
||||
* <http://minetweaker3.powerofbytes.com>
|
||||
*/
|
||||
package minetweaker.api.data;
|
||||
|
||||
|
||||
Reference in new issue
Block a user