New API method, more 1.13 entity support, and cleanup.

Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
matt
2019-02-15 12:50:43 -05:00
parent 4f27abb4a0
commit a64d764cc1
12 changed files with 319 additions and 313 deletions

View File

@ -15,13 +15,13 @@ import java.util.stream.Collectors;
public abstract class FileConfiguration extends MemoryConfiguration {
/**
* Creates an empty {@link FileConfiguration} with no default values.
* Creates an empty FileConfiguration with no default values.
*/
FileConfiguration() {
}
/**
* Creates an empty {@link FileConfiguration} using the specified {@link
* Creates an empty FileConfiguration using the specified {@link
* Configuration} as a source for all default values.
*
* @param defaults Default value provider
@ -31,7 +31,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
}
/**
* Saves this {@link FileConfiguration} to the specified location.
* Saves this FileConfiguration to the specified location.
*
* <p>If the file does not exist, it will be created. If already exists, it
* will be overwritten. If it cannot be overwritten or created, an
@ -59,14 +59,14 @@ public abstract class FileConfiguration extends MemoryConfiguration {
}
/**
* Saves this {@link FileConfiguration} to a string, and returns it.
* Saves this FileConfiguration to a string, and returns it.
*
* @return String containing this configuration.
*/
public abstract String saveToString();
/**
* Loads this {@link FileConfiguration} from the specified location.
* Loads this FileConfiguration from the specified location.
*
* <p>All the values contained within this configuration will be removed,
* leaving only settings and defaults, and the new values will be loaded
@ -85,13 +85,13 @@ public abstract class FileConfiguration extends MemoryConfiguration {
*/
public void load(File file) throws IOException, InvalidConfigurationException {
FileInputStream stream = new FileInputStream(file);
load(new InputStreamReader(stream, StandardCharsets.UTF_8));
try (FileInputStream stream = new FileInputStream(file)) {
load(new InputStreamReader(stream, StandardCharsets.UTF_8));
}
}
/**
* Loads this {@link FileConfiguration} from the specified reader.
* Loads this FileConfiguration from the specified reader.
*
* <p>All the values contained within this configuration will be removed,
* leaving only settings and defaults, and the new values will be loaded
@ -117,7 +117,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
}
/**
* Loads this {@link FileConfiguration} from the specified string, as
* Loads this FileConfiguration from the specified string, as
* opposed to from file.
*
* <p>All the values contained within this configuration will be removed,
@ -133,7 +133,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
public abstract void loadFromString(String contents) throws InvalidConfigurationException;
/**
* Compiles the header for this {@link FileConfiguration} and returns the
* Compiles the header for this FileConfiguration and returns the
* result.
*
* <p>This will use the header from {@link #options()} -> {@link

View File

@ -41,6 +41,7 @@ import java.nio.file.Files;
import java.sql.SQLException;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Consumer;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@ -1817,6 +1818,12 @@ import java.util.zip.ZipInputStream;
return Double.parseDouble(System.getProperty("java.specification.version"));
}
public void forEachPlotArea(Consumer<? super PlotArea> action) {
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
action.accept(area);
}
}
public void foreachPlotArea(@Nonnull final RunnableVal<PlotArea> runnable) {
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
runnable.run(area);

View File

@ -1513,6 +1513,7 @@ public class Plot {
return WorldUtil.IMP.getBiome(loc.getWorld(), loc.getX(), loc.getZ());
}
//TODO Better documentation needed.
/**
* Return the top location for the plot.
*
@ -1525,7 +1526,6 @@ public class Plot {
}
//TODO Better documentation needed.
/**
* Return the bottom location for the plot.
*/
@ -1573,7 +1573,7 @@ public class Plot {
}
/**
* Move the settings for a plot.
* Moves the settings for a plot.
*
* @param plot the plot to move
* @param whenDone
@ -1710,7 +1710,7 @@ public class Plot {
}
/**
* Move the plot to an empty location<br>
* Moves the plot to an empty location<br>
* - The location must be empty
*
* @param destination Where to move the plot
@ -2616,6 +2616,7 @@ public class Plot {
}
/**
*
* Do the plot entry tasks for each player in the plot<br>
* - Usually called when the plot state changes (unclaimed/claimed/flag change etc)
*/
@ -2735,12 +2736,9 @@ public class Plot {
}
/**
* Expand the world border to include the provided plot (if applicable).
* Expands the world border to include this plot if it is beyond the current border.
*/
public void updateWorldBorder() {
if (this.owner == null) {
return;
}
int border = this.area.getBorder();
if (border == Integer.MAX_VALUE) {
return;
@ -2811,7 +2809,7 @@ public class Plot {
}
/**
* Move a plot physically, as well as the corresponding settings.
* Moves a plot physically, as well as the corresponding settings.
*
* @param destination Plot moved to
* @param whenDone task when done

View File

@ -655,7 +655,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
}
}
public interface PlotPlayerConverter<BaseObject> {
@FunctionalInterface public interface PlotPlayerConverter<BaseObject> {
PlotPlayer convert(BaseObject object);
}
}

View File

@ -39,9 +39,9 @@ public class Schematic {
}
public void save(File file) throws IOException {
SpongeSchematicWriter ssw =
new SpongeSchematicWriter(new NBTOutputStream(new FileOutputStream(file)));
ssw.write(clipboard);
ssw.close();
try (SpongeSchematicWriter ssw = new SpongeSchematicWriter(
new NBTOutputStream(new FileOutputStream(file)))) {
ssw.write(clipboard);
}
}
}

View File

@ -87,7 +87,7 @@ public abstract class SchematicHandler {
} else {
MainUtil.sendMessage(null, "&7 - &a success: " + plot.getId());
}
TaskManager.runTask(THIS::run);
TaskManager.runTask(THIS);
});
}
}
@ -104,7 +104,6 @@ public abstract class SchematicHandler {
* @param plot plot to paste in
* @param xOffset offset x to paste it from plot origin
* @param zOffset offset z to paste it from plot origin
* @return boolean true if succeeded
*/
public void paste(final Schematic schematic, final Plot plot, final int xOffset,
final int yOffset, final int zOffset, final boolean autoHeight,
@ -126,7 +125,7 @@ public abstract class SchematicHandler {
if (!flags.isEmpty()) {
for (Map.Entry<String, Tag> entry : flags.entrySet()) {
plot.setFlag(Flags.getFlag(entry.getKey()),
StringTag.class.cast(entry.getValue()).getValue());
((StringTag) entry.getValue()).getValue());
}
}
@ -341,20 +340,17 @@ public abstract class SchematicHandler {
}
public List<String> getSaves(UUID uuid) {
StringBuilder rawJSON = new StringBuilder();
String rawJSON = "";
try {
String website = Settings.Web.URL + "list.php?" + uuid.toString();
URL url = new URL(website);
URLConnection connection = new URL(url.toString()).openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
BufferedReader reader =
new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
rawJSON.append(line);
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(connection.getInputStream()))) {
rawJSON = reader.lines().collect(Collectors.joining());
}
reader.close();
JSONArray array = new JSONArray(rawJSON.toString());
JSONArray array = new JSONArray(rawJSON);
List<String> schematics = new ArrayList<>();
for (int i = 0; i < array.length(); i++) {
String schematic = array.getString(i);

View File

@ -78,13 +78,14 @@ public abstract class WorldUtil {
map.put("SpawnX", new IntTag(home.getX()));
map.put("SpawnY", new IntTag(home.getY()));
map.put("SpawnZ", new IntTag(home.getZ()));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (NBTOutputStream out = new NBTOutputStream(
new GZIPOutputStream(baos, true))) {
//TODO Find what this should be called
out.writeNamedTag("Schematic????", tag);
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
try (NBTOutputStream out = new NBTOutputStream(
new GZIPOutputStream(baos, true))) {
//TODO Find what this should be called
out.writeNamedTag("Schematic????", tag);
}
zos.write(baos.toByteArray());
}
zos.write(baos.toByteArray());
}
}
setSpawn(spawn);