mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 20:56:45 +01:00
parent
00b6158181
commit
af79100f7d
@ -17,8 +17,8 @@ is to provide a lag-free and smooth experience.
|
||||
|
||||
### Developer Resources
|
||||
* *Outdated* [JavaDocs](http://empcraft.com/plotsquared/doc/)
|
||||
* [~~Build Server~~](http://ci.intellectualsites.com/job/PlotSquared/)
|
||||
* [~~Maven Repo~~](http://mvn.intellectualsites.com/content/repositories/intellectualsites/)
|
||||
* [~~Build Server~~](http://ci.xephi.fr/job/PlotSquared/)
|
||||
* [~~Maven Repo~~](http://ci.xephi.fr/plugin/repository/everything/)
|
||||
|
||||
|
||||
# Maven
|
||||
@ -27,13 +27,13 @@ We're now on maven!
|
||||
<!-- Repository -->
|
||||
<repository>
|
||||
<id>intellectualsites</id>
|
||||
<url>http://mvn.intellectualsites.com/content/repositories/intellectualsites/</url>
|
||||
<url>http://ci.xephi.fr/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<!-- Dependency -->
|
||||
<dependency>
|
||||
<groupId>com.intellectualcrafters</groupId>
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>2.12.9</version>
|
||||
<version>3.2.24</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
7
pom.xml
7
pom.xml
@ -8,7 +8,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>3.2.24</version>
|
||||
<version>3.2.25</version>
|
||||
<name>PlotSquared</name>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
@ -164,11 +164,6 @@
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.confuser</groupId>
|
||||
<artifactId>BarAPI</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math3</artifactId>
|
||||
|
@ -11,7 +11,7 @@ import java.util.Set;
|
||||
* A type of {@link ConfigurationSection} that is stored in memory.
|
||||
*/
|
||||
public class MemorySection implements ConfigurationSection {
|
||||
protected final Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
protected final Map<String, Object> map = new LinkedHashMap<>();
|
||||
private final Configuration root;
|
||||
private final ConfigurationSection parent;
|
||||
private final String path;
|
||||
@ -24,7 +24,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
if (obj instanceof String) {
|
||||
try {
|
||||
return Double.parseDouble((String) obj);
|
||||
} catch (final Exception e) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (obj instanceof List) {
|
||||
final List<?> val = ((List<?>) obj);
|
||||
if (val.size() > 0) {
|
||||
@ -41,7 +42,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
if (obj instanceof String) {
|
||||
try {
|
||||
return Integer.parseInt((String) obj);
|
||||
} catch (final Exception e) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (obj instanceof List) {
|
||||
final List<?> val = ((List<?>) obj);
|
||||
if (val.size() > 0) {
|
||||
@ -58,7 +60,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
if (obj instanceof String) {
|
||||
try {
|
||||
return Long.parseLong((String) obj);
|
||||
} catch (final Exception e) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (obj instanceof List) {
|
||||
final List<?> val = ((List<?>) obj);
|
||||
if (val.size() > 0) {
|
||||
@ -119,7 +122,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
|
||||
@Override
|
||||
public Set<String> getKeys(final boolean deep) {
|
||||
final Set<String> result = new LinkedHashSet<String>();
|
||||
final Set<String> result = new LinkedHashSet<>();
|
||||
|
||||
final Configuration root = getRoot();
|
||||
if ((root != null) && root.options().copyDefaults()) {
|
||||
@ -137,7 +140,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getValues(final boolean deep) {
|
||||
final Map<String, Object> result = new LinkedHashMap<String, Object>();
|
||||
final Map<String, Object> result = new LinkedHashMap<>();
|
||||
|
||||
final Configuration root = getRoot();
|
||||
if ((root != null) && root.options().copyDefaults()) {
|
||||
@ -462,10 +465,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
final List<?> list = getList(path);
|
||||
|
||||
if (list == null) {
|
||||
return new ArrayList<String>(0);
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
final List<String> result = new ArrayList<String>();
|
||||
final List<String> result = new ArrayList<>();
|
||||
|
||||
for (final Object object : list) {
|
||||
if ((object instanceof String) || (isPrimitiveWrapper(object))) {
|
||||
@ -481,10 +484,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
final List<?> list = getList(path);
|
||||
|
||||
if (list == null) {
|
||||
return new ArrayList<Integer>(0);
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
final List<Integer> result = new ArrayList<Integer>();
|
||||
final List<Integer> result = new ArrayList<>();
|
||||
|
||||
for (final Object object : list) {
|
||||
if (object instanceof Integer) {
|
||||
@ -492,9 +495,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
} else if (object instanceof String) {
|
||||
try {
|
||||
result.add(Integer.valueOf((String) object));
|
||||
} catch (final Exception ex) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (object instanceof Character) {
|
||||
result.add((int) ((Character) object).charValue());
|
||||
result.add((int) (Character) object);
|
||||
} else if (object instanceof Number) {
|
||||
result.add(((Number) object).intValue());
|
||||
}
|
||||
@ -508,10 +512,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
final List<?> list = getList(path);
|
||||
|
||||
if (list == null) {
|
||||
return new ArrayList<Boolean>(0);
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
final List<Boolean> result = new ArrayList<Boolean>();
|
||||
final List<Boolean> result = new ArrayList<>();
|
||||
|
||||
for (final Object object : list) {
|
||||
if (object instanceof Boolean) {
|
||||
@ -533,10 +537,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
final List<?> list = getList(path);
|
||||
|
||||
if (list == null) {
|
||||
return new ArrayList<Double>(0);
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
final List<Double> result = new ArrayList<Double>();
|
||||
final List<Double> result = new ArrayList<>();
|
||||
|
||||
for (final Object object : list) {
|
||||
if (object instanceof Double) {
|
||||
@ -544,9 +548,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
} else if (object instanceof String) {
|
||||
try {
|
||||
result.add(Double.valueOf((String) object));
|
||||
} catch (final Exception ex) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (object instanceof Character) {
|
||||
result.add((double) ((Character) object).charValue());
|
||||
result.add((double) (Character) object);
|
||||
} else if (object instanceof Number) {
|
||||
result.add(((Number) object).doubleValue());
|
||||
}
|
||||
@ -560,10 +565,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
final List<?> list = getList(path);
|
||||
|
||||
if (list == null) {
|
||||
return new ArrayList<Float>(0);
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
final List<Float> result = new ArrayList<Float>();
|
||||
final List<Float> result = new ArrayList<>();
|
||||
|
||||
for (final Object object : list) {
|
||||
if (object instanceof Float) {
|
||||
@ -571,9 +576,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
} else if (object instanceof String) {
|
||||
try {
|
||||
result.add(Float.valueOf((String) object));
|
||||
} catch (final Exception ex) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (object instanceof Character) {
|
||||
result.add((float) ((Character) object).charValue());
|
||||
result.add((float) (Character) object);
|
||||
} else if (object instanceof Number) {
|
||||
result.add(((Number) object).floatValue());
|
||||
}
|
||||
@ -587,10 +593,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
final List<?> list = getList(path);
|
||||
|
||||
if (list == null) {
|
||||
return new ArrayList<Long>(0);
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
final List<Long> result = new ArrayList<Long>();
|
||||
final List<Long> result = new ArrayList<>();
|
||||
|
||||
for (final Object object : list) {
|
||||
if (object instanceof Long) {
|
||||
@ -598,9 +604,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
} else if (object instanceof String) {
|
||||
try {
|
||||
result.add(Long.valueOf((String) object));
|
||||
} catch (final Exception ex) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (object instanceof Character) {
|
||||
result.add((long) ((Character) object).charValue());
|
||||
result.add((long) (Character) object);
|
||||
} else if (object instanceof Number) {
|
||||
result.add(((Number) object).longValue());
|
||||
}
|
||||
@ -614,10 +621,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
final List<?> list = getList(path);
|
||||
|
||||
if (list == null) {
|
||||
return new ArrayList<Byte>(0);
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
final List<Byte> result = new ArrayList<Byte>();
|
||||
final List<Byte> result = new ArrayList<>();
|
||||
|
||||
for (final Object object : list) {
|
||||
if (object instanceof Byte) {
|
||||
@ -625,7 +632,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
} else if (object instanceof String) {
|
||||
try {
|
||||
result.add(Byte.valueOf((String) object));
|
||||
} catch (final Exception ex) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (object instanceof Character) {
|
||||
result.add((byte) ((Character) object).charValue());
|
||||
} else if (object instanceof Number) {
|
||||
@ -641,10 +649,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
final List<?> list = getList(path);
|
||||
|
||||
if (list == null) {
|
||||
return new ArrayList<Character>(0);
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
final List<Character> result = new ArrayList<Character>();
|
||||
final List<Character> result = new ArrayList<>();
|
||||
|
||||
for (final Object object : list) {
|
||||
if (object instanceof Character) {
|
||||
@ -668,10 +676,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
final List<?> list = getList(path);
|
||||
|
||||
if (list == null) {
|
||||
return new ArrayList<Short>(0);
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
final List<Short> result = new ArrayList<Short>();
|
||||
final List<Short> result = new ArrayList<>();
|
||||
|
||||
for (final Object object : list) {
|
||||
if (object instanceof Short) {
|
||||
@ -679,7 +687,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
} else if (object instanceof String) {
|
||||
try {
|
||||
result.add(Short.valueOf((String) object));
|
||||
} catch (final Exception ex) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (object instanceof Character) {
|
||||
result.add((short) ((Character) object).charValue());
|
||||
} else if (object instanceof Number) {
|
||||
@ -693,7 +702,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
@Override
|
||||
public List<Map<?, ?>> getMapList(final String path) {
|
||||
final List<?> list = getList(path);
|
||||
final List<Map<?, ?>> result = new ArrayList<Map<?, ?>>();
|
||||
final List<Map<?, ?>> result = new ArrayList<>();
|
||||
|
||||
if (list == null) {
|
||||
return result;
|
||||
@ -827,16 +836,14 @@ public class MemorySection implements ConfigurationSection {
|
||||
final char separator = root.options().pathSeparator();
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
if (section != null) {
|
||||
for (ConfigurationSection parent = section; (parent != null) && (parent != relativeTo); parent = parent.getParent()) {
|
||||
if (builder.length() > 0) {
|
||||
builder.insert(0, separator);
|
||||
}
|
||||
|
||||
builder.insert(0, parent.getName());
|
||||
for (ConfigurationSection parent = section; (parent != null) && (parent != relativeTo); parent = parent.getParent()) {
|
||||
if (builder.length() > 0) {
|
||||
builder.insert(0, separator);
|
||||
}
|
||||
|
||||
builder.insert(0, parent.getName());
|
||||
}
|
||||
|
||||
|
||||
if ((key != null) && (key.length() > 0)) {
|
||||
if (builder.length() > 0) {
|
||||
builder.append(separator);
|
||||
@ -851,7 +858,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
@Override
|
||||
public String toString() {
|
||||
final Configuration root = getRoot();
|
||||
return new StringBuilder().append(getClass().getSimpleName()).append("[path='").append(getCurrentPath()).append("', root='").append(root == null ? null : root.getClass().getSimpleName())
|
||||
.append("']").toString();
|
||||
return getClass().getSimpleName() + "[path='" + getCurrentPath() + "', root='" + (root == null ? null : root.getClass().getSimpleName()) +
|
||||
"']";
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.intellectualcrafters.configuration.file;
|
||||
|
||||
import com.intellectualcrafters.configuration.Configuration;
|
||||
import com.intellectualcrafters.configuration.InvalidConfigurationException;
|
||||
import com.intellectualcrafters.configuration.MemoryConfiguration;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -14,12 +19,6 @@ import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
import com.intellectualcrafters.configuration.Configuration;
|
||||
import com.intellectualcrafters.configuration.InvalidConfigurationException;
|
||||
import com.intellectualcrafters.configuration.MemoryConfiguration;
|
||||
|
||||
/**
|
||||
* This is a base class for all File based implementations of {@link
|
||||
* Configuration}
|
||||
@ -99,13 +98,10 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
file.getParentFile().mkdirs();
|
||||
|
||||
final String data = saveToString();
|
||||
|
||||
final Writer writer = new OutputStreamWriter(new FileOutputStream(file), UTF8_OVERRIDE && !UTF_BIG ? StandardCharsets.UTF_8 : Charset.defaultCharset());
|
||||
|
||||
try {
|
||||
|
||||
try (Writer writer = new OutputStreamWriter(new FileOutputStream(file),
|
||||
UTF8_OVERRIDE && !UTF_BIG ? StandardCharsets.UTF_8 : Charset.defaultCharset())) {
|
||||
writer.write(data);
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,19 +208,16 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* @throws IllegalArgumentException thrown when reader is null
|
||||
*/
|
||||
public void load(final Reader reader) throws IOException, InvalidConfigurationException {
|
||||
final BufferedReader input = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader);
|
||||
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
try {
|
||||
|
||||
try (BufferedReader input = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader)) {
|
||||
String line;
|
||||
|
||||
|
||||
while ((line = input.readLine()) != null) {
|
||||
builder.append(line);
|
||||
builder.append('\n');
|
||||
}
|
||||
} finally {
|
||||
input.close();
|
||||
}
|
||||
|
||||
loadFromString(builder.toString());
|
||||
|
@ -18,7 +18,6 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@ -385,15 +384,21 @@ public class PS {
|
||||
*
|
||||
* @param plot Plot Object to update
|
||||
*/
|
||||
public void updatePlot(final Plot plot) {
|
||||
final String world = plot.world;
|
||||
if (!plots.containsKey(world)) {
|
||||
plots.put(world, new ConcurrentHashMap<PlotId, Plot>());
|
||||
}
|
||||
plots.get(world).put(plot.id, plot);
|
||||
public boolean updatePlot(final Plot plot) {
|
||||
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
||||
pp.setMeta("lastplot", plot);
|
||||
}
|
||||
ConcurrentHashMap<PlotId, Plot> map = plots.get(plot.world);
|
||||
if (map == null) {
|
||||
map = new ConcurrentHashMap<PlotId, Plot>();
|
||||
map.put(plot.id, plot);
|
||||
plots.put(plot.world, map);
|
||||
System.out.println("UPDATING PLOT 2!: " + plot);
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("UPDATING PLOT!: " + plot);
|
||||
return map.put(plot.id, plot) == null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -633,7 +638,7 @@ public class PS {
|
||||
}
|
||||
hardmax = Math.min(hardmax, max);
|
||||
final Plot[] cache = new Plot[hardmax + 1];
|
||||
final List<Plot> overflow = new ArrayList<Plot>(overflowSize);
|
||||
final List<Plot> overflow = new ArrayList<>(overflowSize);
|
||||
final ArrayList<Plot> extra = new ArrayList<>();
|
||||
for (final Plot plot : plots) {
|
||||
final int hash = MathMan.getPositiveId(plot.hashCode());
|
||||
@ -643,7 +648,7 @@ public class PS {
|
||||
} else {
|
||||
extra.add(plot);
|
||||
}
|
||||
} else if ((Math.abs(plot.id.x) > 15446) || (Math.abs(plot.id.y) > 15446)) {
|
||||
} else if ((Math.abs(plot.getId().x) > 15446) || (Math.abs(plot.getId().y) > 15446)) {
|
||||
extra.add(plot);
|
||||
} else {
|
||||
overflow.add(plot);
|
||||
@ -651,15 +656,13 @@ public class PS {
|
||||
}
|
||||
final Plot[] overflowArray = overflow.toArray(new Plot[overflow.size()]);
|
||||
sortPlotsByHash(overflowArray);
|
||||
final ArrayList<Plot> result = new ArrayList<Plot>(cache.length + overflowArray.length);
|
||||
final ArrayList<Plot> result = new ArrayList<>(cache.length + overflowArray.length);
|
||||
for (final Plot plot : cache) {
|
||||
if (plot != null) {
|
||||
result.add(plot);
|
||||
}
|
||||
}
|
||||
for (final Plot plot : overflowArray) {
|
||||
result.add(plot);
|
||||
}
|
||||
Collections.addAll(result, overflowArray);
|
||||
for (final Plot plot : extra) {
|
||||
result.add(plot);
|
||||
}
|
||||
@ -678,14 +681,13 @@ public class PS {
|
||||
if (input instanceof ArrayList<?>) {
|
||||
list = (List<Plot>) input;
|
||||
} else {
|
||||
list = new ArrayList<Plot>(input);
|
||||
list = new ArrayList<>(input);
|
||||
}
|
||||
long min = Integer.MAX_VALUE;
|
||||
long max = 0;
|
||||
final int size = list.size();
|
||||
final int limit = Math.min(1048576, size * 2);
|
||||
for (int i = 0; i < size; i++) {
|
||||
final Plot plot = list.get(i);
|
||||
for (final Plot plot : list) {
|
||||
final long time = plot.getTimestamp();
|
||||
if (time < min) {
|
||||
min = time;
|
||||
@ -701,8 +703,7 @@ public class PS {
|
||||
if ((range > limit) && (size > 1024)) {
|
||||
plots = new Plot[limit];
|
||||
final int factor = (int) ((range / limit));
|
||||
for (int i = 0; i < size; i++) {
|
||||
Plot plot = list.get(i);
|
||||
for (Plot plot : list) {
|
||||
int index = (int) (plot.getTimestamp() - min) / factor;
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
@ -730,7 +731,7 @@ public class PS {
|
||||
}
|
||||
}
|
||||
} else if ((range < size) || (size < 1024)) {
|
||||
final ArrayList<Plot> result = new ArrayList<Plot>(list);
|
||||
final ArrayList<Plot> result = new ArrayList<>(list);
|
||||
Collections.sort(result, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(final Plot a, final Plot b) {
|
||||
@ -745,8 +746,7 @@ public class PS {
|
||||
return result;
|
||||
} else if (min != 0) {
|
||||
plots = new Plot[(int) range];
|
||||
for (int i = 0; i < size; i++) {
|
||||
Plot plot = list.get(i);
|
||||
for (Plot plot : list) {
|
||||
int index = (int) (plot.getTimestamp() - min);
|
||||
if (index >= plots.length) {
|
||||
overflow.add(plot);
|
||||
@ -772,8 +772,7 @@ public class PS {
|
||||
}
|
||||
} else {
|
||||
plots = new Plot[(int) range];
|
||||
for (int i = 0; i < size; i++) {
|
||||
Plot plot = list.get(i);
|
||||
for (Plot plot : list) {
|
||||
int index = (int) (plot.getTimestamp());
|
||||
if (index >= plots.length) {
|
||||
overflow.add(plot);
|
||||
@ -824,7 +823,7 @@ public class PS {
|
||||
return result;
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
final ArrayList<Plot> result = new ArrayList<Plot>(list);
|
||||
final ArrayList<Plot> result = new ArrayList<>(list);
|
||||
Collections.sort(result, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(final Plot a, final Plot b) {
|
||||
@ -848,10 +847,10 @@ public class PS {
|
||||
public void sortPlotsByHash(final Plot[] input) {
|
||||
final List<Plot>[] bucket = new ArrayList[32];
|
||||
for (int i = 0; i < bucket.length; i++) {
|
||||
bucket[i] = new ArrayList<Plot>();
|
||||
bucket[i] = new ArrayList<>();
|
||||
}
|
||||
boolean maxLength = false;
|
||||
int tmp = -1, placement = 1;
|
||||
int tmp, placement = 1;
|
||||
while (!maxLength) {
|
||||
maxLength = true;
|
||||
for (final Plot i : input) {
|
||||
@ -882,7 +881,7 @@ public class PS {
|
||||
final int SIZE = 100;
|
||||
final List<Plot>[] bucket = new ArrayList[SIZE];
|
||||
for (int i = 0; i < bucket.length; i++) {
|
||||
bucket[i] = new ArrayList<Plot>();
|
||||
bucket[i] = new ArrayList<>();
|
||||
}
|
||||
boolean maxLength = false;
|
||||
int tmp = -1, placement = 1;
|
||||
@ -907,7 +906,7 @@ public class PS {
|
||||
}
|
||||
|
||||
public enum SortType {
|
||||
CREATION_DATE, CREATION_DATE_TIMESTAMP, DISTANCE_FROM_ORIGIN;
|
||||
CREATION_DATE, CREATION_DATE_TIMESTAMP, DISTANCE_FROM_ORIGIN
|
||||
}
|
||||
|
||||
/**
|
||||
@ -921,7 +920,7 @@ public class PS {
|
||||
// group by world
|
||||
// sort each
|
||||
final HashMap<String, Collection<Plot>> map = new HashMap<>();
|
||||
final ArrayList<String> worlds = new ArrayList<String>(getPlotWorlds());
|
||||
final ArrayList<String> worlds = new ArrayList<>(getPlotWorlds());
|
||||
int totalSize = 0;
|
||||
for (final Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : this.plots.entrySet()) {
|
||||
totalSize += entry.getValue().size();
|
||||
@ -955,7 +954,7 @@ public class PS {
|
||||
return a.hashCode() - b.hashCode();
|
||||
}
|
||||
});
|
||||
final ArrayList<Plot> toReturn = new ArrayList<Plot>(plots.size());
|
||||
final ArrayList<Plot> toReturn = new ArrayList<>(plots.size());
|
||||
for (final String world : worlds) {
|
||||
switch (type) {
|
||||
case CREATION_DATE:
|
||||
@ -1068,9 +1067,6 @@ public class PS {
|
||||
return strings.toArray(new String[strings.size()]);
|
||||
}
|
||||
|
||||
private volatile String lastWorld;
|
||||
private volatile Map<PlotId, Plot> lastMap;
|
||||
|
||||
/**
|
||||
* Get a map of the plots for a world
|
||||
* @param world
|
||||
@ -1080,9 +1076,6 @@ public class PS {
|
||||
public HashMap<PlotId, Plot> getPlots(final String world) {
|
||||
final ConcurrentHashMap<PlotId, Plot> myplots = plots.get(world);
|
||||
if (myplots != null) {
|
||||
if (world == lastWorld) {
|
||||
return new HashMap<>(lastMap);
|
||||
}
|
||||
return new HashMap<>(myplots);
|
||||
}
|
||||
return new HashMap<>(0);
|
||||
@ -1097,7 +1090,7 @@ public class PS {
|
||||
return map.values();
|
||||
}
|
||||
catch (Throwable e) {e.printStackTrace();}
|
||||
HashSet<Plot> toReturn = new HashSet<Plot>(map.entrySet().size());
|
||||
HashSet<Plot> toReturn = new HashSet<>(map.entrySet().size());
|
||||
for (Entry<PlotId, Plot> entry : map.entrySet()) {
|
||||
toReturn.add(entry.getValue());
|
||||
}
|
||||
@ -1105,16 +1098,9 @@ public class PS {
|
||||
}
|
||||
|
||||
public Plot getPlot(final String world, final PlotId id) {
|
||||
if (world == lastWorld) {
|
||||
if (lastMap != null) {
|
||||
return lastMap.get(id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
lastWorld = world;
|
||||
lastMap = plots.get(world);
|
||||
if (lastMap != null) {
|
||||
return lastMap.get(id);
|
||||
ConcurrentHashMap<PlotId, Plot> map = plots.get(world);
|
||||
if (map != null) {
|
||||
return map.get(id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1336,12 +1322,14 @@ public class PS {
|
||||
}
|
||||
case "f":
|
||||
case "floor": {
|
||||
config.set(base + "plot.floor", new ArrayList<String>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
|
||||
config.set(base + "plot.floor",
|
||||
new ArrayList<>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
|
||||
break;
|
||||
}
|
||||
case "m":
|
||||
case "main": {
|
||||
config.set(base + "plot.filling", new ArrayList<String>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
|
||||
config.set(base + "plot.filling",
|
||||
new ArrayList<>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
|
||||
break;
|
||||
}
|
||||
case "w":
|
||||
@ -1968,6 +1956,7 @@ public class PS {
|
||||
Settings.METRICS = config.getBoolean("metrics");
|
||||
Settings.UPDATE_NOTIFICATIONS = config.getBoolean("update-notifications");
|
||||
Settings.MERGE_REMOVES_ROADS = config.getBoolean("merge.remove-terrain");
|
||||
Settings.AUTO_PURGE = config.getBoolean("auto-purge", false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,17 +21,6 @@
|
||||
|
||||
package com.intellectualcrafters.plot.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
@ -53,6 +42,16 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.bukkit.util.BukkitSetBlockManager;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* PlotSquared API
|
||||
@ -262,7 +261,7 @@ public class PlotAPI {
|
||||
perms.add(c.s());
|
||||
}
|
||||
}
|
||||
return perms.toArray(new String[0]);
|
||||
return perms.toArray(new String[perms.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -376,7 +375,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @param msg Message that should be sent to the console
|
||||
*
|
||||
* @see MainUtil#sendConsoleMessage(String)
|
||||
* @see MainUtil#sendConsoleMessage(C, String...)
|
||||
*/
|
||||
public void sendConsoleMessage(final String msg) {
|
||||
PS.log(msg);;
|
||||
@ -553,9 +552,9 @@ public class PlotAPI {
|
||||
*/
|
||||
public Location[] getLocations(final Plot p) {
|
||||
return new Location[] {
|
||||
BukkitUtil.getLocation(MainUtil.getPlotBottomLocAbs(p.world, p.id).subtract(1, 0, 1)),
|
||||
BukkitUtil.getLocation(MainUtil.getPlotTopLocAbs(p.world, p.id)),
|
||||
BukkitUtil.getLocation(MainUtil.getPlotHome(p.world, p.id)) };
|
||||
BukkitUtil.getLocation(MainUtil.getPlotBottomLocAbs(p.world, p.getId()).subtract(1, 0, 1)),
|
||||
BukkitUtil.getLocation(MainUtil.getPlotTopLocAbs(p.world, p.getId())),
|
||||
BukkitUtil.getLocation(MainUtil.getPlotHome(p.world, p.getId())) };
|
||||
}
|
||||
|
||||
/**
|
||||
@ -569,7 +568,7 @@ public class PlotAPI {
|
||||
* @see Plot
|
||||
*/
|
||||
public Location getHomeLocation(final Plot p) {
|
||||
return BukkitUtil.getLocation(MainUtil.getPlotHome(p.world, p.id));
|
||||
return BukkitUtil.getLocation(MainUtil.getPlotHome(p.world, p.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -583,7 +582,7 @@ public class PlotAPI {
|
||||
* @see Plot
|
||||
*/
|
||||
public Location getBottomLocation(final Plot p) {
|
||||
return BukkitUtil.getLocation(MainUtil.getPlotBottomLocAbs(p.world, p.id).subtract(1, 0, 1));
|
||||
return BukkitUtil.getLocation(MainUtil.getPlotBottomLocAbs(p.world, p.getId()).subtract(1, 0, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -597,7 +596,7 @@ public class PlotAPI {
|
||||
* @see Plot
|
||||
*/
|
||||
public Location getTopLocation(final Plot p) {
|
||||
return BukkitUtil.getLocation(MainUtil.getPlotTopLocAbs(p.world, p.id));
|
||||
return BukkitUtil.getLocation(MainUtil.getPlotTopLocAbs(p.world, p.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,9 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -35,6 +32,8 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "add",
|
||||
aliases = { "a" },
|
||||
@ -87,7 +86,7 @@ public class Add extends SubCommand {
|
||||
if (plot.removeTrusted(uuid)) {
|
||||
plot.addMember(uuid);
|
||||
} else {
|
||||
if ((plot.getMembers().size() + plot.getTrusted().size()) >= PS.get().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) {
|
||||
if ((plot.getMembers().size() + plot.getTrusted().size()) >= plot.getWorld().MAX_PLOT_MEMBERS) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
|
||||
return false;
|
||||
}
|
||||
|
@ -202,16 +202,12 @@ public class Auto extends SubCommand {
|
||||
MainUtil.lastPlot.put(worldname, getNextPlot(getLastPlot(worldname), 1));
|
||||
}
|
||||
} else {
|
||||
boolean lastPlot = true;
|
||||
while (!br) {
|
||||
final PlotId start = getNextPlot(getLastPlot(worldname), 1);
|
||||
// Checking if the current set of plots is a viable option.
|
||||
MainUtil.lastPlot.put(worldname, start);
|
||||
if (lastPlot) {}
|
||||
if ((PS.get().getPlot(worldname, start) != null) && (PS.get().getPlot(worldname, start).owner != null)) {
|
||||
continue;
|
||||
} else {
|
||||
lastPlot = false;
|
||||
}
|
||||
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
|
||||
if (MainUtil.canClaim(plr, worldname, start, end)) {
|
||||
|
@ -20,8 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
@ -35,6 +33,8 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "buy",
|
||||
aliases = { "b" },
|
||||
@ -97,7 +97,7 @@ public class Buy extends SubCommand {
|
||||
EconHandler.manager.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), price);
|
||||
final PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
|
||||
if (owner != null) {
|
||||
sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), price + "");
|
||||
sendMessage(plr, C.PLOT_SOLD, plot.getId() + "", plr.getName(), price + "");
|
||||
}
|
||||
FlagManager.removePlotFlag(plot, "price");
|
||||
}
|
||||
|
@ -64,11 +64,11 @@ public class Claim extends SubCommand {
|
||||
MainUtil.teleportPlayer(player, loc, plot);
|
||||
}
|
||||
final String world = plot.world;
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
final Plot plot2 = PS.get().getPlot(world, plot.id);
|
||||
final PlotWorld plotworld = plot.getWorld();
|
||||
final Plot plot2 = PS.get().getPlot(world, plot.getId());
|
||||
if (plotworld.SCHEMATIC_ON_CLAIM) {
|
||||
Schematic sch;
|
||||
if (schematic.equals("")) {
|
||||
if (schematic.isEmpty()) {
|
||||
sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE);
|
||||
} else {
|
||||
sch = SchematicHandler.manager.getSchematic(schematic);
|
||||
@ -110,7 +110,7 @@ public class Claim extends SubCommand {
|
||||
if (!MainUtil.canClaim(plr, plot)) {
|
||||
return sendMessage(plr, C.PLOT_IS_CLAIMED);
|
||||
}
|
||||
final PlotWorld world = PS.get().getPlotWorld(plot.world);
|
||||
final PlotWorld world = plot.getWorld();
|
||||
if ((EconHandler.manager != null) && world.USE_ECONOMY) {
|
||||
final double cost = world.PLOT_PRICE;
|
||||
if (cost > 0d) {
|
||||
|
@ -114,7 +114,7 @@ public class Clear extends SubCommand {
|
||||
}
|
||||
};
|
||||
if (Settings.CONFIRM_CLEAR && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) {
|
||||
CmdConfirm.addPending(plr, "/plot clear " + plot.id, runnable);
|
||||
CmdConfirm.addPending(plr, "/plot clear " + plot.getId(), runnable);
|
||||
} else {
|
||||
TaskManager.runTask(runnable);
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plr.getLocation().getWorld());
|
||||
final PlotWorld plotworld = plr.getLocation().getPlotWorld();
|
||||
if (plotworld.TYPE == 2) {
|
||||
final ArrayList<Plot> toRemove = new ArrayList<>();
|
||||
for (final Plot plot : PS.get().getPlotsInWorld(plr.getLocation().getWorld())) {
|
||||
|
@ -121,7 +121,7 @@ public class Condense extends SubCommand {
|
||||
while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) {
|
||||
final Plot plot = MainUtil.getPlotAbs(worldname, start);
|
||||
if (!plot.hasOwner()) {
|
||||
free.add(plot.id);
|
||||
free.add(plot.getId());
|
||||
}
|
||||
start = Auto.getNextPlot(start, 1);
|
||||
}
|
||||
@ -225,8 +225,8 @@ public class Condense extends SubCommand {
|
||||
public Set<PlotId> getPlots(final Collection<Plot> plots, final int radius) {
|
||||
final HashSet<PlotId> outside = new HashSet<>();
|
||||
for (final Plot plot : plots) {
|
||||
if ((plot.id.x > radius) || (plot.id.x < -radius) || (plot.id.y > radius) || (plot.id.y < -radius)) {
|
||||
outside.add(plot.id);
|
||||
if ((plot.getId().x > radius) || (plot.getId().x < -radius) || (plot.getId().y > radius) || (plot.getId().y < -radius)) {
|
||||
outside.add(plot.getId());
|
||||
}
|
||||
}
|
||||
return outside;
|
||||
|
@ -20,7 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
@ -47,7 +46,7 @@ public class CreateRoadSchematic extends SubCommand {
|
||||
if (plot == null) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!(PS.get().getPlotWorld(loc.getWorld()) instanceof HybridPlotWorld)) {
|
||||
if (!(loc.getPlotWorld() instanceof HybridPlotWorld)) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
HybridUtils.manager.setupRoadSchematic(plot);
|
||||
|
@ -1,11 +1,5 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.database.MySQL;
|
||||
@ -18,6 +12,12 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "database",
|
||||
aliases = { "convert" },
|
||||
@ -95,7 +95,7 @@ public class Database extends SubCommand {
|
||||
for (final Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : map.entrySet()) {
|
||||
for (final Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
final Plot plot = entry2.getValue();
|
||||
if (PS.get().getPlot(plot.world, plot.id) != null) {
|
||||
if (PS.get().getPlot(plot.world, plot.getId()) != null) {
|
||||
MainUtil.sendMessage(player, "Skipping duplicate plot: " + plot + " | id=" + plot.temp);
|
||||
continue;
|
||||
}
|
||||
|
@ -96,8 +96,8 @@ public class DebugClaimTest extends SubCommand {
|
||||
final ArrayList<Plot> plots = new ArrayList<>();
|
||||
for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
|
||||
final Plot plot = MainUtil.getPlotAbs(world, id);
|
||||
if (PS.get().getPlot(world, plot.id) != null) {
|
||||
MainUtil.sendMessage(plr, " - &cDB Already contains: " + plot.id);
|
||||
if (PS.get().getPlot(world, plot.getId()) != null) {
|
||||
MainUtil.sendMessage(plr, " - &cDB Already contains: " + plot.getId());
|
||||
continue;
|
||||
}
|
||||
final Location loc = manager.getSignLoc(plotworld, plot);
|
||||
@ -125,11 +125,11 @@ public class DebugClaimTest extends SubCommand {
|
||||
uuid = UUIDHandler.getUUID(line, null);
|
||||
}
|
||||
if (uuid != null) {
|
||||
MainUtil.sendMessage(plr, " - &aFound plot: " + plot.id + " : " + line);
|
||||
MainUtil.sendMessage(plr, " - &aFound plot: " + plot.getId() + " : " + line);
|
||||
plot.owner = uuid;
|
||||
plots.add(plot);
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, " - &cInvalid playername: " + plot.id + " : " + line);
|
||||
MainUtil.sendMessage(plr, " - &cInvalid playername: " + plot.getId() + " : " + line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,26 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import javax.script.ScriptContext;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import javax.script.SimpleScriptContext;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -74,6 +54,26 @@ import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import javax.script.ScriptContext;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import javax.script.SimpleScriptContext;
|
||||
|
||||
@CommandDeclaration(command = "debugexec", permission = "plots.admin", description = "Mutli-purpose debug command", aliases = { "exec" }, category = CommandCategory.DEBUG)
|
||||
public class DebugExec extends SubCommand {
|
||||
|
||||
@ -286,7 +286,7 @@ public class DebugExec extends SubCommand {
|
||||
}
|
||||
MainUtil.sendMessage(player, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):");
|
||||
for (final Plot plot : ExpireManager.expiredPlots.get(args[1])) {
|
||||
MainUtil.sendMessage(player, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) + " : " + ExpireManager.dates.get(plot.owner));
|
||||
MainUtil.sendMessage(player, " - " + plot.world + ";" + plot.getId().x + ";" + plot.getId().y + ";" + UUIDHandler.getName(plot.owner) + " : " + ExpireManager.dates.get(plot.owner));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class DebugRoadRegen extends SubCommand {
|
||||
public boolean onCommand(final PlotPlayer player, final String... args) {
|
||||
final Location loc = player.getLocation();
|
||||
final String world = loc.getWorld();
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
final PlotWorld plotworld = loc.getPlotWorld();
|
||||
if (!(plotworld instanceof HybridPlotWorld)) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
@ -66,14 +66,14 @@ public class DebugRoadRegen extends SubCommand {
|
||||
}
|
||||
}
|
||||
final boolean result = HybridUtils.manager.regenerateRoad(world, chunk, extend);
|
||||
MainUtil.sendMessage(player, "&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed"));
|
||||
MainUtil.sendMessage(player, "&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result ? "&aSuccess" : "&cFailed"));
|
||||
MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads");
|
||||
} else {
|
||||
final HybridPlotManager manager = (HybridPlotManager) PS.get().getPlotManager(world);
|
||||
manager.createRoadEast(plotworld, plot);
|
||||
manager.createRoadSouth(plotworld, plot);
|
||||
manager.createRoadSouthEast(plotworld, plot);
|
||||
MainUtil.sendMessage(player, "&6Regenerating plot south/east roads: " + plot.id + "\n&6 - Result: &aSuccess");
|
||||
MainUtil.sendMessage(player, "&6Regenerating plot south/east roads: " + plot.getId() + "\n&6 - Result: &aSuccess");
|
||||
MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads");
|
||||
}
|
||||
return true;
|
||||
|
@ -20,9 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -36,6 +33,8 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "delete",
|
||||
permission = "plots.delete",
|
||||
@ -60,7 +59,7 @@ public class Delete extends SubCommand {
|
||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
|
||||
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
final PlotWorld plotworld = plot.getWorld();
|
||||
final HashSet<Plot> plots = MainUtil.getConnectedPlots(plot);
|
||||
final Runnable run = new Runnable() {
|
||||
@Override
|
||||
@ -93,7 +92,7 @@ public class Delete extends SubCommand {
|
||||
}
|
||||
};
|
||||
if (Settings.CONFIRM_DELETE && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) {
|
||||
CmdConfirm.addPending(plr, "/plot delete " + plot.id, run);
|
||||
CmdConfirm.addPending(plr, "/plot delete " + plot.getId(), run);
|
||||
} else {
|
||||
TaskManager.runTask(run);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class Download extends SubCommand {
|
||||
}
|
||||
plot.addRunning();
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK);
|
||||
SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal<CompoundTag>() {
|
||||
SchematicHandler.manager.getCompoundTag(plot.world, plot.getId(), new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
|
@ -94,17 +94,20 @@ public class Info extends SubCommand {
|
||||
};
|
||||
final UUID uuid = player.getUUID();
|
||||
final String name = MainUtil.getName(plot.owner);
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info", new String[] {
|
||||
"&cID: &6" + plot.getId().toString(),
|
||||
"&cOwner: &6" + name,
|
||||
"&cAlias: &6" + plot.getAlias(),
|
||||
"&cBiome: &6" + plot.getBiome().toString().replaceAll("_", "").toLowerCase(),
|
||||
"&cCan Build: &6" + plot.isAdded(uuid),
|
||||
"&cIs Denied: &6" + plot.isDenied(uuid) }));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", new String[] { "&cAmount: &6" + plot.getTrusted().size(), "&8Click to view a list of the trusted users" }));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cMembers", new String[] { "&cAmount: &6" + plot.getMembers().size(), "&8Click to view a list of plot members" }));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cDenied", new String[] { "&cDenied", "&cAmount: &6" + plot.getDenied().size(), "&8Click to view a list of denied players" }));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cFlags", new String[] { "&cFlags", "&cAmount: &6" + plot.getFlags().size(), "&8Click to view a list of plot flags" }));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info", "&cID: &6" + plot.getId().toString(),
|
||||
"&cOwner: &6" + name,
|
||||
"&cAlias: &6" + plot.getAlias(),
|
||||
"&cBiome: &6" + plot.getBiome().replaceAll("_", "").toLowerCase(),
|
||||
"&cCan Build: &6" + plot.isAdded(uuid),
|
||||
"&cIs Denied: &6" + plot.isDenied(uuid)));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", "&cAmount: &6" + plot.getTrusted().size(),
|
||||
"&8Click to view a list of the trusted users"));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cMembers", "&cAmount: &6" + plot.getMembers().size(),
|
||||
"&8Click to view a list of plot members"));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cDenied", "&cDenied", "&cAmount: &6" + plot.getDenied().size(),
|
||||
"&8Click to view a list of denied players"));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cFlags", "&cFlags", "&cAmount: &6" + plot.getFlags().size(),
|
||||
"&8Click to view a list of plot flags"));
|
||||
inv.openInventory();
|
||||
return true;
|
||||
}
|
||||
@ -118,7 +121,7 @@ public class Info extends SubCommand {
|
||||
}
|
||||
// Unclaimed?
|
||||
if (!hasOwner && !containsEveryone && !trustedEveryone) {
|
||||
MainUtil.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y));
|
||||
MainUtil.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.getId().x + ";" + plot.getId().y));
|
||||
return true;
|
||||
}
|
||||
String info = C.PLOT_INFO.s();
|
||||
|
@ -40,7 +40,7 @@ public class Kick extends SubCommand {
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if ((plot == null) || ((!plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.kick"))) {
|
||||
if (((!plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.kick"))) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -20,12 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
@ -43,9 +37,17 @@ import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandHandlingOutput;
|
||||
import com.plotsquared.general.commands.CommandManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PlotSquared command class
|
||||
*
|
||||
*
|
||||
|
||||
*/
|
||||
public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
|
||||
@ -325,9 +327,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
count += 5;
|
||||
}
|
||||
}
|
||||
for (String word : cmd.getDescription().split(" ")) {
|
||||
desc.add(word);
|
||||
}
|
||||
Collections.addAll(desc, cmd.getDescription().split(" "));
|
||||
for (String arg : args) {
|
||||
if (perm.startsWith(arg)) {
|
||||
count++;
|
||||
|
@ -20,10 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -38,6 +34,9 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "merge",
|
||||
aliases = { "m" },
|
||||
@ -79,7 +78,7 @@ public class Merge extends SubCommand {
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
@ -93,7 +92,7 @@ public class Merge extends SubCommand {
|
||||
uuid = plot.owner;
|
||||
}
|
||||
}
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
final PlotWorld plotworld = plot.getWorld();
|
||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d && EconHandler.manager.getMoney(plr) < plotworld.MERGE_PRICE) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, plotworld.MERGE_PRICE + "");
|
||||
return false;
|
||||
@ -164,7 +163,7 @@ public class Merge extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
return true;
|
||||
}
|
||||
Plot adjacent = MainUtil.getPlotAbs(plot.world, MainUtil.getPlotIdRelative(plot.id, direction));
|
||||
Plot adjacent = MainUtil.getPlotAbs(plot.world, MainUtil.getPlotIdRelative(plot.getId(), direction));
|
||||
if (adjacent == null || !adjacent.hasOwner() || adjacent.getMerged((direction + 2) % 4) || adjacent.isOwner(uuid)) {
|
||||
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
|
||||
return false;
|
||||
@ -204,7 +203,7 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (isOnline == false) {
|
||||
if (!isOnline) {
|
||||
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
|
||||
return false;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class Owner extends SetCommand {
|
||||
MainUtil.setSign(name, plot);
|
||||
MainUtil.sendMessage(plr, C.SET_OWNER);
|
||||
if (other != null) {
|
||||
MainUtil.sendMessage(other, C.NOW_OWNER, plot.world + ";" + plot.id);
|
||||
MainUtil.sendMessage(other, C.NOW_OWNER, plot.world + ";" + plot.getId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -85,8 +85,8 @@ public class Purge extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final String worldname = args[1];
|
||||
if (!PS.get().getAllPlotsRaw().containsKey(worldname)) {
|
||||
MainUtil.sendMessage(plr, "INVALID WORLD");
|
||||
if (!PS.get().isPlotWorld(worldname)) {
|
||||
C.NOT_VALID_PLOT_WORLD.send(plr);
|
||||
return false;
|
||||
}
|
||||
final String arg = args[0].toLowerCase();
|
||||
@ -116,7 +116,7 @@ public class Purge extends SubCommand {
|
||||
if (plot.owner != null) {
|
||||
final String name = UUIDHandler.getName(plot.owner);
|
||||
if (name == null) {
|
||||
ids.add(plot.id);
|
||||
ids.add(plot.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -132,7 +132,7 @@ public class Purge extends SubCommand {
|
||||
final Set<PlotId> ids = new HashSet<>();
|
||||
for (final Plot plot : plots) {
|
||||
if (plot.owner == null) {
|
||||
ids.add(plot.id);
|
||||
ids.add(plot.getId());
|
||||
}
|
||||
}
|
||||
final int length = ids.size();
|
||||
@ -147,7 +147,7 @@ public class Purge extends SubCommand {
|
||||
final Set<Plot> plots = PS.get().getPlots(worldname, uuid);
|
||||
final Set<PlotId> ids = new HashSet<>();
|
||||
for (final Plot plot : plots) {
|
||||
ids.add(plot.id);
|
||||
ids.add(plot.getId());
|
||||
}
|
||||
final int length = ids.size();
|
||||
DBFunc.purge(worldname, ids);
|
||||
|
@ -54,7 +54,7 @@ public class RegenAllRoads extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
} else if (args.length != 1) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
|
||||
return false;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class Save extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal<CompoundTag>() {
|
||||
SchematicHandler.manager.getCompoundTag(plot.world, plot.getId(), new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@ -60,7 +60,7 @@ public class Save extends SubCommand {
|
||||
final String name = PS.get().IMP.getServerName().replaceAll("[^A-Za-z0-9]", "");
|
||||
Location[] corners = MainUtil.getCorners(plot);
|
||||
final int size = (corners[1].getX() - corners[0].getX()) + 1;
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id = plot.getId();
|
||||
final String world = plot.world.replaceAll("[^A-Za-z0-9]", "");
|
||||
final String file = time + "_" + world + "_" + id.x + "_" + id.y + "_" + size + "_" + name;
|
||||
final UUID uuid = plr.getUUID();
|
||||
|
@ -20,11 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||
@ -43,6 +38,10 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "set",
|
||||
description = "Set a plot value",
|
||||
@ -67,10 +66,9 @@ public class Set extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean set(PlotPlayer plr, final Plot plot, String value) {
|
||||
final String world = plr.getLocation().getWorld();
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
final PlotManager manager = PS.get().getPlotManager(world);
|
||||
final String[] components = manager.getPlotComponents(plotworld, plot.id);
|
||||
final PlotWorld plotworld = plr.getLocation().getPlotWorld();
|
||||
final PlotManager manager = plr.getLocation().getPlotManager();
|
||||
final String[] components = manager.getPlotComponents(plotworld, plot.getId());
|
||||
final boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(plr.getUUID());
|
||||
|
||||
String[] args = value.split(" ");
|
||||
@ -131,7 +129,7 @@ public class Set extends SubCommand {
|
||||
}
|
||||
plot.addRunning();
|
||||
for (Plot current : MainUtil.getConnectedPlots(plot)) {
|
||||
manager.setComponent(plotworld, current.id, component, blocks);
|
||||
manager.setComponent(plotworld, current.getId(), component, blocks);
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.GENERATING_COMPONENT);
|
||||
SetBlockQueue.addNotify(new Runnable() {
|
||||
@ -149,11 +147,11 @@ public class Set extends SubCommand {
|
||||
}
|
||||
|
||||
public boolean noArgs(PlotPlayer plr) {
|
||||
final ArrayList<String> newValues = new ArrayList<String>();
|
||||
final ArrayList<String> newValues = new ArrayList<>();
|
||||
newValues.addAll(Arrays.asList("biome", "alias", "home", "flag"));
|
||||
Plot plot = plr.getCurrentPlot();
|
||||
if (plot != null) {
|
||||
newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getWorld(), plot.id)));
|
||||
newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getWorld(), plot.getId())));
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringMan.join(newValues, C.BLOCK_LIST_SEPARATER.formatted()));
|
||||
return false;
|
||||
@ -175,7 +173,7 @@ public class Set extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
// components
|
||||
HashSet<String> components = new HashSet<String>(Arrays.asList(plot.getManager().getPlotComponents(plot.getWorld(), plot.id)));
|
||||
HashSet<String> components = new HashSet<>(Arrays.asList(plot.getManager().getPlotComponents(plot.getWorld(), plot.getId())));
|
||||
if (components.contains(args[0].toLowerCase())) {
|
||||
return component.onCommand(plr, Arrays.copyOfRange(args, 0, args.length));
|
||||
}
|
||||
|
@ -20,11 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
@ -38,6 +33,11 @@ import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "setup",
|
||||
permission = "plots.admin.command.setup",
|
||||
@ -48,15 +48,15 @@ category = CommandCategory.ACTIONS)
|
||||
public class Setup extends SubCommand {
|
||||
|
||||
public void displayGenerators(final PlotPlayer plr) {
|
||||
final StringBuffer message = new StringBuffer();
|
||||
final StringBuilder message = new StringBuilder();
|
||||
message.append("&6What generator do you want?");
|
||||
for (final Entry<String, PlotGenerator<?>> entry : SetupUtils.generators.entrySet()) {
|
||||
if (entry.getKey().equals("PlotSquared")) {
|
||||
message.append("\n&8 - &2" + entry.getKey() + " (Default Generator)");
|
||||
message.append("\n&8 - &2").append(entry.getKey()).append(" (Default Generator)");
|
||||
} else if (entry.getValue().isFull()) {
|
||||
message.append("\n&8 - &7" + entry.getKey() + " (Plot Generator)");
|
||||
message.append("\n&8 - &7").append(entry.getKey()).append(" (Plot Generator)");
|
||||
} else {
|
||||
message.append("\n&8 - &7" + entry.getKey() + " (Unknown structure)");
|
||||
message.append("\n&8 - &7").append(entry.getKey()).append(" (Unknown structure)");
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(plr, message.toString());
|
||||
@ -109,8 +109,9 @@ public class Setup extends SubCommand {
|
||||
break;
|
||||
}
|
||||
case 1: { // choose world type
|
||||
final List<String> allTypes = Arrays.asList(new String[] { "default", "augmented", "partial" });
|
||||
final List<String> allDesc = Arrays.asList(new String[] { "Standard plot generation", "Plot generation with vanilla terrain", "Vanilla with clusters of plots" });
|
||||
final List<String> allTypes = Arrays.asList("default", "augmented", "partial");
|
||||
final List<String> allDesc = Arrays.asList("Standard plot generation", "Plot generation with vanilla terrain",
|
||||
"Vanilla with clusters of plots");
|
||||
final ArrayList<String> types = new ArrayList<>();
|
||||
if (SetupUtils.generators.get(object.setupGenerator).isFull()) {
|
||||
types.add("default");
|
||||
@ -170,7 +171,7 @@ public class Setup extends SubCommand {
|
||||
break;
|
||||
}
|
||||
case 2: { // Choose terrain
|
||||
final List<String> terrain = Arrays.asList(new String[] { "none", "ore", "road", "all" });
|
||||
final List<String> terrain = Arrays.asList("none", "ore", "road", "all");
|
||||
if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) {
|
||||
MainUtil.sendMessage(plr, "&cYou must choose the terrain!"
|
||||
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
||||
|
@ -58,7 +58,7 @@ public class Target extends SubCommand {
|
||||
closest = plot;
|
||||
}
|
||||
}
|
||||
id = closest.id;
|
||||
id = closest.getId();
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
|
@ -20,14 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
@ -42,6 +34,15 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "trim",
|
||||
permission = "plots.admin",
|
||||
@ -96,7 +97,8 @@ public class Trim extends SubCommand {
|
||||
PS.debug("INVALID MCA: " + name);
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -134,8 +136,8 @@ public class Trim extends SubCommand {
|
||||
}
|
||||
final Plot plot = plots.remove(0);
|
||||
|
||||
final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id);
|
||||
final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.id);
|
||||
final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.getId());
|
||||
final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.getId());
|
||||
|
||||
final int ccx1 = (pos1.getX() >> 9);
|
||||
final int ccz1 = (pos1.getZ() >> 9);
|
||||
|
@ -20,9 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -36,6 +33,8 @@ import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "trust",
|
||||
aliases = { "t" },
|
||||
@ -91,7 +90,7 @@ public class Trust extends SubCommand {
|
||||
if (plot.removeMember(uuid)) {
|
||||
plot.addTrusted(uuid);
|
||||
} else {
|
||||
if ((plot.getMembers().size() + plot.getTrusted().size()) >= PS.get().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) {
|
||||
if ((plot.getMembers().size() + plot.getTrusted().size()) >= plot.getWorld().MAX_PLOT_MEMBERS) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
|
||||
return false;
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ public class Unclaim extends SubCommand {
|
||||
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
if (plot.unclaim()) {
|
||||
plot.removeSign();
|
||||
MainUtil.sendMessage(plr, C.UNCLAIM_SUCCESS);
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.UNCLAIM_FAILED);
|
||||
|
@ -62,7 +62,7 @@ public class Unlink extends SubCommand {
|
||||
}
|
||||
};
|
||||
if (Settings.CONFIRM_UNLINK && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) {
|
||||
CmdConfirm.addPending(plr, "/plot unlink " + plot.id, runnable);
|
||||
CmdConfirm.addPending(plr, "/plot unlink " + plot.getId(), runnable);
|
||||
} else {
|
||||
TaskManager.runTask(runnable);
|
||||
}
|
||||
|
@ -20,14 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -39,6 +31,14 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "visit",
|
||||
permission = "plots.visit",
|
||||
@ -93,7 +93,7 @@ public class Visit extends SubCommand {
|
||||
} else {
|
||||
final Plot plot = MainUtil.getPlotFromString(player, args[0], true);
|
||||
if (plot != null) {
|
||||
unsorted = new HashSet<>(Arrays.asList(plot.getBasePlot(false)));
|
||||
unsorted = new HashSet<>(Collections.singletonList(plot.getBasePlot(false)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -36,7 +36,7 @@ public class WE_Anywhere extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String[] arguments) {
|
||||
return MainCommand.onCommand(player, "plot", new String[] { "toggle", "worldedit" });
|
||||
return MainCommand.onCommand(player, "plot", "toggle", "worldedit");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -379,10 +379,12 @@ public class list extends SubCommand {
|
||||
|
||||
final PlotMessage flags = new PlotMessage().text(C.color(C.PLOT_INFO_FLAGS.s().replaceAll("%flags%", strFlags))).color("$1");
|
||||
|
||||
PlotMessage message = new PlotMessage().text("[").color("$3").text(i + "").command("/plot visit " + plot.world + ";" + plot.id).tooltip("/plot visit " + plot.world + ";" + plot.id)
|
||||
PlotMessage message = new PlotMessage().text("[").color("$3").text(i + "").command("/plot visit " + plot.world + ";" + plot.getId()).tooltip("/plot visit " + plot.world + ";" + plot
|
||||
|
||||
.getId())
|
||||
.color("$1").text("]").color("$3").text(" " + plot.toString())
|
||||
|
||||
.tooltip(trusted, members, flags).command("/plot info " + plot.world + ";" + plot.id)
|
||||
.tooltip(trusted, members, flags).command("/plot info " + plot.world + ";" + plot.getId())
|
||||
|
||||
.color(color).text(" - ").color("$2");
|
||||
String prefix = "";
|
||||
|
@ -32,9 +32,10 @@ public class plugin extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().IMP.getPluginVersion(), ".")));
|
||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92"));
|
||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki"));
|
||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? StringMan.join(PS.get().IMP.getPluginVersion(), ".") : PS.get().update)));
|
||||
MainUtil.sendMessage(plr, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92");
|
||||
MainUtil.sendMessage(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki");
|
||||
MainUtil.sendMessage(plr,
|
||||
"$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? StringMan.join(PS.get().IMP.getPluginVersion(), ".") : PS.get().update));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import java.util.List;
|
||||
public class Settings {
|
||||
public static boolean USE_SQLUUIDHANDLER = false;
|
||||
|
||||
public static boolean AUTO_PURGE = false;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -40,6 +40,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -392,8 +393,8 @@ public class SQLManager implements AbstractDB {
|
||||
@Override
|
||||
public void set(final PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setInt(2, plot.id.x);
|
||||
statement.setInt(3, plot.id.y);
|
||||
statement.setInt(2, plot.getId().x);
|
||||
statement.setInt(3, plot.getId().y);
|
||||
statement.setString(4, plot.world);
|
||||
}
|
||||
|
||||
@ -418,7 +419,7 @@ public class SQLManager implements AbstractDB {
|
||||
// Creating datastructures
|
||||
final HashMap<PlotId, Plot> plotMap = new HashMap<>();
|
||||
for (final Plot plot : myList) {
|
||||
plotMap.put(plot.id, plot);
|
||||
plotMap.put(plot.getId(), plot);
|
||||
}
|
||||
final ArrayList<SettingsPair> settings = new ArrayList<>();
|
||||
final ArrayList<UUIDPair> helpers = new ArrayList<>();
|
||||
@ -573,8 +574,8 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void setMySQL(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException {
|
||||
stmt.setInt((i * 5) + 1, plot.id.x);
|
||||
stmt.setInt((i * 5) + 2, plot.id.y);
|
||||
stmt.setInt((i * 5) + 1, plot.getId().x);
|
||||
stmt.setInt((i * 5) + 2, plot.getId().y);
|
||||
try {
|
||||
stmt.setString((i * 5) + 3, plot.owner.toString());
|
||||
} catch (final Exception e) {
|
||||
@ -587,8 +588,8 @@ public class SQLManager implements AbstractDB {
|
||||
@Override
|
||||
public void setSQLite(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException {
|
||||
stmt.setNull((i * 6) + 1, 4);
|
||||
stmt.setInt((i * 6) + 2, plot.id.x);
|
||||
stmt.setInt((i * 6) + 3, plot.id.y);
|
||||
stmt.setInt((i * 6) + 2, plot.getId().x);
|
||||
stmt.setInt((i * 6) + 3, plot.getId().y);
|
||||
try {
|
||||
stmt.setString((i * 6) + 4, plot.owner.toString());
|
||||
} catch (final Exception e1) {
|
||||
@ -600,8 +601,8 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void setSQL(final PreparedStatement stmt, final Plot plot) throws SQLException {
|
||||
stmt.setInt(1, plot.id.x);
|
||||
stmt.setInt(2, plot.id.y);
|
||||
stmt.setInt(1, plot.getId().x);
|
||||
stmt.setInt(2, plot.getId().y);
|
||||
stmt.setString(3, plot.owner.toString());
|
||||
stmt.setString(4, plot.world);
|
||||
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||
@ -629,7 +630,7 @@ public class SQLManager implements AbstractDB {
|
||||
try {
|
||||
int count = 0;
|
||||
PreparedStatement preparedStmt = null;
|
||||
String statement = null;
|
||||
String statement;
|
||||
int last = -1;
|
||||
for (int j = 0; j <= amount; j++) {
|
||||
final List<T> subList = objList.subList(j * packet, Math.min(size, (j + 1) * packet));
|
||||
@ -639,13 +640,14 @@ public class SQLManager implements AbstractDB {
|
||||
if (last == -1) {
|
||||
last = subList.size();
|
||||
statement = mod.getCreateMySQL(subList.size());
|
||||
preparedStmt = connection.prepareStatement(statement.toString());
|
||||
System.out.print(statement);
|
||||
preparedStmt = connection.prepareStatement(statement);
|
||||
}
|
||||
if ((subList.size() != last) || (((count % 5000) == 0) && (count > 0))) {
|
||||
preparedStmt.executeBatch();
|
||||
preparedStmt.close();
|
||||
statement = mod.getCreateMySQL(subList.size());
|
||||
preparedStmt = connection.prepareStatement(statement.toString());
|
||||
preparedStmt = connection.prepareStatement(statement);
|
||||
}
|
||||
for (int i = 0; i < subList.size(); i++) {
|
||||
count++;
|
||||
@ -672,7 +674,7 @@ public class SQLManager implements AbstractDB {
|
||||
try {
|
||||
int count = 0;
|
||||
PreparedStatement preparedStmt = null;
|
||||
String statement = null;
|
||||
String statement;
|
||||
int last = -1;
|
||||
for (int j = 0; j <= amount; j++) {
|
||||
final List<T> subList = objList.subList(j * packet, Math.min(size, (j + 1) * packet));
|
||||
@ -682,13 +684,13 @@ public class SQLManager implements AbstractDB {
|
||||
if (last == -1) {
|
||||
last = subList.size();
|
||||
statement = mod.getCreateSQLite(subList.size());
|
||||
preparedStmt = connection.prepareStatement(statement.toString());
|
||||
preparedStmt = connection.prepareStatement(statement);
|
||||
}
|
||||
if ((subList.size() != last) || (((count % 5000) == 0) && (count > 0))) {
|
||||
preparedStmt.executeBatch();
|
||||
preparedStmt.clearParameters();
|
||||
statement = mod.getCreateSQLite(subList.size());
|
||||
preparedStmt = connection.prepareStatement(statement.toString());
|
||||
preparedStmt = connection.prepareStatement(statement);
|
||||
}
|
||||
for (int i = 0; i < subList.size(); i++) {
|
||||
count++;
|
||||
@ -707,9 +709,9 @@ public class SQLManager implements AbstractDB {
|
||||
PS.debug("&cERROR 2: " + " | " + objList.get(0).getClass().getCanonicalName());
|
||||
PS.debug("&6[WARN] " + "Could not bulk save!");
|
||||
try {
|
||||
PreparedStatement preparedStmt = null;
|
||||
PreparedStatement preparedStmt;
|
||||
final String nonBulk = mod.getCreateSQL();
|
||||
preparedStmt = connection.prepareStatement(nonBulk.toString());
|
||||
preparedStmt = connection.prepareStatement(nonBulk);
|
||||
for (final T obj : objList) {
|
||||
try {
|
||||
mod.setSQL(preparedStmt, obj);
|
||||
@ -874,7 +876,7 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void setMySQL(final PreparedStatement stmt, final int i, final Integer id) throws SQLException {
|
||||
stmt.setInt((i * 1) + 1, id);
|
||||
stmt.setInt((i) + 1, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -914,8 +916,8 @@ public class SQLManager implements AbstractDB {
|
||||
addPlotTask(plot, new UniqueStatement("createPlot") {
|
||||
@Override
|
||||
public void set(final PreparedStatement stmt) throws SQLException {
|
||||
stmt.setInt(1, plot.id.x);
|
||||
stmt.setInt(2, plot.id.y);
|
||||
stmt.setInt(1, plot.getId().x);
|
||||
stmt.setInt(2, plot.getId().y);
|
||||
stmt.setString(3, plot.owner.toString());
|
||||
stmt.setString(4, plot.world);
|
||||
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||
@ -947,8 +949,8 @@ public class SQLManager implements AbstractDB {
|
||||
addPlotTask(plot, new UniqueStatement("createPlotAndSettings_" + plot.hashCode()) {
|
||||
@Override
|
||||
public void set(final PreparedStatement stmt) throws SQLException {
|
||||
stmt.setInt(1, plot.id.x);
|
||||
stmt.setInt(2, plot.id.y);
|
||||
stmt.setInt(1, plot.getId().x);
|
||||
stmt.setInt(2, plot.getId().y);
|
||||
stmt.setString(3, plot.owner.toString());
|
||||
stmt.setString(4, plot.world);
|
||||
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||
@ -1007,7 +1009,7 @@ public class SQLManager implements AbstractDB {
|
||||
// ResultSet set = meta.getTables(null, null, prefix + s, null);
|
||||
if (!set.next()) {
|
||||
create++;
|
||||
} else {}
|
||||
}
|
||||
set.close();
|
||||
}
|
||||
if (create == 0) {
|
||||
@ -1397,8 +1399,8 @@ public class SQLManager implements AbstractDB {
|
||||
return plot.temp;
|
||||
}
|
||||
stmt = connection.prepareStatement("SELECT `id` FROM `" + prefix + "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC");
|
||||
stmt.setInt(1, plot.id.x);
|
||||
stmt.setInt(2, plot.id.y);
|
||||
stmt.setInt(1, plot.getId().x);
|
||||
stmt.setInt(2, plot.getId().y);
|
||||
stmt.setString(3, plot.world);
|
||||
final ResultSet r = stmt.executeQuery();
|
||||
int id = Integer.MAX_VALUE;
|
||||
@ -1503,21 +1505,56 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
}
|
||||
|
||||
public void deleteRows(final ArrayList<Integer> rowIds, final String table, final String column) {
|
||||
setBulk(rowIds, new StmtMod<Integer>() {
|
||||
|
||||
@Override
|
||||
public String getCreateMySQL(int size) {
|
||||
return getCreateMySQL(1, "DELETE FROM `" + table + "` WHERE `" + prefix + column + "` IN ", size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreateSQLite(int size) {
|
||||
return getCreateMySQL(1, "DELETE FROM `" + table + "` WHERE `" + prefix + column + "` IN ", size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreateSQL() {
|
||||
return "DELETE FROM `" + table + "` WHERE `" + prefix + column + "` = ?";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMySQL(PreparedStatement stmt, int i, Integer obj) throws SQLException {
|
||||
stmt.setInt((i) + 1, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSQLite(PreparedStatement stmt, int i, Integer obj) throws SQLException {
|
||||
stmt.setInt((i) + 1, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSQL(PreparedStatement stmt, Integer obj) throws SQLException {
|
||||
stmt.setInt(1, obj);
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all plots, helpers, denied, trusted, and every setting from DB into a hashmap
|
||||
*/
|
||||
@Override
|
||||
public ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> getPlots() {
|
||||
final ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> newplots = new ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>>();
|
||||
final ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> newplots = new ConcurrentHashMap<>();
|
||||
final HashMap<Integer, Plot> plots = new HashMap<>();
|
||||
Statement stmt = null;
|
||||
Statement stmt;
|
||||
try {
|
||||
Set<String> worlds = new HashSet<>();
|
||||
if (PS.get().config.contains("worlds")) {
|
||||
worlds = PS.get().config.getConfigurationSection("worlds").getKeys(false);
|
||||
}
|
||||
final HashMap<String, UUID> uuids = new HashMap<String, UUID>();
|
||||
final HashMap<String, Integer> noExist = new HashMap<String, Integer>();
|
||||
final HashMap<String, UUID> uuids = new HashMap<>();
|
||||
final HashMap<String, AtomicInteger> noExist = new HashMap<>();
|
||||
|
||||
PlotId plot_id;
|
||||
int id;
|
||||
@ -1530,15 +1567,22 @@ public class SQLManager implements AbstractDB {
|
||||
*/
|
||||
stmt = connection.createStatement();
|
||||
try (ResultSet r = stmt.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world`, `timestamp` FROM `" + prefix + "plot`")) {
|
||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||
while (r.next()) {
|
||||
plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
|
||||
id = r.getInt("id");
|
||||
final String worldname = r.getString("world");
|
||||
if (!worlds.contains(worldname)) {
|
||||
if (noExist.containsKey(worldname)) {
|
||||
noExist.put(worldname, noExist.get(worldname) + 1);
|
||||
if (Settings.AUTO_PURGE) {
|
||||
toDelete.add(id);
|
||||
continue;
|
||||
} else {
|
||||
noExist.put(worldname, 1);
|
||||
AtomicInteger value = noExist.get(worldname);
|
||||
if (value != null) {
|
||||
value.incrementAndGet();
|
||||
} else {
|
||||
noExist.put(worldname, new AtomicInteger(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
o = r.getString("owner");
|
||||
@ -1550,7 +1594,8 @@ public class SQLManager implements AbstractDB {
|
||||
Timestamp timestamp = null;
|
||||
try {
|
||||
timestamp = r.getTimestamp("timestamp");
|
||||
} catch (final Exception e) {};
|
||||
} catch (SQLException ignored) {
|
||||
}
|
||||
long time;
|
||||
if (timestamp == null) {
|
||||
time = plot_id.hashCode();
|
||||
@ -1558,11 +1603,30 @@ public class SQLManager implements AbstractDB {
|
||||
time = timestamp.getTime();
|
||||
}
|
||||
p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(), new HashSet<UUID>(), "", null, null, worldname, new boolean[] { false, false, false, false }, time, id);
|
||||
ConcurrentHashMap<PlotId, Plot> map = newplots.get(worldname);
|
||||
if (map != null) {
|
||||
Plot last = map.put(p.id, p);
|
||||
if (last != null) {
|
||||
map.put(last.id, last);
|
||||
if (Settings.AUTO_PURGE) {
|
||||
toDelete.add(id);
|
||||
} else {
|
||||
PS.debug("&cPLOT " + id + " in `plot` is a duplicate. Delete this plot or set `auto-purge: true` in the settings.yml.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
map = new ConcurrentHashMap<PlotId, Plot>();
|
||||
newplots.put(worldname, map);
|
||||
map.put(p.id, p);
|
||||
}
|
||||
plots.put(id, p);
|
||||
}
|
||||
deleteRows(toDelete, "plot", "id");
|
||||
}
|
||||
if (Settings.CACHE_RATINGS) {
|
||||
try (ResultSet r = stmt.executeQuery("SELECT `plot_plot_id`, `player`, `rating` FROM `" + prefix + "plot_rating`")) {
|
||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||
while (r.next()) {
|
||||
id = r.getInt("plot_plot_id");
|
||||
o = r.getString("player");
|
||||
@ -1574,13 +1638,16 @@ public class SQLManager implements AbstractDB {
|
||||
final Plot plot = plots.get(id);
|
||||
if (plot != null) {
|
||||
if (plot.getSettings().ratings == null) {
|
||||
plot.getSettings().ratings = new HashMap<UUID, Integer>();
|
||||
plot.getSettings().ratings = new HashMap<>();
|
||||
}
|
||||
plot.getSettings().ratings.put(user, r.getInt("rating"));
|
||||
} else if (Settings.AUTO_PURGE) {
|
||||
toDelete.add(id);
|
||||
} else {
|
||||
PS.debug("&cPLOT " + id + " in plot_rating does not exist. Please create the plot or remove this entry.");
|
||||
PS.debug("&cENTRY " + id + " in `plot_rating` does not exist. Create this plot or set `auto-purge: true` in the settings.yml.");
|
||||
}
|
||||
}
|
||||
deleteRows(toDelete, "plot_rating", "plot_plot_id");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1588,6 +1655,7 @@ public class SQLManager implements AbstractDB {
|
||||
* Getting helpers
|
||||
*/
|
||||
try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + prefix + "plot_helpers`")) {
|
||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||
while (r.next()) {
|
||||
id = r.getInt("plot_plot_id");
|
||||
o = r.getString("user_uuid");
|
||||
@ -1599,16 +1667,20 @@ public class SQLManager implements AbstractDB {
|
||||
final Plot plot = plots.get(id);
|
||||
if (plot != null) {
|
||||
plot.getTrusted().add(user);
|
||||
} else if (Settings.AUTO_PURGE) {
|
||||
toDelete.add(id);
|
||||
} else {
|
||||
PS.debug("&cPLOT " + id + " in plot_helpers does not exist. Please create the plot or remove this entry.");
|
||||
PS.debug("&cENTRY " + id + " in `plot_helpers` does not exist. Create this plot or set `auto-purge: true` in the settings.yml.");
|
||||
}
|
||||
}
|
||||
deleteRows(toDelete, "plot_helpers", "plot_plot_id");
|
||||
}
|
||||
|
||||
/*
|
||||
* Getting trusted
|
||||
*/
|
||||
try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + prefix + "plot_trusted`")) {
|
||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||
while (r.next()) {
|
||||
id = r.getInt("plot_plot_id");
|
||||
o = r.getString("user_uuid");
|
||||
@ -1620,16 +1692,20 @@ public class SQLManager implements AbstractDB {
|
||||
final Plot plot = plots.get(id);
|
||||
if (plot != null) {
|
||||
plot.getMembers().add(user);
|
||||
} else if (Settings.AUTO_PURGE) {
|
||||
toDelete.add(id);
|
||||
} else {
|
||||
PS.debug("&cPLOT " + id + " in plot_trusted does not exist. Please create the plot or remove this entry.");
|
||||
PS.debug("&cENTRY " + id + " in `plot_trusted` does not exist. Create this plot or set `auto-purge: true` in the settings.yml.");
|
||||
}
|
||||
}
|
||||
deleteRows(toDelete, "plot_trusted", "plot_plot_id");
|
||||
}
|
||||
|
||||
/*
|
||||
* Getting denied
|
||||
*/
|
||||
try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + prefix + "plot_denied`")) {
|
||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||
while (r.next()) {
|
||||
id = r.getInt("plot_plot_id");
|
||||
o = r.getString("user_uuid");
|
||||
@ -1641,22 +1717,22 @@ public class SQLManager implements AbstractDB {
|
||||
final Plot plot = plots.get(id);
|
||||
if (plot != null) {
|
||||
plot.getDenied().add(user);
|
||||
} else if (Settings.AUTO_PURGE) {
|
||||
toDelete.add(id);
|
||||
} else {
|
||||
PS.debug("&cPLOT " + id + " in plot_denied does not exist. Please create the plot or remove this entry.");
|
||||
PS.debug("&cENTRY " + id + " in `plot_denied` does not exist. Create this plot or set `auto-purge: true` in the settings.yml.");
|
||||
}
|
||||
}
|
||||
deleteRows(toDelete, "plot_denied", "plot_plot_id");
|
||||
}
|
||||
|
||||
try (ResultSet r = stmt.executeQuery("SELECT * FROM `" + prefix + "plot_settings`")) {
|
||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||
while (r.next()) {
|
||||
id = r.getInt("plot_plot_id");
|
||||
final Plot plot = plots.get(id);
|
||||
if (plot != null) {
|
||||
plots.remove(id);
|
||||
if (!newplots.containsKey(plot.world)) {
|
||||
newplots.put(plot.world, new ConcurrentHashMap<PlotId, Plot>());
|
||||
}
|
||||
newplots.get(plot.world).put(plot.id, plot);
|
||||
final String alias = r.getString("alias");
|
||||
if (alias != null) {
|
||||
plot.getSettings().setAlias(alias);
|
||||
@ -1671,18 +1747,14 @@ public class SQLManager implements AbstractDB {
|
||||
default:
|
||||
try {
|
||||
plot.getSettings().setPosition(BlockLoc.fromString(pos));
|
||||
} catch (final Exception e) {}
|
||||
} catch (final Exception ignored) {}
|
||||
}
|
||||
final Integer m = r.getInt("merged");
|
||||
if (m != null) {
|
||||
final boolean[] merged = new boolean[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
merged[3 - i] = ((m) & (1 << i)) != 0;
|
||||
}
|
||||
plot.getSettings().setMerged(merged);
|
||||
} else {
|
||||
plot.getSettings().setMerged(new boolean[] { false, false, false, false });
|
||||
final boolean[] merged = new boolean[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
merged[3 - i] = ((m) & (1 << i)) != 0;
|
||||
}
|
||||
plot.getSettings().setMerged(merged);
|
||||
String[] flags_string;
|
||||
final String myflags = r.getString("flags");
|
||||
if (myflags == null) {
|
||||
@ -1723,30 +1795,26 @@ public class SQLManager implements AbstractDB {
|
||||
this.setFlags(plot, flags.values());
|
||||
}
|
||||
plot.getSettings().flags = flags;
|
||||
} else if (Settings.AUTO_PURGE) {
|
||||
toDelete.add(id);
|
||||
} else {
|
||||
PS.debug("&cPLOT " + id + " in plot_settings does not exist. Please create the plot or remove this entry.");
|
||||
PS.debug("&cENTRY " + id + " in `plot_settings` does not exist. Create this plot or set `auto-purge: true` in the settings.yml.");
|
||||
}
|
||||
}
|
||||
stmt.close();
|
||||
deleteRows(toDelete, "plot_settings", "plot_plot_id");
|
||||
}
|
||||
if (plots.entrySet().size() > 0) {
|
||||
createEmptySettings(new ArrayList<Integer>(plots.keySet()), null);
|
||||
createEmptySettings(new ArrayList<>(plots.keySet()), null);
|
||||
for (Entry<Integer, Plot> entry : plots.entrySet()) {
|
||||
Plot plot = entry.getValue();
|
||||
plot.getSettings();
|
||||
ConcurrentHashMap<PlotId, Plot> map = newplots.get(plot.world);
|
||||
if (map == null) {
|
||||
map = new ConcurrentHashMap<PlotId, Plot>();
|
||||
newplots.put(plot.world, map);
|
||||
}
|
||||
map.put(plot.id, plot);
|
||||
entry.getValue().getSettings();
|
||||
}
|
||||
}
|
||||
boolean invalidPlot = false;
|
||||
for (final Entry<String, Integer> entry : noExist.entrySet()) {
|
||||
for (final Entry<String, AtomicInteger> entry : noExist.entrySet()) {
|
||||
final String worldname = entry.getKey();
|
||||
invalidPlot = true;
|
||||
PS.debug("&c[WARNING] Found " + noExist.get(worldname) + " plots in DB for non existant world; '" + worldname + "'.");
|
||||
PS.debug("&c[WARNING] Found " + entry.getValue().intValue() + " plots in DB for non existant world; '" + worldname + "'.");
|
||||
}
|
||||
if (invalidPlot) {
|
||||
PS.debug("&c[WARNING] - Please create the world/s or remove the plots using the purge command");
|
||||
@ -1815,8 +1883,8 @@ public class SQLManager implements AbstractDB {
|
||||
addPlotTask(original, new UniqueStatement("movePlot") {
|
||||
@Override
|
||||
public void set(final PreparedStatement stmt) throws SQLException {
|
||||
stmt.setInt(1, newPlot.id.x);
|
||||
stmt.setInt(2, newPlot.id.y);
|
||||
stmt.setInt(1, newPlot.getId().x);
|
||||
stmt.setInt(2, newPlot.getId().y);
|
||||
stmt.setString(3, newPlot.world);
|
||||
stmt.setInt(4, getId(original));
|
||||
}
|
||||
@ -1883,13 +1951,13 @@ public class SQLManager implements AbstractDB {
|
||||
String stmt_prefix = "";
|
||||
final StringBuilder idstr2 = new StringBuilder("");
|
||||
for (final Integer id : uniqueIds) {
|
||||
idstr2.append(stmt_prefix + id);
|
||||
idstr2.append(stmt_prefix).append(id);
|
||||
stmt_prefix = " OR `id` = ";
|
||||
}
|
||||
stmt_prefix = "";
|
||||
final StringBuilder idstr = new StringBuilder("");
|
||||
for (final Integer id : uniqueIds) {
|
||||
idstr.append(stmt_prefix + id);
|
||||
idstr.append(stmt_prefix).append(id);
|
||||
stmt_prefix = " OR `plot_plot_id` = ";
|
||||
}
|
||||
PreparedStatement stmt = connection.prepareStatement("DELETE FROM `" + prefix + "plot_helpers` WHERE `plot_plot_id` = " + idstr + "");
|
||||
@ -1976,7 +2044,7 @@ public class SQLManager implements AbstractDB {
|
||||
public void set(final PreparedStatement statement) throws SQLException {
|
||||
if (plot != null) {
|
||||
statement.setString(1, plot.world);
|
||||
statement.setInt(2, plot.id.hashCode());
|
||||
statement.setInt(2, plot.getId().hashCode());
|
||||
statement.setString(3, comment.comment);
|
||||
statement.setString(4, comment.inbox);
|
||||
statement.setString(5, comment.senderName);
|
||||
@ -2004,7 +2072,7 @@ public class SQLManager implements AbstractDB {
|
||||
public void set(final PreparedStatement statement) throws SQLException {
|
||||
if (plot != null) {
|
||||
statement.setString(1, plot.world);
|
||||
statement.setInt(2, plot.id.hashCode());
|
||||
statement.setInt(2, plot.getId().hashCode());
|
||||
statement.setString(3, inbox);
|
||||
} else {
|
||||
statement.setString(1, inbox);
|
||||
@ -2028,7 +2096,7 @@ public class SQLManager implements AbstractDB {
|
||||
public void set(final PreparedStatement statement) throws SQLException {
|
||||
if (plot != null) {
|
||||
statement.setString(1, plot.world);
|
||||
statement.setInt(2, plot.id.hashCode());
|
||||
statement.setInt(2, plot.getId().hashCode());
|
||||
statement.setString(3, inbox);
|
||||
} else {
|
||||
statement.setString(1, inbox);
|
||||
@ -2048,7 +2116,7 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void addBatch(final PreparedStatement statement) throws SQLException {
|
||||
final ArrayList<PlotComment> comments = new ArrayList<PlotComment>();
|
||||
final ArrayList<PlotComment> comments = new ArrayList<>();
|
||||
final ResultSet set = statement.executeQuery();
|
||||
PlotComment comment;
|
||||
while (set.next()) {
|
||||
@ -2078,7 +2146,7 @@ public class SQLManager implements AbstractDB {
|
||||
@Override
|
||||
public void set(final PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, plot.world);
|
||||
statement.setInt(2, plot.id.hashCode());
|
||||
statement.setInt(2, plot.getId().hashCode());
|
||||
statement.setString(3, comment.comment);
|
||||
statement.setString(4, comment.inbox);
|
||||
statement.setInt(5, (int) (comment.timestamp / 1000));
|
||||
@ -2190,7 +2258,7 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public HashMap<UUID, Integer> getRatings(final Plot plot) {
|
||||
final HashMap<UUID, Integer> map = new HashMap<UUID, Integer>();
|
||||
final HashMap<UUID, Integer> map = new HashMap<>();
|
||||
try {
|
||||
final PreparedStatement statement = connection.prepareStatement("SELECT `rating`, `player` FROM `" + prefix + "plot_rating` WHERE `plot_plot_id` = ? ");
|
||||
statement.setInt(1, getId(plot));
|
||||
@ -2285,8 +2353,8 @@ public class SQLManager implements AbstractDB {
|
||||
if (PS.get().config.contains("worlds")) {
|
||||
worlds = PS.get().config.getConfigurationSection("worlds").getKeys(false);
|
||||
}
|
||||
final HashMap<String, UUID> uuids = new HashMap<String, UUID>();
|
||||
final HashMap<String, Integer> noExist = new HashMap<String, Integer>();
|
||||
final HashMap<String, UUID> uuids = new HashMap<>();
|
||||
final HashMap<String, Integer> noExist = new HashMap<>();
|
||||
/*
|
||||
* Getting clusters
|
||||
*/
|
||||
@ -2381,15 +2449,11 @@ public class SQLManager implements AbstractDB {
|
||||
} catch (final Exception e) {}
|
||||
}
|
||||
final Integer m = r.getInt("merged");
|
||||
if (m != null) {
|
||||
final boolean[] merged = new boolean[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
merged[3 - i] = ((m) & (1 << i)) != 0;
|
||||
}
|
||||
cluster.settings.setMerged(merged);
|
||||
} else {
|
||||
cluster.settings.setMerged(new boolean[] { false, false, false, false });
|
||||
final boolean[] merged = new boolean[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
merged[3 - i] = ((m) & (1 << i)) != 0;
|
||||
}
|
||||
cluster.settings.setMerged(merged);
|
||||
String[] flags_string;
|
||||
final String myflags = r.getString("flags");
|
||||
if (myflags == null) {
|
||||
@ -2730,7 +2794,7 @@ public class SQLManager implements AbstractDB {
|
||||
toCreate.add(plot);
|
||||
continue;
|
||||
}
|
||||
final Plot dataplot = worldplots.remove(plot.id);
|
||||
final Plot dataplot = worldplots.remove(plot.getId());
|
||||
if (dataplot == null) {
|
||||
PS.debug("&8 - &7Creating plot (2): " + plot);
|
||||
toCreate.add(plot);
|
||||
@ -2742,7 +2806,7 @@ public class SQLManager implements AbstractDB {
|
||||
setOwner(plot, plot.owner);
|
||||
}
|
||||
// trusted
|
||||
if (!plot.getTrusted().equals(dataplot.trusted)) {
|
||||
if (!plot.getTrusted().equals(dataplot.getTrusted())) {
|
||||
final HashSet<UUID> toAdd = (HashSet<UUID>) plot.getTrusted().clone();
|
||||
final HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getTrusted().clone();
|
||||
toRemove.removeAll(plot.getTrusted());
|
||||
@ -2759,7 +2823,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!plot.getMembers().equals(dataplot.members)) {
|
||||
if (!plot.getMembers().equals(dataplot.getMembers())) {
|
||||
final HashSet<UUID> toAdd = (HashSet<UUID>) plot.getMembers().clone();
|
||||
final HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getMembers().clone();
|
||||
toRemove.removeAll(plot.getMembers());
|
||||
@ -2776,7 +2840,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!plot.getDenied().equals(dataplot.denied)) {
|
||||
if (!plot.getDenied().equals(dataplot.getDenied())) {
|
||||
final HashSet<UUID> toAdd = (HashSet<UUID>) plot.getDenied().clone();
|
||||
final HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getDenied().clone();
|
||||
toRemove.removeAll(plot.getDenied());
|
||||
@ -2797,12 +2861,12 @@ public class SQLManager implements AbstractDB {
|
||||
final PlotSettings ds = dataplot.getSettings();
|
||||
final boolean[] pm = ps.getMerged();
|
||||
final boolean[] dm = ds.getMerged();
|
||||
if ((pm[0] != dm[0]) || (pm[1] != dm[1]) || (pm[1] != dm[1]) || (pm[1] != dm[1])) {
|
||||
if ((pm[0] != dm[0]) || (pm[1] != dm[1])) {
|
||||
PS.debug("&8 - &7Correcting merge for: " + plot);
|
||||
setMerged(dataplot, ps.getMerged());
|
||||
}
|
||||
final HashMap<String, Flag> pf = ps.flags;
|
||||
final HashMap<String, Flag> df = ds.flags;
|
||||
final HashMap<String, Flag> pf = plot.getFlags();
|
||||
final HashMap<String, Flag> df = dataplot.getFlags();
|
||||
if ((pf.size() != 0) && (df.size() != 0)) {
|
||||
if ((pf.size() != df.size()) || !StringMan.isEqual(StringMan.joinOrdered(pf.values(), ","), StringMan.joinOrdered(df.values(), ","))) {
|
||||
PS.debug("&8 - &7Correcting flags for: " + plot);
|
||||
|
@ -11,9 +11,9 @@ public abstract class StmtMod<T> {
|
||||
public String getCreateMySQL(final int size, final String query, final int params) {
|
||||
final StringBuilder statement = new StringBuilder(query);
|
||||
for (int i = 0; i < (size - 1); i++) {
|
||||
statement.append("(" + StringMan.repeat(",(?)", params).substring(1) + "),");
|
||||
statement.append("(" + StringMan.repeat(",?", params).substring(1) + "),");
|
||||
}
|
||||
statement.append("(" + StringMan.repeat(",(?)", params).substring(1) + ")");
|
||||
statement.append("(" + StringMan.repeat(",?", params).substring(1) + ")");
|
||||
return statement.toString();
|
||||
}
|
||||
|
||||
|
@ -415,8 +415,7 @@ public class FlagManager {
|
||||
*/
|
||||
public static AbstractFlag getFlag(final String string, final boolean create) {
|
||||
if ((getFlag(string) == null) && create) {
|
||||
final AbstractFlag flag = new AbstractFlag(string);
|
||||
return flag;
|
||||
return new AbstractFlag(string);
|
||||
}
|
||||
return getFlag(string);
|
||||
}
|
||||
@ -433,7 +432,7 @@ public class FlagManager {
|
||||
}
|
||||
|
||||
public static HashMap<String, Flag> parseFlags(final List<String> flagstrings) {
|
||||
final HashMap<String, Flag> map = new HashMap<String, Flag>();
|
||||
final HashMap<String, Flag> map = new HashMap<>();
|
||||
for (final String key : flagstrings) {
|
||||
final String[] split;
|
||||
if (key.contains(";")) {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
@ -12,6 +10,8 @@ import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* A plot manager with square plots which tesselate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot)
|
||||
*/
|
||||
@ -58,9 +58,9 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
@Override
|
||||
public boolean unclaimPlot(final PlotWorld plotworld, final Plot plot, final Runnable whenDone) {
|
||||
final ClassicPlotWorld dpw = ((ClassicPlotWorld) plotworld);
|
||||
setWallFilling(dpw, plot.id, new PlotBlock[] { dpw.WALL_FILLING });
|
||||
setWallFilling(dpw, plot.getId(), new PlotBlock[] { dpw.WALL_FILLING });
|
||||
if ((dpw.WALL_BLOCK.id != 0) || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) {
|
||||
setWall(dpw, plot.id, new PlotBlock[] { dpw.WALL_BLOCK });
|
||||
setWall(dpw, plot.getId(), new PlotBlock[] { dpw.WALL_BLOCK });
|
||||
}
|
||||
SetBlockQueue.addNotify(whenDone);
|
||||
return true;
|
||||
@ -84,7 +84,6 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
for (RegionWrapper region : MainUtil.getRegions(plot)) {
|
||||
Location pos1 = new Location(plot.world, region.minX, 1, region.minZ);
|
||||
Location pos2 = new Location(plot.world, region.maxX, 255, region.maxZ);
|
||||
@ -271,8 +270,8 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
@Override
|
||||
public boolean createRoadEast(final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sx = pos2.getX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = pos1.getZ() - 2;
|
||||
@ -293,8 +292,8 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
@Override
|
||||
public boolean createRoadSouth(final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sz = pos2.getZ() + 1;
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
final int sx = pos1.getX() - 2;
|
||||
@ -314,7 +313,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
@Override
|
||||
public boolean createRoadSouthEast(final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sx = pos2.getX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = pos2.getZ() + 1;
|
||||
@ -329,8 +328,8 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
@Override
|
||||
public boolean removeRoadEast(final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sx = pos2.getX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = pos1.getZ() - 1;
|
||||
@ -344,8 +343,8 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
@Override
|
||||
public boolean removeRoadSouth(final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sz = pos2.getZ() + 1;
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
final int sx = pos1.getX() - 1;
|
||||
@ -359,7 +358,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
@Override
|
||||
public boolean removeRoadSouthEast(final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location loc = getPlotTopLocAbs(dpw, plot.id);
|
||||
final Location loc = getPlotTopLocAbs(dpw, plot.getId());
|
||||
final int sx = loc.getX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = loc.getZ() + 1;
|
||||
@ -412,7 +411,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
if ((claim.id != 0) || !claim.equals(unclaim)) {
|
||||
setWall(plotworld, plot.id, new PlotBlock[] { claim });
|
||||
setWall(plotworld, plot.getId(), new PlotBlock[] { claim });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -20,13 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.Template;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
@ -43,11 +36,19 @@ import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class HybridPlotManager extends ClassicPlotManager {
|
||||
|
||||
@Override
|
||||
public void exportTemplate(final PlotWorld plotworld) throws IOException {
|
||||
final HashSet<FileBytes> files = new HashSet<>(Arrays.asList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld))));
|
||||
final HashSet<FileBytes> files = new HashSet<>(
|
||||
Collections.singletonList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld))));
|
||||
final String psRoot = PS.get().IMP.getDirectory() + File.separator;
|
||||
final String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator;
|
||||
final String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator;
|
||||
@ -77,7 +78,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
return true;
|
||||
}
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id = plot.getId();
|
||||
final PlotId id2 = new PlotId(id.x + 1, id.y);
|
||||
final Location bot = getPlotBottomLocAbs(hpw, id2);
|
||||
final Location top = getPlotTopLocAbs(hpw, id);
|
||||
@ -133,7 +134,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
return true;
|
||||
}
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id = plot.getId();
|
||||
final PlotId id2 = new PlotId(id.x, id.y + 1);
|
||||
final Location bot = getPlotBottomLocAbs(hpw, id2);
|
||||
final Location top = getPlotTopLocAbs(hpw, id);
|
||||
@ -150,7 +151,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
return true;
|
||||
}
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id = plot.getId();
|
||||
final PlotId id2 = new PlotId(id.x + 1, id.y + 1);
|
||||
final Location pos1 = getPlotTopLocAbs(hpw, id).add(1, 0, 1);
|
||||
final Location pos2 = getPlotBottomLocAbs(hpw, id2);
|
||||
@ -171,7 +172,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
final String world = plotworld.worldname;
|
||||
final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld);
|
||||
|
||||
final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id);
|
||||
final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.getId());
|
||||
final Location pos2 = MainUtil.getPlotTopLoc_(plot);
|
||||
// If augmented
|
||||
final boolean canRegen = (plotworld.TYPE == 0) && (plotworld.TERRAIN == 0);
|
||||
|
@ -1,16 +1,5 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -33,6 +22,17 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public abstract class HybridUtils {
|
||||
|
||||
public static HybridUtils manager;
|
||||
@ -113,7 +113,7 @@ public abstract class HybridUtils {
|
||||
public static boolean UPDATE = false;
|
||||
|
||||
public final ArrayList<ChunkLoc> getChunks(final ChunkLoc region) {
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||
final int sx = region.x << 5;
|
||||
final int sz = region.z << 5;
|
||||
for (int x = sx; x < (sx + 32); x++) {
|
||||
@ -133,7 +133,7 @@ public abstract class HybridUtils {
|
||||
if (whenDone == null) {
|
||||
return;
|
||||
}
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
final PlotWorld plotworld = plot.getWorld();
|
||||
if (!(plotworld instanceof ClassicPlotWorld)) {
|
||||
whenDone.value = -1;
|
||||
TaskManager.runTask(whenDone);
|
||||
@ -185,14 +185,14 @@ public abstract class HybridUtils {
|
||||
public boolean scheduleRoadUpdate(final String world, final Set<ChunkLoc> rgs, final int extend) {
|
||||
HybridUtils.regions = rgs;
|
||||
HybridUtils.world = world;
|
||||
chunks = new HashSet<ChunkLoc>();
|
||||
chunks = new HashSet<>();
|
||||
final AtomicInteger count = new AtomicInteger(0);
|
||||
final long baseTime = System.currentTimeMillis();
|
||||
final AtomicInteger last = new AtomicInteger();
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (UPDATE == false) {
|
||||
if (!UPDATE) {
|
||||
last.set(0);
|
||||
Iterator<ChunkLoc> iter = chunks.iterator();
|
||||
while (iter.hasNext()) {
|
||||
@ -212,7 +212,6 @@ public abstract class HybridUtils {
|
||||
HybridUtils.UPDATE = false;
|
||||
PS.debug(C.PREFIX.s() + "Finished road conversion");
|
||||
// CANCEL TASK
|
||||
return;
|
||||
} else {
|
||||
final Runnable task = this;
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@ -298,8 +297,8 @@ public abstract class HybridUtils {
|
||||
|
||||
public boolean setupRoadSchematic(final Plot plot) {
|
||||
final String world = plot.world;
|
||||
final Location bot = MainUtil.getPlotBottomLocAbs(world, plot.id).subtract(1, 0, 1);
|
||||
final Location top = MainUtil.getPlotTopLocAbs(world, plot.id);
|
||||
final Location bot = MainUtil.getPlotBottomLocAbs(world, plot.getId()).subtract(1, 0, 1);
|
||||
final Location top = MainUtil.getPlotTopLocAbs(world, plot.getId());
|
||||
final HybridPlotWorld plotworld = (HybridPlotWorld) PS.get().getPlotWorld(world);
|
||||
final int sx = (bot.getX() - plotworld.ROAD_WIDTH) + 1;
|
||||
final int sz = bot.getZ() + 1;
|
||||
@ -307,20 +306,13 @@ public abstract class HybridUtils {
|
||||
final int ex = bot.getX();
|
||||
final int ez = top.getZ();
|
||||
final int ey = get_ey(world, sx, ex, sz, ez, sy);
|
||||
final Location pos1 = new Location(world, sx, sy, sz);
|
||||
final Location pos2 = new Location(world, ex, ey, ez);
|
||||
final int bx = sx;
|
||||
final int bz = sz - plotworld.ROAD_WIDTH;
|
||||
final int by = sy;
|
||||
final int tx = ex;
|
||||
final int tz = sz - 1;
|
||||
final int ty = get_ey(world, bx, tx, bz, tz, by);
|
||||
final int ty = get_ey(world, sx, ex, bz, tz, sy);
|
||||
|
||||
final Set<RegionWrapper> sideroad = new HashSet<>(Arrays.asList(new RegionWrapper(sx, ex, sy, ey, sz, ez)));
|
||||
final Set<RegionWrapper> intersection = new HashSet<>(Arrays.asList(new RegionWrapper(bx, tx, by, ty, bz, tz)));
|
||||
|
||||
final Location pos3 = new Location(world, bx, by, bz);
|
||||
final Location pos4 = new Location(world, tx, ty, tz);
|
||||
final Set<RegionWrapper> sideroad = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ey, sz, ez)));
|
||||
final Set<RegionWrapper> intersection = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ty, bz, tz)));
|
||||
|
||||
final String dir = PS.get().IMP.getDirectory() + File.separator + "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.world + File.separator;
|
||||
SchematicHandler.manager.getCompoundTag(world, sideroad, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -12,6 +9,10 @@ import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* A plot manager with a square grid layout, with square shaped plots
|
||||
*/
|
||||
@ -169,7 +170,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
// northwest
|
||||
return plot.getMerged(7) ? id : null;
|
||||
}
|
||||
PS.debug("invalid location: " + merged);
|
||||
PS.debug("invalid location: " + Arrays.toString(merged));
|
||||
} catch (Exception e) {
|
||||
PS.debug("Invalid plot / road width in settings.yml for world: " + plotworld.worldname);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
public class Plot {
|
||||
/**
|
||||
* plot ID
|
||||
* Direct access is Deprecated: use getId()
|
||||
* Direct access is Deprecated: use id
|
||||
*/
|
||||
@Deprecated
|
||||
public final PlotId id;
|
||||
@ -384,7 +384,7 @@ public class Plot {
|
||||
* @return boolean false if the player is allowed to enter
|
||||
*/
|
||||
public boolean isDenied(final UUID uuid) {
|
||||
return (getDenied() != null) && ((denied.contains(DBFunc.everyone) && !isAdded(uuid)) || (!isAdded(uuid) && denied.contains(uuid)));
|
||||
return (denied != null) && ((denied.contains(DBFunc.everyone) && !isAdded(uuid)) || (!isAdded(uuid) && denied.contains(uuid)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -464,7 +464,7 @@ public class Plot {
|
||||
origin = this;
|
||||
PlotId min = id;
|
||||
for (Plot plot : MainUtil.getConnectedPlots(this)) {
|
||||
if (plot.id.y < min.y || (plot.id.y == min.y && plot.id.x < min.x)) {
|
||||
if (plot.id.y < min.y || (plot.id.y.equals(min.y) && plot.id.x < min.x)) {
|
||||
origin = plot;
|
||||
min = plot.id;
|
||||
}
|
||||
@ -877,7 +877,7 @@ public class Plot {
|
||||
* - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot creation.
|
||||
* @return true if plot was created successfully
|
||||
*/
|
||||
public boolean create() {
|
||||
public Plot create() {
|
||||
return MainUtil.createPlot(owner, this);
|
||||
}
|
||||
|
||||
@ -1053,7 +1053,7 @@ public class Plot {
|
||||
if ((settings != null) && (settings.getAlias().length() > 1)) {
|
||||
return settings.getAlias();
|
||||
}
|
||||
return world + ";" + getId().x + ";" + getId().y;
|
||||
return world + ";" + id.x + ";" + id.y;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1064,7 +1064,7 @@ public class Plot {
|
||||
public boolean removeDenied(final UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
boolean result = false;
|
||||
for (UUID other : new HashSet<>(getDenied())) {
|
||||
for (UUID other : new HashSet<>(denied)) {
|
||||
result = result || PlotHandler.removeDenied(this, other);
|
||||
}
|
||||
return result;
|
||||
@ -1080,7 +1080,7 @@ public class Plot {
|
||||
public boolean removeTrusted(final UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
boolean result = false;
|
||||
for (UUID other : new HashSet<>(getTrusted())) {
|
||||
for (UUID other : new HashSet<>(trusted)) {
|
||||
result = result || PlotHandler.removeTrusted(this, other);
|
||||
}
|
||||
return result;
|
||||
@ -1094,9 +1094,12 @@ public class Plot {
|
||||
* @param uuid
|
||||
*/
|
||||
public boolean removeMember(final UUID uuid) {
|
||||
if (members == null) {
|
||||
return false;
|
||||
}
|
||||
if (uuid == DBFunc.everyone) {
|
||||
boolean result = false;
|
||||
for (UUID other : new HashSet<>(getMembers())) {
|
||||
for (UUID other : new HashSet<>(members)) {
|
||||
result = result || PlotHandler.removeMember(this, other);
|
||||
}
|
||||
return result;
|
||||
@ -1220,7 +1223,7 @@ public class Plot {
|
||||
if (settings == null) {
|
||||
return "";
|
||||
}
|
||||
return getSettings().getAlias();
|
||||
return settings.getAlias();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1238,7 +1241,7 @@ public class Plot {
|
||||
* @param merged
|
||||
*/
|
||||
public void setMerged(boolean[] merged) {
|
||||
getSettings().merged = merged;
|
||||
getSettings().setMerged(merged);
|
||||
DBFunc.setMerged(this, merged);
|
||||
MainUtil.connected_cache = null;
|
||||
MainUtil.regions_cache = null;
|
||||
@ -1266,7 +1269,7 @@ public class Plot {
|
||||
if (value) {
|
||||
Plot other = MainUtil.getPlotRelative(this, direction).getBasePlot(false);
|
||||
if (!other.equals(getBasePlot(false))) {
|
||||
Plot base = ((other.id.y < id.y) || ((other.id.y == id.y) && (other.id.x < id.x))) ? other : origin;
|
||||
Plot base = ((other.id.y < id.y) || ((other.id.y.equals(id.y)) && (other.id.x < id.x))) ? other : origin;
|
||||
origin.origin = base;
|
||||
other.origin = base;
|
||||
origin = base;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -28,7 +28,7 @@ public class PlotHandler {
|
||||
}
|
||||
return owners;
|
||||
}
|
||||
return new HashSet<>(Arrays.asList(plot.owner));
|
||||
return new HashSet<>(Collections.singletonList(plot.owner));
|
||||
}
|
||||
|
||||
public static boolean isOwner(final Plot plot, final UUID uuid) {
|
||||
|
@ -84,41 +84,7 @@ public class PlotId {
|
||||
}
|
||||
|
||||
public static PlotId unpair(int hash) {
|
||||
if (hash >= 0) {
|
||||
if ((hash % 2) == 0) {
|
||||
// + +
|
||||
hash /= 2;
|
||||
final int i = (int) (Math.abs(-1 + Math.sqrt(1 + (8 * hash))) / 2);
|
||||
final int idx = hash - ((i * (1 + i)) / 2);
|
||||
final int idy = ((i * (3 + i)) / 2) - hash;
|
||||
return new PlotId(idx, idy);
|
||||
} else {
|
||||
// + -
|
||||
hash -= 1;
|
||||
hash /= 2;
|
||||
final int i = (int) (Math.abs(-1 + Math.sqrt(1 + (8 * hash))) / 2);
|
||||
final int idx = hash - ((i * (1 + i)) / 2);
|
||||
final int idy = ((i * (3 + i)) / 2) - hash;
|
||||
return new PlotId(idx, -idy);
|
||||
}
|
||||
} else {
|
||||
if ((hash % 2) == 0) {
|
||||
// - +
|
||||
hash /= -2;
|
||||
final int i = (int) (Math.abs(-1 + Math.sqrt(1 + (8 * hash))) / 2);
|
||||
final int idx = hash - ((i * (1 + i)) / 2);
|
||||
final int idy = ((i * (3 + i)) / 2) - hash;
|
||||
return new PlotId(-idx, idy);
|
||||
} else {
|
||||
// - -
|
||||
hash += 1;
|
||||
hash /= -2;
|
||||
final int i = (int) (Math.abs(-1 + Math.sqrt(1 + (8 * hash))) / 2);
|
||||
final int idx = hash - ((i * (1 + i)) / 2);
|
||||
final int idy = ((i * (3 + i)) / 2) - hash;
|
||||
return new PlotId(-idx, -idy);
|
||||
}
|
||||
}
|
||||
return new PlotId(hash >> 16, hash & 0xFFFF);
|
||||
}
|
||||
|
||||
private int hash;
|
||||
@ -131,22 +97,7 @@ public class PlotId {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (hash == 0) {
|
||||
if (x >= 0) {
|
||||
if (y >= 0) {
|
||||
hash = (x * x) + (3 * x) + (2 * x * y) + y + (y * y);
|
||||
} else {
|
||||
final int y1 = -y;
|
||||
hash = (x * x) + (3 * x) + (2 * x * y1) + y1 + (y1 * y1) + 1;
|
||||
}
|
||||
} else {
|
||||
final int x1 = -x;
|
||||
if (y >= 0) {
|
||||
hash = -((x1 * x1) + (3 * x1) + (2 * x1 * y) + y + (y * y));
|
||||
} else {
|
||||
final int y1 = -y;
|
||||
hash = -((x1 * x1) + (3 * x1) + (2 * x1 * y1) + y1 + (y1 * y1) + 1);
|
||||
}
|
||||
}
|
||||
hash = (x << 16) | (y & 0xFFFF);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
@ -20,13 +20,13 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.Template;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.Template;
|
||||
|
||||
public abstract class PlotManager {
|
||||
/*
|
||||
* Plot locations (methods with Abs in them will not need to consider mega
|
||||
@ -86,7 +86,8 @@ public abstract class PlotManager {
|
||||
public abstract boolean finishPlotUnlink(final PlotWorld plotworld, final ArrayList<PlotId> plotIds);
|
||||
|
||||
public void exportTemplate(final PlotWorld plotworld) throws IOException {
|
||||
final HashSet<FileBytes> files = new HashSet<>(Arrays.asList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld))));
|
||||
final HashSet<FileBytes> files = new HashSet<>(
|
||||
Collections.singletonList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld))));
|
||||
Template.zipAll(plotworld.worldname, files);
|
||||
}
|
||||
|
||||
|
@ -20,11 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
@ -36,6 +31,11 @@ import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Jesse Boyd
|
||||
*/
|
||||
@ -198,7 +198,7 @@ public abstract class PlotWorld {
|
||||
if ((flags == null) || (flags.size() == 0)) {
|
||||
flags = config.getStringList("flags");
|
||||
if ((flags == null) || (flags.size() == 0)) {
|
||||
flags = new ArrayList<String>();
|
||||
flags = new ArrayList<>();
|
||||
final ConfigurationSection section = config.getConfigurationSection("flags");
|
||||
final Set<String> keys = section.getKeys(false);
|
||||
for (final String key : keys) {
|
||||
@ -233,7 +233,7 @@ public abstract class PlotWorld {
|
||||
options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT);
|
||||
options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT);
|
||||
options.put("plot.create_signs", PlotWorld.ALLOW_SIGNS_DEFAULT);
|
||||
options.put("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT.toString());
|
||||
options.put("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT);
|
||||
options.put("schematic.on_claim", PlotWorld.SCHEMATIC_ON_CLAIM_DEFAULT);
|
||||
options.put("schematic.file", PlotWorld.SCHEMATIC_FILE_DEFAULT);
|
||||
options.put("schematic.specify_on_claim", PlotWorld.SCHEMATIC_CLAIM_SPECIFY_DEFAULT);
|
||||
|
@ -1,14 +1,5 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
@ -18,11 +9,19 @@ import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class BO3Handler {
|
||||
|
||||
/**
|
||||
@ -51,7 +50,7 @@ public class BO3Handler {
|
||||
* @return
|
||||
*/
|
||||
public static boolean saveBO3(final PlotPlayer plr, final Plot plot) {
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
final PlotWorld plotworld = plot.getWorld();
|
||||
if (!(plotworld instanceof ClassicPlotWorld) || (plotworld.TYPE != 0)) {
|
||||
MainUtil.sendMessage(plr, "BO3 exporting only supports type 0 classic generation.");
|
||||
return false;
|
||||
|
@ -148,7 +148,7 @@ public class ClusterManager {
|
||||
}
|
||||
|
||||
public static PlotCluster getCluster(final Plot plot) {
|
||||
return getCluster(plot.world, plot.id);
|
||||
return getCluster(plot.world, plot.getId());
|
||||
}
|
||||
|
||||
public static PlotCluster getClusterAbs(final Location loc) {
|
||||
@ -238,7 +238,7 @@ public class ClusterManager {
|
||||
public static PlotId estimatePlotId(final Location loc) {
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot != null) {
|
||||
return plot.id;
|
||||
return plot.getId();
|
||||
}
|
||||
final PlotId a = new PlotId(0, 0);
|
||||
final PlotId b = new PlotId(1, 1);
|
||||
|
@ -100,13 +100,13 @@ public class ExpireManager {
|
||||
for (final UUID helper : plot.getTrusted()) {
|
||||
final PlotPlayer player = UUIDHandler.getPlayer(helper);
|
||||
if (player != null) {
|
||||
MainUtil.sendMessage(player, C.PLOT_REMOVED_USER, plot.id.toString());
|
||||
MainUtil.sendMessage(player, C.PLOT_REMOVED_USER, plot.getId().toString());
|
||||
}
|
||||
}
|
||||
for (final UUID helper : plot.getMembers()) {
|
||||
final PlotPlayer player = UUIDHandler.getPlayer(helper);
|
||||
if (player != null) {
|
||||
MainUtil.sendMessage(player, C.PLOT_REMOVED_USER, plot.id.toString());
|
||||
MainUtil.sendMessage(player, C.PLOT_REMOVED_USER, plot.getId().toString());
|
||||
}
|
||||
}
|
||||
final PlotManager manager = PS.get().getPlotManager(world);
|
||||
|
@ -31,7 +31,7 @@ public class HastebinUtility {
|
||||
|
||||
final BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String inputLine;
|
||||
final StringBuffer response = new StringBuffer();
|
||||
final StringBuilder response = new StringBuilder();
|
||||
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
|
@ -23,8 +23,8 @@ package com.intellectualcrafters.plot.util;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -54,6 +54,7 @@ import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
@ -152,9 +153,9 @@ public class MainUtil {
|
||||
return regions_cache;
|
||||
}
|
||||
if (!origin.isMerged()) {
|
||||
final Location pos1 = MainUtil.getPlotBottomLocAbs(origin.world, origin.id);
|
||||
final Location pos2 = MainUtil.getPlotTopLocAbs(origin.world, origin.id);
|
||||
connected_cache = new HashSet<>(Arrays.asList(origin));
|
||||
final Location pos1 = MainUtil.getPlotBottomLocAbs(origin.world, origin.getId());
|
||||
final Location pos2 = MainUtil.getPlotTopLocAbs(origin.world, origin.getId());
|
||||
connected_cache = new HashSet<>(Collections.singletonList(origin));
|
||||
regions_cache = new HashSet<>(1);
|
||||
regions_cache.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(), pos2.getZ()));
|
||||
return regions_cache;
|
||||
@ -164,20 +165,20 @@ public class MainUtil {
|
||||
HashSet<PlotId> visited = new HashSet<>();
|
||||
ArrayList<PlotId> ids;
|
||||
for (Plot current : plots) {
|
||||
if (visited.contains(current.id)) {
|
||||
if (visited.contains(current.getId())) {
|
||||
continue;
|
||||
}
|
||||
boolean merge = true;
|
||||
boolean tmp = true;
|
||||
PlotId bot = new PlotId(current.id.x, current.id.y);
|
||||
PlotId top = new PlotId(current.id.x, current.id.y);
|
||||
PlotId bot = new PlotId(current.getId().x, current.getId().y);
|
||||
PlotId top = new PlotId(current.getId().x, current.getId().y);
|
||||
while (merge) {
|
||||
merge = false;
|
||||
ids = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, bot.y - 1));
|
||||
tmp = true;
|
||||
for (PlotId id : ids) {
|
||||
Plot plot = MainUtil.getPlotAbs(origin.world, id);
|
||||
if (plot == null || !plot.getMerged(2) || (visited.contains(plot.id))) {
|
||||
if (plot == null || !plot.getMerged(2) || (visited.contains(plot.getId()))) {
|
||||
tmp = false;
|
||||
}
|
||||
}
|
||||
@ -189,7 +190,7 @@ public class MainUtil {
|
||||
tmp = true;
|
||||
for (PlotId id : ids) {
|
||||
Plot plot = MainUtil.getPlotAbs(origin.world, id);
|
||||
if (plot == null || !plot.getMerged(3) || (visited.contains(plot.id))) {
|
||||
if (plot == null || !plot.getMerged(3) || (visited.contains(plot.getId()))) {
|
||||
tmp = false;
|
||||
}
|
||||
}
|
||||
@ -201,7 +202,7 @@ public class MainUtil {
|
||||
tmp = true;
|
||||
for (PlotId id : ids) {
|
||||
Plot plot = MainUtil.getPlotAbs(origin.world, id);
|
||||
if (plot == null || !plot.getMerged(0) || (visited.contains(plot.id))) {
|
||||
if (plot == null || !plot.getMerged(0) || (visited.contains(plot.getId()))) {
|
||||
tmp = false;
|
||||
}
|
||||
}
|
||||
@ -213,7 +214,7 @@ public class MainUtil {
|
||||
tmp = true;
|
||||
for (PlotId id : ids) {
|
||||
Plot plot = MainUtil.getPlotAbs(origin.world, id);
|
||||
if (plot == null || !plot.getMerged(1) || (visited.contains(plot.id))) {
|
||||
if (plot == null || !plot.getMerged(1) || (visited.contains(plot.getId()))) {
|
||||
tmp = false;
|
||||
}
|
||||
}
|
||||
@ -436,7 +437,7 @@ public class MainUtil {
|
||||
}
|
||||
}
|
||||
if (id != null) {
|
||||
if (plot.id.equals(id)) {
|
||||
if (plot.getId().equals(id)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@ -568,7 +569,7 @@ public class MainUtil {
|
||||
ArrayList<PlotId> ids = new ArrayList<>(plots.size());
|
||||
for (Plot current : plots) {
|
||||
current.setHome(null);
|
||||
ids.add(current.id);
|
||||
ids.add(current.getId());
|
||||
}
|
||||
final boolean result = EventUtil.manager.callUnlink(plot.world, ids);
|
||||
if (!result) {
|
||||
@ -578,8 +579,8 @@ public class MainUtil {
|
||||
if (createSign) {
|
||||
plot.removeSign();
|
||||
}
|
||||
final PlotManager manager = PS.get().getPlotManager(plot.world);
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
final PlotManager manager = plot.getManager();
|
||||
final PlotWorld plotworld = plot.getWorld();
|
||||
if (createRoad) {
|
||||
manager.startPlotUnlink(plotworld, ids);
|
||||
}
|
||||
@ -652,14 +653,14 @@ public class MainUtil {
|
||||
/**
|
||||
* Check if a plot is in a plot area.<br>
|
||||
* - Useful as plot objects can be created with any location which may not be valid.
|
||||
* @param location
|
||||
* @param plot
|
||||
* @return
|
||||
*/
|
||||
public static boolean isPlotArea(final Plot plot) {
|
||||
if (!Settings.ENABLE_CLUSTERS) {
|
||||
return true;
|
||||
}
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
final PlotWorld plotworld = plot.getWorld();
|
||||
if (plotworld.TYPE == 2) {
|
||||
return plot.getCluster() != null;
|
||||
}
|
||||
@ -743,7 +744,7 @@ public class MainUtil {
|
||||
*/
|
||||
public static Location getDefaultHome(Plot plot) {
|
||||
plot = plot.getBasePlot(false);
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
final PlotWorld plotworld = plot.getWorld();
|
||||
if (plotworld.DEFAULT_HOME != null) {
|
||||
final int x;
|
||||
final int z;
|
||||
@ -765,8 +766,8 @@ public class MainUtil {
|
||||
RegionWrapper largest = getLargestRegion(plot);
|
||||
final int x = ((largest.maxX - largest.minX) / 2) + largest.minX;
|
||||
final int z = largest.minZ - 1;
|
||||
final PlotManager manager = PS.get().getPlotManager(plot.world);
|
||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PS.get().getPlotWorld(plot.world), plot).getY());
|
||||
final PlotManager manager = plot.getManager();
|
||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(plot.getWorld(), plot).getY());
|
||||
return new Location(plot.world, x, y + 1, z);
|
||||
}
|
||||
|
||||
@ -782,7 +783,7 @@ public class MainUtil {
|
||||
final boolean result = EventUtil.manager.callTeleport(player, from, plot);
|
||||
if (result) {
|
||||
final Location location;
|
||||
if (PS.get().getPlotWorld(plot.world).HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) {
|
||||
if (plot.getWorld().HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) {
|
||||
location = MainUtil.getPlotHome(plot);
|
||||
} else {
|
||||
location = getDefaultHome(plot);
|
||||
@ -855,7 +856,7 @@ public class MainUtil {
|
||||
* @param loc
|
||||
*/
|
||||
public static void update(final String world, final ChunkLoc loc) {
|
||||
BlockUpdateUtil.setBlockManager.update(world, Arrays.asList(loc));
|
||||
BlockUpdateUtil.setBlockManager.update(world, Collections.singletonList(loc));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -910,7 +911,7 @@ public class MainUtil {
|
||||
* @return Plot relative
|
||||
*/
|
||||
public static Plot getPlotRelative(final Plot plot, final int direction) {
|
||||
return getPlotAbs(plot.world, getPlotIdRelative(plot.id, direction));
|
||||
return getPlotAbs(plot.world, getPlotIdRelative(plot.getId(), direction));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -944,14 +945,14 @@ public class MainUtil {
|
||||
for (final PlotId pid : MainUtil.getPlotSelectionIds(pos1, pos2)) {
|
||||
final Plot plot = MainUtil.getPlotAbs(world, pid);
|
||||
if (plot.hasOwner()) {
|
||||
if ((plot.id.x > pos1.x) || (plot.id.y > pos1.y) || (plot.id.x < pos2.x) || (plot.id.y < pos2.y)) {
|
||||
if ((plot.getId().x > pos1.x) || (plot.getId().y > pos1.y) || (plot.getId().x < pos2.x) || (plot.getId().y < pos2.y)) {
|
||||
result.add(plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (final Plot plot : PS.get().getPlotsInWorld(world)) {
|
||||
if ((plot.id.x > pos1.x) || (plot.id.y > pos1.y) || (plot.id.x < pos2.x) || (plot.id.y < pos2.y)) {
|
||||
if ((plot.getId().x > pos1.x) || (plot.getId().y > pos1.y) || (plot.getId().x < pos2.x) || (plot.getId().y < pos2.y)) {
|
||||
result.add(plot);
|
||||
}
|
||||
}
|
||||
@ -1051,7 +1052,7 @@ public class MainUtil {
|
||||
if (plotworld.TERRAIN == 3) {
|
||||
return;
|
||||
}
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id = plot.getId();
|
||||
final PlotId id2 = new PlotId(id.x + 1, id.y + 1);
|
||||
final Location pos1 = getPlotTopLocAbs(plot.world, id).add(1, 0, 1);
|
||||
final Location pos2 = getPlotBottomLocAbs(plot.world, id2).subtract(1, 0, 1);
|
||||
@ -1059,7 +1060,7 @@ public class MainUtil {
|
||||
pos2.setY(256);
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, null);
|
||||
} else {
|
||||
PS.get().getPlotManager(plot.world).removeRoadSouthEast(plotworld, plot);
|
||||
plot.getManager().removeRoadSouthEast(plotworld, plot);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1074,7 +1075,7 @@ public class MainUtil {
|
||||
if (plotworld.TERRAIN == 3) {
|
||||
return;
|
||||
}
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id = plot.getId();
|
||||
final PlotId id2 = new PlotId(id.x + 1, id.y);
|
||||
final Location bot = getPlotBottomLocAbs(plot.world, id2);
|
||||
final Location top = getPlotTopLocAbs(plot.world, id);
|
||||
@ -1082,7 +1083,7 @@ public class MainUtil {
|
||||
final Location pos2 = new Location(plot.world, bot.getX(), 256, top.getZ());
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, null);
|
||||
} else {
|
||||
PS.get().getPlotManager(plot.world).removeRoadEast(plotworld, plot);
|
||||
plot.getManager().removeRoadEast(plotworld, plot);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1097,7 +1098,7 @@ public class MainUtil {
|
||||
if (plotworld.TERRAIN == 3) {
|
||||
return;
|
||||
}
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id = plot.getId();
|
||||
final PlotId id2 = new PlotId(id.x, id.y + 1);
|
||||
final Location bot = getPlotBottomLocAbs(plot.world, id2);
|
||||
final Location top = getPlotTopLocAbs(plot.world, id);
|
||||
@ -1105,7 +1106,7 @@ public class MainUtil {
|
||||
final Location pos2 = new Location(plot.world, top.getX(), 256, bot.getZ());
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, null);
|
||||
} else {
|
||||
PS.get().getPlotManager(plot.world).removeRoadSouth(plotworld, plot);
|
||||
plot.getManager().removeRoadSouth(plotworld, plot);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1118,8 +1119,8 @@ public class MainUtil {
|
||||
*/
|
||||
public static void mergePlot(final String world, Plot lesserPlot, Plot greaterPlot, final boolean removeRoads) {
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
if (lesserPlot.id.x.equals(greaterPlot.id.x)) {
|
||||
if (lesserPlot.id.y > greaterPlot.id.y) {
|
||||
if (lesserPlot.getId().x.equals(greaterPlot.getId().x)) {
|
||||
if (lesserPlot.getId().y > greaterPlot.getId().y) {
|
||||
Plot tmp = lesserPlot;
|
||||
lesserPlot = greaterPlot;
|
||||
greaterPlot = tmp;
|
||||
@ -1135,15 +1136,15 @@ public class MainUtil {
|
||||
removeRoadSouthEast(plotworld, lesserPlot);
|
||||
}
|
||||
MainUtil.removeRoadSouth(plotworld, lesserPlot);
|
||||
Plot other = getPlotAbs(world, getPlotIdRelative(lesserPlot.id, 3));
|
||||
Plot other = getPlotAbs(world, getPlotIdRelative(lesserPlot.getId(), 3));
|
||||
if (other.getMerged(2) && other.getMerged(1)) {
|
||||
MainUtil.removeRoadSouthEast(plotworld, other);
|
||||
mergePlot(world, greaterPlot, getPlotAbs(world, getPlotIdRelative(greaterPlot.id, 3)), removeRoads);
|
||||
mergePlot(world, greaterPlot, getPlotAbs(world, getPlotIdRelative(greaterPlot.getId(), 3)), removeRoads);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (lesserPlot.id.x > greaterPlot.id.x) {
|
||||
if (lesserPlot.getId().x > greaterPlot.getId().x) {
|
||||
Plot tmp = lesserPlot;
|
||||
lesserPlot = greaterPlot;
|
||||
greaterPlot = tmp;
|
||||
@ -1159,10 +1160,10 @@ public class MainUtil {
|
||||
if (lesserPlot.getMerged(5)) {
|
||||
removeRoadSouthEast(plotworld, lesserPlot);
|
||||
}
|
||||
Plot other = getPlotAbs(world, getPlotIdRelative(lesserPlot.id, 0));
|
||||
Plot other = getPlotAbs(world, getPlotIdRelative(lesserPlot.getId(), 0));
|
||||
if (other.getMerged(2) && other.getMerged(1)) {
|
||||
MainUtil.removeRoadSouthEast(plotworld, other);
|
||||
mergePlot(world, greaterPlot, getPlotAbs(world, getPlotIdRelative(greaterPlot.id, 0)), removeRoads);
|
||||
mergePlot(world, greaterPlot, getPlotAbs(world, getPlotIdRelative(greaterPlot.getId(), 0)), removeRoads);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1269,11 +1270,11 @@ public class MainUtil {
|
||||
return;
|
||||
}
|
||||
final String rename = name == null ? "unknown" : name;
|
||||
final PlotManager manager = PS.get().getPlotManager(p.world);
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(p.world);
|
||||
final PlotManager manager = p.getManager();
|
||||
final PlotWorld plotworld = p.getWorld();
|
||||
if (plotworld.ALLOW_SIGNS) {
|
||||
final Location loc = manager.getSignLoc(plotworld, p);
|
||||
final String id = p.id.x + ";" + p.id.y;
|
||||
final String id = p.getId().x + ";" + p.getId().y;
|
||||
final String[] lines = new String[] {
|
||||
C.OWNER_SIGN_LINE_1.formatted().replaceAll("%id%", id),
|
||||
C.OWNER_SIGN_LINE_2.formatted().replaceAll("%id%", id).replaceAll("%plr%", rename),
|
||||
@ -1314,7 +1315,7 @@ public class MainUtil {
|
||||
* Get the corner locations for a list of regions<br>
|
||||
* @see Plot#getCorners()
|
||||
* @param world
|
||||
* @param region
|
||||
* @param regions
|
||||
* @return
|
||||
*/
|
||||
public static Location[] getCorners(String world, Collection<RegionWrapper> regions) {
|
||||
@ -1353,22 +1354,22 @@ public class MainUtil {
|
||||
*/
|
||||
public static PlotId[] getCornerIds(Plot plot) {
|
||||
if (!plot.isMerged()) {
|
||||
return new PlotId[] { plot.id, plot.id };
|
||||
return new PlotId[] { plot.getId(), plot.getId() };
|
||||
}
|
||||
PlotId min = new PlotId(plot.id.x, plot.id.y);
|
||||
PlotId max = new PlotId(plot.id.x, plot.id.y);
|
||||
PlotId min = new PlotId(plot.getId().x, plot.getId().y);
|
||||
PlotId max = new PlotId(plot.getId().x, plot.getId().y);
|
||||
for (Plot current : getConnectedPlots(plot)) {
|
||||
if (current.id.x < min.x) {
|
||||
min.x = current.id.x;
|
||||
if (current.getId().x < min.x) {
|
||||
min.x = current.getId().x;
|
||||
}
|
||||
else if (current.id.x > max.x) {
|
||||
max.x = current.id.x;
|
||||
else if (current.getId().x > max.x) {
|
||||
max.x = current.getId().x;
|
||||
}
|
||||
if (current.id.y < min.y) {
|
||||
min.y = current.id.y;
|
||||
if (current.getId().y < min.y) {
|
||||
min.y = current.getId().y;
|
||||
}
|
||||
else if (current.id.y > max.y) {
|
||||
max.y = current.id.y;
|
||||
else if (current.getId().y > max.y) {
|
||||
max.y = current.getId().y;
|
||||
}
|
||||
}
|
||||
return new PlotId[] { min, max };
|
||||
@ -1398,7 +1399,7 @@ public class MainUtil {
|
||||
HashSet<Plot> visited = new HashSet<>();
|
||||
HashSet<PlotId> merged = new HashSet<>();
|
||||
for (Plot current : getConnectedPlots(plot)) {
|
||||
merged.add(current.id);
|
||||
merged.add(current.getId());
|
||||
}
|
||||
ArrayDeque<Plot> frontier = new ArrayDeque<>(getConnectedPlots(plot));
|
||||
Plot current;
|
||||
@ -1413,8 +1414,8 @@ public class MainUtil {
|
||||
Plot other = getPlotRelative(current, 0);
|
||||
if (other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false)) || ((plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1))) {
|
||||
mergePlot(current.world, current, other, removeRoads);
|
||||
merged.add(current.id);
|
||||
merged.add(other.id);
|
||||
merged.add(current.getId());
|
||||
merged.add(other.getId());
|
||||
toReturn = true;
|
||||
}
|
||||
}
|
||||
@ -1422,8 +1423,8 @@ public class MainUtil {
|
||||
Plot other = getPlotRelative(current, 1);
|
||||
if (other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false)) || ((plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1))) {
|
||||
mergePlot(current.world, current, other, removeRoads);
|
||||
merged.add(current.id);
|
||||
merged.add(other.id);
|
||||
merged.add(current.getId());
|
||||
merged.add(other.getId());
|
||||
toReturn = true;
|
||||
}
|
||||
}
|
||||
@ -1431,8 +1432,8 @@ public class MainUtil {
|
||||
Plot other = getPlotRelative(current, 2);
|
||||
if (other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false)) || ((plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1))) {
|
||||
mergePlot(current.world, current, other, removeRoads);
|
||||
merged.add(current.id);
|
||||
merged.add(other.id);
|
||||
merged.add(current.getId());
|
||||
merged.add(other.getId());
|
||||
toReturn = true;
|
||||
}
|
||||
}
|
||||
@ -1440,14 +1441,14 @@ public class MainUtil {
|
||||
Plot other = getPlotRelative(current, 3);
|
||||
if (other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false)) || ((plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1))) {
|
||||
mergePlot(current.world, current, other, removeRoads);
|
||||
merged.add(current.id);
|
||||
merged.add(other.id);
|
||||
merged.add(current.getId());
|
||||
merged.add(other.getId());
|
||||
toReturn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (removeRoads && toReturn) {
|
||||
PlotManager manager = PS.get().getPlotManager(plot.world);
|
||||
PlotManager manager = plot.getManager();
|
||||
ArrayList<PlotId> ids = new ArrayList<>(merged);
|
||||
manager.finishPlotMerge(plot.getWorld(), ids);
|
||||
}
|
||||
@ -1465,7 +1466,7 @@ public class MainUtil {
|
||||
final String world = plot.world;
|
||||
final PlotManager manager = PS.get().getPlotManager(world);
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
final PlotId id = new PlotId(Math.abs(plot.id.x) + 1, Math.abs(plot.id.x) + 1);
|
||||
final PlotId id = new PlotId(Math.abs(plot.getId().x) + 1, Math.abs(plot.getId().x) + 1);
|
||||
final Location bot = manager.getPlotBottomLocAbs(plotworld, id);
|
||||
final Location top = manager.getPlotTopLocAbs(plotworld, id);
|
||||
final int border = worldBorder.get(plot.world);
|
||||
@ -1480,47 +1481,69 @@ public class MainUtil {
|
||||
/**
|
||||
* Create a plot and notify the world border and plot merger
|
||||
*/
|
||||
public static boolean createPlot(final UUID uuid, final Plot plot) {
|
||||
public static Plot createPlot(final UUID uuid, final Plot plot) {
|
||||
System.out.println("CLAIMING PLOT 1");
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
}
|
||||
System.out.println("CLAIMING PLOT 2");
|
||||
Plot existing = PS.get().getPlot(plot.world, plot.id);
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
}
|
||||
if (MainUtil.worldBorder.containsKey(plot.world)) {
|
||||
updateWorldBorder(plot);
|
||||
}
|
||||
final String w = plot.world;
|
||||
if (PS.get().getPlot(plot.world, plot.id) != null) {
|
||||
return true;
|
||||
}
|
||||
final Plot p = new Plot(w, plot.id, uuid);
|
||||
if (p.owner == null) {
|
||||
return false;
|
||||
}
|
||||
PS.get().updatePlot(p);
|
||||
DBFunc.createPlotAndSettings(p, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
if (plotworld.AUTO_MERGE) {
|
||||
autoMerge(p, -1, Integer.MAX_VALUE, uuid, true);
|
||||
plot.owner = uuid;
|
||||
plot.getTrusted().clear();
|
||||
plot.getMembers().clear();
|
||||
plot.getDenied().clear();
|
||||
plot.settings = new PlotSettings();
|
||||
if (PS.get().updatePlot(plot)) {
|
||||
DBFunc.createPlotAndSettings(plot, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PlotWorld plotworld = plot.getWorld();
|
||||
if (plotworld.AUTO_MERGE) {
|
||||
autoMerge(plot, -1, Integer.MAX_VALUE, uuid, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
});
|
||||
}
|
||||
return plot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plot without notifying the merge function or world border manager
|
||||
*/
|
||||
public static Plot createPlotAbs(final UUID uuid, final Plot plot) {
|
||||
final String w = plot.world;
|
||||
Plot p = PS.get().getPlot(plot.world, plot.id);
|
||||
if (p != null) {
|
||||
return p;
|
||||
}
|
||||
p = new Plot(w, plot.id, uuid);
|
||||
if (p.owner == null) {
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
}
|
||||
PS.get().updatePlot(p);
|
||||
DBFunc.createPlotAndSettings(p, null);
|
||||
return p;
|
||||
Plot existing = getPlot(plot.world, plot.id);
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
}
|
||||
if (MainUtil.worldBorder.containsKey(plot.world)) {
|
||||
updateWorldBorder(plot);
|
||||
}
|
||||
plot.owner = uuid;
|
||||
plot.getTrusted().clear();
|
||||
plot.getMembers().clear();
|
||||
plot.getDenied().clear();
|
||||
plot.settings = new PlotSettings();
|
||||
if (PS.get().updatePlot(plot)) {
|
||||
DBFunc.createPlotAndSettings(plot, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PlotWorld plotworld = plot.getWorld();
|
||||
if (plotworld.AUTO_MERGE) {
|
||||
autoMerge(plot, -1, Integer.MAX_VALUE, uuid, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return plot;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1598,7 +1621,7 @@ public class MainUtil {
|
||||
* @return
|
||||
*/
|
||||
public static boolean clear(final Plot plot, final boolean isDelete, final Runnable whenDone) {
|
||||
if (!EventUtil.manager.callClear(plot.world, plot.id)) {
|
||||
if (!EventUtil.manager.callClear(plot.world, plot.getId())) {
|
||||
return false;
|
||||
}
|
||||
final HashSet<RegionWrapper> regions = getRegions(plot);
|
||||
@ -1608,8 +1631,8 @@ public class MainUtil {
|
||||
removeSign(plot);
|
||||
}
|
||||
MainUtil.unlinkPlot(plot, true, !isDelete);
|
||||
final PlotManager manager = PS.get().getPlotManager(plot.world);
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
final PlotManager manager = plot.getManager();
|
||||
final PlotWorld plotworld = plot.getWorld();
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -1864,7 +1887,7 @@ public class MainUtil {
|
||||
*
|
||||
*/
|
||||
public static Location getPlotHome(final Plot plot) {
|
||||
return getPlotHome(plot.world, plot.id);
|
||||
return getPlotHome(plot.world, plot.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1905,17 +1928,17 @@ public class MainUtil {
|
||||
* @return Location top of mega plot
|
||||
*/
|
||||
public static Location getPlotTopLoc_(Plot plot) {
|
||||
Location top = getPlotTopLocAbs(plot.world, plot.id);
|
||||
Location top = getPlotTopLocAbs(plot.world, plot.getId());
|
||||
if (!plot.isMerged()) {
|
||||
return top;
|
||||
}
|
||||
PlotId id;
|
||||
if (plot.getMerged(2)) {
|
||||
id = getPlotIdRelative(plot.id, 2);
|
||||
id = getPlotIdRelative(plot.getId(), 2);
|
||||
top.setZ(getPlotBottomLocAbs(plot.world, id).getZ() - 1);
|
||||
}
|
||||
if (plot.getMerged(1)) {
|
||||
id = getPlotIdRelative(plot.id, 1);
|
||||
id = getPlotIdRelative(plot.getId(), 1);
|
||||
top.setX(getPlotBottomLocAbs(plot.world, id).getX() - 1);
|
||||
}
|
||||
return top;
|
||||
@ -1931,17 +1954,17 @@ public class MainUtil {
|
||||
* @return Location bottom of mega plot
|
||||
*/
|
||||
public static Location getPlotBottomLoc_(Plot plot) {
|
||||
Location bot = getPlotBottomLocAbs(plot.world, plot.id);
|
||||
Location bot = getPlotBottomLocAbs(plot.world, plot.getId());
|
||||
if (!plot.isMerged()) {
|
||||
return bot;
|
||||
}
|
||||
PlotId id;
|
||||
if (plot.getMerged(0)) {
|
||||
id = getPlotIdRelative(plot.id, 0);
|
||||
id = getPlotIdRelative(plot.getId(), 0);
|
||||
bot.setZ(getPlotTopLocAbs(plot.world, id).getZ() + 1);
|
||||
}
|
||||
if (plot.getMerged(3)) {
|
||||
id = getPlotIdRelative(plot.id, 3);
|
||||
id = getPlotIdRelative(plot.getId(), 3);
|
||||
bot.setX(getPlotTopLocAbs(plot.world, id).getX() + 1);
|
||||
}
|
||||
return bot;
|
||||
@ -2092,18 +2115,18 @@ public class MainUtil {
|
||||
return false;
|
||||
}
|
||||
// Swap cached
|
||||
final PlotId temp = new PlotId(p1.id.x.intValue(), p1.id.y.intValue());
|
||||
p1.id.x = p2.id.x.intValue();
|
||||
p1.id.y = p2.id.y.intValue();
|
||||
p2.id.x = temp.x;
|
||||
p2.id.y = temp.y;
|
||||
final PlotId temp = new PlotId(p1.getId().x, p1.getId().y);
|
||||
p1.getId().x = p2.getId().x;
|
||||
p1.getId().y = p2.getId().y;
|
||||
p2.getId().x = temp.x;
|
||||
p2.getId().y = temp.y;
|
||||
final Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
|
||||
raw.get(p1.world).remove(p1.id);
|
||||
raw.get(p2.world).remove(p2.id);
|
||||
p1.id.recalculateHash();
|
||||
p2.id.recalculateHash();
|
||||
raw.get(p1.world).put(p1.id, p1);
|
||||
raw.get(p2.world).put(p2.id, p2);
|
||||
raw.get(p1.world).remove(p1.getId());
|
||||
raw.get(p2.world).remove(p2.getId());
|
||||
p1.getId().recalculateHash();
|
||||
p2.getId().recalculateHash();
|
||||
raw.get(p1.world).put(p1.getId(), p1);
|
||||
raw.get(p2.world).put(p2.getId(), p2);
|
||||
// Swap database
|
||||
DBFunc.dbManager.swapPlots(p2, p1);
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
@ -2129,11 +2152,11 @@ public class MainUtil {
|
||||
return false;
|
||||
}
|
||||
final Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
|
||||
raw.get(pos1.world).remove(pos1.id);
|
||||
pos1.id.x = (int) pos2.id.x;
|
||||
pos1.id.y = (int) pos2.id.y;
|
||||
pos1.id.recalculateHash();
|
||||
raw.get(pos2.world).put(pos1.id, pos1);
|
||||
raw.get(pos1.world).remove(pos1.getId());
|
||||
pos1.getId().x = (int) pos2.getId().x;
|
||||
pos1.getId().y = (int) pos2.getId().y;
|
||||
pos1.getId().recalculateHash();
|
||||
raw.get(pos2.world).put(pos1.getId(), pos1);
|
||||
DBFunc.movePlot(pos1, pos2);
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
return true;
|
||||
@ -2148,7 +2171,7 @@ public class MainUtil {
|
||||
* @return
|
||||
*/
|
||||
public static boolean move(final Plot origin, final Plot destination, final Runnable whenDone, boolean allowSwap) {
|
||||
PlotId offset = new PlotId(destination.id.x - origin.id.x, destination.id.y - origin.id.y);
|
||||
PlotId offset = new PlotId(destination.getId().x - origin.getId().x, destination.getId().y - origin.getId().y);
|
||||
Location db = destination.getBottomAbs();
|
||||
Location ob = origin.getBottomAbs();
|
||||
final int offsetX = db.getX() - ob.getX();
|
||||
@ -2160,7 +2183,7 @@ public class MainUtil {
|
||||
boolean occupied = false;
|
||||
HashSet<Plot> plots = MainUtil.getConnectedPlots(origin);
|
||||
for (Plot plot : plots) {
|
||||
Plot other = MainUtil.getPlotAbs(destination.world, new PlotId(plot.id.x + offset.x, plot.id.y + offset.y));
|
||||
Plot other = MainUtil.getPlotAbs(destination.world, new PlotId(plot.getId().x + offset.x, plot.getId().y + offset.y));
|
||||
if (other.owner != null) {
|
||||
if (!allowSwap) {
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
@ -2174,7 +2197,7 @@ public class MainUtil {
|
||||
final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(getRegions(origin));
|
||||
// move / swap data
|
||||
for (Plot plot : plots) {
|
||||
Plot other = MainUtil.getPlotAbs(destination.world, new PlotId(plot.id.x + offset.x, plot.id.y + offset.y));
|
||||
Plot other = MainUtil.getPlotAbs(destination.world, new PlotId(plot.getId().x + offset.x, plot.getId().y + offset.y));
|
||||
swapData(plot, other, null);
|
||||
}
|
||||
// copy terrain
|
||||
@ -2235,7 +2258,7 @@ public class MainUtil {
|
||||
* @return
|
||||
*/
|
||||
public static boolean copy(final Plot origin, final Plot destination, final Runnable whenDone) {
|
||||
PlotId offset = new PlotId(destination.id.x - origin.id.x, destination.id.y - origin.id.y);
|
||||
PlotId offset = new PlotId(destination.getId().x - origin.getId().x, destination.getId().y - origin.getId().y);
|
||||
Location db = destination.getBottomAbs();
|
||||
Location ob = origin.getBottomAbs();
|
||||
final int offsetX = db.getX() - ob.getX();
|
||||
@ -2246,7 +2269,7 @@ public class MainUtil {
|
||||
}
|
||||
HashSet<Plot> plots = MainUtil.getConnectedPlots(origin);
|
||||
for (Plot plot : plots) {
|
||||
Plot other = MainUtil.getPlotAbs(destination.world, new PlotId(plot.id.x + offset.x, plot.id.y + offset.y));
|
||||
Plot other = MainUtil.getPlotAbs(destination.world, new PlotId(plot.getId().x + offset.x, plot.getId().y + offset.y));
|
||||
if (other.owner != null) {
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
return false;
|
||||
@ -2256,7 +2279,7 @@ public class MainUtil {
|
||||
updateWorldBorder(destination);
|
||||
// copy data
|
||||
for (Plot plot : plots) {
|
||||
Plot other = MainUtil.getPlotAbs(destination.world , new PlotId(plot.id.x + offset.x, plot.id.y + offset.y));
|
||||
Plot other = MainUtil.getPlotAbs(destination.world , new PlotId(plot.getId().x + offset.x, plot.getId().y + offset.y));
|
||||
other = createPlotAbs(plot.owner, other);
|
||||
if ((plot.getFlags() != null) && (plot.getFlags().size() > 0)) {
|
||||
other.getSettings().flags = plot.getFlags();
|
||||
@ -2399,12 +2422,12 @@ public class MainUtil {
|
||||
return null;
|
||||
}
|
||||
if (plot.settings == null) {
|
||||
return new HashSet<>(Arrays.asList(plot));
|
||||
return new HashSet<>(Collections.singletonList(plot));
|
||||
}
|
||||
boolean[] merged = plot.getMerged();
|
||||
int hash = hash(merged);
|
||||
if (hash == 0) {
|
||||
return new HashSet<>(Arrays.asList(plot));
|
||||
return new HashSet<>(Collections.singletonList(plot));
|
||||
}
|
||||
if (connected_cache != null && connected_cache.contains(plot)) {
|
||||
return connected_cache;
|
||||
@ -2416,7 +2439,7 @@ public class MainUtil {
|
||||
connected_cache.add(plot);
|
||||
Plot tmp;
|
||||
if (merged[0]) {
|
||||
tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.id, 0));
|
||||
tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.getId(), 0));
|
||||
if (!tmp.getMerged(2)) {
|
||||
// invalid merge
|
||||
PS.debug("Fixing invalid merge: " + plot);
|
||||
@ -2432,7 +2455,7 @@ public class MainUtil {
|
||||
frontier.add(tmp);
|
||||
}
|
||||
if (merged[1]) {
|
||||
tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.id, 1));
|
||||
tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.getId(), 1));
|
||||
if (!tmp.getMerged(3)) {
|
||||
// invalid merge
|
||||
PS.debug("Fixing invalid merge: " + plot);
|
||||
@ -2448,7 +2471,7 @@ public class MainUtil {
|
||||
frontier.add(tmp);
|
||||
}
|
||||
if (merged[2]) {
|
||||
tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.id, 2));
|
||||
tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.getId(), 2));
|
||||
if (!tmp.getMerged(0)) {
|
||||
// invalid merge
|
||||
PS.debug("Fixing invalid merge: " + plot);
|
||||
@ -2464,7 +2487,7 @@ public class MainUtil {
|
||||
frontier.add(tmp);
|
||||
}
|
||||
if (merged[3]) {
|
||||
tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.id, 3));
|
||||
tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.getId(), 3));
|
||||
if (!tmp.getMerged(1)) {
|
||||
// invalid merge
|
||||
PS.debug("Fixing invalid merge: " + plot);
|
||||
@ -2491,28 +2514,28 @@ public class MainUtil {
|
||||
queuecache.remove(current);
|
||||
merged = current.getMerged();
|
||||
if (merged[0]) {
|
||||
tmp = getPlotAbs(current.world, getPlotIdRelative(current.id, 0));
|
||||
tmp = getPlotAbs(current.world, getPlotIdRelative(current.getId(), 0));
|
||||
if (!queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
|
||||
queuecache.add(tmp);
|
||||
frontier.add(tmp);
|
||||
}
|
||||
}
|
||||
if (merged[1]) {
|
||||
tmp = getPlotAbs(current.world, getPlotIdRelative(current.id, 1));
|
||||
tmp = getPlotAbs(current.world, getPlotIdRelative(current.getId(), 1));
|
||||
if (!queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
|
||||
queuecache.add(tmp);
|
||||
frontier.add(tmp);
|
||||
}
|
||||
}
|
||||
if (merged[2]) {
|
||||
tmp = getPlotAbs(current.world, getPlotIdRelative(current.id, 2));
|
||||
tmp = getPlotAbs(current.world, getPlotIdRelative(current.getId(), 2));
|
||||
if (!queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
|
||||
queuecache.add(tmp);
|
||||
frontier.add(tmp);
|
||||
}
|
||||
}
|
||||
if (merged[3]) {
|
||||
tmp = getPlotAbs(current.world, getPlotIdRelative(current.id, 3));
|
||||
tmp = getPlotAbs(current.world, getPlotIdRelative(current.getId(), 3));
|
||||
if (!queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
|
||||
queuecache.add(tmp);
|
||||
frontier.add(tmp);
|
||||
@ -2547,7 +2570,7 @@ public class MainUtil {
|
||||
if (plot != null) {
|
||||
return getConnectedPlots(plot);
|
||||
}
|
||||
return new HashSet<>(Arrays.asList(new Plot(world, id, null)));
|
||||
return new HashSet<>(Collections.singletonList(new Plot(world, id, null)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2693,7 +2716,7 @@ public class MainUtil {
|
||||
* @return
|
||||
*/
|
||||
public static boolean setComponent(final Plot plot, final String component, final PlotBlock[] blocks) {
|
||||
return PS.get().getPlotManager(plot.world).setComponent(PS.get().getPlotWorld(plot.world), plot.id, component, blocks);
|
||||
return plot.getManager().setComponent(plot.getWorld(), plot.getId(), component, blocks);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2708,7 +2731,7 @@ public class MainUtil {
|
||||
public static void format(String info, final Plot plot, final PlotPlayer player, final boolean full, final RunnableVal<String> whenDone) {
|
||||
final int num = MainUtil.getConnectedPlots(plot).size();
|
||||
final String alias = plot.getAlias().length() > 0 ? plot.getAlias() : C.NONE.s();
|
||||
final Location bot = plot.getBottom();
|
||||
final Location bot = plot.getCorners()[0];
|
||||
final String biome = BlockManager.manager.getBiome(plot.world, bot.getX(), bot.getZ());
|
||||
final String trusted = getPlayerList(plot.getTrusted());
|
||||
final String members = getPlayerList(plot.getMembers());
|
||||
@ -2725,7 +2748,7 @@ public class MainUtil {
|
||||
|
||||
final String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners());
|
||||
|
||||
info = info.replaceAll("%id%", plot.id.toString());
|
||||
info = info.replaceAll("%id%", plot.getId().toString());
|
||||
info = info.replaceAll("%alias%", alias);
|
||||
info = info.replaceAll("%num%", num + "");
|
||||
info = info.replaceAll("%desc%", description);
|
||||
@ -2776,7 +2799,7 @@ public class MainUtil {
|
||||
*/
|
||||
public static String getPlayerList(final Collection<UUID> uuids) {
|
||||
final ArrayList<UUID> l = new ArrayList<>(uuids);
|
||||
if ((l == null) || (l.size() < 1)) {
|
||||
if (l.size() < 1) {
|
||||
return C.NONE.s();
|
||||
}
|
||||
final String c = C.PLOT_USER_LIST.s();
|
||||
|
@ -1,5 +1,20 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.InputSupplier;
|
||||
import com.google.common.io.OutputSupplier;
|
||||
import com.google.common.primitives.Primitives;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
@ -16,6 +31,7 @@ import java.util.AbstractList;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -24,22 +40,6 @@ import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.InputSupplier;
|
||||
import com.google.common.io.OutputSupplier;
|
||||
import com.google.common.primitives.Primitives;
|
||||
|
||||
public class NbtFactory {
|
||||
// Convert between NBT id and the equivalent class in java
|
||||
private static final BiMap<Integer, Class<?>> NBT_CLASS = HashBiMap.create();
|
||||
@ -191,7 +191,7 @@ public class NbtFactory {
|
||||
* @return An existing map, a new map or NULL.
|
||||
*/
|
||||
public NbtCompound getMap(final String key, final boolean createNew) {
|
||||
return getMap(Arrays.asList(key), createNew);
|
||||
return getMap(Collections.singletonList(key), createNew);
|
||||
}
|
||||
|
||||
// Done
|
||||
|
@ -1,5 +1,30 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellectualcrafters.jnbt.ByteArrayTag;
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.jnbt.IntTag;
|
||||
import com.intellectualcrafters.jnbt.ListTag;
|
||||
import com.intellectualcrafters.jnbt.NBTInputStream;
|
||||
import com.intellectualcrafters.jnbt.NBTOutputStream;
|
||||
import com.intellectualcrafters.jnbt.ShortTag;
|
||||
import com.intellectualcrafters.jnbt.StringTag;
|
||||
import com.intellectualcrafters.jnbt.Tag;
|
||||
import com.intellectualcrafters.json.JSONArray;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import com.plotsquared.object.schematic.StateWrapper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -29,31 +54,6 @@ import java.util.UUID;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellectualcrafters.jnbt.ByteArrayTag;
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.jnbt.IntTag;
|
||||
import com.intellectualcrafters.jnbt.ListTag;
|
||||
import com.intellectualcrafters.jnbt.NBTInputStream;
|
||||
import com.intellectualcrafters.jnbt.NBTOutputStream;
|
||||
import com.intellectualcrafters.jnbt.ShortTag;
|
||||
import com.intellectualcrafters.jnbt.StringTag;
|
||||
import com.intellectualcrafters.jnbt.Tag;
|
||||
import com.intellectualcrafters.json.JSONArray;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import com.plotsquared.object.schematic.StateWrapper;
|
||||
|
||||
public abstract class SchematicHandler {
|
||||
public static SchematicHandler manager;
|
||||
|
||||
@ -85,9 +85,9 @@ public abstract class SchematicHandler {
|
||||
}
|
||||
final String name;
|
||||
if (namingScheme == null) {
|
||||
name = plot.id.x + ";" + plot.id.y + "," + plot.world + "," + o;
|
||||
name = plot.getId().x + ";" + plot.getId().y + "," + plot.world + "," + o;
|
||||
} else {
|
||||
name = namingScheme.replaceAll("%owner%", o).replaceAll("%id%", plot.id.toString()).replaceAll("%idx%", plot.id.x + "").replaceAll("%idy%", plot.id.y + "")
|
||||
name = namingScheme.replaceAll("%owner%", o).replaceAll("%id%", plot.getId().toString()).replaceAll("%idx%", plot.getId().x + "").replaceAll("%idy%", plot.getId().y + "")
|
||||
.replaceAll("%world%", plot.world);
|
||||
}
|
||||
final String directory;
|
||||
@ -97,21 +97,21 @@ public abstract class SchematicHandler {
|
||||
directory = outputDir.getPath();
|
||||
}
|
||||
final Runnable THIS = this;
|
||||
SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal<CompoundTag>() {
|
||||
SchematicHandler.manager.getCompoundTag(plot.world, plot.getId(), new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (value == null) {
|
||||
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id);
|
||||
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.getId());
|
||||
} else {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(null, "&6ID: " + plot.id);
|
||||
MainUtil.sendMessage(null, "&6ID: " + plot.getId());
|
||||
final boolean result = SchematicHandler.manager.save(value, directory + File.separator + name + ".schematic");
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.id);
|
||||
MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.getId());
|
||||
} else {
|
||||
MainUtil.sendMessage(null, "&7 - &a success: " + plot.id);
|
||||
MainUtil.sendMessage(null, "&7 - &a success: " + plot.getId());
|
||||
}
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
@ -346,14 +346,12 @@ public abstract class SchematicHandler {
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
TaskManager.runTask(whenDone);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -6,6 +6,7 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -97,6 +98,6 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||
}
|
||||
|
||||
public static UUID getUUIDOf(String name) throws Exception {
|
||||
return new UUIDFetcher(Arrays.asList(name)).call().get(name);
|
||||
return new UUIDFetcher(Collections.singletonList(name)).call().get(name);
|
||||
}
|
||||
}
|
@ -2,21 +2,13 @@ package com.plotsquared.bukkit.chat;
|
||||
|
||||
import static com.plotsquared.bukkit.chat.TextualComponent.rawText;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.intellectualcrafters.configuration.serialization.ConfigurationSerializable;
|
||||
import com.intellectualcrafters.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.Achievement;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -28,13 +20,21 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.intellectualcrafters.configuration.serialization.ConfigurationSerializable;
|
||||
import com.intellectualcrafters.configuration.serialization.ConfigurationSerialization;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Represents a formattable message. Such messages can use elements such as colors, formatting codes, hover and click data, and other features provided by the vanilla Minecraft <a href="http://minecraft.gamepedia.com/Tellraw#Raw_JSON_Text">JSON message formatter</a>.
|
||||
@ -61,7 +61,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
@Override
|
||||
public FancyMessage clone() throws CloneNotSupportedException {
|
||||
final FancyMessage instance = (FancyMessage) super.clone();
|
||||
instance.messageParts = new ArrayList<MessagePart>(messageParts.size());
|
||||
instance.messageParts = new ArrayList<>(messageParts.size());
|
||||
for (int i = 0; i < messageParts.size(); i++) {
|
||||
instance.messageParts.add(i, messageParts.get(i).clone());
|
||||
}
|
||||
@ -79,7 +79,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
}
|
||||
|
||||
public FancyMessage(final TextualComponent firstPartText) {
|
||||
messageParts = new ArrayList<MessagePart>();
|
||||
messageParts = new ArrayList<>();
|
||||
messageParts.add(new MessagePart(firstPartText));
|
||||
jsonString = null;
|
||||
dirty = false;
|
||||
@ -503,9 +503,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
* @return This builder instance.
|
||||
*/
|
||||
public FancyMessage translationReplacements(final FancyMessage... replacements) {
|
||||
for (final FancyMessage str : replacements) {
|
||||
latest().translationReplacements.add(str);
|
||||
}
|
||||
Collections.addAll(latest().translationReplacements, replacements);
|
||||
|
||||
dirty = true;
|
||||
|
||||
@ -742,7 +740,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
// Doc copied from interface
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("messageParts", messageParts);
|
||||
// map.put("JSON", toJSONString());
|
||||
return map;
|
||||
@ -791,7 +789,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
// Deserialize text
|
||||
if (TextualComponent.isTextKey(entry.getKey())) {
|
||||
// The map mimics the YAML serialization, which has a "key" field and one or more "value" fields
|
||||
final Map<String, Object> serializedMapForm = new HashMap<String, Object>(); // Must be object due to Bukkit serializer API compliance
|
||||
final Map<String, Object> serializedMapForm = new HashMap<>(); // Must be object due to Bukkit serializer API compliance
|
||||
serializedMapForm.put("key", entry.getKey());
|
||||
if (entry.getValue().isJsonPrimitive()) {
|
||||
// Assume string
|
||||
|
@ -1,18 +1,17 @@
|
||||
package com.plotsquared.bukkit.database.plotme;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.intellectualcrafters.configuration.file.FileConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
public abstract class APlotMeConnector {
|
||||
public abstract Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder);
|
||||
@ -42,15 +41,12 @@ public abstract class APlotMeConnector {
|
||||
final String wallblock = plotConfig.getString("worlds." + world + ".WallBlockId"); //
|
||||
PS.get().config.set("worlds." + actualWorldName + ".wall.block", wallblock);
|
||||
final String floor = plotConfig.getString("worlds." + world + ".PlotFloorBlockId"); //
|
||||
PS.get().config.set("worlds." + actualWorldName + ".plot.floor", Arrays.asList(floor));
|
||||
PS.get().config.set("worlds." + actualWorldName + ".plot.floor", Collections.singletonList(floor));
|
||||
final String filling = plotConfig.getString("worlds." + world + ".PlotFillingBlockId"); //
|
||||
PS.get().config.set("worlds." + actualWorldName + ".plot.filling", Arrays.asList(filling));
|
||||
PS.get().config.set("worlds." + actualWorldName + ".plot.filling", Collections.singletonList(filling));
|
||||
final String road = plotConfig.getString("worlds." + world + ".RoadMainBlockId");
|
||||
PS.get().config.set("worlds." + actualWorldName + ".road.block", road);
|
||||
Integer height = plotConfig.getInt("worlds." + world + ".RoadHeight"); //
|
||||
if (height == null) {
|
||||
height = 64;
|
||||
}
|
||||
PS.get().config.set("worlds." + actualWorldName + ".road.height", height);
|
||||
}
|
||||
|
||||
|
@ -123,9 +123,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
e.printStackTrace();
|
||||
owner = UUID.nameUUIDFromBytes(bytes);
|
||||
}
|
||||
if (owner != null) {
|
||||
UUIDHandler.add(new StringWrapper(name), owner);
|
||||
}
|
||||
UUIDHandler.add(new StringWrapper(name), owner);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -166,13 +164,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
|
||||
r.close();
|
||||
stmt.close();
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
PS.log(" - " + prefix + "Denied");
|
||||
stmt = connection.prepareStatement("SELECT * FROM `" + prefix + "Denied`");
|
||||
r = stmt.executeQuery();
|
||||
|
||||
|
||||
while (r.next()) {
|
||||
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||
final String name = r.getString("player");
|
||||
@ -195,9 +193,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
e.printStackTrace();
|
||||
denied = UUID.nameUUIDFromBytes(bytes);
|
||||
}
|
||||
if (denied != null) {
|
||||
UUIDHandler.add(new StringWrapper(name), denied);
|
||||
}
|
||||
UUIDHandler.add(new StringWrapper(name), denied);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -213,10 +209,10 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
plots.get(world).get(id).getDenied().add(denied);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "Allowed`");
|
||||
r = stmt.executeQuery();
|
||||
|
||||
|
||||
while (r.next()) {
|
||||
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||
final String name = r.getString("player");
|
||||
@ -239,9 +235,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
e.printStackTrace();
|
||||
helper = UUID.nameUUIDFromBytes(bytes);
|
||||
}
|
||||
if (helper != null) {
|
||||
UUIDHandler.add(new StringWrapper(name), helper);
|
||||
}
|
||||
UUIDHandler.add(new StringWrapper(name), helper);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -257,11 +251,12 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
plots.get(world).get(id).getTrusted().add(helper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
r.close();
|
||||
stmt.close();
|
||||
|
||||
} catch (final Exception e) {}
|
||||
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
return plots;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ import java.nio.file.Paths;
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
@ -51,7 +52,9 @@ import com.plotsquared.bukkit.generator.HybridGen;
|
||||
|
||||
/**
|
||||
* Created 2014-08-17 for PlotSquared
|
||||
*
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class LikePlotMeConverter {
|
||||
private final String plugin;
|
||||
@ -128,7 +131,8 @@ public class LikePlotMeConverter {
|
||||
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
|
||||
content = content.replaceAll(plugin, "PlotSquared");
|
||||
Files.write(path, content.getBytes(charset));
|
||||
} catch (final Exception e) {}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean run(final APlotMeConnector connector) {
|
||||
@ -210,7 +214,7 @@ public class LikePlotMeConverter {
|
||||
pathwidth = 7;
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".road.width", pathwidth);
|
||||
|
||||
|
||||
Integer pathheight = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if ((pathheight == null) || (pathheight == 0)) {
|
||||
pathheight = 64;
|
||||
@ -232,21 +236,21 @@ public class LikePlotMeConverter {
|
||||
if (floor == null) {
|
||||
floor = "2";
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
|
||||
PS.get().config.set("worlds." + world + ".plot.floor", Collections.singletonList(floor));
|
||||
String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); //
|
||||
if (filling == null) {
|
||||
filling = "3";
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
|
||||
PS.get().config.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
|
||||
String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock");
|
||||
if (road == null) {
|
||||
road = "5";
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".road.block", road);
|
||||
Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if ((height == null) || (height == 0)) {
|
||||
if (height == 0) {
|
||||
height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
|
||||
if ((height == null) || (height == 0)) {
|
||||
if (height == 0) {
|
||||
height = 64;
|
||||
}
|
||||
}
|
||||
@ -255,12 +259,13 @@ public class LikePlotMeConverter {
|
||||
PS.get().config.set("worlds." + actualWorldName + ".wall.height", height);
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
}
|
||||
} catch (final Exception e) {}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
for (final String world : plots.keySet()) {
|
||||
int duplicate = 0;
|
||||
for (final Plot plot : plots.get(world).values()) {
|
||||
if (PS.get().getPlot(world, plot.id) == null) {
|
||||
if (PS.get().getPlot(world, plot.getId()) == null) {
|
||||
createdPlots.add(plot);
|
||||
} else {
|
||||
duplicate++;
|
||||
|
@ -136,8 +136,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
final Plot plot = entry.getValue();
|
||||
final HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.world);
|
||||
if (mergeMap != null) {
|
||||
if (mergeMap.containsKey(plot.id)) {
|
||||
plot.setMerged(mergeMap.get(plot.id));
|
||||
if (mergeMap.containsKey(plot.getId())) {
|
||||
plot.setMerged(mergeMap.get(plot.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -188,7 +188,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
map = new HashMap<>();
|
||||
processed.put(plot.world, map);
|
||||
}
|
||||
map.put(plot.id, plot);
|
||||
map.put(plot.getId(), plot);
|
||||
}
|
||||
return processed;
|
||||
}
|
||||
|
@ -20,15 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.generator;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotManager;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
@ -36,12 +27,22 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* The default generator is very messy, as we have decided to try externalize all calculations from within the loop. -
|
||||
* You will see a lot of slower implementations have a single for loop. - This is perfectly fine to do, it will just
|
||||
* mean world generation may take somewhat longer
|
||||
*
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class HybridGen extends BukkitPlotGenerator {
|
||||
|
||||
@ -120,7 +121,7 @@ public class HybridGen extends BukkitPlotGenerator {
|
||||
biome = Biome.valueOf(this.plotworld.PLOT_BIOME);
|
||||
try {
|
||||
maxY = Bukkit.getWorld(plotworld.worldname).getMaxHeight();
|
||||
} catch (final NullPointerException e) {}
|
||||
} catch (final NullPointerException ignored) {}
|
||||
if (maxY == 0) {
|
||||
maxY = 256;
|
||||
}
|
||||
@ -176,7 +177,7 @@ public class HybridGen extends BukkitPlotGenerator {
|
||||
public List<BukkitPlotPopulator> getPopulators(final String world) {
|
||||
// You can have as many populators as you would like, e.g. tree
|
||||
// populator, ore populator
|
||||
return Arrays.asList((BukkitPlotPopulator) new HybridPop(plotworld));
|
||||
return Collections.singletonList((BukkitPlotPopulator) new HybridPop(plotworld));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,6 +293,5 @@ public class HybridGen extends BukkitPlotGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,9 @@ import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
|
||||
/**
|
||||
* Player Events involving plots
|
||||
*
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation", "unchecked" })
|
||||
public class PlayerEvents extends com.plotsquared.listener.PlotListener implements Listener {
|
||||
@ -593,7 +595,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
final String message = event.getMessage();
|
||||
String format = C.PLOT_CHAT_FORMAT.s();
|
||||
final String sender = event.getPlayer().getDisplayName();
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id = plot.getId();
|
||||
final Set<Player> recipients = event.getRecipients();
|
||||
recipients.clear();
|
||||
for (final Player p : Bukkit.getOnlinePlayers()) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.plotsquared.bukkit.listeners.worldedit;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
@ -35,16 +36,16 @@ public class WEListener implements Listener {
|
||||
public final HashSet<String> rad2 = new HashSet<>(Arrays.asList("fill", "fillr", "removenear", "remove"));
|
||||
public final HashSet<String> rad2_1 = new HashSet<>(Arrays.asList("hcyl", "cyl"));
|
||||
public final HashSet<String> rad2_2 = new HashSet<>(Arrays.asList("sphere", "pyramid"));
|
||||
public final HashSet<String> rad2_3 = new HashSet<>(Arrays.asList("brush smooth"));
|
||||
public final HashSet<String> rad3_1 = new HashSet<>(Arrays.asList("brush gravity"));
|
||||
public final HashSet<String> rad2_3 = new HashSet<>(Collections.singletonList("brush smooth"));
|
||||
public final HashSet<String> rad3_1 = new HashSet<>(Collections.singletonList("brush gravity"));
|
||||
public final HashSet<String> rad3_2 = new HashSet<>(Arrays.asList("brush sphere", "brush cylinder"));
|
||||
|
||||
public final HashSet<String> region = new HashSet<>(Arrays.asList("move", "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "naturalize", "paste", "count", "distr",
|
||||
"regen", "copy", "cut", "green", "setbiome"));
|
||||
public final HashSet<String> regionExtend = new HashSet<>(Arrays.asList("stack"));
|
||||
public final HashSet<String> regionExtend = new HashSet<>(Collections.singletonList("stack"));
|
||||
public final HashSet<String> unregioned = new HashSet<>(Arrays.asList("paste", "redo", "undo", "rotate", "flip", "generate", "schematic", "schem"));
|
||||
public final HashSet<String> unsafe1 = new HashSet<>(Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks"));
|
||||
public final HashSet<String> restricted = new HashSet<>(Arrays.asList("up"));
|
||||
public final HashSet<String> restricted = new HashSet<>(Collections.singletonList("up"));
|
||||
public final HashSet<String> other = new HashSet<>(Arrays.asList("undo", "redo"));
|
||||
|
||||
public boolean checkCommand(final List<String> list, final String cmd) {
|
||||
@ -137,11 +138,9 @@ public class WEListener implements Listener {
|
||||
final long volume = Math.abs((pos1.getBlockX() - pos2.getBlockX()) * (pos1.getBlockY() - pos2.getBlockY()) * (pos1.getBlockZ() - pos2.getBlockZ())) * modifier;
|
||||
return checkVolume(pp, volume, max, e);
|
||||
}
|
||||
|
||||
private final boolean set = false;
|
||||
|
||||
|
||||
public boolean delay(final Player player, final String command, final boolean delayed) {
|
||||
if (!Settings.QUEUE_COMMANDS || !Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT || set) {
|
||||
if (!Settings.QUEUE_COMMANDS || !Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
|
||||
return false;
|
||||
}
|
||||
final boolean free = SetBlockQueue.addNotify(null);
|
||||
|
@ -1,13 +1,25 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.BlockUpdateUtil;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||
import com.plotsquared.bukkit.object.entity.EntityWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.DyeColor;
|
||||
@ -43,26 +55,13 @@ import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.BlockUpdateUtil;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||
import com.plotsquared.bukkit.object.entity.EntityWrapper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class BukkitChunkManager extends ChunkManager {
|
||||
@Override
|
||||
@ -83,7 +82,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
// Chunk chunk = worldObj.getChunkAt(loc.x, loc.z);
|
||||
worldObj.regenerateChunk(loc.x, loc.z);
|
||||
if (BlockUpdateUtil.setBlockManager != null) {
|
||||
BlockUpdateUtil.setBlockManager.update(world, Arrays.asList(loc));
|
||||
BlockUpdateUtil.setBlockManager.update(world, Collections.singletonList(loc));
|
||||
}
|
||||
for (final Player player : worldObj.getPlayers()) {
|
||||
final org.bukkit.Location locObj = player.getLocation();
|
||||
@ -854,8 +853,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
|
||||
@Override
|
||||
public boolean loadChunk(final String world, final ChunkLoc loc, final boolean force) {
|
||||
boolean result = BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
|
||||
return result;
|
||||
return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -902,10 +900,8 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
BukkitSetBlockManager.setBlockManager.set(world2, xx, y, zz, 0, (byte) 0);
|
||||
}
|
||||
} else if (id2 == 0) {
|
||||
if (id1 != 0) {
|
||||
BukkitSetBlockManager.setBlockManager.set(world1, x, y, z, 0, (byte) 0);
|
||||
BukkitSetBlockManager.setBlockManager.set(world2, xx, y, zz, id1, data1);
|
||||
}
|
||||
BukkitSetBlockManager.setBlockManager.set(world1, x, y, z, 0, (byte) 0);
|
||||
BukkitSetBlockManager.setBlockManager.set(world2, xx, y, zz, id1, data1);
|
||||
} else if (id1 == id2) {
|
||||
if (data1 != data2) {
|
||||
block1.setData(data2);
|
||||
@ -948,8 +944,8 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
final int[] count = new int[6];
|
||||
final World world = BukkitUtil.getWorld(plot.world);
|
||||
|
||||
final Location bot = MainUtil.getPlotBottomLocAbs(plot.world, plot.id);
|
||||
final Location top = MainUtil.getPlotTopLocAbs(plot.world, plot.id);
|
||||
final Location bot = MainUtil.getPlotBottomLocAbs(plot.world, plot.getId());
|
||||
final Location top = MainUtil.getPlotTopLocAbs(plot.world, plot.getId());
|
||||
final int bx = bot.getX() >> 4;
|
||||
final int bz = bot.getZ() >> 4;
|
||||
|
||||
@ -985,7 +981,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
count(count, entity);
|
||||
} else {
|
||||
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(loc));
|
||||
if (plot.id.equals(id)) {
|
||||
if (plot.getId().equals(id)) {
|
||||
count(count, entity);
|
||||
}
|
||||
}
|
||||
@ -999,7 +995,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
for (final Entity entity : ents) {
|
||||
if ((X == bx) || (X == tx) || (Z == bz) || (Z == tz)) {
|
||||
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity));
|
||||
if (plot.id.equals(id)) {
|
||||
if (plot.getId().equals(id)) {
|
||||
count(count, entity);
|
||||
}
|
||||
} else {
|
||||
@ -1169,7 +1165,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
restoreEntities(world, 0, 0);
|
||||
}
|
||||
MainUtil.update(world.getName(), chunkLoc);
|
||||
BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
|
||||
BukkitSetBlockManager.setBlockManager.update(Collections.singletonList(chunk));
|
||||
CURRENT_PLOT_CLEAR = null;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
@ -54,19 +55,19 @@ public class BukkitEconHandler extends EconHandler {
|
||||
public double getMoney(final PlotPlayer player) {
|
||||
final double bal = super.getMoney(player);
|
||||
if (Double.isNaN(bal)) {
|
||||
return econ.getBalance(player.getName());
|
||||
return econ.getBalance(((BukkitPlayer)player).player);
|
||||
}
|
||||
return bal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void withdrawMoney(final PlotPlayer player, final double amount) {
|
||||
econ.withdrawPlayer(player.getName(), amount);
|
||||
econ.withdrawPlayer(((BukkitPlayer)player).player, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void depositMoney(final PlotPlayer player, final double amount) {
|
||||
econ.depositPlayer(player.getName(), amount);
|
||||
econ.depositPlayer(((BukkitPlayer)player).player, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,7 +11,7 @@ public class BukkitTaskManager extends TaskManager {
|
||||
return BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, r, interval, interval);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation") @Override
|
||||
public int taskRepeatAsync(final Runnable r, final int interval) {
|
||||
return BukkitMain.THIS.getServer().getScheduler().scheduleAsyncRepeatingTask(BukkitMain.THIS, r, interval, interval);
|
||||
}
|
||||
|
@ -24,10 +24,8 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
|
||||
|
||||
public LowerOfflineUUIDWrapper() {
|
||||
try {
|
||||
getOnline = Server.class.getMethod("getOnlinePlayers", new Class[0]);
|
||||
} catch (final NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (final SecurityException e) {
|
||||
getOnline = Server.class.getMethod("getOnlinePlayers");
|
||||
} catch (final NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -73,7 +71,8 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
|
||||
@Override
|
||||
public Player[] getOnlinePlayers() {
|
||||
if (getOnline == null) {
|
||||
return Bukkit.getOnlinePlayers().toArray(new Player[0]);
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
try {
|
||||
final Object players = getOnline.invoke(Bukkit.getServer(), arg);
|
||||
@ -82,12 +81,13 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
final Collection<? extends Player> p = (Collection<? extends Player>) players;
|
||||
return p.toArray(new Player[0]);
|
||||
return p.toArray(new Player[p.size()]);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
PS.debug("Failed to resolve online players");
|
||||
getOnline = null;
|
||||
return Bukkit.getOnlinePlayers().toArray(new Player[0]);
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,8 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
public OfflineUUIDWrapper() {
|
||||
try {
|
||||
getOnline = Server.class.getMethod("getOnlinePlayers", new Class[0]);
|
||||
} catch (final NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (final SecurityException e) {
|
||||
getOnline = Server.class.getMethod("getOnlinePlayers");
|
||||
} catch (final NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -72,7 +70,8 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
public Player[] getOnlinePlayers() {
|
||||
if (getOnline == null) {
|
||||
return Bukkit.getOnlinePlayers().toArray(new Player[0]);
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
try {
|
||||
final Object players = getOnline.invoke(Bukkit.getServer(), arg);
|
||||
@ -81,12 +80,13 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
final Collection<? extends Player> p = (Collection<? extends Player>) players;
|
||||
return p.toArray(new Player[0]);
|
||||
return p.toArray(new Player[p.size()]);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
PS.debug("Failed to resolve online players");
|
||||
getOnline = null;
|
||||
return Bukkit.getOnlinePlayers().toArray(new Player[0]);
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,5 @@
|
||||
package com.plotsquared.bukkit.uuid;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -29,6 +12,22 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
|
||||
@ -220,7 +219,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
connection.setUseCaches(false);
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
String body = JSONArray.toJSONString(Arrays.asList(name));
|
||||
String body = JSONArray.toJSONString(Collections.singletonList(name));
|
||||
OutputStream stream = connection.getOutputStream();
|
||||
stream.write(body.getBytes());
|
||||
stream.flush();
|
||||
|
@ -24,7 +24,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
@ -46,7 +45,9 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
|
||||
*/
|
||||
public class PlotListener {
|
||||
|
||||
@ -55,7 +56,7 @@ public class PlotListener {
|
||||
return false;
|
||||
}
|
||||
final Plot last = (Plot) pp.getMeta("lastplot");
|
||||
if ((last != null) && !last.id.equals(plot.id)) {
|
||||
if ((last != null) && !last.getId().equals(plot.getId())) {
|
||||
plotExit(pp, last);
|
||||
}
|
||||
pp.setMeta("lastplot", MainUtil.getPlot(plot));
|
||||
@ -103,7 +104,7 @@ public class PlotListener {
|
||||
if (!Permissions.hasPermission(pp, "plots.gamemode.bypass")) {
|
||||
pp.setGamemode((PlotGamemode) gamemodeFlag.getValue());
|
||||
} else {
|
||||
MainUtil.sendMessage(pp, StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.id, "{gamemode}", gamemodeFlag.getValue()));
|
||||
MainUtil.sendMessage(pp, StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.getId(), "{gamemode}", gamemodeFlag.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,10 +164,10 @@ public class PlotListener {
|
||||
@Override
|
||||
public void run() {
|
||||
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||
if ((lastPlot != null) && plot.id.equals(lastPlot.id)) {
|
||||
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) {
|
||||
final Map<String, String> replacements = new HashMap<>();
|
||||
replacements.put("%x%", lastPlot.id.x + "");
|
||||
replacements.put("%z%", lastPlot.id.y + "");
|
||||
replacements.put("%x%", lastPlot.getId().x + "");
|
||||
replacements.put("%z%", lastPlot.getId().y + "");
|
||||
replacements.put("%world%", plot.world);
|
||||
replacements.put("%greeting%", greeting);
|
||||
replacements.put("%alias", plot.toString());
|
||||
@ -188,7 +189,7 @@ public class PlotListener {
|
||||
pp.deleteMeta("lastplot");
|
||||
EventUtil.manager.callLeave(pp, plot);
|
||||
if (plot.hasOwner()) {
|
||||
final PlotWorld pw = PS.get().getPlotWorld(pp.getLocation().getWorld());
|
||||
final PlotWorld pw = plot.getWorld();
|
||||
if (pw == null) {
|
||||
return true;
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ public class MainListener {
|
||||
// - Getting displayname currently causes NPE, so wait until sponge fixes that
|
||||
|
||||
final String sender = player.getName();
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id = plot.getId();
|
||||
final String newMessage = StringMan.replaceAll(C.PLOT_CHAT_FORMAT.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
||||
final Text forcedMessage = event.getMessage();
|
||||
// String forcedMessage = StringMan.replaceAll(C.PLOT_CHAT_FORCED.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
||||
@ -811,7 +811,7 @@ public class MainListener {
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if ((lastPlot != null) && id.equals(lastPlot.id)) {
|
||||
} else if ((lastPlot != null) && id.equals(lastPlot.getId())) {
|
||||
return;
|
||||
} else {
|
||||
final Plot plot = MainUtil.getPlot(worldname, id);
|
||||
@ -873,7 +873,7 @@ public class MainListener {
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if ((lastPlot != null) && id.equals(lastPlot.id)) {
|
||||
} else if ((lastPlot != null) && id.equals(lastPlot.getId())) {
|
||||
return;
|
||||
} else {
|
||||
final Plot plot = MainUtil.getPlot(worldname, id);
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.plotsquared.sponge.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import org.spongepowered.api.command.CommandCallable;
|
||||
import org.spongepowered.api.command.CommandException;
|
||||
import org.spongepowered.api.command.CommandResult;
|
||||
@ -14,10 +12,11 @@ import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.text.Texts;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeCommand implements CommandCallable {
|
||||
|
||||
@ -42,7 +41,7 @@ public class SpongeCommand implements CommandCallable {
|
||||
@Override
|
||||
public List<String> getSuggestions(final CommandSource cmd, final String string) throws CommandException {
|
||||
// TODO Auto-generated method stub
|
||||
return new ArrayList<>(Arrays.asList("TEST"));
|
||||
return new ArrayList<>(Collections.singletonList("TEST"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,16 +1,16 @@
|
||||
package com.plotsquared.sponge.uuid;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.profile.GameProfile;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.profile.GameProfile;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
@ -75,7 +75,8 @@ public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
||||
}
|
||||
|
||||
public Player[] getOnlinePlayers() {
|
||||
return SpongeMain.THIS.getServer().getOnlinePlayers().toArray(new Player[0]);
|
||||
Collection<Player> onlinePlayers = SpongeMain.THIS.getServer().getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user