Update README / pom / merge with 8629c4a6f5

closes #809
This commit is contained in:
Jesse Boyd 2016-01-11 07:00:56 +11:00
parent 00b6158181
commit af79100f7d
79 changed files with 946 additions and 939 deletions

View File

@ -17,8 +17,8 @@ is to provide a lag-free and smooth experience.
### Developer Resources ### Developer Resources
* *Outdated* [JavaDocs](http://empcraft.com/plotsquared/doc/) * *Outdated* [JavaDocs](http://empcraft.com/plotsquared/doc/)
* [~~Build Server~~](http://ci.intellectualsites.com/job/PlotSquared/) * [~~Build Server~~](http://ci.xephi.fr/job/PlotSquared/)
* [~~Maven Repo~~](http://mvn.intellectualsites.com/content/repositories/intellectualsites/) * [~~Maven Repo~~](http://ci.xephi.fr/plugin/repository/everything/)
# Maven # Maven
@ -27,13 +27,13 @@ We're now on maven!
<!-- Repository --> <!-- Repository -->
<repository> <repository>
<id>intellectualsites</id> <id>intellectualsites</id>
<url>http://mvn.intellectualsites.com/content/repositories/intellectualsites/</url> <url>http://ci.xephi.fr/plugin/repository/everything/</url>
</repository> </repository>
<!-- Dependency --> <!-- Dependency -->
<dependency> <dependency>
<groupId>com.intellectualcrafters</groupId> <groupId>com.intellectualcrafters</groupId>
<artifactId>PlotSquared</artifactId> <artifactId>PlotSquared</artifactId>
<version>2.12.9</version> <version>3.2.24</version>
</dependency> </dependency>
``` ```

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<artifactId>PlotSquared</artifactId> <artifactId>PlotSquared</artifactId>
<version>3.2.24</version> <version>3.2.25</version>
<name>PlotSquared</name> <name>PlotSquared</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>
@ -164,11 +164,6 @@
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>me.confuser</groupId>
<artifactId>BarAPI</artifactId>
<version>2.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId> <artifactId>commons-math3</artifactId>

View File

@ -11,7 +11,7 @@ import java.util.Set;
* A type of {@link ConfigurationSection} that is stored in memory. * A type of {@link ConfigurationSection} that is stored in memory.
*/ */
public class MemorySection implements ConfigurationSection { 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 Configuration root;
private final ConfigurationSection parent; private final ConfigurationSection parent;
private final String path; private final String path;
@ -24,7 +24,8 @@ public class MemorySection implements ConfigurationSection {
if (obj instanceof String) { if (obj instanceof String) {
try { try {
return Double.parseDouble((String) obj); return Double.parseDouble((String) obj);
} catch (final Exception e) {} } catch (NumberFormatException ignored) {
}
} else if (obj instanceof List) { } else if (obj instanceof List) {
final List<?> val = ((List<?>) obj); final List<?> val = ((List<?>) obj);
if (val.size() > 0) { if (val.size() > 0) {
@ -41,7 +42,8 @@ public class MemorySection implements ConfigurationSection {
if (obj instanceof String) { if (obj instanceof String) {
try { try {
return Integer.parseInt((String) obj); return Integer.parseInt((String) obj);
} catch (final Exception e) {} } catch (NumberFormatException ignored) {
}
} else if (obj instanceof List) { } else if (obj instanceof List) {
final List<?> val = ((List<?>) obj); final List<?> val = ((List<?>) obj);
if (val.size() > 0) { if (val.size() > 0) {
@ -58,7 +60,8 @@ public class MemorySection implements ConfigurationSection {
if (obj instanceof String) { if (obj instanceof String) {
try { try {
return Long.parseLong((String) obj); return Long.parseLong((String) obj);
} catch (final Exception e) {} } catch (NumberFormatException ignored) {
}
} else if (obj instanceof List) { } else if (obj instanceof List) {
final List<?> val = ((List<?>) obj); final List<?> val = ((List<?>) obj);
if (val.size() > 0) { if (val.size() > 0) {
@ -119,7 +122,7 @@ public class MemorySection implements ConfigurationSection {
@Override @Override
public Set<String> getKeys(final boolean deep) { public Set<String> getKeys(final boolean deep) {
final Set<String> result = new LinkedHashSet<String>(); final Set<String> result = new LinkedHashSet<>();
final Configuration root = getRoot(); final Configuration root = getRoot();
if ((root != null) && root.options().copyDefaults()) { if ((root != null) && root.options().copyDefaults()) {
@ -137,7 +140,7 @@ public class MemorySection implements ConfigurationSection {
@Override @Override
public Map<String, Object> getValues(final boolean deep) { 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(); final Configuration root = getRoot();
if ((root != null) && root.options().copyDefaults()) { if ((root != null) && root.options().copyDefaults()) {
@ -462,10 +465,10 @@ public class MemorySection implements ConfigurationSection {
final List<?> list = getList(path); final List<?> list = getList(path);
if (list == null) { 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) { for (final Object object : list) {
if ((object instanceof String) || (isPrimitiveWrapper(object))) { if ((object instanceof String) || (isPrimitiveWrapper(object))) {
@ -481,10 +484,10 @@ public class MemorySection implements ConfigurationSection {
final List<?> list = getList(path); final List<?> list = getList(path);
if (list == null) { 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) { for (final Object object : list) {
if (object instanceof Integer) { if (object instanceof Integer) {
@ -492,9 +495,10 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) { } else if (object instanceof String) {
try { try {
result.add(Integer.valueOf((String) object)); result.add(Integer.valueOf((String) object));
} catch (final Exception ex) {} } catch (NumberFormatException ignored) {
}
} else if (object instanceof Character) { } else if (object instanceof Character) {
result.add((int) ((Character) object).charValue()); result.add((int) (Character) object);
} else if (object instanceof Number) { } else if (object instanceof Number) {
result.add(((Number) object).intValue()); result.add(((Number) object).intValue());
} }
@ -508,10 +512,10 @@ public class MemorySection implements ConfigurationSection {
final List<?> list = getList(path); final List<?> list = getList(path);
if (list == null) { 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) { for (final Object object : list) {
if (object instanceof Boolean) { if (object instanceof Boolean) {
@ -533,10 +537,10 @@ public class MemorySection implements ConfigurationSection {
final List<?> list = getList(path); final List<?> list = getList(path);
if (list == null) { 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) { for (final Object object : list) {
if (object instanceof Double) { if (object instanceof Double) {
@ -544,9 +548,10 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) { } else if (object instanceof String) {
try { try {
result.add(Double.valueOf((String) object)); result.add(Double.valueOf((String) object));
} catch (final Exception ex) {} } catch (NumberFormatException ignored) {
}
} else if (object instanceof Character) { } else if (object instanceof Character) {
result.add((double) ((Character) object).charValue()); result.add((double) (Character) object);
} else if (object instanceof Number) { } else if (object instanceof Number) {
result.add(((Number) object).doubleValue()); result.add(((Number) object).doubleValue());
} }
@ -560,10 +565,10 @@ public class MemorySection implements ConfigurationSection {
final List<?> list = getList(path); final List<?> list = getList(path);
if (list == null) { 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) { for (final Object object : list) {
if (object instanceof Float) { if (object instanceof Float) {
@ -571,9 +576,10 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) { } else if (object instanceof String) {
try { try {
result.add(Float.valueOf((String) object)); result.add(Float.valueOf((String) object));
} catch (final Exception ex) {} } catch (NumberFormatException ignored) {
}
} else if (object instanceof Character) { } else if (object instanceof Character) {
result.add((float) ((Character) object).charValue()); result.add((float) (Character) object);
} else if (object instanceof Number) { } else if (object instanceof Number) {
result.add(((Number) object).floatValue()); result.add(((Number) object).floatValue());
} }
@ -587,10 +593,10 @@ public class MemorySection implements ConfigurationSection {
final List<?> list = getList(path); final List<?> list = getList(path);
if (list == null) { 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) { for (final Object object : list) {
if (object instanceof Long) { if (object instanceof Long) {
@ -598,9 +604,10 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) { } else if (object instanceof String) {
try { try {
result.add(Long.valueOf((String) object)); result.add(Long.valueOf((String) object));
} catch (final Exception ex) {} } catch (NumberFormatException ignored) {
}
} else if (object instanceof Character) { } else if (object instanceof Character) {
result.add((long) ((Character) object).charValue()); result.add((long) (Character) object);
} else if (object instanceof Number) { } else if (object instanceof Number) {
result.add(((Number) object).longValue()); result.add(((Number) object).longValue());
} }
@ -614,10 +621,10 @@ public class MemorySection implements ConfigurationSection {
final List<?> list = getList(path); final List<?> list = getList(path);
if (list == null) { 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) { for (final Object object : list) {
if (object instanceof Byte) { if (object instanceof Byte) {
@ -625,7 +632,8 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) { } else if (object instanceof String) {
try { try {
result.add(Byte.valueOf((String) object)); result.add(Byte.valueOf((String) object));
} catch (final Exception ex) {} } catch (NumberFormatException ignored) {
}
} else if (object instanceof Character) { } else if (object instanceof Character) {
result.add((byte) ((Character) object).charValue()); result.add((byte) ((Character) object).charValue());
} else if (object instanceof Number) { } else if (object instanceof Number) {
@ -641,10 +649,10 @@ public class MemorySection implements ConfigurationSection {
final List<?> list = getList(path); final List<?> list = getList(path);
if (list == null) { 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) { for (final Object object : list) {
if (object instanceof Character) { if (object instanceof Character) {
@ -668,10 +676,10 @@ public class MemorySection implements ConfigurationSection {
final List<?> list = getList(path); final List<?> list = getList(path);
if (list == null) { 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) { for (final Object object : list) {
if (object instanceof Short) { if (object instanceof Short) {
@ -679,7 +687,8 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) { } else if (object instanceof String) {
try { try {
result.add(Short.valueOf((String) object)); result.add(Short.valueOf((String) object));
} catch (final Exception ex) {} } catch (NumberFormatException ignored) {
}
} else if (object instanceof Character) { } else if (object instanceof Character) {
result.add((short) ((Character) object).charValue()); result.add((short) ((Character) object).charValue());
} else if (object instanceof Number) { } else if (object instanceof Number) {
@ -693,7 +702,7 @@ public class MemorySection implements ConfigurationSection {
@Override @Override
public List<Map<?, ?>> getMapList(final String path) { public List<Map<?, ?>> getMapList(final String path) {
final List<?> list = getList(path); final List<?> list = getList(path);
final List<Map<?, ?>> result = new ArrayList<Map<?, ?>>(); final List<Map<?, ?>> result = new ArrayList<>();
if (list == null) { if (list == null) {
return result; return result;
@ -827,7 +836,6 @@ public class MemorySection implements ConfigurationSection {
final char separator = root.options().pathSeparator(); final char separator = root.options().pathSeparator();
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
if (section != null) {
for (ConfigurationSection parent = section; (parent != null) && (parent != relativeTo); parent = parent.getParent()) { for (ConfigurationSection parent = section; (parent != null) && (parent != relativeTo); parent = parent.getParent()) {
if (builder.length() > 0) { if (builder.length() > 0) {
builder.insert(0, separator); builder.insert(0, separator);
@ -835,7 +843,6 @@ public class MemorySection implements ConfigurationSection {
builder.insert(0, parent.getName()); builder.insert(0, parent.getName());
} }
}
if ((key != null) && (key.length() > 0)) { if ((key != null) && (key.length() > 0)) {
if (builder.length() > 0) { if (builder.length() > 0) {
@ -851,7 +858,7 @@ public class MemorySection implements ConfigurationSection {
@Override @Override
public String toString() { public String toString() {
final Configuration root = getRoot(); final Configuration root = getRoot();
return new StringBuilder().append(getClass().getSimpleName()).append("[path='").append(getCurrentPath()).append("', root='").append(root == null ? null : root.getClass().getSimpleName()) return getClass().getSimpleName() + "[path='" + getCurrentPath() + "', root='" + (root == null ? null : root.getClass().getSimpleName()) +
.append("']").toString(); "']";
} }
} }

View File

@ -1,5 +1,10 @@
package com.intellectualcrafters.configuration.file; 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.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -14,12 +19,6 @@ import java.io.Writer;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; 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 * This is a base class for all File based implementations of {@link
* Configuration} * Configuration}
@ -100,12 +99,9 @@ public abstract class FileConfiguration extends MemoryConfiguration {
final String data = saveToString(); final String data = saveToString();
final Writer writer = new OutputStreamWriter(new FileOutputStream(file), UTF8_OVERRIDE && !UTF_BIG ? StandardCharsets.UTF_8 : Charset.defaultCharset()); try (Writer writer = new OutputStreamWriter(new FileOutputStream(file),
UTF8_OVERRIDE && !UTF_BIG ? StandardCharsets.UTF_8 : Charset.defaultCharset())) {
try {
writer.write(data); writer.write(data);
} finally {
writer.close();
} }
} }
@ -212,19 +208,16 @@ public abstract class FileConfiguration extends MemoryConfiguration {
* @throws IllegalArgumentException thrown when reader is null * @throws IllegalArgumentException thrown when reader is null
*/ */
public void load(final Reader reader) throws IOException, InvalidConfigurationException { 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(); final StringBuilder builder = new StringBuilder();
try { try (BufferedReader input = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader)) {
String line; String line;
while ((line = input.readLine()) != null) { while ((line = input.readLine()) != null) {
builder.append(line); builder.append(line);
builder.append('\n'); builder.append('\n');
} }
} finally {
input.close();
} }
loadFromString(builder.toString()); loadFromString(builder.toString());

View File

@ -18,7 +18,6 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -385,15 +384,21 @@ public class PS {
* *
* @param plot Plot Object to update * @param plot Plot Object to update
*/ */
public void updatePlot(final Plot plot) { public boolean 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);
for (PlotPlayer pp : plot.getPlayersInPlot()) { for (PlotPlayer pp : plot.getPlayersInPlot()) {
pp.setMeta("lastplot", plot); 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); hardmax = Math.min(hardmax, max);
final Plot[] cache = new Plot[hardmax + 1]; 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<>(); final ArrayList<Plot> extra = new ArrayList<>();
for (final Plot plot : plots) { for (final Plot plot : plots) {
final int hash = MathMan.getPositiveId(plot.hashCode()); final int hash = MathMan.getPositiveId(plot.hashCode());
@ -643,7 +648,7 @@ public class PS {
} else { } else {
extra.add(plot); 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); extra.add(plot);
} else { } else {
overflow.add(plot); overflow.add(plot);
@ -651,15 +656,13 @@ public class PS {
} }
final Plot[] overflowArray = overflow.toArray(new Plot[overflow.size()]); final Plot[] overflowArray = overflow.toArray(new Plot[overflow.size()]);
sortPlotsByHash(overflowArray); 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) { for (final Plot plot : cache) {
if (plot != null) { if (plot != null) {
result.add(plot); result.add(plot);
} }
} }
for (final Plot plot : overflowArray) { Collections.addAll(result, overflowArray);
result.add(plot);
}
for (final Plot plot : extra) { for (final Plot plot : extra) {
result.add(plot); result.add(plot);
} }
@ -678,14 +681,13 @@ public class PS {
if (input instanceof ArrayList<?>) { if (input instanceof ArrayList<?>) {
list = (List<Plot>) input; list = (List<Plot>) input;
} else { } else {
list = new ArrayList<Plot>(input); list = new ArrayList<>(input);
} }
long min = Integer.MAX_VALUE; long min = Integer.MAX_VALUE;
long max = 0; long max = 0;
final int size = list.size(); final int size = list.size();
final int limit = Math.min(1048576, size * 2); final int limit = Math.min(1048576, size * 2);
for (int i = 0; i < size; i++) { for (final Plot plot : list) {
final Plot plot = list.get(i);
final long time = plot.getTimestamp(); final long time = plot.getTimestamp();
if (time < min) { if (time < min) {
min = time; min = time;
@ -701,8 +703,7 @@ public class PS {
if ((range > limit) && (size > 1024)) { if ((range > limit) && (size > 1024)) {
plots = new Plot[limit]; plots = new Plot[limit];
final int factor = (int) ((range / limit)); final int factor = (int) ((range / limit));
for (int i = 0; i < size; i++) { for (Plot plot : list) {
Plot plot = list.get(i);
int index = (int) (plot.getTimestamp() - min) / factor; int index = (int) (plot.getTimestamp() - min) / factor;
if (index < 0) { if (index < 0) {
index = 0; index = 0;
@ -730,7 +731,7 @@ public class PS {
} }
} }
} else if ((range < size) || (size < 1024)) { } 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>() { Collections.sort(result, new Comparator<Plot>() {
@Override @Override
public int compare(final Plot a, final Plot b) { public int compare(final Plot a, final Plot b) {
@ -745,8 +746,7 @@ public class PS {
return result; return result;
} else if (min != 0) { } else if (min != 0) {
plots = new Plot[(int) range]; plots = new Plot[(int) range];
for (int i = 0; i < size; i++) { for (Plot plot : list) {
Plot plot = list.get(i);
int index = (int) (plot.getTimestamp() - min); int index = (int) (plot.getTimestamp() - min);
if (index >= plots.length) { if (index >= plots.length) {
overflow.add(plot); overflow.add(plot);
@ -772,8 +772,7 @@ public class PS {
} }
} else { } else {
plots = new Plot[(int) range]; plots = new Plot[(int) range];
for (int i = 0; i < size; i++) { for (Plot plot : list) {
Plot plot = list.get(i);
int index = (int) (plot.getTimestamp()); int index = (int) (plot.getTimestamp());
if (index >= plots.length) { if (index >= plots.length) {
overflow.add(plot); overflow.add(plot);
@ -824,7 +823,7 @@ public class PS {
return result; return result;
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
final ArrayList<Plot> result = new ArrayList<Plot>(list); final ArrayList<Plot> result = new ArrayList<>(list);
Collections.sort(result, new Comparator<Plot>() { Collections.sort(result, new Comparator<Plot>() {
@Override @Override
public int compare(final Plot a, final Plot b) { public int compare(final Plot a, final Plot b) {
@ -848,10 +847,10 @@ public class PS {
public void sortPlotsByHash(final Plot[] input) { public void sortPlotsByHash(final Plot[] input) {
final List<Plot>[] bucket = new ArrayList[32]; final List<Plot>[] bucket = new ArrayList[32];
for (int i = 0; i < bucket.length; i++) { for (int i = 0; i < bucket.length; i++) {
bucket[i] = new ArrayList<Plot>(); bucket[i] = new ArrayList<>();
} }
boolean maxLength = false; boolean maxLength = false;
int tmp = -1, placement = 1; int tmp, placement = 1;
while (!maxLength) { while (!maxLength) {
maxLength = true; maxLength = true;
for (final Plot i : input) { for (final Plot i : input) {
@ -882,7 +881,7 @@ public class PS {
final int SIZE = 100; final int SIZE = 100;
final List<Plot>[] bucket = new ArrayList[SIZE]; final List<Plot>[] bucket = new ArrayList[SIZE];
for (int i = 0; i < bucket.length; i++) { for (int i = 0; i < bucket.length; i++) {
bucket[i] = new ArrayList<Plot>(); bucket[i] = new ArrayList<>();
} }
boolean maxLength = false; boolean maxLength = false;
int tmp = -1, placement = 1; int tmp = -1, placement = 1;
@ -907,7 +906,7 @@ public class PS {
} }
public enum SortType { 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 // group by world
// sort each // sort each
final HashMap<String, Collection<Plot>> map = new HashMap<>(); 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; int totalSize = 0;
for (final Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : this.plots.entrySet()) { for (final Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : this.plots.entrySet()) {
totalSize += entry.getValue().size(); totalSize += entry.getValue().size();
@ -955,7 +954,7 @@ public class PS {
return a.hashCode() - b.hashCode(); 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) { for (final String world : worlds) {
switch (type) { switch (type) {
case CREATION_DATE: case CREATION_DATE:
@ -1068,9 +1067,6 @@ public class PS {
return strings.toArray(new String[strings.size()]); 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 * Get a map of the plots for a world
* @param world * @param world
@ -1080,9 +1076,6 @@ public class PS {
public HashMap<PlotId, Plot> getPlots(final String world) { public HashMap<PlotId, Plot> getPlots(final String world) {
final ConcurrentHashMap<PlotId, Plot> myplots = plots.get(world); final ConcurrentHashMap<PlotId, Plot> myplots = plots.get(world);
if (myplots != null) { if (myplots != null) {
if (world == lastWorld) {
return new HashMap<>(lastMap);
}
return new HashMap<>(myplots); return new HashMap<>(myplots);
} }
return new HashMap<>(0); return new HashMap<>(0);
@ -1097,7 +1090,7 @@ public class PS {
return map.values(); return map.values();
} }
catch (Throwable e) {e.printStackTrace();} 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()) { for (Entry<PlotId, Plot> entry : map.entrySet()) {
toReturn.add(entry.getValue()); toReturn.add(entry.getValue());
} }
@ -1105,16 +1098,9 @@ public class PS {
} }
public Plot getPlot(final String world, final PlotId id) { public Plot getPlot(final String world, final PlotId id) {
if (world == lastWorld) { ConcurrentHashMap<PlotId, Plot> map = plots.get(world);
if (lastMap != null) { if (map != null) {
return lastMap.get(id); return map.get(id);
}
return null;
}
lastWorld = world;
lastMap = plots.get(world);
if (lastMap != null) {
return lastMap.get(id);
} }
return null; return null;
} }
@ -1336,12 +1322,14 @@ public class PS {
} }
case "f": case "f":
case "floor": { 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; break;
} }
case "m": case "m":
case "main": { 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; break;
} }
case "w": case "w":
@ -1968,6 +1956,7 @@ public class PS {
Settings.METRICS = config.getBoolean("metrics"); Settings.METRICS = config.getBoolean("metrics");
Settings.UPDATE_NOTIFICATIONS = config.getBoolean("update-notifications"); Settings.UPDATE_NOTIFICATIONS = config.getBoolean("update-notifications");
Settings.MERGE_REMOVES_ROADS = config.getBoolean("merge.remove-terrain"); Settings.MERGE_REMOVES_ROADS = config.getBoolean("merge.remove-terrain");
Settings.AUTO_PURGE = config.getBoolean("auto-purge", false);
} }
/** /**

View File

@ -21,17 +21,6 @@
package com.intellectualcrafters.plot.api; 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.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.MainCommand;
@ -53,6 +42,16 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.util.BukkitSetBlockManager; import com.plotsquared.bukkit.util.BukkitSetBlockManager;
import com.plotsquared.bukkit.util.BukkitUtil; 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 * PlotSquared API
@ -262,7 +261,7 @@ public class PlotAPI {
perms.add(c.s()); 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 * @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) { public void sendConsoleMessage(final String msg) {
PS.log(msg);; PS.log(msg);;
@ -553,9 +552,9 @@ public class PlotAPI {
*/ */
public Location[] getLocations(final Plot p) { public Location[] getLocations(final Plot p) {
return new Location[] { return new Location[] {
BukkitUtil.getLocation(MainUtil.getPlotBottomLocAbs(p.world, p.id).subtract(1, 0, 1)), BukkitUtil.getLocation(MainUtil.getPlotBottomLocAbs(p.world, p.getId()).subtract(1, 0, 1)),
BukkitUtil.getLocation(MainUtil.getPlotTopLocAbs(p.world, p.id)), BukkitUtil.getLocation(MainUtil.getPlotTopLocAbs(p.world, p.getId())),
BukkitUtil.getLocation(MainUtil.getPlotHome(p.world, p.id)) }; BukkitUtil.getLocation(MainUtil.getPlotHome(p.world, p.getId())) };
} }
/** /**
@ -569,7 +568,7 @@ public class PlotAPI {
* @see Plot * @see Plot
*/ */
public Location getHomeLocation(final Plot p) { 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 * @see Plot
*/ */
public Location getBottomLocation(final Plot p) { 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 * @see Plot
*/ */
public Location getTopLocation(final Plot p) { public Location getTopLocation(final Plot p) {
return BukkitUtil.getLocation(MainUtil.getPlotTopLocAbs(p.world, p.id)); return BukkitUtil.getLocation(MainUtil.getPlotTopLocAbs(p.world, p.getId()));
} }
/** /**

View File

@ -20,9 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Location; 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.Argument;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.UUID;
@CommandDeclaration( @CommandDeclaration(
command = "add", command = "add",
aliases = { "a" }, aliases = { "a" },
@ -87,7 +86,7 @@ public class Add extends SubCommand {
if (plot.removeTrusted(uuid)) { if (plot.removeTrusted(uuid)) {
plot.addMember(uuid); plot.addMember(uuid);
} else { } 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); MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
return false; return false;
} }

View File

@ -202,16 +202,12 @@ public class Auto extends SubCommand {
MainUtil.lastPlot.put(worldname, getNextPlot(getLastPlot(worldname), 1)); MainUtil.lastPlot.put(worldname, getNextPlot(getLastPlot(worldname), 1));
} }
} else { } else {
boolean lastPlot = true;
while (!br) { while (!br) {
final PlotId start = getNextPlot(getLastPlot(worldname), 1); final PlotId start = getNextPlot(getLastPlot(worldname), 1);
// Checking if the current set of plots is a viable option. // Checking if the current set of plots is a viable option.
MainUtil.lastPlot.put(worldname, start); MainUtil.lastPlot.put(worldname, start);
if (lastPlot) {}
if ((PS.get().getPlot(worldname, start) != null) && (PS.get().getPlot(worldname, start).owner != null)) { if ((PS.get().getPlot(worldname, start) != null) && (PS.get().getPlot(worldname, start).owner != null)) {
continue; continue;
} else {
lastPlot = false;
} }
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1); final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
if (MainUtil.canClaim(plr, worldname, start, end)) { if (MainUtil.canClaim(plr, worldname, start, end)) {

View File

@ -20,8 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import java.util.Set;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
@ -35,6 +33,8 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.Set;
@CommandDeclaration( @CommandDeclaration(
command = "buy", command = "buy",
aliases = { "b" }, aliases = { "b" },
@ -97,7 +97,7 @@ public class Buy extends SubCommand {
EconHandler.manager.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), price); EconHandler.manager.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), price);
final PlotPlayer owner = UUIDHandler.getPlayer(plot.owner); final PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
if (owner != null) { 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"); FlagManager.removePlotFlag(plot, "price");
} }

View File

@ -64,11 +64,11 @@ public class Claim extends SubCommand {
MainUtil.teleportPlayer(player, loc, plot); MainUtil.teleportPlayer(player, loc, plot);
} }
final String world = plot.world; final String world = plot.world;
final PlotWorld plotworld = PS.get().getPlotWorld(world); final PlotWorld plotworld = plot.getWorld();
final Plot plot2 = PS.get().getPlot(world, plot.id); final Plot plot2 = PS.get().getPlot(world, plot.getId());
if (plotworld.SCHEMATIC_ON_CLAIM) { if (plotworld.SCHEMATIC_ON_CLAIM) {
Schematic sch; Schematic sch;
if (schematic.equals("")) { if (schematic.isEmpty()) {
sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE); sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE);
} else { } else {
sch = SchematicHandler.manager.getSchematic(schematic); sch = SchematicHandler.manager.getSchematic(schematic);
@ -110,7 +110,7 @@ public class Claim extends SubCommand {
if (!MainUtil.canClaim(plr, plot)) { if (!MainUtil.canClaim(plr, plot)) {
return sendMessage(plr, C.PLOT_IS_CLAIMED); 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) { if ((EconHandler.manager != null) && world.USE_ECONOMY) {
final double cost = world.PLOT_PRICE; final double cost = world.PLOT_PRICE;
if (cost > 0d) { if (cost > 0d) {

View File

@ -114,7 +114,7 @@ public class Clear extends SubCommand {
} }
}; };
if (Settings.CONFIRM_CLEAR && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) { 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 { } else {
TaskManager.runTask(runnable); TaskManager.runTask(runnable);
} }

View File

@ -249,7 +249,7 @@ public class Cluster extends SubCommand {
return false; return false;
} }
} }
final PlotWorld plotworld = PS.get().getPlotWorld(plr.getLocation().getWorld()); final PlotWorld plotworld = plr.getLocation().getPlotWorld();
if (plotworld.TYPE == 2) { if (plotworld.TYPE == 2) {
final ArrayList<Plot> toRemove = new ArrayList<>(); final ArrayList<Plot> toRemove = new ArrayList<>();
for (final Plot plot : PS.get().getPlotsInWorld(plr.getLocation().getWorld())) { for (final Plot plot : PS.get().getPlotsInWorld(plr.getLocation().getWorld())) {

View File

@ -121,7 +121,7 @@ public class Condense extends SubCommand {
while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) { while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) {
final Plot plot = MainUtil.getPlotAbs(worldname, start); final Plot plot = MainUtil.getPlotAbs(worldname, start);
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
free.add(plot.id); free.add(plot.getId());
} }
start = Auto.getNextPlot(start, 1); 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) { public Set<PlotId> getPlots(final Collection<Plot> plots, final int radius) {
final HashSet<PlotId> outside = new HashSet<>(); final HashSet<PlotId> outside = new HashSet<>();
for (final Plot plot : plots) { for (final Plot plot : plots) {
if ((plot.id.x > radius) || (plot.id.x < -radius) || (plot.id.y > radius) || (plot.id.y < -radius)) { if ((plot.getId().x > radius) || (plot.getId().x < -radius) || (plot.getId().y > radius) || (plot.getId().y < -radius)) {
outside.add(plot.id); outside.add(plot.getId());
} }
} }
return outside; return outside;

View File

@ -20,7 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.HybridUtils;
@ -47,7 +46,7 @@ public class CreateRoadSchematic extends SubCommand {
if (plot == null) { if (plot == null) {
return sendMessage(player, C.NOT_IN_PLOT); 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); return sendMessage(player, C.NOT_IN_PLOT_WORLD);
} }
HybridUtils.manager.setupRoadSchematic(plot); HybridUtils.manager.setupRoadSchematic(plot);

View File

@ -1,11 +1,5 @@
package com.intellectualcrafters.plot.commands; 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.PS;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.database.MySQL; import com.intellectualcrafters.plot.database.MySQL;
@ -18,6 +12,12 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration; 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( @CommandDeclaration(
command = "database", command = "database",
aliases = { "convert" }, aliases = { "convert" },
@ -95,7 +95,7 @@ public class Database extends SubCommand {
for (final Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : map.entrySet()) { for (final Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : map.entrySet()) {
for (final Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) { for (final Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
final Plot plot = entry2.getValue(); 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); MainUtil.sendMessage(player, "Skipping duplicate plot: " + plot + " | id=" + plot.temp);
continue; continue;
} }

View File

@ -96,8 +96,8 @@ public class DebugClaimTest extends SubCommand {
final ArrayList<Plot> plots = new ArrayList<>(); final ArrayList<Plot> plots = new ArrayList<>();
for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) { for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
final Plot plot = MainUtil.getPlotAbs(world, id); final Plot plot = MainUtil.getPlotAbs(world, id);
if (PS.get().getPlot(world, plot.id) != null) { if (PS.get().getPlot(world, plot.getId()) != null) {
MainUtil.sendMessage(plr, " - &cDB Already contains: " + plot.id); MainUtil.sendMessage(plr, " - &cDB Already contains: " + plot.getId());
continue; continue;
} }
final Location loc = manager.getSignLoc(plotworld, plot); final Location loc = manager.getSignLoc(plotworld, plot);
@ -125,11 +125,11 @@ public class DebugClaimTest extends SubCommand {
uuid = UUIDHandler.getUUID(line, null); uuid = UUIDHandler.getUUID(line, null);
} }
if (uuid != null) { if (uuid != null) {
MainUtil.sendMessage(plr, " - &aFound plot: " + plot.id + " : " + line); MainUtil.sendMessage(plr, " - &aFound plot: " + plot.getId() + " : " + line);
plot.owner = uuid; plot.owner = uuid;
plots.add(plot); plots.add(plot);
} else { } else {
MainUtil.sendMessage(plr, " - &cInvalid playername: " + plot.id + " : " + line); MainUtil.sendMessage(plr, " - &cInvalid playername: " + plot.getId() + " : " + line);
} }
} }
} }

View File

@ -20,26 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; 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.google.common.io.Files;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; 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.Command;
import com.plotsquared.general.commands.CommandDeclaration; 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) @CommandDeclaration(command = "debugexec", permission = "plots.admin", description = "Mutli-purpose debug command", aliases = { "exec" }, category = CommandCategory.DEBUG)
public class DebugExec extends SubCommand { 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() + "):"); MainUtil.sendMessage(player, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):");
for (final Plot plot : ExpireManager.expiredPlots.get(args[1])) { 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; return true;
} }

View File

@ -47,7 +47,7 @@ public class DebugRoadRegen extends SubCommand {
public boolean onCommand(final PlotPlayer player, final String... args) { public boolean onCommand(final PlotPlayer player, final String... args) {
final Location loc = player.getLocation(); final Location loc = player.getLocation();
final String world = loc.getWorld(); final String world = loc.getWorld();
final PlotWorld plotworld = PS.get().getPlotWorld(world); final PlotWorld plotworld = loc.getPlotWorld();
if (!(plotworld instanceof HybridPlotWorld)) { if (!(plotworld instanceof HybridPlotWorld)) {
return sendMessage(player, C.NOT_IN_PLOT_WORLD); 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); 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"); MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads");
} else { } else {
final HybridPlotManager manager = (HybridPlotManager) PS.get().getPlotManager(world); final HybridPlotManager manager = (HybridPlotManager) PS.get().getPlotManager(world);
manager.createRoadEast(plotworld, plot); manager.createRoadEast(plotworld, plot);
manager.createRoadSouth(plotworld, plot); manager.createRoadSouth(plotworld, plot);
manager.createRoadSouthEast(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"); MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads");
} }
return true; return true;

View File

@ -20,9 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; 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.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
@ -36,6 +33,8 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.HashSet;
@CommandDeclaration( @CommandDeclaration(
command = "delete", command = "delete",
permission = "plots.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")) { if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
return !sendMessage(plr, C.NO_PLOT_PERMS); 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 HashSet<Plot> plots = MainUtil.getConnectedPlots(plot);
final Runnable run = new Runnable() { final Runnable run = new Runnable() {
@Override @Override
@ -93,7 +92,7 @@ public class Delete extends SubCommand {
} }
}; };
if (Settings.CONFIRM_DELETE && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) { 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 { } else {
TaskManager.runTask(run); TaskManager.runTask(run);
} }

View File

@ -48,7 +48,7 @@ public class Download extends SubCommand {
} }
plot.addRunning(); plot.addRunning();
MainUtil.sendMessage(plr, C.GENERATING_LINK); 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 @Override
public void run() { public void run() {
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {

View File

@ -94,17 +94,20 @@ public class Info extends SubCommand {
}; };
final UUID uuid = player.getUUID(); final UUID uuid = player.getUUID();
final String name = MainUtil.getName(plot.owner); final String name = MainUtil.getName(plot.owner);
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info", new String[] { inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info", "&cID: &6" + plot.getId().toString(),
"&cID: &6" + plot.getId().toString(),
"&cOwner: &6" + name, "&cOwner: &6" + name,
"&cAlias: &6" + plot.getAlias(), "&cAlias: &6" + plot.getAlias(),
"&cBiome: &6" + plot.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cBiome: &6" + plot.getBiome().replaceAll("_", "").toLowerCase(),
"&cCan Build: &6" + plot.isAdded(uuid), "&cCan Build: &6" + plot.isAdded(uuid),
"&cIs Denied: &6" + plot.isDenied(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, "&cTrusted", "&cAmount: &6" + plot.getTrusted().size(),
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" })); "&8Click to view a list of the trusted users"));
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, "&cMembers", "&cAmount: &6" + plot.getMembers().size(),
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" })); "&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(); inv.openInventory();
return true; return true;
} }
@ -118,7 +121,7 @@ public class Info extends SubCommand {
} }
// Unclaimed? // Unclaimed?
if (!hasOwner && !containsEveryone && !trustedEveryone) { 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; return true;
} }
String info = C.PLOT_INFO.s(); String info = C.PLOT_INFO.s();

View File

@ -40,7 +40,7 @@ public class Kick extends SubCommand {
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); 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); MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;
} }

View File

@ -20,12 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; 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.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.ConsolePlayer; 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.CommandHandlingOutput;
import com.plotsquared.general.commands.CommandManager; 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 * PlotSquared command class
* *
*/ */
public class MainCommand extends CommandManager<PlotPlayer> { public class MainCommand extends CommandManager<PlotPlayer> {
@ -325,9 +327,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
count += 5; count += 5;
} }
} }
for (String word : cmd.getDescription().split(" ")) { Collections.addAll(desc, cmd.getDescription().split(" "));
desc.add(word);
}
for (String arg : args) { for (String arg : args) {
if (perm.startsWith(arg)) { if (perm.startsWith(arg)) {
count++; count++;

View File

@ -20,10 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; 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.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
@ -38,6 +34,9 @@ import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.HashSet;
import java.util.UUID;
@CommandDeclaration( @CommandDeclaration(
command = "merge", command = "merge",
aliases = { "m" }, aliases = { "m" },
@ -79,7 +78,7 @@ public class Merge extends SubCommand {
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(plr, C.NOT_IN_PLOT);
} }
if ((plot == null) || !plot.hasOwner()) { if (!plot.hasOwner()) {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED); MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
return false; return false;
} }
@ -93,7 +92,7 @@ public class Merge extends SubCommand {
uuid = plot.owner; 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) { 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 + ""); sendMessage(plr, C.CANNOT_AFFORD_MERGE, plotworld.MERGE_PRICE + "");
return false; return false;
@ -164,7 +163,7 @@ public class Merge extends SubCommand {
MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
return true; 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)) { if (adjacent == null || !adjacent.hasOwner() || adjacent.getMerged((direction + 2) % 4) || adjacent.isOwner(uuid)) {
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE); MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
return false; return false;
@ -204,7 +203,7 @@ public class Merge extends SubCommand {
} }
}); });
} }
if (isOnline == false) { if (!isOnline) {
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE); MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
return false; return false;
} }

View File

@ -83,7 +83,7 @@ public class Owner extends SetCommand {
MainUtil.setSign(name, plot); MainUtil.setSign(name, plot);
MainUtil.sendMessage(plr, C.SET_OWNER); MainUtil.sendMessage(plr, C.SET_OWNER);
if (other != null) { 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; return true;
} }

View File

@ -85,8 +85,8 @@ public class Purge extends SubCommand {
return false; return false;
} }
final String worldname = args[1]; final String worldname = args[1];
if (!PS.get().getAllPlotsRaw().containsKey(worldname)) { if (!PS.get().isPlotWorld(worldname)) {
MainUtil.sendMessage(plr, "INVALID WORLD"); C.NOT_VALID_PLOT_WORLD.send(plr);
return false; return false;
} }
final String arg = args[0].toLowerCase(); final String arg = args[0].toLowerCase();
@ -116,7 +116,7 @@ public class Purge extends SubCommand {
if (plot.owner != null) { if (plot.owner != null) {
final String name = UUIDHandler.getName(plot.owner); final String name = UUIDHandler.getName(plot.owner);
if (name == null) { 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<>(); final Set<PlotId> ids = new HashSet<>();
for (final Plot plot : plots) { for (final Plot plot : plots) {
if (plot.owner == null) { if (plot.owner == null) {
ids.add(plot.id); ids.add(plot.getId());
} }
} }
final int length = ids.size(); 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<Plot> plots = PS.get().getPlots(worldname, uuid);
final Set<PlotId> ids = new HashSet<>(); final Set<PlotId> ids = new HashSet<>();
for (final Plot plot : plots) { for (final Plot plot : plots) {
ids.add(plot.id); ids.add(plot.getId());
} }
final int length = ids.size(); final int length = ids.size();
DBFunc.purge(worldname, ids); DBFunc.purge(worldname, ids);

View File

@ -54,7 +54,7 @@ public class RegenAllRoads extends SubCommand {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]"); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
return false; return false;
} }
} else { } else if (args.length != 1) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]"); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
return false; return false;
} }

View File

@ -50,7 +50,7 @@ public class Save extends SubCommand {
return false; return false;
} }
plot.addRunning(); plot.addRunning();
SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal<CompoundTag>() { SchematicHandler.manager.getCompoundTag(plot.world, plot.getId(), new RunnableVal<CompoundTag>() {
@Override @Override
public void run() { public void run() {
TaskManager.runTaskAsync(new Runnable() { 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]", ""); final String name = PS.get().IMP.getServerName().replaceAll("[^A-Za-z0-9]", "");
Location[] corners = MainUtil.getCorners(plot); Location[] corners = MainUtil.getCorners(plot);
final int size = (corners[1].getX() - corners[0].getX()) + 1; 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 world = plot.world.replaceAll("[^A-Za-z0-9]", "");
final String file = time + "_" + world + "_" + id.x + "_" + id.y + "_" + size + "_" + name; final String file = time + "_" + world + "_" + id.x + "_" + id.y + "_" + size + "_" + name;
final UUID uuid = plr.getUUID(); final UUID uuid = plr.getUUID();

View File

@ -20,11 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; 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.C;
import com.intellectualcrafters.plot.config.Configuration; import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.flag.AbstractFlag; 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.Command;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@CommandDeclaration( @CommandDeclaration(
command = "set", command = "set",
description = "Set a plot value", description = "Set a plot value",
@ -67,10 +66,9 @@ public class Set extends SubCommand {
@Override @Override
public boolean set(PlotPlayer plr, final Plot plot, String value) { public boolean set(PlotPlayer plr, final Plot plot, String value) {
final String world = plr.getLocation().getWorld(); final PlotWorld plotworld = plr.getLocation().getPlotWorld();
final PlotWorld plotworld = PS.get().getPlotWorld(world); final PlotManager manager = plr.getLocation().getPlotManager();
final PlotManager manager = PS.get().getPlotManager(world); final String[] components = manager.getPlotComponents(plotworld, plot.getId());
final String[] components = manager.getPlotComponents(plotworld, plot.id);
final boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(plr.getUUID()); final boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(plr.getUUID());
String[] args = value.split(" "); String[] args = value.split(" ");
@ -131,7 +129,7 @@ public class Set extends SubCommand {
} }
plot.addRunning(); plot.addRunning();
for (Plot current : MainUtil.getConnectedPlots(plot)) { 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); MainUtil.sendMessage(plr, C.GENERATING_COMPONENT);
SetBlockQueue.addNotify(new Runnable() { SetBlockQueue.addNotify(new Runnable() {
@ -149,11 +147,11 @@ public class Set extends SubCommand {
} }
public boolean noArgs(PlotPlayer plr) { 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")); newValues.addAll(Arrays.asList("biome", "alias", "home", "flag"));
Plot plot = plr.getCurrentPlot(); Plot plot = plr.getCurrentPlot();
if (plot != null) { 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())); MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringMan.join(newValues, C.BLOCK_LIST_SEPARATER.formatted()));
return false; return false;
@ -175,7 +173,7 @@ public class Set extends SubCommand {
return false; return false;
} }
// components // 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())) { if (components.contains(args[0].toLowerCase())) {
return component.onCommand(plr, Arrays.copyOfRange(args, 0, args.length)); return component.onCommand(plr, Arrays.copyOfRange(args, 0, args.length));
} }

View File

@ -20,11 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; 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.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.ConfigurationNode;
@ -38,6 +33,11 @@ import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map.Entry;
@CommandDeclaration( @CommandDeclaration(
command = "setup", command = "setup",
permission = "plots.admin.command.setup", permission = "plots.admin.command.setup",
@ -48,15 +48,15 @@ category = CommandCategory.ACTIONS)
public class Setup extends SubCommand { public class Setup extends SubCommand {
public void displayGenerators(final PlotPlayer plr) { public void displayGenerators(final PlotPlayer plr) {
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
message.append("&6What generator do you want?"); message.append("&6What generator do you want?");
for (final Entry<String, PlotGenerator<?>> entry : SetupUtils.generators.entrySet()) { for (final Entry<String, PlotGenerator<?>> entry : SetupUtils.generators.entrySet()) {
if (entry.getKey().equals("PlotSquared")) { 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()) { } 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 { } 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()); MainUtil.sendMessage(plr, message.toString());
@ -109,8 +109,9 @@ public class Setup extends SubCommand {
break; break;
} }
case 1: { // choose world type case 1: { // choose world type
final List<String> allTypes = Arrays.asList(new String[] { "default", "augmented", "partial" }); final List<String> allTypes = Arrays.asList("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> allDesc = Arrays.asList("Standard plot generation", "Plot generation with vanilla terrain",
"Vanilla with clusters of plots");
final ArrayList<String> types = new ArrayList<>(); final ArrayList<String> types = new ArrayList<>();
if (SetupUtils.generators.get(object.setupGenerator).isFull()) { if (SetupUtils.generators.get(object.setupGenerator).isFull()) {
types.add("default"); types.add("default");
@ -170,7 +171,7 @@ public class Setup extends SubCommand {
break; break;
} }
case 2: { // Choose terrain 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())) { if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) {
MainUtil.sendMessage(plr, "&cYou must choose the terrain!" MainUtil.sendMessage(plr, "&cYou must choose the terrain!"
+ "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &2NONE&8 - &7No terrain at all"

View File

@ -58,7 +58,7 @@ public class Target extends SubCommand {
closest = plot; closest = plot;
} }
} }
id = closest.id; id = closest.getId();
} else { } else {
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
return false; return false;

View File

@ -20,14 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; 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.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.ChunkLoc;
@ -42,6 +34,15 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration; 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( @CommandDeclaration(
command = "trim", command = "trim",
permission = "plots.admin", permission = "plots.admin",
@ -96,7 +97,8 @@ public class Trim extends SubCommand {
PS.debug("INVALID MCA: " + name); 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 Plot plot = plots.remove(0);
final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id); final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.getId());
final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.id); final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.getId());
final int ccx1 = (pos1.getX() >> 9); final int ccx1 = (pos1.getX() >> 9);
final int ccz1 = (pos1.getZ() >> 9); final int ccz1 = (pos1.getZ() >> 9);

View File

@ -20,9 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Location; 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.Argument;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.UUID;
@CommandDeclaration( @CommandDeclaration(
command = "trust", command = "trust",
aliases = { "t" }, aliases = { "t" },
@ -91,7 +90,7 @@ public class Trust extends SubCommand {
if (plot.removeMember(uuid)) { if (plot.removeMember(uuid)) {
plot.addTrusted(uuid); plot.addTrusted(uuid);
} else { } 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); MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
return false; return false;
} }

View File

@ -53,6 +53,7 @@ public class Unclaim extends SubCommand {
return !sendMessage(plr, C.NO_PLOT_PERMS); return !sendMessage(plr, C.NO_PLOT_PERMS);
} }
if (plot.unclaim()) { if (plot.unclaim()) {
plot.removeSign();
MainUtil.sendMessage(plr, C.UNCLAIM_SUCCESS); MainUtil.sendMessage(plr, C.UNCLAIM_SUCCESS);
} else { } else {
MainUtil.sendMessage(plr, C.UNCLAIM_FAILED); MainUtil.sendMessage(plr, C.UNCLAIM_FAILED);

View File

@ -62,7 +62,7 @@ public class Unlink extends SubCommand {
} }
}; };
if (Settings.CONFIRM_UNLINK && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) { 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 { } else {
TaskManager.runTask(runnable); TaskManager.runTask(runnable);
} }

View File

@ -20,14 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; 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.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot; 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.Argument;
import com.plotsquared.general.commands.CommandDeclaration; 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( @CommandDeclaration(
command = "visit", command = "visit",
permission = "plots.visit", permission = "plots.visit",
@ -93,7 +93,7 @@ public class Visit extends SubCommand {
} else { } else {
final Plot plot = MainUtil.getPlotFromString(player, args[0], true); final Plot plot = MainUtil.getPlotFromString(player, args[0], true);
if (plot != null) { if (plot != null) {
unsorted = new HashSet<>(Arrays.asList(plot.getBasePlot(false))); unsorted = new HashSet<>(Collections.singletonList(plot.getBasePlot(false)));
} }
} }
break; break;

View File

@ -36,7 +36,7 @@ public class WE_Anywhere extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer player, final String[] arguments) { 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");
} }
} }

View File

@ -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"); 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()) .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"); .color(color).text(" - ").color("$2");
String prefix = ""; String prefix = "";

View File

@ -32,9 +32,10 @@ public class plugin extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { 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&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, "$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, "$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&lNewest Version$2: $1" + (PS.get().update == null ? StringMan.join(PS.get().IMP.getPluginVersion(), ".") : PS.get().update));
return true; return true;
} }
} }

View File

@ -30,6 +30,7 @@ import java.util.List;
public class Settings { public class Settings {
public static boolean USE_SQLUUIDHANDLER = false; public static boolean USE_SQLUUIDHANDLER = false;
public static boolean AUTO_PURGE = false;
/** /**
* *
*/ */

View File

@ -40,6 +40,7 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
@ -392,8 +393,8 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void set(final PreparedStatement statement) throws SQLException { public void set(final PreparedStatement statement) throws SQLException {
statement.setString(1, uuid.toString()); statement.setString(1, uuid.toString());
statement.setInt(2, plot.id.x); statement.setInt(2, plot.getId().x);
statement.setInt(3, plot.id.y); statement.setInt(3, plot.getId().y);
statement.setString(4, plot.world); statement.setString(4, plot.world);
} }
@ -418,7 +419,7 @@ public class SQLManager implements AbstractDB {
// Creating datastructures // Creating datastructures
final HashMap<PlotId, Plot> plotMap = new HashMap<>(); final HashMap<PlotId, Plot> plotMap = new HashMap<>();
for (final Plot plot : myList) { for (final Plot plot : myList) {
plotMap.put(plot.id, plot); plotMap.put(plot.getId(), plot);
} }
final ArrayList<SettingsPair> settings = new ArrayList<>(); final ArrayList<SettingsPair> settings = new ArrayList<>();
final ArrayList<UUIDPair> helpers = new ArrayList<>(); final ArrayList<UUIDPair> helpers = new ArrayList<>();
@ -573,8 +574,8 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void setMySQL(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException { 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) + 1, plot.getId().x);
stmt.setInt((i * 5) + 2, plot.id.y); stmt.setInt((i * 5) + 2, plot.getId().y);
try { try {
stmt.setString((i * 5) + 3, plot.owner.toString()); stmt.setString((i * 5) + 3, plot.owner.toString());
} catch (final Exception e) { } catch (final Exception e) {
@ -587,8 +588,8 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void setSQLite(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException { public void setSQLite(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException {
stmt.setNull((i * 6) + 1, 4); stmt.setNull((i * 6) + 1, 4);
stmt.setInt((i * 6) + 2, plot.id.x); stmt.setInt((i * 6) + 2, plot.getId().x);
stmt.setInt((i * 6) + 3, plot.id.y); stmt.setInt((i * 6) + 3, plot.getId().y);
try { try {
stmt.setString((i * 6) + 4, plot.owner.toString()); stmt.setString((i * 6) + 4, plot.owner.toString());
} catch (final Exception e1) { } catch (final Exception e1) {
@ -600,8 +601,8 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void setSQL(final PreparedStatement stmt, final Plot plot) throws SQLException { public void setSQL(final PreparedStatement stmt, final Plot plot) throws SQLException {
stmt.setInt(1, plot.id.x); stmt.setInt(1, plot.getId().x);
stmt.setInt(2, plot.id.y); stmt.setInt(2, plot.getId().y);
stmt.setString(3, plot.owner.toString()); stmt.setString(3, plot.owner.toString());
stmt.setString(4, plot.world); stmt.setString(4, plot.world);
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp())); stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
@ -629,7 +630,7 @@ public class SQLManager implements AbstractDB {
try { try {
int count = 0; int count = 0;
PreparedStatement preparedStmt = null; PreparedStatement preparedStmt = null;
String statement = null; String statement;
int last = -1; int last = -1;
for (int j = 0; j <= amount; j++) { for (int j = 0; j <= amount; j++) {
final List<T> subList = objList.subList(j * packet, Math.min(size, (j + 1) * packet)); 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) { if (last == -1) {
last = subList.size(); last = subList.size();
statement = mod.getCreateMySQL(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))) { if ((subList.size() != last) || (((count % 5000) == 0) && (count > 0))) {
preparedStmt.executeBatch(); preparedStmt.executeBatch();
preparedStmt.close(); preparedStmt.close();
statement = mod.getCreateMySQL(subList.size()); statement = mod.getCreateMySQL(subList.size());
preparedStmt = connection.prepareStatement(statement.toString()); preparedStmt = connection.prepareStatement(statement);
} }
for (int i = 0; i < subList.size(); i++) { for (int i = 0; i < subList.size(); i++) {
count++; count++;
@ -672,7 +674,7 @@ public class SQLManager implements AbstractDB {
try { try {
int count = 0; int count = 0;
PreparedStatement preparedStmt = null; PreparedStatement preparedStmt = null;
String statement = null; String statement;
int last = -1; int last = -1;
for (int j = 0; j <= amount; j++) { for (int j = 0; j <= amount; j++) {
final List<T> subList = objList.subList(j * packet, Math.min(size, (j + 1) * packet)); 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) { if (last == -1) {
last = subList.size(); last = subList.size();
statement = mod.getCreateSQLite(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))) { if ((subList.size() != last) || (((count % 5000) == 0) && (count > 0))) {
preparedStmt.executeBatch(); preparedStmt.executeBatch();
preparedStmt.clearParameters(); preparedStmt.clearParameters();
statement = mod.getCreateSQLite(subList.size()); statement = mod.getCreateSQLite(subList.size());
preparedStmt = connection.prepareStatement(statement.toString()); preparedStmt = connection.prepareStatement(statement);
} }
for (int i = 0; i < subList.size(); i++) { for (int i = 0; i < subList.size(); i++) {
count++; count++;
@ -707,9 +709,9 @@ public class SQLManager implements AbstractDB {
PS.debug("&cERROR 2: " + " | " + objList.get(0).getClass().getCanonicalName()); PS.debug("&cERROR 2: " + " | " + objList.get(0).getClass().getCanonicalName());
PS.debug("&6[WARN] " + "Could not bulk save!"); PS.debug("&6[WARN] " + "Could not bulk save!");
try { try {
PreparedStatement preparedStmt = null; PreparedStatement preparedStmt;
final String nonBulk = mod.getCreateSQL(); final String nonBulk = mod.getCreateSQL();
preparedStmt = connection.prepareStatement(nonBulk.toString()); preparedStmt = connection.prepareStatement(nonBulk);
for (final T obj : objList) { for (final T obj : objList) {
try { try {
mod.setSQL(preparedStmt, obj); mod.setSQL(preparedStmt, obj);
@ -874,7 +876,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void setMySQL(final PreparedStatement stmt, final int i, final Integer id) throws SQLException { 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 @Override
@ -914,8 +916,8 @@ public class SQLManager implements AbstractDB {
addPlotTask(plot, new UniqueStatement("createPlot") { addPlotTask(plot, new UniqueStatement("createPlot") {
@Override @Override
public void set(final PreparedStatement stmt) throws SQLException { public void set(final PreparedStatement stmt) throws SQLException {
stmt.setInt(1, plot.id.x); stmt.setInt(1, plot.getId().x);
stmt.setInt(2, plot.id.y); stmt.setInt(2, plot.getId().y);
stmt.setString(3, plot.owner.toString()); stmt.setString(3, plot.owner.toString());
stmt.setString(4, plot.world); stmt.setString(4, plot.world);
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp())); stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
@ -947,8 +949,8 @@ public class SQLManager implements AbstractDB {
addPlotTask(plot, new UniqueStatement("createPlotAndSettings_" + plot.hashCode()) { addPlotTask(plot, new UniqueStatement("createPlotAndSettings_" + plot.hashCode()) {
@Override @Override
public void set(final PreparedStatement stmt) throws SQLException { public void set(final PreparedStatement stmt) throws SQLException {
stmt.setInt(1, plot.id.x); stmt.setInt(1, plot.getId().x);
stmt.setInt(2, plot.id.y); stmt.setInt(2, plot.getId().y);
stmt.setString(3, plot.owner.toString()); stmt.setString(3, plot.owner.toString());
stmt.setString(4, plot.world); stmt.setString(4, plot.world);
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp())); 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); // ResultSet set = meta.getTables(null, null, prefix + s, null);
if (!set.next()) { if (!set.next()) {
create++; create++;
} else {} }
set.close(); set.close();
} }
if (create == 0) { if (create == 0) {
@ -1397,8 +1399,8 @@ public class SQLManager implements AbstractDB {
return plot.temp; 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 = 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(1, plot.getId().x);
stmt.setInt(2, plot.id.y); stmt.setInt(2, plot.getId().y);
stmt.setString(3, plot.world); stmt.setString(3, plot.world);
final ResultSet r = stmt.executeQuery(); final ResultSet r = stmt.executeQuery();
int id = Integer.MAX_VALUE; 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 * Load all plots, helpers, denied, trusted, and every setting from DB into a hashmap
*/ */
@Override @Override
public ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> getPlots() { 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<>(); final HashMap<Integer, Plot> plots = new HashMap<>();
Statement stmt = null; Statement stmt;
try { try {
Set<String> worlds = new HashSet<>(); Set<String> worlds = new HashSet<>();
if (PS.get().config.contains("worlds")) { if (PS.get().config.contains("worlds")) {
worlds = PS.get().config.getConfigurationSection("worlds").getKeys(false); worlds = PS.get().config.getConfigurationSection("worlds").getKeys(false);
} }
final HashMap<String, UUID> uuids = new HashMap<String, UUID>(); final HashMap<String, UUID> uuids = new HashMap<>();
final HashMap<String, Integer> noExist = new HashMap<String, Integer>(); final HashMap<String, AtomicInteger> noExist = new HashMap<>();
PlotId plot_id; PlotId plot_id;
int id; int id;
@ -1530,15 +1567,22 @@ public class SQLManager implements AbstractDB {
*/ */
stmt = connection.createStatement(); stmt = connection.createStatement();
try (ResultSet r = stmt.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world`, `timestamp` FROM `" + prefix + "plot`")) { 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()) { while (r.next()) {
plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z")); plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
id = r.getInt("id"); id = r.getInt("id");
final String worldname = r.getString("world"); final String worldname = r.getString("world");
if (!worlds.contains(worldname)) { if (!worlds.contains(worldname)) {
if (noExist.containsKey(worldname)) { if (Settings.AUTO_PURGE) {
noExist.put(worldname, noExist.get(worldname) + 1); toDelete.add(id);
continue;
} else { } 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"); o = r.getString("owner");
@ -1550,7 +1594,8 @@ public class SQLManager implements AbstractDB {
Timestamp timestamp = null; Timestamp timestamp = null;
try { try {
timestamp = r.getTimestamp("timestamp"); timestamp = r.getTimestamp("timestamp");
} catch (final Exception e) {}; } catch (SQLException ignored) {
}
long time; long time;
if (timestamp == null) { if (timestamp == null) {
time = plot_id.hashCode(); time = plot_id.hashCode();
@ -1558,11 +1603,30 @@ public class SQLManager implements AbstractDB {
time = timestamp.getTime(); 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); 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); plots.put(id, p);
} }
deleteRows(toDelete, "plot", "id");
} }
if (Settings.CACHE_RATINGS) { if (Settings.CACHE_RATINGS) {
try (ResultSet r = stmt.executeQuery("SELECT `plot_plot_id`, `player`, `rating` FROM `" + prefix + "plot_rating`")) { try (ResultSet r = stmt.executeQuery("SELECT `plot_plot_id`, `player`, `rating` FROM `" + prefix + "plot_rating`")) {
ArrayList<Integer> toDelete = new ArrayList<>();
while (r.next()) { while (r.next()) {
id = r.getInt("plot_plot_id"); id = r.getInt("plot_plot_id");
o = r.getString("player"); o = r.getString("player");
@ -1574,13 +1638,16 @@ public class SQLManager implements AbstractDB {
final Plot plot = plots.get(id); final Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
if (plot.getSettings().ratings == 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")); plot.getSettings().ratings.put(user, r.getInt("rating"));
} else if (Settings.AUTO_PURGE) {
toDelete.add(id);
} else { } 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 * Getting helpers
*/ */
try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + prefix + "plot_helpers`")) { try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + prefix + "plot_helpers`")) {
ArrayList<Integer> toDelete = new ArrayList<>();
while (r.next()) { while (r.next()) {
id = r.getInt("plot_plot_id"); id = r.getInt("plot_plot_id");
o = r.getString("user_uuid"); o = r.getString("user_uuid");
@ -1599,16 +1667,20 @@ public class SQLManager implements AbstractDB {
final Plot plot = plots.get(id); final Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
plot.getTrusted().add(user); plot.getTrusted().add(user);
} else if (Settings.AUTO_PURGE) {
toDelete.add(id);
} else { } 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 * Getting trusted
*/ */
try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + prefix + "plot_trusted`")) { try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + prefix + "plot_trusted`")) {
ArrayList<Integer> toDelete = new ArrayList<>();
while (r.next()) { while (r.next()) {
id = r.getInt("plot_plot_id"); id = r.getInt("plot_plot_id");
o = r.getString("user_uuid"); o = r.getString("user_uuid");
@ -1620,16 +1692,20 @@ public class SQLManager implements AbstractDB {
final Plot plot = plots.get(id); final Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
plot.getMembers().add(user); plot.getMembers().add(user);
} else if (Settings.AUTO_PURGE) {
toDelete.add(id);
} else { } 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 * Getting denied
*/ */
try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + prefix + "plot_denied`")) { try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + prefix + "plot_denied`")) {
ArrayList<Integer> toDelete = new ArrayList<>();
while (r.next()) { while (r.next()) {
id = r.getInt("plot_plot_id"); id = r.getInt("plot_plot_id");
o = r.getString("user_uuid"); o = r.getString("user_uuid");
@ -1641,22 +1717,22 @@ public class SQLManager implements AbstractDB {
final Plot plot = plots.get(id); final Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
plot.getDenied().add(user); plot.getDenied().add(user);
} else if (Settings.AUTO_PURGE) {
toDelete.add(id);
} else { } 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`")) { try (ResultSet r = stmt.executeQuery("SELECT * FROM `" + prefix + "plot_settings`")) {
ArrayList<Integer> toDelete = new ArrayList<>();
while (r.next()) { while (r.next()) {
id = r.getInt("plot_plot_id"); id = r.getInt("plot_plot_id");
final Plot plot = plots.get(id); final Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
plots.remove(id); 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"); final String alias = r.getString("alias");
if (alias != null) { if (alias != null) {
plot.getSettings().setAlias(alias); plot.getSettings().setAlias(alias);
@ -1671,18 +1747,14 @@ public class SQLManager implements AbstractDB {
default: default:
try { try {
plot.getSettings().setPosition(BlockLoc.fromString(pos)); plot.getSettings().setPosition(BlockLoc.fromString(pos));
} catch (final Exception e) {} } catch (final Exception ignored) {}
} }
final Integer m = r.getInt("merged"); final Integer m = r.getInt("merged");
if (m != null) {
final boolean[] merged = new boolean[4]; final boolean[] merged = new boolean[4];
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
merged[3 - i] = ((m) & (1 << i)) != 0; merged[3 - i] = ((m) & (1 << i)) != 0;
} }
plot.getSettings().setMerged(merged); plot.getSettings().setMerged(merged);
} else {
plot.getSettings().setMerged(new boolean[] { false, false, false, false });
}
String[] flags_string; String[] flags_string;
final String myflags = r.getString("flags"); final String myflags = r.getString("flags");
if (myflags == null) { if (myflags == null) {
@ -1723,30 +1795,26 @@ public class SQLManager implements AbstractDB {
this.setFlags(plot, flags.values()); this.setFlags(plot, flags.values());
} }
plot.getSettings().flags = flags; plot.getSettings().flags = flags;
} else if (Settings.AUTO_PURGE) {
toDelete.add(id);
} else { } 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(); stmt.close();
deleteRows(toDelete, "plot_settings", "plot_plot_id");
} }
if (plots.entrySet().size() > 0) { 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()) { for (Entry<Integer, Plot> entry : plots.entrySet()) {
Plot plot = entry.getValue(); entry.getValue().getSettings();
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);
} }
} }
boolean invalidPlot = false; boolean invalidPlot = false;
for (final Entry<String, Integer> entry : noExist.entrySet()) { for (final Entry<String, AtomicInteger> entry : noExist.entrySet()) {
final String worldname = entry.getKey(); final String worldname = entry.getKey();
invalidPlot = true; 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) { if (invalidPlot) {
PS.debug("&c[WARNING] - Please create the world/s or remove the plots using the purge command"); 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") { addPlotTask(original, new UniqueStatement("movePlot") {
@Override @Override
public void set(final PreparedStatement stmt) throws SQLException { public void set(final PreparedStatement stmt) throws SQLException {
stmt.setInt(1, newPlot.id.x); stmt.setInt(1, newPlot.getId().x);
stmt.setInt(2, newPlot.id.y); stmt.setInt(2, newPlot.getId().y);
stmt.setString(3, newPlot.world); stmt.setString(3, newPlot.world);
stmt.setInt(4, getId(original)); stmt.setInt(4, getId(original));
} }
@ -1883,13 +1951,13 @@ public class SQLManager implements AbstractDB {
String stmt_prefix = ""; String stmt_prefix = "";
final StringBuilder idstr2 = new StringBuilder(""); final StringBuilder idstr2 = new StringBuilder("");
for (final Integer id : uniqueIds) { for (final Integer id : uniqueIds) {
idstr2.append(stmt_prefix + id); idstr2.append(stmt_prefix).append(id);
stmt_prefix = " OR `id` = "; stmt_prefix = " OR `id` = ";
} }
stmt_prefix = ""; stmt_prefix = "";
final StringBuilder idstr = new StringBuilder(""); final StringBuilder idstr = new StringBuilder("");
for (final Integer id : uniqueIds) { for (final Integer id : uniqueIds) {
idstr.append(stmt_prefix + id); idstr.append(stmt_prefix).append(id);
stmt_prefix = " OR `plot_plot_id` = "; stmt_prefix = " OR `plot_plot_id` = ";
} }
PreparedStatement stmt = connection.prepareStatement("DELETE FROM `" + prefix + "plot_helpers` WHERE `plot_plot_id` = " + idstr + ""); 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 { public void set(final PreparedStatement statement) throws SQLException {
if (plot != null) { if (plot != null) {
statement.setString(1, plot.world); statement.setString(1, plot.world);
statement.setInt(2, plot.id.hashCode()); statement.setInt(2, plot.getId().hashCode());
statement.setString(3, comment.comment); statement.setString(3, comment.comment);
statement.setString(4, comment.inbox); statement.setString(4, comment.inbox);
statement.setString(5, comment.senderName); statement.setString(5, comment.senderName);
@ -2004,7 +2072,7 @@ public class SQLManager implements AbstractDB {
public void set(final PreparedStatement statement) throws SQLException { public void set(final PreparedStatement statement) throws SQLException {
if (plot != null) { if (plot != null) {
statement.setString(1, plot.world); statement.setString(1, plot.world);
statement.setInt(2, plot.id.hashCode()); statement.setInt(2, plot.getId().hashCode());
statement.setString(3, inbox); statement.setString(3, inbox);
} else { } else {
statement.setString(1, inbox); statement.setString(1, inbox);
@ -2028,7 +2096,7 @@ public class SQLManager implements AbstractDB {
public void set(final PreparedStatement statement) throws SQLException { public void set(final PreparedStatement statement) throws SQLException {
if (plot != null) { if (plot != null) {
statement.setString(1, plot.world); statement.setString(1, plot.world);
statement.setInt(2, plot.id.hashCode()); statement.setInt(2, plot.getId().hashCode());
statement.setString(3, inbox); statement.setString(3, inbox);
} else { } else {
statement.setString(1, inbox); statement.setString(1, inbox);
@ -2048,7 +2116,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void addBatch(final PreparedStatement statement) throws SQLException { 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(); final ResultSet set = statement.executeQuery();
PlotComment comment; PlotComment comment;
while (set.next()) { while (set.next()) {
@ -2078,7 +2146,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void set(final PreparedStatement statement) throws SQLException { public void set(final PreparedStatement statement) throws SQLException {
statement.setString(1, plot.world); statement.setString(1, plot.world);
statement.setInt(2, plot.id.hashCode()); statement.setInt(2, plot.getId().hashCode());
statement.setString(3, comment.comment); statement.setString(3, comment.comment);
statement.setString(4, comment.inbox); statement.setString(4, comment.inbox);
statement.setInt(5, (int) (comment.timestamp / 1000)); statement.setInt(5, (int) (comment.timestamp / 1000));
@ -2190,7 +2258,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public HashMap<UUID, Integer> getRatings(final Plot plot) { 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 { try {
final PreparedStatement statement = connection.prepareStatement("SELECT `rating`, `player` FROM `" + prefix + "plot_rating` WHERE `plot_plot_id` = ? "); final PreparedStatement statement = connection.prepareStatement("SELECT `rating`, `player` FROM `" + prefix + "plot_rating` WHERE `plot_plot_id` = ? ");
statement.setInt(1, getId(plot)); statement.setInt(1, getId(plot));
@ -2285,8 +2353,8 @@ public class SQLManager implements AbstractDB {
if (PS.get().config.contains("worlds")) { if (PS.get().config.contains("worlds")) {
worlds = PS.get().config.getConfigurationSection("worlds").getKeys(false); worlds = PS.get().config.getConfigurationSection("worlds").getKeys(false);
} }
final HashMap<String, UUID> uuids = new HashMap<String, UUID>(); final HashMap<String, UUID> uuids = new HashMap<>();
final HashMap<String, Integer> noExist = new HashMap<String, Integer>(); final HashMap<String, Integer> noExist = new HashMap<>();
/* /*
* Getting clusters * Getting clusters
*/ */
@ -2381,15 +2449,11 @@ public class SQLManager implements AbstractDB {
} catch (final Exception e) {} } catch (final Exception e) {}
} }
final Integer m = r.getInt("merged"); final Integer m = r.getInt("merged");
if (m != null) {
final boolean[] merged = new boolean[4]; final boolean[] merged = new boolean[4];
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
merged[3 - i] = ((m) & (1 << i)) != 0; merged[3 - i] = ((m) & (1 << i)) != 0;
} }
cluster.settings.setMerged(merged); cluster.settings.setMerged(merged);
} else {
cluster.settings.setMerged(new boolean[] { false, false, false, false });
}
String[] flags_string; String[] flags_string;
final String myflags = r.getString("flags"); final String myflags = r.getString("flags");
if (myflags == null) { if (myflags == null) {
@ -2730,7 +2794,7 @@ public class SQLManager implements AbstractDB {
toCreate.add(plot); toCreate.add(plot);
continue; continue;
} }
final Plot dataplot = worldplots.remove(plot.id); final Plot dataplot = worldplots.remove(plot.getId());
if (dataplot == null) { if (dataplot == null) {
PS.debug("&8 - &7Creating plot (2): " + plot); PS.debug("&8 - &7Creating plot (2): " + plot);
toCreate.add(plot); toCreate.add(plot);
@ -2742,7 +2806,7 @@ public class SQLManager implements AbstractDB {
setOwner(plot, plot.owner); setOwner(plot, plot.owner);
} }
// trusted // 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> toAdd = (HashSet<UUID>) plot.getTrusted().clone();
final HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getTrusted().clone(); final HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getTrusted().clone();
toRemove.removeAll(plot.getTrusted()); 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> toAdd = (HashSet<UUID>) plot.getMembers().clone();
final HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getMembers().clone(); final HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getMembers().clone();
toRemove.removeAll(plot.getMembers()); 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> toAdd = (HashSet<UUID>) plot.getDenied().clone();
final HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getDenied().clone(); final HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getDenied().clone();
toRemove.removeAll(plot.getDenied()); toRemove.removeAll(plot.getDenied());
@ -2797,12 +2861,12 @@ public class SQLManager implements AbstractDB {
final PlotSettings ds = dataplot.getSettings(); final PlotSettings ds = dataplot.getSettings();
final boolean[] pm = ps.getMerged(); final boolean[] pm = ps.getMerged();
final boolean[] dm = ds.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); PS.debug("&8 - &7Correcting merge for: " + plot);
setMerged(dataplot, ps.getMerged()); setMerged(dataplot, ps.getMerged());
} }
final HashMap<String, Flag> pf = ps.flags; final HashMap<String, Flag> pf = plot.getFlags();
final HashMap<String, Flag> df = ds.flags; final HashMap<String, Flag> df = dataplot.getFlags();
if ((pf.size() != 0) && (df.size() != 0)) { if ((pf.size() != 0) && (df.size() != 0)) {
if ((pf.size() != df.size()) || !StringMan.isEqual(StringMan.joinOrdered(pf.values(), ","), StringMan.joinOrdered(df.values(), ","))) { if ((pf.size() != df.size()) || !StringMan.isEqual(StringMan.joinOrdered(pf.values(), ","), StringMan.joinOrdered(df.values(), ","))) {
PS.debug("&8 - &7Correcting flags for: " + plot); PS.debug("&8 - &7Correcting flags for: " + plot);

View File

@ -11,9 +11,9 @@ public abstract class StmtMod<T> {
public String getCreateMySQL(final int size, final String query, final int params) { public String getCreateMySQL(final int size, final String query, final int params) {
final StringBuilder statement = new StringBuilder(query); final StringBuilder statement = new StringBuilder(query);
for (int i = 0; i < (size - 1); i++) { 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(); return statement.toString();
} }

View File

@ -415,8 +415,7 @@ public class FlagManager {
*/ */
public static AbstractFlag getFlag(final String string, final boolean create) { public static AbstractFlag getFlag(final String string, final boolean create) {
if ((getFlag(string) == null) && create) { if ((getFlag(string) == null) && create) {
final AbstractFlag flag = new AbstractFlag(string); return new AbstractFlag(string);
return flag;
} }
return getFlag(string); return getFlag(string);
} }
@ -433,7 +432,7 @@ public class FlagManager {
} }
public static HashMap<String, Flag> parseFlags(final List<String> flagstrings) { 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) { for (final String key : flagstrings) {
final String[] split; final String[] split;
if (key.contains(";")) { if (key.contains(";")) {

View File

@ -1,7 +1,5 @@
package com.intellectualcrafters.plot.generator; package com.intellectualcrafters.plot.generator;
import java.util.ArrayList;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock; 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.MainUtil;
import com.intellectualcrafters.plot.util.SetBlockQueue; 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) * 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 @Override
public boolean unclaimPlot(final PlotWorld plotworld, final Plot plot, final Runnable whenDone) { public boolean unclaimPlot(final PlotWorld plotworld, final Plot plot, final Runnable whenDone) {
final ClassicPlotWorld dpw = ((ClassicPlotWorld) plotworld); 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)) { 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); SetBlockQueue.addNotify(whenDone);
return true; return true;
@ -84,7 +84,6 @@ public class ClassicPlotManager extends SquarePlotManager {
if (!plot.isBasePlot()) { if (!plot.isBasePlot()) {
return false; return false;
} }
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
for (RegionWrapper region : MainUtil.getRegions(plot)) { for (RegionWrapper region : MainUtil.getRegions(plot)) {
Location pos1 = new Location(plot.world, region.minX, 1, region.minZ); Location pos1 = new Location(plot.world, region.minX, 1, region.minZ);
Location pos2 = new Location(plot.world, region.maxX, 255, region.maxZ); Location pos2 = new Location(plot.world, region.maxX, 255, region.maxZ);
@ -271,8 +270,8 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override @Override
public boolean createRoadEast(final PlotWorld plotworld, final Plot plot) { public boolean createRoadEast(final PlotWorld plotworld, final Plot plot) {
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
final int sx = pos2.getX() + 1; final int sx = pos2.getX() + 1;
final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1;
final int sz = pos1.getZ() - 2; final int sz = pos1.getZ() - 2;
@ -293,8 +292,8 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override @Override
public boolean createRoadSouth(final PlotWorld plotworld, final Plot plot) { public boolean createRoadSouth(final PlotWorld plotworld, final Plot plot) {
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
final int sz = pos2.getZ() + 1; final int sz = pos2.getZ() + 1;
final int ez = (sz + dpw.ROAD_WIDTH) - 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1;
final int sx = pos1.getX() - 2; final int sx = pos1.getX() - 2;
@ -314,7 +313,7 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override @Override
public boolean createRoadSouthEast(final PlotWorld plotworld, final Plot plot) { public boolean createRoadSouthEast(final PlotWorld plotworld, final Plot plot) {
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; 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 sx = pos2.getX() + 1;
final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1;
final int sz = pos2.getZ() + 1; final int sz = pos2.getZ() + 1;
@ -329,8 +328,8 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override @Override
public boolean removeRoadEast(final PlotWorld plotworld, final Plot plot) { public boolean removeRoadEast(final PlotWorld plotworld, final Plot plot) {
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
final int sx = pos2.getX() + 1; final int sx = pos2.getX() + 1;
final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1;
final int sz = pos1.getZ() - 1; final int sz = pos1.getZ() - 1;
@ -344,8 +343,8 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override @Override
public boolean removeRoadSouth(final PlotWorld plotworld, final Plot plot) { public boolean removeRoadSouth(final PlotWorld plotworld, final Plot plot) {
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id); final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id); final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
final int sz = pos2.getZ() + 1; final int sz = pos2.getZ() + 1;
final int ez = (sz + dpw.ROAD_WIDTH) - 1; final int ez = (sz + dpw.ROAD_WIDTH) - 1;
final int sx = pos1.getX() - 1; final int sx = pos1.getX() - 1;
@ -359,7 +358,7 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override @Override
public boolean removeRoadSouthEast(final PlotWorld plotworld, final Plot plot) { public boolean removeRoadSouthEast(final PlotWorld plotworld, final Plot plot) {
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; 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 sx = loc.getX() + 1;
final int ex = (sx + dpw.ROAD_WIDTH) - 1; final int ex = (sx + dpw.ROAD_WIDTH) - 1;
final int sz = loc.getZ() + 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 unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
if ((claim.id != 0) || !claim.equals(unclaim)) { if ((claim.id != 0) || !claim.equals(unclaim)) {
setWall(plotworld, plot.id, new PlotBlock[] { claim }); setWall(plotworld, plot.getId(), new PlotBlock[] { claim });
} }
return true; return true;
} }

View File

@ -20,13 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.generator; 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.PS;
import com.intellectualcrafters.plot.commands.Template; import com.intellectualcrafters.plot.commands.Template;
import com.intellectualcrafters.plot.object.ChunkLoc; 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.MainUtil;
import com.intellectualcrafters.plot.util.SetBlockQueue; 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 { public class HybridPlotManager extends ClassicPlotManager {
@Override @Override
public void exportTemplate(final PlotWorld plotworld) throws IOException { 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 psRoot = PS.get().IMP.getDirectory() + File.separator;
final String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + 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; 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) { if (!hpw.ROAD_SCHEMATIC_ENABLED) {
return true; return true;
} }
final PlotId id = plot.id; final PlotId id = plot.getId();
final PlotId id2 = new PlotId(id.x + 1, id.y); final PlotId id2 = new PlotId(id.x + 1, id.y);
final Location bot = getPlotBottomLocAbs(hpw, id2); final Location bot = getPlotBottomLocAbs(hpw, id2);
final Location top = getPlotTopLocAbs(hpw, id); final Location top = getPlotTopLocAbs(hpw, id);
@ -133,7 +134,7 @@ public class HybridPlotManager extends ClassicPlotManager {
if (!hpw.ROAD_SCHEMATIC_ENABLED) { if (!hpw.ROAD_SCHEMATIC_ENABLED) {
return true; return true;
} }
final PlotId id = plot.id; final PlotId id = plot.getId();
final PlotId id2 = new PlotId(id.x, id.y + 1); final PlotId id2 = new PlotId(id.x, id.y + 1);
final Location bot = getPlotBottomLocAbs(hpw, id2); final Location bot = getPlotBottomLocAbs(hpw, id2);
final Location top = getPlotTopLocAbs(hpw, id); final Location top = getPlotTopLocAbs(hpw, id);
@ -150,7 +151,7 @@ public class HybridPlotManager extends ClassicPlotManager {
if (!hpw.ROAD_SCHEMATIC_ENABLED) { if (!hpw.ROAD_SCHEMATIC_ENABLED) {
return true; return true;
} }
final PlotId id = plot.id; final PlotId id = plot.getId();
final PlotId id2 = new PlotId(id.x + 1, id.y + 1); final PlotId id2 = new PlotId(id.x + 1, id.y + 1);
final Location pos1 = getPlotTopLocAbs(hpw, id).add(1, 0, 1); final Location pos1 = getPlotTopLocAbs(hpw, id).add(1, 0, 1);
final Location pos2 = getPlotBottomLocAbs(hpw, id2); final Location pos2 = getPlotBottomLocAbs(hpw, id2);
@ -171,7 +172,7 @@ public class HybridPlotManager extends ClassicPlotManager {
final String world = plotworld.worldname; final String world = plotworld.worldname;
final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld); 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); final Location pos2 = MainUtil.getPlotTopLoc_(plot);
// If augmented // If augmented
final boolean canRegen = (plotworld.TYPE == 0) && (plotworld.TERRAIN == 0); final boolean canRegen = (plotworld.TYPE == 0) && (plotworld.TERRAIN == 0);

View File

@ -1,16 +1,5 @@
package com.intellectualcrafters.plot.generator; 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.jnbt.CompoundTag;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; 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.SetBlockQueue;
import com.intellectualcrafters.plot.util.TaskManager; 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 abstract class HybridUtils {
public static HybridUtils manager; public static HybridUtils manager;
@ -113,7 +113,7 @@ public abstract class HybridUtils {
public static boolean UPDATE = false; public static boolean UPDATE = false;
public final ArrayList<ChunkLoc> getChunks(final ChunkLoc region) { 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 sx = region.x << 5;
final int sz = region.z << 5; final int sz = region.z << 5;
for (int x = sx; x < (sx + 32); x++) { for (int x = sx; x < (sx + 32); x++) {
@ -133,7 +133,7 @@ public abstract class HybridUtils {
if (whenDone == null) { if (whenDone == null) {
return; return;
} }
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world); final PlotWorld plotworld = plot.getWorld();
if (!(plotworld instanceof ClassicPlotWorld)) { if (!(plotworld instanceof ClassicPlotWorld)) {
whenDone.value = -1; whenDone.value = -1;
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
@ -185,14 +185,14 @@ public abstract class HybridUtils {
public boolean scheduleRoadUpdate(final String world, final Set<ChunkLoc> rgs, final int extend) { public boolean scheduleRoadUpdate(final String world, final Set<ChunkLoc> rgs, final int extend) {
HybridUtils.regions = rgs; HybridUtils.regions = rgs;
HybridUtils.world = world; HybridUtils.world = world;
chunks = new HashSet<ChunkLoc>(); chunks = new HashSet<>();
final AtomicInteger count = new AtomicInteger(0); final AtomicInteger count = new AtomicInteger(0);
final long baseTime = System.currentTimeMillis(); final long baseTime = System.currentTimeMillis();
final AtomicInteger last = new AtomicInteger(); final AtomicInteger last = new AtomicInteger();
TaskManager.runTask(new Runnable() { TaskManager.runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
if (UPDATE == false) { if (!UPDATE) {
last.set(0); last.set(0);
Iterator<ChunkLoc> iter = chunks.iterator(); Iterator<ChunkLoc> iter = chunks.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
@ -212,7 +212,6 @@ public abstract class HybridUtils {
HybridUtils.UPDATE = false; HybridUtils.UPDATE = false;
PS.debug(C.PREFIX.s() + "Finished road conversion"); PS.debug(C.PREFIX.s() + "Finished road conversion");
// CANCEL TASK // CANCEL TASK
return;
} else { } else {
final Runnable task = this; final Runnable task = this;
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@ -298,8 +297,8 @@ public abstract class HybridUtils {
public boolean setupRoadSchematic(final Plot plot) { public boolean setupRoadSchematic(final Plot plot) {
final String world = plot.world; final String world = plot.world;
final Location bot = MainUtil.getPlotBottomLocAbs(world, plot.id).subtract(1, 0, 1); final Location bot = MainUtil.getPlotBottomLocAbs(world, plot.getId()).subtract(1, 0, 1);
final Location top = MainUtil.getPlotTopLocAbs(world, plot.id); final Location top = MainUtil.getPlotTopLocAbs(world, plot.getId());
final HybridPlotWorld plotworld = (HybridPlotWorld) PS.get().getPlotWorld(world); final HybridPlotWorld plotworld = (HybridPlotWorld) PS.get().getPlotWorld(world);
final int sx = (bot.getX() - plotworld.ROAD_WIDTH) + 1; final int sx = (bot.getX() - plotworld.ROAD_WIDTH) + 1;
final int sz = bot.getZ() + 1; final int sz = bot.getZ() + 1;
@ -307,20 +306,13 @@ public abstract class HybridUtils {
final int ex = bot.getX(); final int ex = bot.getX();
final int ez = top.getZ(); final int ez = top.getZ();
final int ey = get_ey(world, sx, ex, sz, ez, sy); 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 bz = sz - plotworld.ROAD_WIDTH;
final int by = sy;
final int tx = ex;
final int tz = sz - 1; 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> sideroad = new HashSet<>(Collections.singletonList(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 Set<RegionWrapper> intersection = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ty, bz, tz)));
final Location pos3 = new Location(world, bx, by, bz);
final Location pos4 = new Location(world, tx, ty, tz);
final String dir = PS.get().IMP.getDirectory() + File.separator + "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.world + File.separator; 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>() { SchematicHandler.manager.getCompoundTag(world, sideroad, new RunnableVal<CompoundTag>() {
@Override @Override

View File

@ -1,8 +1,5 @@
package com.intellectualcrafters.plot.generator; package com.intellectualcrafters.plot.generator;
import java.util.HashSet;
import java.util.Iterator;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; 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.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil; 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 * A plot manager with a square grid layout, with square shaped plots
*/ */
@ -169,7 +170,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
// northwest // northwest
return plot.getMerged(7) ? id : null; return plot.getMerged(7) ? id : null;
} }
PS.debug("invalid location: " + merged); PS.debug("invalid location: " + Arrays.toString(merged));
} catch (Exception e) { } catch (Exception e) {
PS.debug("Invalid plot / road width in settings.yml for world: " + plotworld.worldname); PS.debug("Invalid plot / road width in settings.yml for world: " + plotworld.worldname);
} }

View File

@ -54,7 +54,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
public class Plot { public class Plot {
/** /**
* plot ID * plot ID
* Direct access is Deprecated: use getId() * Direct access is Deprecated: use id
*/ */
@Deprecated @Deprecated
public final PlotId id; public final PlotId id;
@ -384,7 +384,7 @@ public class Plot {
* @return boolean false if the player is allowed to enter * @return boolean false if the player is allowed to enter
*/ */
public boolean isDenied(final UUID uuid) { 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; origin = this;
PlotId min = id; PlotId min = id;
for (Plot plot : MainUtil.getConnectedPlots(this)) { 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; origin = plot;
min = plot.id; 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. * - 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 * @return true if plot was created successfully
*/ */
public boolean create() { public Plot create() {
return MainUtil.createPlot(owner, this); return MainUtil.createPlot(owner, this);
} }
@ -1053,7 +1053,7 @@ public class Plot {
if ((settings != null) && (settings.getAlias().length() > 1)) { if ((settings != null) && (settings.getAlias().length() > 1)) {
return settings.getAlias(); 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) { public boolean removeDenied(final UUID uuid) {
if (uuid == DBFunc.everyone) { if (uuid == DBFunc.everyone) {
boolean result = false; boolean result = false;
for (UUID other : new HashSet<>(getDenied())) { for (UUID other : new HashSet<>(denied)) {
result = result || PlotHandler.removeDenied(this, other); result = result || PlotHandler.removeDenied(this, other);
} }
return result; return result;
@ -1080,7 +1080,7 @@ public class Plot {
public boolean removeTrusted(final UUID uuid) { public boolean removeTrusted(final UUID uuid) {
if (uuid == DBFunc.everyone) { if (uuid == DBFunc.everyone) {
boolean result = false; boolean result = false;
for (UUID other : new HashSet<>(getTrusted())) { for (UUID other : new HashSet<>(trusted)) {
result = result || PlotHandler.removeTrusted(this, other); result = result || PlotHandler.removeTrusted(this, other);
} }
return result; return result;
@ -1094,9 +1094,12 @@ public class Plot {
* @param uuid * @param uuid
*/ */
public boolean removeMember(final UUID uuid) { public boolean removeMember(final UUID uuid) {
if (members == null) {
return false;
}
if (uuid == DBFunc.everyone) { if (uuid == DBFunc.everyone) {
boolean result = false; boolean result = false;
for (UUID other : new HashSet<>(getMembers())) { for (UUID other : new HashSet<>(members)) {
result = result || PlotHandler.removeMember(this, other); result = result || PlotHandler.removeMember(this, other);
} }
return result; return result;
@ -1220,7 +1223,7 @@ public class Plot {
if (settings == null) { if (settings == null) {
return ""; return "";
} }
return getSettings().getAlias(); return settings.getAlias();
} }
/** /**
@ -1238,7 +1241,7 @@ public class Plot {
* @param merged * @param merged
*/ */
public void setMerged(boolean[] merged) { public void setMerged(boolean[] merged) {
getSettings().merged = merged; getSettings().setMerged(merged);
DBFunc.setMerged(this, merged); DBFunc.setMerged(this, merged);
MainUtil.connected_cache = null; MainUtil.connected_cache = null;
MainUtil.regions_cache = null; MainUtil.regions_cache = null;
@ -1266,7 +1269,7 @@ public class Plot {
if (value) { if (value) {
Plot other = MainUtil.getPlotRelative(this, direction).getBasePlot(false); Plot other = MainUtil.getPlotRelative(this, direction).getBasePlot(false);
if (!other.equals(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; origin.origin = base;
other.origin = base; other.origin = base;
origin = base; origin = base;

View File

@ -1,6 +1,6 @@
package com.intellectualcrafters.plot.object; package com.intellectualcrafters.plot.object;
import java.util.Arrays; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -28,7 +28,7 @@ public class PlotHandler {
} }
return owners; 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) { public static boolean isOwner(final Plot plot, final UUID uuid) {

View File

@ -84,41 +84,7 @@ public class PlotId {
} }
public static PlotId unpair(int hash) { public static PlotId unpair(int hash) {
if (hash >= 0) { return new PlotId(hash >> 16, hash & 0xFFFF);
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);
}
}
} }
private int hash; private int hash;
@ -131,22 +97,7 @@ public class PlotId {
@Override @Override
public int hashCode() { public int hashCode() {
if (hash == 0) { if (hash == 0) {
if (x >= 0) { hash = (x << 16) | (y & 0xFFFF);
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);
}
}
} }
return hash; return hash;
} }

View File

@ -20,13 +20,13 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.object; package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.commands.Template;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import com.intellectualcrafters.plot.commands.Template;
public abstract class PlotManager { public abstract class PlotManager {
/* /*
* Plot locations (methods with Abs in them will not need to consider mega * 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 abstract boolean finishPlotUnlink(final PlotWorld plotworld, final ArrayList<PlotId> plotIds);
public void exportTemplate(final PlotWorld plotworld) throws IOException { 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); Template.zipAll(plotworld.worldname, files);
} }

View File

@ -20,11 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.object; 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.configuration.ConfigurationSection;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Configuration; 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.PlotGamemode;
import com.intellectualcrafters.plot.util.StringMan; 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 * @author Jesse Boyd
*/ */
@ -198,7 +198,7 @@ public abstract class PlotWorld {
if ((flags == null) || (flags.size() == 0)) { if ((flags == null) || (flags.size() == 0)) {
flags = config.getStringList("flags"); flags = config.getStringList("flags");
if ((flags == null) || (flags.size() == 0)) { if ((flags == null) || (flags.size() == 0)) {
flags = new ArrayList<String>(); flags = new ArrayList<>();
final ConfigurationSection section = config.getConfigurationSection("flags"); final ConfigurationSection section = config.getConfigurationSection("flags");
final Set<String> keys = section.getKeys(false); final Set<String> keys = section.getKeys(false);
for (final String key : keys) { for (final String key : keys) {
@ -233,7 +233,7 @@ public abstract class PlotWorld {
options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT); options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT);
options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT); options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT);
options.put("plot.create_signs", PlotWorld.ALLOW_SIGNS_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.on_claim", PlotWorld.SCHEMATIC_ON_CLAIM_DEFAULT);
options.put("schematic.file", PlotWorld.SCHEMATIC_FILE_DEFAULT); options.put("schematic.file", PlotWorld.SCHEMATIC_FILE_DEFAULT);
options.put("schematic.specify_on_claim", PlotWorld.SCHEMATIC_CLAIM_SPECIFY_DEFAULT); options.put("schematic.specify_on_claim", PlotWorld.SCHEMATIC_CLAIM_SPECIFY_DEFAULT);

View File

@ -1,14 +1,5 @@
package com.intellectualcrafters.plot.util; 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.PS;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.FlagManager; 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.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.RegionWrapper; 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 { public class BO3Handler {
/** /**
@ -51,7 +50,7 @@ public class BO3Handler {
* @return * @return
*/ */
public static boolean saveBO3(final PlotPlayer plr, final Plot plot) { 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)) { if (!(plotworld instanceof ClassicPlotWorld) || (plotworld.TYPE != 0)) {
MainUtil.sendMessage(plr, "BO3 exporting only supports type 0 classic generation."); MainUtil.sendMessage(plr, "BO3 exporting only supports type 0 classic generation.");
return false; return false;

View File

@ -148,7 +148,7 @@ public class ClusterManager {
} }
public static PlotCluster getCluster(final Plot plot) { 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) { public static PlotCluster getClusterAbs(final Location loc) {
@ -238,7 +238,7 @@ public class ClusterManager {
public static PlotId estimatePlotId(final Location loc) { public static PlotId estimatePlotId(final Location loc) {
final Plot plot = MainUtil.getPlotAbs(loc); final Plot plot = MainUtil.getPlotAbs(loc);
if (plot != null) { if (plot != null) {
return plot.id; return plot.getId();
} }
final PlotId a = new PlotId(0, 0); final PlotId a = new PlotId(0, 0);
final PlotId b = new PlotId(1, 1); final PlotId b = new PlotId(1, 1);

View File

@ -100,13 +100,13 @@ public class ExpireManager {
for (final UUID helper : plot.getTrusted()) { for (final UUID helper : plot.getTrusted()) {
final PlotPlayer player = UUIDHandler.getPlayer(helper); final PlotPlayer player = UUIDHandler.getPlayer(helper);
if (player != null) { 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()) { for (final UUID helper : plot.getMembers()) {
final PlotPlayer player = UUIDHandler.getPlayer(helper); final PlotPlayer player = UUIDHandler.getPlayer(helper);
if (player != null) { 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); final PlotManager manager = PS.get().getPlotManager(world);

View File

@ -31,7 +31,7 @@ public class HastebinUtility {
final BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); final BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine; String inputLine;
final StringBuffer response = new StringBuffer(); final StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) { while ((inputLine = in.readLine()) != null) {
response.append(inputLine); response.append(inputLine);

View File

@ -23,8 +23,8 @@ package com.intellectualcrafters.plot.util;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; 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.PlotId;
import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotSettings;
import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RegionWrapper;
@ -152,9 +153,9 @@ public class MainUtil {
return regions_cache; return regions_cache;
} }
if (!origin.isMerged()) { if (!origin.isMerged()) {
final Location pos1 = MainUtil.getPlotBottomLocAbs(origin.world, origin.id); final Location pos1 = MainUtil.getPlotBottomLocAbs(origin.world, origin.getId());
final Location pos2 = MainUtil.getPlotTopLocAbs(origin.world, origin.id); final Location pos2 = MainUtil.getPlotTopLocAbs(origin.world, origin.getId());
connected_cache = new HashSet<>(Arrays.asList(origin)); connected_cache = new HashSet<>(Collections.singletonList(origin));
regions_cache = new HashSet<>(1); regions_cache = new HashSet<>(1);
regions_cache.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(), pos2.getZ())); regions_cache.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(), pos2.getZ()));
return regions_cache; return regions_cache;
@ -164,20 +165,20 @@ public class MainUtil {
HashSet<PlotId> visited = new HashSet<>(); HashSet<PlotId> visited = new HashSet<>();
ArrayList<PlotId> ids; ArrayList<PlotId> ids;
for (Plot current : plots) { for (Plot current : plots) {
if (visited.contains(current.id)) { if (visited.contains(current.getId())) {
continue; continue;
} }
boolean merge = true; boolean merge = true;
boolean tmp = true; boolean tmp = true;
PlotId bot = new PlotId(current.id.x, current.id.y); PlotId bot = new PlotId(current.getId().x, current.getId().y);
PlotId top = new PlotId(current.id.x, current.id.y); PlotId top = new PlotId(current.getId().x, current.getId().y);
while (merge) { while (merge) {
merge = false; merge = false;
ids = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, bot.y - 1)); ids = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, bot.y - 1));
tmp = true; tmp = true;
for (PlotId id : ids) { for (PlotId id : ids) {
Plot plot = MainUtil.getPlotAbs(origin.world, id); 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; tmp = false;
} }
} }
@ -189,7 +190,7 @@ public class MainUtil {
tmp = true; tmp = true;
for (PlotId id : ids) { for (PlotId id : ids) {
Plot plot = MainUtil.getPlotAbs(origin.world, id); 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; tmp = false;
} }
} }
@ -201,7 +202,7 @@ public class MainUtil {
tmp = true; tmp = true;
for (PlotId id : ids) { for (PlotId id : ids) {
Plot plot = MainUtil.getPlotAbs(origin.world, id); 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; tmp = false;
} }
} }
@ -213,7 +214,7 @@ public class MainUtil {
tmp = true; tmp = true;
for (PlotId id : ids) { for (PlotId id : ids) {
Plot plot = MainUtil.getPlotAbs(origin.world, id); 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; tmp = false;
} }
} }
@ -436,7 +437,7 @@ public class MainUtil {
} }
} }
if (id != null) { if (id != null) {
if (plot.id.equals(id)) { if (plot.getId().equals(id)) {
count++; count++;
} }
} }
@ -568,7 +569,7 @@ public class MainUtil {
ArrayList<PlotId> ids = new ArrayList<>(plots.size()); ArrayList<PlotId> ids = new ArrayList<>(plots.size());
for (Plot current : plots) { for (Plot current : plots) {
current.setHome(null); current.setHome(null);
ids.add(current.id); ids.add(current.getId());
} }
final boolean result = EventUtil.manager.callUnlink(plot.world, ids); final boolean result = EventUtil.manager.callUnlink(plot.world, ids);
if (!result) { if (!result) {
@ -578,8 +579,8 @@ public class MainUtil {
if (createSign) { if (createSign) {
plot.removeSign(); plot.removeSign();
} }
final PlotManager manager = PS.get().getPlotManager(plot.world); final PlotManager manager = plot.getManager();
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world); final PlotWorld plotworld = plot.getWorld();
if (createRoad) { if (createRoad) {
manager.startPlotUnlink(plotworld, ids); manager.startPlotUnlink(plotworld, ids);
} }
@ -652,14 +653,14 @@ public class MainUtil {
/** /**
* Check if a plot is in a plot area.<br> * 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. * - Useful as plot objects can be created with any location which may not be valid.
* @param location * @param plot
* @return * @return
*/ */
public static boolean isPlotArea(final Plot plot) { public static boolean isPlotArea(final Plot plot) {
if (!Settings.ENABLE_CLUSTERS) { if (!Settings.ENABLE_CLUSTERS) {
return true; return true;
} }
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world); final PlotWorld plotworld = plot.getWorld();
if (plotworld.TYPE == 2) { if (plotworld.TYPE == 2) {
return plot.getCluster() != null; return plot.getCluster() != null;
} }
@ -743,7 +744,7 @@ public class MainUtil {
*/ */
public static Location getDefaultHome(Plot plot) { public static Location getDefaultHome(Plot plot) {
plot = plot.getBasePlot(false); plot = plot.getBasePlot(false);
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world); final PlotWorld plotworld = plot.getWorld();
if (plotworld.DEFAULT_HOME != null) { if (plotworld.DEFAULT_HOME != null) {
final int x; final int x;
final int z; final int z;
@ -765,8 +766,8 @@ public class MainUtil {
RegionWrapper largest = getLargestRegion(plot); RegionWrapper largest = getLargestRegion(plot);
final int x = ((largest.maxX - largest.minX) / 2) + largest.minX; final int x = ((largest.maxX - largest.minX) / 2) + largest.minX;
final int z = largest.minZ - 1; final int z = largest.minZ - 1;
final PlotManager manager = PS.get().getPlotManager(plot.world); final PlotManager manager = plot.getManager();
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PS.get().getPlotWorld(plot.world), plot).getY()); 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); 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); final boolean result = EventUtil.manager.callTeleport(player, from, plot);
if (result) { if (result) {
final Location location; 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); location = MainUtil.getPlotHome(plot);
} else { } else {
location = getDefaultHome(plot); location = getDefaultHome(plot);
@ -855,7 +856,7 @@ public class MainUtil {
* @param loc * @param loc
*/ */
public static void update(final String world, final ChunkLoc 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 * @return Plot relative
*/ */
public static Plot getPlotRelative(final Plot plot, final int direction) { 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)) { for (final PlotId pid : MainUtil.getPlotSelectionIds(pos1, pos2)) {
final Plot plot = MainUtil.getPlotAbs(world, pid); final Plot plot = MainUtil.getPlotAbs(world, pid);
if (plot.hasOwner()) { 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); result.add(plot);
} }
} }
} }
} else { } else {
for (final Plot plot : PS.get().getPlotsInWorld(world)) { 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); result.add(plot);
} }
} }
@ -1051,7 +1052,7 @@ public class MainUtil {
if (plotworld.TERRAIN == 3) { if (plotworld.TERRAIN == 3) {
return; return;
} }
final PlotId id = plot.id; final PlotId id = plot.getId();
final PlotId id2 = new PlotId(id.x + 1, id.y + 1); final PlotId id2 = new PlotId(id.x + 1, id.y + 1);
final Location pos1 = getPlotTopLocAbs(plot.world, id).add(1, 0, 1); final Location pos1 = getPlotTopLocAbs(plot.world, id).add(1, 0, 1);
final Location pos2 = getPlotBottomLocAbs(plot.world, id2).subtract(1, 0, 1); final Location pos2 = getPlotBottomLocAbs(plot.world, id2).subtract(1, 0, 1);
@ -1059,7 +1060,7 @@ public class MainUtil {
pos2.setY(256); pos2.setY(256);
ChunkManager.manager.regenerateRegion(pos1, pos2, null); ChunkManager.manager.regenerateRegion(pos1, pos2, null);
} else { } 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) { if (plotworld.TERRAIN == 3) {
return; return;
} }
final PlotId id = plot.id; final PlotId id = plot.getId();
final PlotId id2 = new PlotId(id.x + 1, id.y); final PlotId id2 = new PlotId(id.x + 1, id.y);
final Location bot = getPlotBottomLocAbs(plot.world, id2); final Location bot = getPlotBottomLocAbs(plot.world, id2);
final Location top = getPlotTopLocAbs(plot.world, id); 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()); final Location pos2 = new Location(plot.world, bot.getX(), 256, top.getZ());
ChunkManager.manager.regenerateRegion(pos1, pos2, null); ChunkManager.manager.regenerateRegion(pos1, pos2, null);
} else { } 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) { if (plotworld.TERRAIN == 3) {
return; return;
} }
final PlotId id = plot.id; final PlotId id = plot.getId();
final PlotId id2 = new PlotId(id.x, id.y + 1); final PlotId id2 = new PlotId(id.x, id.y + 1);
final Location bot = getPlotBottomLocAbs(plot.world, id2); final Location bot = getPlotBottomLocAbs(plot.world, id2);
final Location top = getPlotTopLocAbs(plot.world, id); 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()); final Location pos2 = new Location(plot.world, top.getX(), 256, bot.getZ());
ChunkManager.manager.regenerateRegion(pos1, pos2, null); ChunkManager.manager.regenerateRegion(pos1, pos2, null);
} else { } 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) { public static void mergePlot(final String world, Plot lesserPlot, Plot greaterPlot, final boolean removeRoads) {
final PlotWorld plotworld = PS.get().getPlotWorld(world); final PlotWorld plotworld = PS.get().getPlotWorld(world);
if (lesserPlot.id.x.equals(greaterPlot.id.x)) { if (lesserPlot.getId().x.equals(greaterPlot.getId().x)) {
if (lesserPlot.id.y > greaterPlot.id.y) { if (lesserPlot.getId().y > greaterPlot.getId().y) {
Plot tmp = lesserPlot; Plot tmp = lesserPlot;
lesserPlot = greaterPlot; lesserPlot = greaterPlot;
greaterPlot = tmp; greaterPlot = tmp;
@ -1135,15 +1136,15 @@ public class MainUtil {
removeRoadSouthEast(plotworld, lesserPlot); removeRoadSouthEast(plotworld, lesserPlot);
} }
MainUtil.removeRoadSouth(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)) { if (other.getMerged(2) && other.getMerged(1)) {
MainUtil.removeRoadSouthEast(plotworld, other); 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 { } else {
if (lesserPlot.id.x > greaterPlot.id.x) { if (lesserPlot.getId().x > greaterPlot.getId().x) {
Plot tmp = lesserPlot; Plot tmp = lesserPlot;
lesserPlot = greaterPlot; lesserPlot = greaterPlot;
greaterPlot = tmp; greaterPlot = tmp;
@ -1159,10 +1160,10 @@ public class MainUtil {
if (lesserPlot.getMerged(5)) { if (lesserPlot.getMerged(5)) {
removeRoadSouthEast(plotworld, lesserPlot); 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)) { if (other.getMerged(2) && other.getMerged(1)) {
MainUtil.removeRoadSouthEast(plotworld, other); 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; return;
} }
final String rename = name == null ? "unknown" : name; final String rename = name == null ? "unknown" : name;
final PlotManager manager = PS.get().getPlotManager(p.world); final PlotManager manager = p.getManager();
final PlotWorld plotworld = PS.get().getPlotWorld(p.world); final PlotWorld plotworld = p.getWorld();
if (plotworld.ALLOW_SIGNS) { if (plotworld.ALLOW_SIGNS) {
final Location loc = manager.getSignLoc(plotworld, p); 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[] { final String[] lines = new String[] {
C.OWNER_SIGN_LINE_1.formatted().replaceAll("%id%", id), C.OWNER_SIGN_LINE_1.formatted().replaceAll("%id%", id),
C.OWNER_SIGN_LINE_2.formatted().replaceAll("%id%", id).replaceAll("%plr%", rename), 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> * Get the corner locations for a list of regions<br>
* @see Plot#getCorners() * @see Plot#getCorners()
* @param world * @param world
* @param region * @param regions
* @return * @return
*/ */
public static Location[] getCorners(String world, Collection<RegionWrapper> regions) { public static Location[] getCorners(String world, Collection<RegionWrapper> regions) {
@ -1353,22 +1354,22 @@ public class MainUtil {
*/ */
public static PlotId[] getCornerIds(Plot plot) { public static PlotId[] getCornerIds(Plot plot) {
if (!plot.isMerged()) { 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 min = new PlotId(plot.getId().x, plot.getId().y);
PlotId max = new PlotId(plot.id.x, plot.id.y); PlotId max = new PlotId(plot.getId().x, plot.getId().y);
for (Plot current : getConnectedPlots(plot)) { for (Plot current : getConnectedPlots(plot)) {
if (current.id.x < min.x) { if (current.getId().x < min.x) {
min.x = current.id.x; min.x = current.getId().x;
} }
else if (current.id.x > max.x) { else if (current.getId().x > max.x) {
max.x = current.id.x; max.x = current.getId().x;
} }
if (current.id.y < min.y) { if (current.getId().y < min.y) {
min.y = current.id.y; min.y = current.getId().y;
} }
else if (current.id.y > max.y) { else if (current.getId().y > max.y) {
max.y = current.id.y; max.y = current.getId().y;
} }
} }
return new PlotId[] { min, max }; return new PlotId[] { min, max };
@ -1398,7 +1399,7 @@ public class MainUtil {
HashSet<Plot> visited = new HashSet<>(); HashSet<Plot> visited = new HashSet<>();
HashSet<PlotId> merged = new HashSet<>(); HashSet<PlotId> merged = new HashSet<>();
for (Plot current : getConnectedPlots(plot)) { for (Plot current : getConnectedPlots(plot)) {
merged.add(current.id); merged.add(current.getId());
} }
ArrayDeque<Plot> frontier = new ArrayDeque<>(getConnectedPlots(plot)); ArrayDeque<Plot> frontier = new ArrayDeque<>(getConnectedPlots(plot));
Plot current; Plot current;
@ -1413,8 +1414,8 @@ public class MainUtil {
Plot other = getPlotRelative(current, 0); 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))) { 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); mergePlot(current.world, current, other, removeRoads);
merged.add(current.id); merged.add(current.getId());
merged.add(other.id); merged.add(other.getId());
toReturn = true; toReturn = true;
} }
} }
@ -1422,8 +1423,8 @@ public class MainUtil {
Plot other = getPlotRelative(current, 1); 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))) { 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); mergePlot(current.world, current, other, removeRoads);
merged.add(current.id); merged.add(current.getId());
merged.add(other.id); merged.add(other.getId());
toReturn = true; toReturn = true;
} }
} }
@ -1431,8 +1432,8 @@ public class MainUtil {
Plot other = getPlotRelative(current, 2); 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))) { 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); mergePlot(current.world, current, other, removeRoads);
merged.add(current.id); merged.add(current.getId());
merged.add(other.id); merged.add(other.getId());
toReturn = true; toReturn = true;
} }
} }
@ -1440,14 +1441,14 @@ public class MainUtil {
Plot other = getPlotRelative(current, 3); 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))) { 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); mergePlot(current.world, current, other, removeRoads);
merged.add(current.id); merged.add(current.getId());
merged.add(other.id); merged.add(other.getId());
toReturn = true; toReturn = true;
} }
} }
} }
if (removeRoads && toReturn) { if (removeRoads && toReturn) {
PlotManager manager = PS.get().getPlotManager(plot.world); PlotManager manager = plot.getManager();
ArrayList<PlotId> ids = new ArrayList<>(merged); ArrayList<PlotId> ids = new ArrayList<>(merged);
manager.finishPlotMerge(plot.getWorld(), ids); manager.finishPlotMerge(plot.getWorld(), ids);
} }
@ -1465,7 +1466,7 @@ public class MainUtil {
final String world = plot.world; final String world = plot.world;
final PlotManager manager = PS.get().getPlotManager(world); final PlotManager manager = PS.get().getPlotManager(world);
final PlotWorld plotworld = PS.get().getPlotWorld(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 bot = manager.getPlotBottomLocAbs(plotworld, id);
final Location top = manager.getPlotTopLocAbs(plotworld, id); final Location top = manager.getPlotTopLocAbs(plotworld, id);
final int border = worldBorder.get(plot.world); 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 * 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)) { if (MainUtil.worldBorder.containsKey(plot.world)) {
updateWorldBorder(plot); updateWorldBorder(plot);
} }
final String w = plot.world; plot.owner = uuid;
if (PS.get().getPlot(plot.world, plot.id) != null) { plot.getTrusted().clear();
return true; plot.getMembers().clear();
} plot.getDenied().clear();
final Plot p = new Plot(w, plot.id, uuid); plot.settings = new PlotSettings();
if (p.owner == null) { if (PS.get().updatePlot(plot)) {
return false; DBFunc.createPlotAndSettings(plot, new Runnable() {
}
PS.get().updatePlot(p);
DBFunc.createPlotAndSettings(p, new Runnable() {
@Override @Override
public void run() { public void run() {
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world); final PlotWorld plotworld = plot.getWorld();
if (plotworld.AUTO_MERGE) { if (plotworld.AUTO_MERGE) {
autoMerge(p, -1, Integer.MAX_VALUE, uuid, true); autoMerge(plot, -1, Integer.MAX_VALUE, uuid, true);
} }
} }
}); });
return true; }
return plot;
} }
/** /**
* Create a plot without notifying the merge function or world border manager * Create a plot without notifying the merge function or world border manager
*/ */
public static Plot createPlotAbs(final UUID uuid, final Plot plot) { public static Plot createPlotAbs(final UUID uuid, final Plot plot) {
final String w = plot.world; if (uuid == null) {
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) {
return null; return null;
} }
PS.get().updatePlot(p); Plot existing = getPlot(plot.world, plot.id);
DBFunc.createPlotAndSettings(p, null); if (existing != null) {
return p; 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 * @return
*/ */
public static boolean clear(final Plot plot, final boolean isDelete, final Runnable whenDone) { 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; return false;
} }
final HashSet<RegionWrapper> regions = getRegions(plot); final HashSet<RegionWrapper> regions = getRegions(plot);
@ -1608,8 +1631,8 @@ public class MainUtil {
removeSign(plot); removeSign(plot);
} }
MainUtil.unlinkPlot(plot, true, !isDelete); MainUtil.unlinkPlot(plot, true, !isDelete);
final PlotManager manager = PS.get().getPlotManager(plot.world); final PlotManager manager = plot.getManager();
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world); final PlotWorld plotworld = plot.getWorld();
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override @Override
public void run() { public void run() {
@ -1864,7 +1887,7 @@ public class MainUtil {
* *
*/ */
public static Location getPlotHome(final Plot plot) { 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 * @return Location top of mega plot
*/ */
public static Location getPlotTopLoc_(Plot plot) { public static Location getPlotTopLoc_(Plot plot) {
Location top = getPlotTopLocAbs(plot.world, plot.id); Location top = getPlotTopLocAbs(plot.world, plot.getId());
if (!plot.isMerged()) { if (!plot.isMerged()) {
return top; return top;
} }
PlotId id; PlotId id;
if (plot.getMerged(2)) { if (plot.getMerged(2)) {
id = getPlotIdRelative(plot.id, 2); id = getPlotIdRelative(plot.getId(), 2);
top.setZ(getPlotBottomLocAbs(plot.world, id).getZ() - 1); top.setZ(getPlotBottomLocAbs(plot.world, id).getZ() - 1);
} }
if (plot.getMerged(1)) { if (plot.getMerged(1)) {
id = getPlotIdRelative(plot.id, 1); id = getPlotIdRelative(plot.getId(), 1);
top.setX(getPlotBottomLocAbs(plot.world, id).getX() - 1); top.setX(getPlotBottomLocAbs(plot.world, id).getX() - 1);
} }
return top; return top;
@ -1931,17 +1954,17 @@ public class MainUtil {
* @return Location bottom of mega plot * @return Location bottom of mega plot
*/ */
public static Location getPlotBottomLoc_(Plot plot) { public static Location getPlotBottomLoc_(Plot plot) {
Location bot = getPlotBottomLocAbs(plot.world, plot.id); Location bot = getPlotBottomLocAbs(plot.world, plot.getId());
if (!plot.isMerged()) { if (!plot.isMerged()) {
return bot; return bot;
} }
PlotId id; PlotId id;
if (plot.getMerged(0)) { if (plot.getMerged(0)) {
id = getPlotIdRelative(plot.id, 0); id = getPlotIdRelative(plot.getId(), 0);
bot.setZ(getPlotTopLocAbs(plot.world, id).getZ() + 1); bot.setZ(getPlotTopLocAbs(plot.world, id).getZ() + 1);
} }
if (plot.getMerged(3)) { if (plot.getMerged(3)) {
id = getPlotIdRelative(plot.id, 3); id = getPlotIdRelative(plot.getId(), 3);
bot.setX(getPlotTopLocAbs(plot.world, id).getX() + 1); bot.setX(getPlotTopLocAbs(plot.world, id).getX() + 1);
} }
return bot; return bot;
@ -2092,18 +2115,18 @@ public class MainUtil {
return false; return false;
} }
// Swap cached // Swap cached
final PlotId temp = new PlotId(p1.id.x.intValue(), p1.id.y.intValue()); final PlotId temp = new PlotId(p1.getId().x, p1.getId().y);
p1.id.x = p2.id.x.intValue(); p1.getId().x = p2.getId().x;
p1.id.y = p2.id.y.intValue(); p1.getId().y = p2.getId().y;
p2.id.x = temp.x; p2.getId().x = temp.x;
p2.id.y = temp.y; p2.getId().y = temp.y;
final Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw(); final Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
raw.get(p1.world).remove(p1.id); raw.get(p1.world).remove(p1.getId());
raw.get(p2.world).remove(p2.id); raw.get(p2.world).remove(p2.getId());
p1.id.recalculateHash(); p1.getId().recalculateHash();
p2.id.recalculateHash(); p2.getId().recalculateHash();
raw.get(p1.world).put(p1.id, p1); raw.get(p1.world).put(p1.getId(), p1);
raw.get(p2.world).put(p2.id, p2); raw.get(p2.world).put(p2.getId(), p2);
// Swap database // Swap database
DBFunc.dbManager.swapPlots(p2, p1); DBFunc.dbManager.swapPlots(p2, p1);
TaskManager.runTaskLater(whenDone, 1); TaskManager.runTaskLater(whenDone, 1);
@ -2129,11 +2152,11 @@ public class MainUtil {
return false; return false;
} }
final Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw(); final Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
raw.get(pos1.world).remove(pos1.id); raw.get(pos1.world).remove(pos1.getId());
pos1.id.x = (int) pos2.id.x; pos1.getId().x = (int) pos2.getId().x;
pos1.id.y = (int) pos2.id.y; pos1.getId().y = (int) pos2.getId().y;
pos1.id.recalculateHash(); pos1.getId().recalculateHash();
raw.get(pos2.world).put(pos1.id, pos1); raw.get(pos2.world).put(pos1.getId(), pos1);
DBFunc.movePlot(pos1, pos2); DBFunc.movePlot(pos1, pos2);
TaskManager.runTaskLater(whenDone, 1); TaskManager.runTaskLater(whenDone, 1);
return true; return true;
@ -2148,7 +2171,7 @@ public class MainUtil {
* @return * @return
*/ */
public static boolean move(final Plot origin, final Plot destination, final Runnable whenDone, boolean allowSwap) { 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 db = destination.getBottomAbs();
Location ob = origin.getBottomAbs(); Location ob = origin.getBottomAbs();
final int offsetX = db.getX() - ob.getX(); final int offsetX = db.getX() - ob.getX();
@ -2160,7 +2183,7 @@ public class MainUtil {
boolean occupied = false; boolean occupied = false;
HashSet<Plot> plots = MainUtil.getConnectedPlots(origin); HashSet<Plot> plots = MainUtil.getConnectedPlots(origin);
for (Plot plot : plots) { 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 (other.owner != null) {
if (!allowSwap) { if (!allowSwap) {
TaskManager.runTaskLater(whenDone, 1); TaskManager.runTaskLater(whenDone, 1);
@ -2174,7 +2197,7 @@ public class MainUtil {
final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(getRegions(origin)); final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(getRegions(origin));
// move / swap data // move / swap data
for (Plot plot : plots) { 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); swapData(plot, other, null);
} }
// copy terrain // copy terrain
@ -2235,7 +2258,7 @@ public class MainUtil {
* @return * @return
*/ */
public static boolean copy(final Plot origin, final Plot destination, final Runnable whenDone) { 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 db = destination.getBottomAbs();
Location ob = origin.getBottomAbs(); Location ob = origin.getBottomAbs();
final int offsetX = db.getX() - ob.getX(); final int offsetX = db.getX() - ob.getX();
@ -2246,7 +2269,7 @@ public class MainUtil {
} }
HashSet<Plot> plots = MainUtil.getConnectedPlots(origin); HashSet<Plot> plots = MainUtil.getConnectedPlots(origin);
for (Plot plot : plots) { 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 (other.owner != null) {
TaskManager.runTaskLater(whenDone, 1); TaskManager.runTaskLater(whenDone, 1);
return false; return false;
@ -2256,7 +2279,7 @@ public class MainUtil {
updateWorldBorder(destination); updateWorldBorder(destination);
// copy data // copy data
for (Plot plot : plots) { 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); other = createPlotAbs(plot.owner, other);
if ((plot.getFlags() != null) && (plot.getFlags().size() > 0)) { if ((plot.getFlags() != null) && (plot.getFlags().size() > 0)) {
other.getSettings().flags = plot.getFlags(); other.getSettings().flags = plot.getFlags();
@ -2399,12 +2422,12 @@ public class MainUtil {
return null; return null;
} }
if (plot.settings == null) { if (plot.settings == null) {
return new HashSet<>(Arrays.asList(plot)); return new HashSet<>(Collections.singletonList(plot));
} }
boolean[] merged = plot.getMerged(); boolean[] merged = plot.getMerged();
int hash = hash(merged); int hash = hash(merged);
if (hash == 0) { if (hash == 0) {
return new HashSet<>(Arrays.asList(plot)); return new HashSet<>(Collections.singletonList(plot));
} }
if (connected_cache != null && connected_cache.contains(plot)) { if (connected_cache != null && connected_cache.contains(plot)) {
return connected_cache; return connected_cache;
@ -2416,7 +2439,7 @@ public class MainUtil {
connected_cache.add(plot); connected_cache.add(plot);
Plot tmp; Plot tmp;
if (merged[0]) { if (merged[0]) {
tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.id, 0)); tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.getId(), 0));
if (!tmp.getMerged(2)) { if (!tmp.getMerged(2)) {
// invalid merge // invalid merge
PS.debug("Fixing invalid merge: " + plot); PS.debug("Fixing invalid merge: " + plot);
@ -2432,7 +2455,7 @@ public class MainUtil {
frontier.add(tmp); frontier.add(tmp);
} }
if (merged[1]) { if (merged[1]) {
tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.id, 1)); tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.getId(), 1));
if (!tmp.getMerged(3)) { if (!tmp.getMerged(3)) {
// invalid merge // invalid merge
PS.debug("Fixing invalid merge: " + plot); PS.debug("Fixing invalid merge: " + plot);
@ -2448,7 +2471,7 @@ public class MainUtil {
frontier.add(tmp); frontier.add(tmp);
} }
if (merged[2]) { if (merged[2]) {
tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.id, 2)); tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.getId(), 2));
if (!tmp.getMerged(0)) { if (!tmp.getMerged(0)) {
// invalid merge // invalid merge
PS.debug("Fixing invalid merge: " + plot); PS.debug("Fixing invalid merge: " + plot);
@ -2464,7 +2487,7 @@ public class MainUtil {
frontier.add(tmp); frontier.add(tmp);
} }
if (merged[3]) { if (merged[3]) {
tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.id, 3)); tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.getId(), 3));
if (!tmp.getMerged(1)) { if (!tmp.getMerged(1)) {
// invalid merge // invalid merge
PS.debug("Fixing invalid merge: " + plot); PS.debug("Fixing invalid merge: " + plot);
@ -2491,28 +2514,28 @@ public class MainUtil {
queuecache.remove(current); queuecache.remove(current);
merged = current.getMerged(); merged = current.getMerged();
if (merged[0]) { 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)) { if (!queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
queuecache.add(tmp); queuecache.add(tmp);
frontier.add(tmp); frontier.add(tmp);
} }
} }
if (merged[1]) { 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)) { if (!queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
queuecache.add(tmp); queuecache.add(tmp);
frontier.add(tmp); frontier.add(tmp);
} }
} }
if (merged[2]) { 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)) { if (!queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
queuecache.add(tmp); queuecache.add(tmp);
frontier.add(tmp); frontier.add(tmp);
} }
} }
if (merged[3]) { 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)) { if (!queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
queuecache.add(tmp); queuecache.add(tmp);
frontier.add(tmp); frontier.add(tmp);
@ -2547,7 +2570,7 @@ public class MainUtil {
if (plot != null) { if (plot != null) {
return getConnectedPlots(plot); 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 * @return
*/ */
public static boolean setComponent(final Plot plot, final String component, final PlotBlock[] blocks) { 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) { 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 int num = MainUtil.getConnectedPlots(plot).size();
final String alias = plot.getAlias().length() > 0 ? plot.getAlias() : C.NONE.s(); 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 biome = BlockManager.manager.getBiome(plot.world, bot.getX(), bot.getZ());
final String trusted = getPlayerList(plot.getTrusted()); final String trusted = getPlayerList(plot.getTrusted());
final String members = getPlayerList(plot.getMembers()); final String members = getPlayerList(plot.getMembers());
@ -2725,7 +2748,7 @@ public class MainUtil {
final String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners()); 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("%alias%", alias);
info = info.replaceAll("%num%", num + ""); info = info.replaceAll("%num%", num + "");
info = info.replaceAll("%desc%", description); info = info.replaceAll("%desc%", description);
@ -2776,7 +2799,7 @@ public class MainUtil {
*/ */
public static String getPlayerList(final Collection<UUID> uuids) { public static String getPlayerList(final Collection<UUID> uuids) {
final ArrayList<UUID> l = new ArrayList<>(uuids); final ArrayList<UUID> l = new ArrayList<>(uuids);
if ((l == null) || (l.size() < 1)) { if (l.size() < 1) {
return C.NONE.s(); return C.NONE.s();
} }
final String c = C.PLOT_USER_LIST.s(); final String c = C.PLOT_USER_LIST.s();

View File

@ -1,5 +1,20 @@
package com.intellectualcrafters.plot.util; 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.BufferedInputStream;
import java.io.DataInput; import java.io.DataInput;
import java.io.DataInputStream; import java.io.DataInputStream;
@ -16,6 +31,7 @@ import java.util.AbstractList;
import java.util.AbstractMap; import java.util.AbstractMap;
import java.util.AbstractSet; import java.util.AbstractSet;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -24,22 +40,6 @@ import java.util.concurrent.ConcurrentMap;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream; 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 { public class NbtFactory {
// Convert between NBT id and the equivalent class in java // Convert between NBT id and the equivalent class in java
private static final BiMap<Integer, Class<?>> NBT_CLASS = HashBiMap.create(); 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. * @return An existing map, a new map or NULL.
*/ */
public NbtCompound getMap(final String key, final boolean createNew) { public NbtCompound getMap(final String key, final boolean createNew) {
return getMap(Arrays.asList(key), createNew); return getMap(Collections.singletonList(key), createNew);
} }
// Done // Done

View File

@ -1,5 +1,30 @@
package com.intellectualcrafters.plot.util; 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.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -29,31 +54,6 @@ import java.util.UUID;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream; 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 abstract class SchematicHandler {
public static SchematicHandler manager; public static SchematicHandler manager;
@ -85,9 +85,9 @@ public abstract class SchematicHandler {
} }
final String name; final String name;
if (namingScheme == null) { if (namingScheme == null) {
name = plot.id.x + ";" + plot.id.y + "," + plot.world + "," + o; name = plot.getId().x + ";" + plot.getId().y + "," + plot.world + "," + o;
} else { } 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); .replaceAll("%world%", plot.world);
} }
final String directory; final String directory;
@ -97,21 +97,21 @@ public abstract class SchematicHandler {
directory = outputDir.getPath(); directory = outputDir.getPath();
} }
final Runnable THIS = this; 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 @Override
public void run() { public void run() {
if (value == null) { if (value == null) {
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id); MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.getId());
} else { } else {
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { 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"); final boolean result = SchematicHandler.manager.save(value, directory + File.separator + name + ".schematic");
if (!result) { if (!result) {
MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.id); MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.getId());
} else { } else {
MainUtil.sendMessage(null, "&7 - &a success: " + plot.id); MainUtil.sendMessage(null, "&7 - &a success: " + plot.getId());
} }
TaskManager.runTask(new Runnable() { TaskManager.runTask(new Runnable() {
@Override @Override
@ -346,14 +346,12 @@ public abstract class SchematicHandler {
} }
} }
}); });
return;
} }
} }
}); });
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return;
} }
} }
}); });

View File

@ -6,6 +6,7 @@ import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -97,6 +98,6 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
} }
public static UUID getUUIDOf(String name) throws Exception { 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);
} }
} }

View File

@ -2,21 +2,13 @@ package com.plotsquared.bukkit.chat;
import static com.plotsquared.bukkit.chat.TextualComponent.rawText; import static com.plotsquared.bukkit.chat.TextualComponent.rawText;
import java.io.IOException; import com.google.gson.JsonArray;
import java.io.StringWriter; import com.google.gson.JsonElement;
import java.lang.reflect.Constructor; import com.google.gson.JsonObject;
import java.lang.reflect.Field; import com.google.gson.JsonParser;
import java.lang.reflect.InvocationTargetException; import com.google.gson.stream.JsonWriter;
import java.lang.reflect.Method; import com.intellectualcrafters.configuration.serialization.ConfigurationSerializable;
import java.lang.reflect.Modifier; import com.intellectualcrafters.configuration.serialization.ConfigurationSerialization;
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 org.bukkit.Achievement; import org.bukkit.Achievement;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -28,13 +20,21 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.google.gson.JsonArray; import java.io.IOException;
import com.google.gson.JsonElement; import java.io.StringWriter;
import com.google.gson.JsonObject; import java.lang.reflect.Constructor;
import com.google.gson.JsonParser; import java.lang.reflect.Field;
import com.google.gson.stream.JsonWriter; import java.lang.reflect.InvocationTargetException;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerializable; import java.lang.reflect.Method;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerialization; 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>. * 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 @Override
public FancyMessage clone() throws CloneNotSupportedException { public FancyMessage clone() throws CloneNotSupportedException {
final FancyMessage instance = (FancyMessage) super.clone(); 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++) { for (int i = 0; i < messageParts.size(); i++) {
instance.messageParts.add(i, messageParts.get(i).clone()); instance.messageParts.add(i, messageParts.get(i).clone());
} }
@ -79,7 +79,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
} }
public FancyMessage(final TextualComponent firstPartText) { public FancyMessage(final TextualComponent firstPartText) {
messageParts = new ArrayList<MessagePart>(); messageParts = new ArrayList<>();
messageParts.add(new MessagePart(firstPartText)); messageParts.add(new MessagePart(firstPartText));
jsonString = null; jsonString = null;
dirty = false; dirty = false;
@ -503,9 +503,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
* @return This builder instance. * @return This builder instance.
*/ */
public FancyMessage translationReplacements(final FancyMessage... replacements) { public FancyMessage translationReplacements(final FancyMessage... replacements) {
for (final FancyMessage str : replacements) { Collections.addAll(latest().translationReplacements, replacements);
latest().translationReplacements.add(str);
}
dirty = true; dirty = true;
@ -742,7 +740,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
// Doc copied from interface // Doc copied from interface
@Override @Override
public Map<String, Object> serialize() { 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("messageParts", messageParts);
// map.put("JSON", toJSONString()); // map.put("JSON", toJSONString());
return map; return map;
@ -791,7 +789,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
// Deserialize text // Deserialize text
if (TextualComponent.isTextKey(entry.getKey())) { if (TextualComponent.isTextKey(entry.getKey())) {
// The map mimics the YAML serialization, which has a "key" field and one or more "value" fields // 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()); serializedMapForm.put("key", entry.getKey());
if (entry.getValue().isJsonPrimitive()) { if (entry.getValue().isJsonPrimitive()) {
// Assume string // Assume string

View File

@ -1,18 +1,17 @@
package com.plotsquared.bukkit.database.plotme; 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.configuration.file.FileConfiguration;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId; 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 class APlotMeConnector {
public abstract Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder); 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"); // final String wallblock = plotConfig.getString("worlds." + world + ".WallBlockId"); //
PS.get().config.set("worlds." + actualWorldName + ".wall.block", wallblock); PS.get().config.set("worlds." + actualWorldName + ".wall.block", wallblock);
final String floor = plotConfig.getString("worlds." + world + ".PlotFloorBlockId"); // 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"); // 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"); final String road = plotConfig.getString("worlds." + world + ".RoadMainBlockId");
PS.get().config.set("worlds." + actualWorldName + ".road.block", road); PS.get().config.set("worlds." + actualWorldName + ".road.block", road);
Integer height = plotConfig.getInt("worlds." + world + ".RoadHeight"); // Integer height = plotConfig.getInt("worlds." + world + ".RoadHeight"); //
if (height == null) {
height = 64;
}
PS.get().config.set("worlds." + actualWorldName + ".road.height", height); PS.get().config.set("worlds." + actualWorldName + ".road.height", height);
} }

View File

@ -123,10 +123,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
e.printStackTrace(); e.printStackTrace();
owner = UUID.nameUUIDFromBytes(bytes); owner = UUID.nameUUIDFromBytes(bytes);
} }
if (owner != null) {
UUIDHandler.add(new StringWrapper(name), owner); UUIDHandler.add(new StringWrapper(name), owner);
} }
}
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -195,10 +193,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
e.printStackTrace(); e.printStackTrace();
denied = UUID.nameUUIDFromBytes(bytes); denied = UUID.nameUUIDFromBytes(bytes);
} }
if (denied != null) {
UUIDHandler.add(new StringWrapper(name), denied); UUIDHandler.add(new StringWrapper(name), denied);
} }
}
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -239,10 +235,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
e.printStackTrace(); e.printStackTrace();
helper = UUID.nameUUIDFromBytes(bytes); helper = UUID.nameUUIDFromBytes(bytes);
} }
if (helper != null) {
UUIDHandler.add(new StringWrapper(name), helper); UUIDHandler.add(new StringWrapper(name), helper);
} }
}
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -261,7 +255,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
r.close(); r.close();
stmt.close(); stmt.close();
} catch (final Exception e) {} } catch (SQLException e) {
}
return plots; return plots;
} }

View File

@ -30,6 +30,7 @@ import java.nio.file.Paths;
import java.sql.Connection; import java.sql.Connection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
@ -52,6 +53,8 @@ import com.plotsquared.bukkit.generator.HybridGen;
/** /**
* Created 2014-08-17 for PlotSquared * Created 2014-08-17 for PlotSquared
* *
*/ */
public class LikePlotMeConverter { public class LikePlotMeConverter {
private final String plugin; private final String plugin;
@ -128,7 +131,8 @@ public class LikePlotMeConverter {
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared"); content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
content = content.replaceAll(plugin, "PlotSquared"); content = content.replaceAll(plugin, "PlotSquared");
Files.write(path, content.getBytes(charset)); Files.write(path, content.getBytes(charset));
} catch (final Exception e) {} } catch (IOException e) {
}
} }
public boolean run(final APlotMeConnector connector) { public boolean run(final APlotMeConnector connector) {
@ -232,21 +236,21 @@ public class LikePlotMeConverter {
if (floor == null) { if (floor == null) {
floor = "2"; 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"); // String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); //
if (filling == null) { if (filling == null) {
filling = "3"; 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"); String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock");
if (road == null) { if (road == null) {
road = "5"; road = "5";
} }
PS.get().config.set("worlds." + world + ".road.block", road); PS.get().config.set("worlds." + world + ".road.block", road);
Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // 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"); // height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
if ((height == null) || (height == 0)) { if (height == 0) {
height = 64; height = 64;
} }
} }
@ -255,12 +259,13 @@ public class LikePlotMeConverter {
PS.get().config.set("worlds." + actualWorldName + ".wall.height", height); PS.get().config.set("worlds." + actualWorldName + ".wall.height", height);
PS.get().config.save(PS.get().configFile); PS.get().config.save(PS.get().configFile);
} }
} catch (final Exception e) {} } catch (IOException e) {
}
} }
for (final String world : plots.keySet()) { for (final String world : plots.keySet()) {
int duplicate = 0; int duplicate = 0;
for (final Plot plot : plots.get(world).values()) { 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); createdPlots.add(plot);
} else { } else {
duplicate++; duplicate++;

View File

@ -136,8 +136,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
final Plot plot = entry.getValue(); final Plot plot = entry.getValue();
final HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.world); final HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.world);
if (mergeMap != null) { if (mergeMap != null) {
if (mergeMap.containsKey(plot.id)) { if (mergeMap.containsKey(plot.getId())) {
plot.setMerged(mergeMap.get(plot.id)); plot.setMerged(mergeMap.get(plot.getId()));
} }
} }
} }
@ -188,7 +188,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
map = new HashMap<>(); map = new HashMap<>();
processed.put(plot.world, map); processed.put(plot.world, map);
} }
map.put(plot.id, plot); map.put(plot.getId(), plot);
} }
return processed; return processed;
} }

View File

@ -20,15 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.generator; 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.HybridPlotManager;
import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.object.PlotLoc; 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.PlotWorld;
import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.RegionWrapper; 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. - * 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 * 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 * mean world generation may take somewhat longer
* *
*/ */
public class HybridGen extends BukkitPlotGenerator { public class HybridGen extends BukkitPlotGenerator {
@ -120,7 +121,7 @@ public class HybridGen extends BukkitPlotGenerator {
biome = Biome.valueOf(this.plotworld.PLOT_BIOME); biome = Biome.valueOf(this.plotworld.PLOT_BIOME);
try { try {
maxY = Bukkit.getWorld(plotworld.worldname).getMaxHeight(); maxY = Bukkit.getWorld(plotworld.worldname).getMaxHeight();
} catch (final NullPointerException e) {} } catch (final NullPointerException ignored) {}
if (maxY == 0) { if (maxY == 0) {
maxY = 256; maxY = 256;
} }
@ -176,7 +177,7 @@ public class HybridGen extends BukkitPlotGenerator {
public List<BukkitPlotPopulator> getPopulators(final String world) { public List<BukkitPlotPopulator> getPopulators(final String world) {
// You can have as many populators as you would like, e.g. tree // You can have as many populators as you would like, e.g. tree
// populator, ore populator // 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;
} }
} }

View File

@ -124,6 +124,8 @@ import com.plotsquared.bukkit.util.BukkitUtil;
/** /**
* Player Events involving plots * Player Events involving plots
* *
*/ */
@SuppressWarnings({ "deprecation", "unchecked" }) @SuppressWarnings({ "deprecation", "unchecked" })
public class PlayerEvents extends com.plotsquared.listener.PlotListener implements Listener { 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(); final String message = event.getMessage();
String format = C.PLOT_CHAT_FORMAT.s(); String format = C.PLOT_CHAT_FORMAT.s();
final String sender = event.getPlayer().getDisplayName(); final String sender = event.getPlayer().getDisplayName();
final PlotId id = plot.id; final PlotId id = plot.getId();
final Set<Player> recipients = event.getRecipients(); final Set<Player> recipients = event.getRecipients();
recipients.clear(); recipients.clear();
for (final Player p : Bukkit.getOnlinePlayers()) { for (final Player p : Bukkit.getOnlinePlayers()) {

View File

@ -1,6 +1,7 @@
package com.plotsquared.bukkit.listeners.worldedit; package com.plotsquared.bukkit.listeners.worldedit;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; 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 = 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_1 = new HashSet<>(Arrays.asList("hcyl", "cyl"));
public final HashSet<String> rad2_2 = new HashSet<>(Arrays.asList("sphere", "pyramid")); 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> rad2_3 = new HashSet<>(Collections.singletonList("brush smooth"));
public final HashSet<String> rad3_1 = new HashSet<>(Arrays.asList("brush gravity")); 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> 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", 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")); "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> 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> 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 final HashSet<String> other = new HashSet<>(Arrays.asList("undo", "redo"));
public boolean checkCommand(final List<String> list, final String cmd) { public boolean checkCommand(final List<String> list, final String cmd) {
@ -138,10 +139,8 @@ public class WEListener implements Listener {
return checkVolume(pp, volume, max, e); return checkVolume(pp, volume, max, e);
} }
private final boolean set = false;
public boolean delay(final Player player, final String command, final boolean delayed) { 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; return false;
} }
final boolean free = SetBlockQueue.addNotify(null); final boolean free = SetBlockQueue.addNotify(null);

View File

@ -1,13 +1,25 @@
package com.plotsquared.bukkit.util; package com.plotsquared.bukkit.util;
import java.util.ArrayList; import com.intellectualcrafters.plot.PS;
import java.util.Arrays; import com.intellectualcrafters.plot.object.BlockLoc;
import java.util.HashMap; import com.intellectualcrafters.plot.object.ChunkLoc;
import java.util.HashSet; import com.intellectualcrafters.plot.object.Location;
import java.util.List; import com.intellectualcrafters.plot.object.Plot;
import java.util.Random; import com.intellectualcrafters.plot.object.PlotBlock;
import java.util.Set; 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.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
@ -43,26 +55,13 @@ import org.bukkit.generator.BlockPopulator;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.intellectualcrafters.plot.PS; import java.util.ArrayList;
import com.intellectualcrafters.plot.object.BlockLoc; import java.util.Collections;
import com.intellectualcrafters.plot.object.ChunkLoc; import java.util.HashMap;
import com.intellectualcrafters.plot.object.Location; import java.util.HashSet;
import com.intellectualcrafters.plot.object.Plot; import java.util.List;
import com.intellectualcrafters.plot.object.PlotBlock; import java.util.Random;
import com.intellectualcrafters.plot.object.PlotId; import java.util.Set;
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;
public class BukkitChunkManager extends ChunkManager { public class BukkitChunkManager extends ChunkManager {
@Override @Override
@ -83,7 +82,7 @@ public class BukkitChunkManager extends ChunkManager {
// Chunk chunk = worldObj.getChunkAt(loc.x, loc.z); // Chunk chunk = worldObj.getChunkAt(loc.x, loc.z);
worldObj.regenerateChunk(loc.x, loc.z); worldObj.regenerateChunk(loc.x, loc.z);
if (BlockUpdateUtil.setBlockManager != null) { if (BlockUpdateUtil.setBlockManager != null) {
BlockUpdateUtil.setBlockManager.update(world, Arrays.asList(loc)); BlockUpdateUtil.setBlockManager.update(world, Collections.singletonList(loc));
} }
for (final Player player : worldObj.getPlayers()) { for (final Player player : worldObj.getPlayers()) {
final org.bukkit.Location locObj = player.getLocation(); final org.bukkit.Location locObj = player.getLocation();
@ -854,8 +853,7 @@ public class BukkitChunkManager extends ChunkManager {
@Override @Override
public boolean loadChunk(final String world, final ChunkLoc loc, final boolean force) { 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 BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
return result;
} }
@Override @Override
@ -902,10 +900,8 @@ public class BukkitChunkManager extends ChunkManager {
BukkitSetBlockManager.setBlockManager.set(world2, xx, y, zz, 0, (byte) 0); BukkitSetBlockManager.setBlockManager.set(world2, xx, y, zz, 0, (byte) 0);
} }
} else if (id2 == 0) { } else if (id2 == 0) {
if (id1 != 0) {
BukkitSetBlockManager.setBlockManager.set(world1, x, y, z, 0, (byte) 0); BukkitSetBlockManager.setBlockManager.set(world1, x, y, z, 0, (byte) 0);
BukkitSetBlockManager.setBlockManager.set(world2, xx, y, zz, id1, data1); BukkitSetBlockManager.setBlockManager.set(world2, xx, y, zz, id1, data1);
}
} else if (id1 == id2) { } else if (id1 == id2) {
if (data1 != data2) { if (data1 != data2) {
block1.setData(data2); block1.setData(data2);
@ -948,8 +944,8 @@ public class BukkitChunkManager extends ChunkManager {
final int[] count = new int[6]; final int[] count = new int[6];
final World world = BukkitUtil.getWorld(plot.world); final World world = BukkitUtil.getWorld(plot.world);
final Location bot = MainUtil.getPlotBottomLocAbs(plot.world, plot.id); final Location bot = MainUtil.getPlotBottomLocAbs(plot.world, plot.getId());
final Location top = MainUtil.getPlotTopLocAbs(plot.world, plot.id); final Location top = MainUtil.getPlotTopLocAbs(plot.world, plot.getId());
final int bx = bot.getX() >> 4; final int bx = bot.getX() >> 4;
final int bz = bot.getZ() >> 4; final int bz = bot.getZ() >> 4;
@ -985,7 +981,7 @@ public class BukkitChunkManager extends ChunkManager {
count(count, entity); count(count, entity);
} else { } else {
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(loc)); final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(loc));
if (plot.id.equals(id)) { if (plot.getId().equals(id)) {
count(count, entity); count(count, entity);
} }
} }
@ -999,7 +995,7 @@ public class BukkitChunkManager extends ChunkManager {
for (final Entity entity : ents) { for (final Entity entity : ents) {
if ((X == bx) || (X == tx) || (Z == bz) || (Z == tz)) { if ((X == bx) || (X == tx) || (Z == bz) || (Z == tz)) {
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity)); final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity));
if (plot.id.equals(id)) { if (plot.getId().equals(id)) {
count(count, entity); count(count, entity);
} }
} else { } else {
@ -1169,7 +1165,7 @@ public class BukkitChunkManager extends ChunkManager {
restoreEntities(world, 0, 0); restoreEntities(world, 0, 0);
} }
MainUtil.update(world.getName(), chunkLoc); MainUtil.update(world.getName(), chunkLoc);
BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); BukkitSetBlockManager.setBlockManager.update(Collections.singletonList(chunk));
CURRENT_PLOT_CLEAR = null; CURRENT_PLOT_CLEAR = null;
} }

View File

@ -1,5 +1,6 @@
package com.plotsquared.bukkit.util; package com.plotsquared.bukkit.util;
import com.plotsquared.bukkit.object.BukkitPlayer;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
@ -54,19 +55,19 @@ public class BukkitEconHandler extends EconHandler {
public double getMoney(final PlotPlayer player) { public double getMoney(final PlotPlayer player) {
final double bal = super.getMoney(player); final double bal = super.getMoney(player);
if (Double.isNaN(bal)) { if (Double.isNaN(bal)) {
return econ.getBalance(player.getName()); return econ.getBalance(((BukkitPlayer)player).player);
} }
return bal; return bal;
} }
@Override @Override
public void withdrawMoney(final PlotPlayer player, final double amount) { public void withdrawMoney(final PlotPlayer player, final double amount) {
econ.withdrawPlayer(player.getName(), amount); econ.withdrawPlayer(((BukkitPlayer)player).player, amount);
} }
@Override @Override
public void depositMoney(final PlotPlayer player, final double amount) { public void depositMoney(final PlotPlayer player, final double amount) {
econ.depositPlayer(player.getName(), amount); econ.depositPlayer(((BukkitPlayer)player).player, amount);
} }
@Override @Override

View File

@ -11,7 +11,7 @@ public class BukkitTaskManager extends TaskManager {
return BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, r, interval, interval); return BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, r, interval, interval);
} }
@Override @SuppressWarnings("deprecation") @Override
public int taskRepeatAsync(final Runnable r, final int interval) { public int taskRepeatAsync(final Runnable r, final int interval) {
return BukkitMain.THIS.getServer().getScheduler().scheduleAsyncRepeatingTask(BukkitMain.THIS, r, interval, interval); return BukkitMain.THIS.getServer().getScheduler().scheduleAsyncRepeatingTask(BukkitMain.THIS, r, interval, interval);
} }

View File

@ -24,10 +24,8 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
public LowerOfflineUUIDWrapper() { public LowerOfflineUUIDWrapper() {
try { try {
getOnline = Server.class.getMethod("getOnlinePlayers", new Class[0]); getOnline = Server.class.getMethod("getOnlinePlayers");
} catch (final NoSuchMethodException e) { } catch (final NoSuchMethodException | SecurityException e) {
e.printStackTrace();
} catch (final SecurityException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -73,7 +71,8 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
@Override @Override
public Player[] getOnlinePlayers() { public Player[] getOnlinePlayers() {
if (getOnline == null) { if (getOnline == null) {
return Bukkit.getOnlinePlayers().toArray(new Player[0]); Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
} }
try { try {
final Object players = getOnline.invoke(Bukkit.getServer(), arg); final Object players = getOnline.invoke(Bukkit.getServer(), arg);
@ -82,12 +81,13 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
} else { } else {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final Collection<? extends Player> p = (Collection<? extends Player>) players; 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) { } catch (final Exception e) {
PS.debug("Failed to resolve online players"); PS.debug("Failed to resolve online players");
getOnline = null; getOnline = null;
return Bukkit.getOnlinePlayers().toArray(new Player[0]); Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
} }
} }

View File

@ -25,10 +25,8 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
public OfflineUUIDWrapper() { public OfflineUUIDWrapper() {
try { try {
getOnline = Server.class.getMethod("getOnlinePlayers", new Class[0]); getOnline = Server.class.getMethod("getOnlinePlayers");
} catch (final NoSuchMethodException e) { } catch (final NoSuchMethodException | SecurityException e) {
e.printStackTrace();
} catch (final SecurityException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -72,7 +70,8 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
public Player[] getOnlinePlayers() { public Player[] getOnlinePlayers() {
if (getOnline == null) { if (getOnline == null) {
return Bukkit.getOnlinePlayers().toArray(new Player[0]); Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
} }
try { try {
final Object players = getOnline.invoke(Bukkit.getServer(), arg); final Object players = getOnline.invoke(Bukkit.getServer(), arg);
@ -81,12 +80,13 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
} else { } else {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final Collection<? extends Player> p = (Collection<? extends Player>) players; 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) { } catch (final Exception e) {
PS.debug("Failed to resolve online players"); PS.debug("Failed to resolve online players");
getOnline = null; getOnline = null;
return Bukkit.getOnlinePlayers().toArray(new Player[0]); Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
} }
} }

View File

@ -1,22 +1,5 @@
package com.plotsquared.bukkit.uuid; 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.google.common.collect.HashBiMap;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; 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.UUIDHandler;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; 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 { public class SQLUUIDHandler extends UUIDHandlerImplementation {
@ -220,7 +219,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
connection.setUseCaches(false); connection.setUseCaches(false);
connection.setDoInput(true); connection.setDoInput(true);
connection.setDoOutput(true); connection.setDoOutput(true);
String body = JSONArray.toJSONString(Arrays.asList(name)); String body = JSONArray.toJSONString(Collections.singletonList(name));
OutputStream stream = connection.getOutputStream(); OutputStream stream = connection.getOutputStream();
stream.write(body.getBytes()); stream.write(body.getBytes());
stream.flush(); stream.flush();

View File

@ -24,7 +24,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
@ -47,6 +46,8 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
/** /**
*/ */
public class PlotListener { public class PlotListener {
@ -55,7 +56,7 @@ public class PlotListener {
return false; return false;
} }
final Plot last = (Plot) pp.getMeta("lastplot"); 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); plotExit(pp, last);
} }
pp.setMeta("lastplot", MainUtil.getPlot(plot)); pp.setMeta("lastplot", MainUtil.getPlot(plot));
@ -103,7 +104,7 @@ public class PlotListener {
if (!Permissions.hasPermission(pp, "plots.gamemode.bypass")) { if (!Permissions.hasPermission(pp, "plots.gamemode.bypass")) {
pp.setGamemode((PlotGamemode) gamemodeFlag.getValue()); pp.setGamemode((PlotGamemode) gamemodeFlag.getValue());
} else { } 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 @Override
public void run() { public void run() {
final Plot lastPlot = (Plot) pp.getMeta("lastplot"); 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<>(); final Map<String, String> replacements = new HashMap<>();
replacements.put("%x%", lastPlot.id.x + ""); replacements.put("%x%", lastPlot.getId().x + "");
replacements.put("%z%", lastPlot.id.y + ""); replacements.put("%z%", lastPlot.getId().y + "");
replacements.put("%world%", plot.world); replacements.put("%world%", plot.world);
replacements.put("%greeting%", greeting); replacements.put("%greeting%", greeting);
replacements.put("%alias", plot.toString()); replacements.put("%alias", plot.toString());
@ -188,7 +189,7 @@ public class PlotListener {
pp.deleteMeta("lastplot"); pp.deleteMeta("lastplot");
EventUtil.manager.callLeave(pp, plot); EventUtil.manager.callLeave(pp, plot);
if (plot.hasOwner()) { if (plot.hasOwner()) {
final PlotWorld pw = PS.get().getPlotWorld(pp.getLocation().getWorld()); final PlotWorld pw = plot.getWorld();
if (pw == null) { if (pw == null) {
return true; return true;
} }

View File

@ -399,7 +399,7 @@ public class MainListener {
// - Getting displayname currently causes NPE, so wait until sponge fixes that // - Getting displayname currently causes NPE, so wait until sponge fixes that
final String sender = player.getName(); 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 String newMessage = StringMan.replaceAll(C.PLOT_CHAT_FORMAT.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
final Text forcedMessage = event.getMessage(); final Text forcedMessage = event.getMessage();
// String forcedMessage = StringMan.replaceAll(C.PLOT_CHAT_FORCED.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender); // 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; return;
} }
} else if ((lastPlot != null) && id.equals(lastPlot.id)) { } else if ((lastPlot != null) && id.equals(lastPlot.getId())) {
return; return;
} else { } else {
final Plot plot = MainUtil.getPlot(worldname, id); final Plot plot = MainUtil.getPlot(worldname, id);
@ -873,7 +873,7 @@ public class MainListener {
} }
return; return;
} }
} else if ((lastPlot != null) && id.equals(lastPlot.id)) { } else if ((lastPlot != null) && id.equals(lastPlot.getId())) {
return; return;
} else { } else {
final Plot plot = MainUtil.getPlot(worldname, id); final Plot plot = MainUtil.getPlot(worldname, id);

View File

@ -1,11 +1,9 @@
package com.plotsquared.sponge.util; package com.plotsquared.sponge.util;
import java.util.ArrayList; import com.intellectualcrafters.plot.commands.MainCommand;
import java.util.Arrays; import com.intellectualcrafters.plot.object.ConsolePlayer;
import java.util.List; import com.intellectualcrafters.plot.object.PlotPlayer;
import java.util.Optional; import com.plotsquared.sponge.SpongeMain;
import java.util.UUID;
import org.spongepowered.api.command.CommandCallable; import org.spongepowered.api.command.CommandCallable;
import org.spongepowered.api.command.CommandException; import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult; 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.Text;
import org.spongepowered.api.text.Texts; import org.spongepowered.api.text.Texts;
import com.intellectualcrafters.plot.commands.MainCommand; import java.util.ArrayList;
import com.intellectualcrafters.plot.object.ConsolePlayer; import java.util.Collections;
import com.intellectualcrafters.plot.object.PlotPlayer; import java.util.List;
import com.plotsquared.sponge.SpongeMain; import java.util.Optional;
import java.util.UUID;
public class SpongeCommand implements CommandCallable { public class SpongeCommand implements CommandCallable {
@ -42,7 +41,7 @@ public class SpongeCommand implements CommandCallable {
@Override @Override
public List<String> getSuggestions(final CommandSource cmd, final String string) throws CommandException { public List<String> getSuggestions(final CommandSource cmd, final String string) throws CommandException {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return new ArrayList<>(Arrays.asList("TEST")); return new ArrayList<>(Collections.singletonList("TEST"));
} }
@Override @Override

View File

@ -1,16 +1,16 @@
package com.plotsquared.sponge.uuid; 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.google.common.base.Charsets;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer; import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.sponge.SpongeMain; 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 { public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
@ -75,7 +75,8 @@ public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
} }
public Player[] getOnlinePlayers() { 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 @Override

Binary file not shown.