Various changes

This commit is contained in:
Matt 2016-03-14 02:18:04 -04:00
parent ae885eafca
commit bee6f83e79
25 changed files with 250 additions and 263 deletions

View File

@ -623,10 +623,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
PS.get().loadWorld(worldname, (BukkitPlotGenerator) gen); PS.get().loadWorld(worldname, (BukkitPlotGenerator) gen);
} else if (gen != null) { } else if (gen != null) {
PS.get().loadWorld(worldname, new BukkitPlotGenerator(worldname, gen)); PS.get().loadWorld(worldname, new BukkitPlotGenerator(worldname, gen));
} else { } else if (PS.get().config.contains("worlds." + worldname)) {
if (PS.get().config.contains("worlds." + worldname)) { PS.get().loadWorld(worldname, null);
PS.get().loadWorld(worldname, null);
}
} }
} }

View File

@ -51,12 +51,12 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
} }
ChatColor color = ChatColor.WHITE; ChatColor color = ChatColor.WHITE;
ArrayList<ChatColor> styles = new ArrayList<ChatColor>(); ArrayList<ChatColor> styles = new ArrayList<>();
String clickActionName = null, clickActionData = null, hoverActionName = null; String clickActionName = null, clickActionData = null, hoverActionName = null;
JsonRepresentedObject hoverActionData = null; JsonRepresentedObject hoverActionData = null;
TextualComponent text = null; TextualComponent text = null;
String insertionData = null; String insertionData = null;
ArrayList<JsonRepresentedObject> translationReplacements = new ArrayList<JsonRepresentedObject>(); ArrayList<JsonRepresentedObject> translationReplacements = new ArrayList<>();
MessagePart(final TextualComponent text) { MessagePart(final TextualComponent text) {
this.text = text; this.text = text;
@ -134,7 +134,7 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
@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("text", text); map.put("text", text);
map.put("styles", styles); map.put("styles", styles);
map.put("color", color.getChar()); map.put("color", color.getChar());

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.Collections;
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);
@ -69,35 +68,14 @@ public abstract class APlotMeConnector {
public void setMerged(final HashMap<String, HashMap<PlotId, boolean[]>> merges, final String world, final PlotId id, final int direction) { public void setMerged(final HashMap<String, HashMap<PlotId, boolean[]>> merges, final String world, final PlotId id, final int direction) {
final HashMap<PlotId, boolean[]> plots = merges.get(world); final HashMap<PlotId, boolean[]> plots = merges.get(world);
PlotId id2; PlotId id2 = new PlotId(id.x, id.y);
switch (direction) {
case 0: {
id2 = new PlotId(id.x, id.y);
break;
}
case 1: {
id2 = new PlotId(id.x, id.y);
break;
}
case 2: {
id2 = new PlotId(id.x, id.y);
break;
}
case 3: {
id2 = new PlotId(id.x, id.y);
break;
}
default: {
return;
}
}
boolean[] merge1; boolean[] merge1;
boolean[] merge2;
if (plots.containsKey(id)) { if (plots.containsKey(id)) {
merge1 = plots.get(id); merge1 = plots.get(id);
} else { } else {
merge1 = new boolean[] { false, false, false, false }; merge1 = new boolean[] { false, false, false, false };
} }
boolean[] merge2;
if (plots.containsKey(id2)) { if (plots.containsKey(id2)) {
merge2 = plots.get(id2); merge2 = plots.get(id2);
} else { } else {

View File

@ -24,7 +24,11 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.GeneratorWrapper; import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.SetupObject;
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 com.intellectualcrafters.plot.util.PlotChunk; import com.intellectualcrafters.plot.util.PlotChunk;
@ -48,9 +52,9 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
private final PseudoRandom random = new PseudoRandom(); private final PseudoRandom random = new PseudoRandom();
private final IndependentPlotGenerator plotGenerator; private final IndependentPlotGenerator plotGenerator;
private final List<BlockPopulator> populators = new ArrayList<>(); private final List<BlockPopulator> populators = new ArrayList<>();
private final ChunkGenerator platformGenerator;
private final boolean full;
private boolean loaded = false; private boolean loaded = false;
private ChunkGenerator platformGenerator;
private boolean full;
public BukkitPlotGenerator(IndependentPlotGenerator generator) { public BukkitPlotGenerator(IndependentPlotGenerator generator) {
this.plotGenerator = generator; this.plotGenerator = generator;
@ -58,11 +62,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
populators.add(new BlockPopulator() { populators.add(new BlockPopulator() {
@Override @Override
public void populate(World world, Random r, Chunk c) { public void populate(World world, Random r, Chunk c) {
if (!(chunkSetter instanceof GenChunk)) {
PS.debug("Current PlotChunk is not relevant to population?");
PS.stacktrace();
return;
}
GenChunk result = (GenChunk) chunkSetter; GenChunk result = (GenChunk) chunkSetter;
if (result.result_data != null) { if (result.result_data != null) {
for (int i = 0; i < result.result_data.length; i++) { for (int i = 0; i < result.result_data.length; i++) {
@ -90,7 +89,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName() + " is already a BukkitPlotGenerator!"); throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName() + " is already a BukkitPlotGenerator!");
} }
this.full = false; this.full = false;
PS.get().debug("BukkitPlotGenerator does not fully support: " + cg); PS.debug("BukkitPlotGenerator does not fully support: " + cg);
platformGenerator = cg; platformGenerator = cg;
plotGenerator = new IndependentPlotGenerator() { plotGenerator = new IndependentPlotGenerator() {
@Override @Override
@ -229,11 +228,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
@Override @Override
public ChunkData generateChunkData(World world, Random random, int cx, int cz, BiomeGrid grid) { public ChunkData generateChunkData(World world, Random random, int cx, int cz, BiomeGrid grid) {
if (!(chunkSetter instanceof GenChunk)) {
PS.debug("Current PlotChunk is not relevant to generation?");
PS.stacktrace();
return null;
}
GenChunk result = (GenChunk) chunkSetter; GenChunk result = (GenChunk) chunkSetter;
// Set the chunk location // Set the chunk location
result.setChunkWrapper(SetQueue.IMP.new ChunkWrapper(world.getName(), cx, cz)); result.setChunkWrapper(SetQueue.IMP.new ChunkWrapper(world.getName(), cx, cz));
@ -278,10 +272,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
@Override @Override
public short[][] generateExtBlockSections(final World world, final Random r, final int cx, final int cz, final BiomeGrid grid) { public short[][] generateExtBlockSections(final World world, final Random r, final int cx, final int cz, final BiomeGrid grid) {
if (!(chunkSetter instanceof GenChunk)) {
PS.stacktrace();
return new short[16][];
}
GenChunk result = (GenChunk) chunkSetter; GenChunk result = (GenChunk) chunkSetter;
// Set the chunk location // Set the chunk location
result.setChunkWrapper(SetQueue.IMP.new ChunkWrapper(world.getName(), cx, cz)); result.setChunkWrapper(SetQueue.IMP.new ChunkWrapper(world.getName(), cx, cz));

View File

@ -27,16 +27,6 @@ import com.plotsquared.bukkit.object.BukkitLazyBlock;
import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlayerBlockEventType; import com.plotsquared.listener.PlayerBlockEventType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -115,11 +105,21 @@ import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
/** /**
* Player Events involving plots * Player Events involving plots
* *
*/ */
@SuppressWarnings({ "deprecation", "unchecked" })
public class PlayerEvents extends com.plotsquared.listener.PlotListener implements Listener { public class PlayerEvents extends com.plotsquared.listener.PlotListener implements Listener {
private boolean pistonBlocks = true; private boolean pistonBlocks = true;
@ -353,11 +353,11 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (c.equals(cmdLabel.getName())) { if (c.equals(cmdLabel.getName())) {
break; break;
} }
PluginCommand p;
final String label = cmdLabel.getName().replaceFirst("/", ""); final String label = cmdLabel.getName().replaceFirst("/", "");
if (aliases.contains(label)) { if (aliases.contains(label)) {
continue; continue;
} }
PluginCommand p;
if ((p = Bukkit.getPluginCommand(label)) != null) { if ((p = Bukkit.getPluginCommand(label)) != null) {
for (String a : p.getAliases()) { for (String a : p.getAliases()) {
if (aliases.contains(a)) { if (aliases.contains(a)) {

View File

@ -34,6 +34,7 @@ import org.bukkit.util.Vector;
public class EntityWrapper { public class EntityWrapper {
private final int hash;
public EntityType type; public EntityType type;
public float yaw; public float yaw;
public float pitch; public float pitch;
@ -54,8 +55,6 @@ public class EntityWrapper {
private HorseStats horse; private HorseStats horse;
private ArmorStandStats stand; private ArmorStandStats stand;
private int hash;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public EntityWrapper(final org.bukkit.entity.Entity entity, final short depth) { public EntityWrapper(final org.bukkit.entity.Entity entity, final short depth) {
hash = entity.getEntityId(); hash = entity.getEntityId();
@ -153,10 +152,7 @@ public class EntityWrapper {
} }
// END MISC // // END MISC //
// INVENTORY HOLDER // // INVENTORY HOLDER //
case MINECART_CHEST: { case MINECART_CHEST:
storeInventory((InventoryHolder) entity);
return;
}
case MINECART_HOPPER: { case MINECART_HOPPER: {
storeInventory((InventoryHolder) entity); storeInventory((InventoryHolder) entity);
return; return;
@ -508,10 +504,7 @@ public class EntityWrapper {
} }
// END MISC // // END MISC //
// INVENTORY HOLDER // // INVENTORY HOLDER //
case MINECART_CHEST: { case MINECART_CHEST:
restoreInventory((InventoryHolder) entity);
return entity;
}
case MINECART_HOPPER: { case MINECART_HOPPER: {
restoreInventory((InventoryHolder) entity); restoreInventory((InventoryHolder) entity);
return entity; return entity;

View File

@ -558,7 +558,7 @@ public class JSONArray {
* @return this. * @return this.
*/ */
public JSONArray put(final int value) { public JSONArray put(final int value) {
this.put(new Integer(value)); this.put(Integer.valueOf(value));
return this; return this;
} }
@ -570,7 +570,7 @@ public class JSONArray {
* @return this. * @return this.
*/ */
public JSONArray put(final long value) { public JSONArray put(final long value) {
this.put(new Long(value)); this.put(Long.valueOf(value));
return this; return this;
} }
@ -658,7 +658,7 @@ public class JSONArray {
* @throws JSONException If the index is negative. * @throws JSONException If the index is negative.
*/ */
public JSONArray put(final int index, final int value) throws JSONException { public JSONArray put(final int index, final int value) throws JSONException {
this.put(index, new Integer(value)); this.put(index, Integer.valueOf(value));
return this; return this;
} }
@ -674,7 +674,7 @@ public class JSONArray {
* @throws JSONException If the index is negative. * @throws JSONException If the index is negative.
*/ */
public JSONArray put(final int index, final long value) throws JSONException { public JSONArray put(final int index, final long value) throws JSONException {
this.put(index, new Long(value)); this.put(index, Long.valueOf(value));
return this; return this;
} }

View File

@ -452,7 +452,7 @@ public class JSONObject {
return d; return d;
} }
} else { } else {
final Long myLong = new Long(string); final Long myLong = Long.valueOf(string);
if (string.equals(myLong.toString())) { if (string.equals(myLong.toString())) {
if (myLong == myLong.intValue()) { if (myLong == myLong.intValue()) {
return myLong.intValue(); return myLong.intValue();

View File

@ -8,18 +8,19 @@ import java.util.Iterator;
* @author JSON.org * @author JSON.org
* @version 2014-05-03 * @version 2014-05-03
*/ */
public class XML { class XML {
public static final Character AMP = '&';
public static final Character APOS = '\'';
public static final Character BANG = '!';
public static final Character EQ = '=';
public static final Character GT = '>';
public static final Character LT = '<';
public static final Character QUEST = '?';
public static final Character QUOT = '"';
public static final Character SLASH = '/';
public static String escape(final String string) { static final Character AMP = '&';
static final Character APOS = '\'';
static final Character BANG = '!';
static final Character EQ = '=';
static final Character GT = '>';
static final Character LT = '<';
static final Character QUEST = '?';
static final Character QUOT = '"';
static final Character SLASH = '/';
static String escape(final String string) {
final StringBuilder sb = new StringBuilder(string.length()); final StringBuilder sb = new StringBuilder(string.length());
for (int i = 0, length = string.length(); i < length; i++) { for (int i = 0, length = string.length(); i < length; i++) {
final char c = string.charAt(i); final char c = string.charAt(i);
@ -53,14 +54,13 @@ public class XML {
* *
* @throws JSONException * @throws JSONException
*/ */
public static void noSpace(final String string) throws JSONException { static void noSpace(final String string) throws JSONException {
int i;
final int length = string.length(); final int length = string.length();
if (length == 0) { if (length == 0) {
throw new JSONException("Empty string."); throw new JSONException("Empty string.");
} }
for (i = 0; i < length; i += 1) { for (char c : string.toCharArray()) {
if (Character.isWhitespace(string.charAt(i))) { if (Character.isWhitespace(c)) {
throw new JSONException("'" + string + "' contains a space character."); throw new JSONException("'" + string + "' contains a space character.");
} }
} }
@ -78,12 +78,6 @@ public class XML {
* @throws JSONException * @throws JSONException
*/ */
private static boolean parse(final XMLTokener x, final JSONObject context, final String name) throws JSONException { private static boolean parse(final XMLTokener x, final JSONObject context, final String name) throws JSONException {
char c;
int i;
JSONObject jsonobject = null;
String string;
String tagName;
Object token;
// Test for and skip past these forms: // Test for and skip past these forms:
// <!-- ... --> // <!-- ... -->
// <! ... > // <! ... >
@ -93,10 +87,11 @@ public class XML {
// <> // <>
// <= // <=
// << // <<
token = x.nextToken(); Object token = x.nextToken();
// <! // <!
String string;
if (token == BANG) { if (token == BANG) {
c = x.next(); char c = x.next();
if (c == '-') { if (c == '-') {
if (x.next() == '-') { if (x.next() == '-') {
x.skipPast("-->"); x.skipPast("-->");
@ -116,7 +111,7 @@ public class XML {
} }
throw x.syntaxError("Expected 'CDATA['"); throw x.syntaxError("Expected 'CDATA['");
} }
i = 1; int i = 1;
do { do {
token = x.nextMeta(); token = x.nextMeta();
if (token == null) { if (token == null) {
@ -149,9 +144,9 @@ public class XML {
throw x.syntaxError("Misshaped tag"); throw x.syntaxError("Misshaped tag");
// Open tag < // Open tag <
} else { } else {
tagName = (String) token; String tagName = (String) token;
token = null; token = null;
jsonobject = new JSONObject(); JSONObject jsonobject = new JSONObject();
for (;;) { for (;;) {
if (token == null) { if (token == null) {
token = x.nextToken(); token = x.nextToken();
@ -225,7 +220,7 @@ public class XML {
* *
* @return A simple JSON value. * @return A simple JSON value.
*/ */
public static Object stringToValue(final String string) { static Object stringToValue(final String string) {
if ("true".equalsIgnoreCase(string)) { if ("true".equalsIgnoreCase(string)) {
return Boolean.TRUE; return Boolean.TRUE;
} }
@ -292,12 +287,8 @@ public class XML {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
int i; int i;
JSONArray ja; JSONArray ja;
JSONObject jo;
String key;
Iterator<String> keys;
int length; int length;
String string; String string;
Object value;
if (object instanceof JSONObject) { if (object instanceof JSONObject) {
// Emit <tagName> // Emit <tagName>
if (tagName != null) { if (tagName != null) {
@ -306,11 +297,11 @@ public class XML {
sb.append('>'); sb.append('>');
} }
// Loop thru the keys. // Loop thru the keys.
jo = (JSONObject) object; JSONObject jo = (JSONObject) object;
keys = jo.keys(); Iterator<String> keys = jo.keys();
while (keys.hasNext()) { while (keys.hasNext()) {
key = keys.next(); String key = keys.next();
value = jo.opt(key); Object value = jo.opt(key);
if (value == null) { if (value == null) {
value = ""; value = "";
} }
@ -378,7 +369,7 @@ public class XML {
} }
return sb.toString(); return sb.toString();
} else { } else {
string = (object == null) ? "null" : escape(object.toString()); string = escape(object.toString());
return (tagName == null) ? "\"" + string + "\"" : return (tagName == null) ? "\"" + string + "\"" :
(string.isEmpty()) ? "<" + tagName + "/>" : "<" + tagName + ">" + string + "</" + tagName + ">"; (string.isEmpty()) ? "<" + tagName + "/>" : "<" + tagName + ">" + string + "</" + tagName + ">";
} }

View File

@ -7,8 +7,24 @@ import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.generator.AugmentedUtils; import com.intellectualcrafters.plot.generator.AugmentedUtils;
import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotMessage;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.RunnableVal3;
import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.CmdConfirm;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.io.IOException; import java.io.IOException;
@ -16,14 +32,8 @@ import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
@CommandDeclaration( @CommandDeclaration(command = "area", permission = "plots.area", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE,
command = "area", description = "Create a new PlotArea", aliases = "world", usage = "/plot area <create|info|list|tp|regen>")
permission = "plots.area",
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.NONE,
description = "Create a new PlotArea",
aliases = { "world" },
usage = "/plot area <create|info|list|tp|regen>")
public class Area extends SubCommand { public class Area extends SubCommand {
@Override @Override
@ -48,7 +58,7 @@ public class Area extends SubCommand {
case 2: { case 2: {
switch (args[1].toLowerCase()) { switch (args[1].toLowerCase()) {
case "pos1": { // Set position 1 case "pos1": { // Set position 1
HybridPlotWorld area = plr.<HybridPlotWorld> getMeta("area_create_area"); HybridPlotWorld area = plr.getMeta("area_create_area");
if (area == null) { if (area == null) {
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]..."); C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
return false; return false;
@ -61,13 +71,13 @@ public class Area extends SubCommand {
return true; return true;
} }
case "pos2": { // Set position 2 and finish creation for type=2 (partial) case "pos2": { // Set position 2 and finish creation for type=2 (partial)
final HybridPlotWorld area = plr.<HybridPlotWorld> getMeta("area_create_area"); final HybridPlotWorld area = plr.getMeta("area_create_area");
if (area == null) { if (area == null) {
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]..."); C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
return false; return false;
} }
Location pos1 = plr.getLocation(); Location pos1 = plr.getLocation();
Location pos2 = plr.<Location> getMeta("area_pos1"); Location pos2 = plr.getMeta("area_pos1");
int dx = Math.abs(pos1.getX() - pos2.getX()); int dx = Math.abs(pos1.getX() - pos2.getX());
int dz = Math.abs(pos1.getZ() - pos2.getZ()); int dz = Math.abs(pos1.getZ() - pos2.getZ());
int numx = Math.max(1, (dx + 1 + area.ROAD_WIDTH + (area.SIZE / 2)) / area.SIZE); int numx = Math.max(1, (dx + 1 + area.ROAD_WIDTH + (area.SIZE / 2)) / area.SIZE);

View File

@ -24,7 +24,13 @@ 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.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
@ -35,13 +41,8 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration( @CommandDeclaration(command = "cluster", aliases = "clusters", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE,
command = "cluster", permission = "plots.cluster", description = "Manage a plot cluster")
aliases = { "clusters" },
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.NONE,
permission = "plots.cluster",
description = "Manage a plot cluster")
public class Cluster extends SubCommand { public class Cluster extends SubCommand {
@Override @Override
@ -379,7 +380,6 @@ public class Cluster extends SubCommand {
for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) { for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
final PlotCluster current = plot.getCluster(); final PlotCluster current = plot.getCluster();
if ((current != null) && current.equals(cluster)) { if ((current != null) && current.equals(cluster)) {
plr.getLocation().getWorld();
plot.unclaim(); plot.unclaim();
} }
} }

View File

@ -94,12 +94,12 @@ public class Condense extends SubCommand {
int size = sizes.get(i); int size = sizes.get(i);
ArrayList<Plot> array = buckets[size]; ArrayList<Plot> array = buckets[size];
if (array == null) { if (array == null) {
array = new ArrayList<Plot>(); array = new ArrayList<>();
buckets[size] = array; buckets[size] = array;
} }
array.add(plot); array.add(plot);
} }
final ArrayList<Plot> allPlots = new ArrayList<Plot>(plots.size()); final ArrayList<Plot> allPlots = new ArrayList<>(plots.size());
for (int i = buckets.length - 1; i >= 0; i--) { for (int i = buckets.length - 1; i >= 0; i--) {
ArrayList<Plot> array = buckets[i]; ArrayList<Plot> array = buckets[i];
if (array != null) { if (array != null) {

View File

@ -44,14 +44,8 @@ import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration( @CommandDeclaration(command = "rate", permission = "plots.rate", description = "Rate the plot", usage = "/plot rate [#|next]", aliases = "rt",
command = "rate", category = CommandCategory.INFO, requiredType = RequiredType.NONE)
permission = "plots.rate",
description = "Rate the plot",
usage = "/plot rate [#|next]",
aliases = {"rt"},
category = CommandCategory.INFO,
requiredType = RequiredType.NONE)
public class Rate extends SubCommand { public class Rate extends SubCommand {
@Override @Override
@ -221,21 +215,23 @@ public class Rate extends SubCommand {
private int value; private int value;
public MutableInt(int i) { MutableInt(int i) {
value = i; value = i;
} }
public void increment() {
void increment() {
value++; value++;
} }
public void decrement() {
void decrement() {
value--; value--;
} }
public int getValue() { int getValue() {
return value; return value;
} }
public void add(Number v) { void add(Number v) {
this.value += v.intValue(); this.value += v.intValue();
} }
} }

View File

@ -31,7 +31,14 @@ import com.intellectualcrafters.plot.object.PlotMessage;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.Rating; import com.intellectualcrafters.plot.object.Rating;
import com.intellectualcrafters.plot.object.RunnableVal3; import com.intellectualcrafters.plot.object.RunnableVal3;
import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.ArrayList; import java.util.ArrayList;
@ -97,7 +104,7 @@ public class list extends SubCommand {
} }
public void noArgs(final PlotPlayer plr) { public void noArgs(final PlotPlayer plr) {
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(plr)); MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + Arrays.toString(getArgumentList(plr)));
} }
@Override @Override
@ -228,10 +235,9 @@ public class list extends SubCommand {
@Override @Override
public int compare(final Plot p1, final Plot p2) { public int compare(final Plot p1, final Plot p2) {
double v1 = 0; double v1 = 0;
double v2 = 0; final int p1s = p1.getSettings().getRatings().size();
final int p1s = p1.getSettings().ratings != null ? p1.getSettings().ratings.size() : 0; final int p2s = p2.getRatings().size();
final int p2s = p2.getSettings().ratings != null ? p2.getSettings().ratings.size() : 0; if (!p1.getSettings().getRatings().isEmpty()) {
if ((p1.getSettings().ratings != null) && (p1s > 0)) {
for (final Entry<UUID, Rating> entry : p1.getRatings().entrySet()) { for (final Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
final double av = entry.getValue().getAverageRating(); final double av = entry.getValue().getAverageRating();
v1 += av * av; v1 += av * av;
@ -239,7 +245,8 @@ public class list extends SubCommand {
v1 /= p1s; v1 /= p1s;
v1 += p1s; v1 += p1s;
} }
if ((p2.getSettings().ratings != null) && (p2s > 0)) { double v2 = 0;
if (!p2.getSettings().getRatings().isEmpty()) {
for (final Entry<UUID, Rating> entry : p2.getRatings().entrySet()) { for (final Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
final double av = entry.getValue().getAverageRating(); final double av = entry.getValue().getAverageRating();
v2 += av * av; v2 += av * av;
@ -415,13 +422,4 @@ public class list extends SubCommand {
}, "/plot list " + args[0], C.PLOT_LIST_HEADER_PAGED.s()); }, "/plot list " + args[0], C.PLOT_LIST_HEADER_PAGED.s());
} }
private String getArgumentList(final String[] strings) {
final StringBuilder builder = new StringBuilder();
String prefix = "";
for (final String s : strings) {
builder.append(prefix + s);
prefix = " | ";
}
return builder.toString();
}
} }

View File

@ -20,6 +20,13 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.config; package com.intellectualcrafters.plot.config;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.CommandCaller;
import java.io.File; import java.io.File;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
@ -28,13 +35,6 @@ import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.CommandCaller;
/** /**
* Captions class. * Captions class.
* *
@ -655,9 +655,7 @@ public enum C {
*/ */
C(final String d, final boolean prefix, final String cat) { C(final String d, final boolean prefix, final String cat) {
this.d = d; this.d = d;
if (s == null) { this.s = d;
s = d;
}
this.prefix = prefix; this.prefix = prefix;
this.cat = cat.toLowerCase(); this.cat = cat.toLowerCase();
} }

View File

@ -20,14 +20,14 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.database; package com.intellectualcrafters.plot.database;
import com.intellectualcrafters.plot.PS;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import com.intellectualcrafters.plot.PS;
/** /**
* Connects to and uses a MySQL database * Connects to and uses a MySQL database
* *
@ -103,8 +103,9 @@ public class MySQL extends Database {
if (checkConnection()) { if (checkConnection()) {
openConnection(); openConnection();
} }
final Statement statement = connection.createStatement(); try (Statement statement = connection.createStatement()) {
return statement.executeQuery(query); return statement.executeQuery(query);
}
} }
@Override @Override
@ -112,7 +113,8 @@ public class MySQL extends Database {
if (checkConnection()) { if (checkConnection()) {
openConnection(); openConnection();
} }
final Statement statement = connection.createStatement(); try (Statement statement = connection.createStatement()) {
return statement.executeUpdate(query); return statement.executeUpdate(query);
}
} }
} }

View File

@ -2577,7 +2577,8 @@ public class SQLManager implements AbstractDB {
try { try {
BlockLoc loc = BlockLoc.fromString(pos); BlockLoc loc = BlockLoc.fromString(pos);
cluster.settings.setPosition(loc); cluster.settings.setPosition(loc);
} catch (final Exception e) {} } catch (final Exception ignored) {
}
} }
final Integer m = r.getInt("merged"); final Integer m = r.getInt("merged");
final boolean[] merged = new boolean[4]; final boolean[] merged = new boolean[4];

View File

@ -20,6 +20,8 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.database; package com.intellectualcrafters.plot.database;
import com.intellectualcrafters.plot.PS;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.sql.Connection; import java.sql.Connection;
@ -28,11 +30,10 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import com.intellectualcrafters.plot.PS;
/** /**
* Connects to and uses a SQLite database * Connects to and uses a SQLite database
* *
* @author tips48 * @author tips48
*/ */
public class SQLite extends Database { public class SQLite extends Database {
@ -94,8 +95,9 @@ public class SQLite extends Database {
if (checkConnection()) { if (checkConnection()) {
openConnection(); openConnection();
} }
final Statement statement = connection.createStatement(); try (Statement statement = connection.createStatement()) {
return statement.executeQuery(query); return statement.executeQuery(query);
}
} }
@Override @Override
@ -103,8 +105,9 @@ public class SQLite extends Database {
if (checkConnection()) { if (checkConnection()) {
openConnection(); openConnection();
} }
final Statement statement = connection.createStatement(); try (Statement statement = connection.createStatement()) {
return statement.executeUpdate(query); return statement.executeUpdate(query);
}
} }
@Override @Override

View File

@ -97,16 +97,6 @@ public class HybridPlotWorld extends ClassicPlotWorld {
case 163: case 163:
case 164: case 164:
case 180: case 180:
data = wrap(data, 0);
data = wrap(data, 4);
data = wrap(data, 8);
data = wrap(data, 12);
return data;
case 26:
case 86:
data = wrap(data, 0);
return data;
case 64: case 64:
case 71: case 71:
case 193: case 193:
@ -127,6 +117,11 @@ public class HybridPlotWorld extends ClassicPlotWorld {
data = wrap(data, 8); data = wrap(data, 8);
data = wrap(data, 12); data = wrap(data, 12);
return data; return data;
case 26:
case 86:
data = wrap(data, 0);
return data;
case 28: case 28:
case 66: case 66:
case 157: case 157:

View File

@ -2069,7 +2069,7 @@ public class Plot {
} }
visited.add(current); visited.add(current);
Set<Plot> plots; Set<Plot> plots;
if ((max >= 0) && ((dir == -1) || (dir == 0)) && !current.getMerged(0)) { if ((dir == -1 || (dir == 0)) && !current.getMerged(0)) {
final Plot other = current.getRelative(0); final Plot other = current.getRelative(0);
if ((other != null) if ((other != null)
&& other.isOwner(uuid) && other.isOwner(uuid)

View File

@ -1,41 +1,22 @@
package com.intellectualcrafters.plot.object; package com.intellectualcrafters.plot.object;
import java.util.HashSet;
import java.util.UUID;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import java.util.HashSet;
import java.util.UUID;
public class PlotCluster { public class PlotCluster {
public PlotArea area; public PlotArea area;
public PlotSettings settings; public PlotSettings settings;
public UUID owner; public UUID owner;
public HashSet<UUID> helpers = new HashSet<UUID>(); public HashSet<UUID> helpers = new HashSet<>();
public HashSet<UUID> invited = new HashSet<UUID>(); public HashSet<UUID> invited = new HashSet<>();
public int temp;
private PlotId pos1; private PlotId pos1;
private PlotId pos2; private PlotId pos2;
private RegionWrapper region; private RegionWrapper region;
public int temp;
public PlotId getP1() {
return pos1;
}
public PlotId getP2() {
return pos2;
}
public void setP1(final PlotId id) {
pos1 = id;
setRegion();
}
public void setP2(final PlotId id) {
pos2 = id;
setRegion();
}
public PlotCluster(final PlotArea area, final PlotId pos1, final PlotId pos2, final UUID owner) { public PlotCluster(final PlotArea area, final PlotId pos1, final PlotId pos2, final UUID owner) {
this.area = area; this.area = area;
this.pos1 = pos1; this.pos1 = pos1;
@ -56,6 +37,24 @@ public class PlotCluster {
setRegion(); setRegion();
} }
public PlotId getP1() {
return pos1;
}
public void setP1(final PlotId id) {
pos1 = id;
setRegion();
}
public PlotId getP2() {
return pos2;
}
public void setP2(final PlotId id) {
pos2 = id;
setRegion();
}
private void setRegion() { private void setRegion() {
region = new RegionWrapper(pos1.x, pos2.x, pos1.y, pos2.y); region = new RegionWrapper(pos1.x, pos2.x, pos1.y, pos2.y);
} }
@ -84,6 +83,14 @@ public class PlotCluster {
return ((1 + pos2.x) - pos1.x) * ((1 + pos2.y) - pos1.y); return ((1 + pos2.x) - pos1.x) * ((1 + pos2.y) - pos1.y);
} }
public void setArea(PlotArea plotarea) {
if (this.area != null) {
this.area.removeCluster(this);
}
this.area = plotarea;
plotarea.addCluster(this);
}
@Override @Override
public int hashCode() { public int hashCode() {
return pos1.hashCode(); return pos1.hashCode();
@ -155,14 +162,6 @@ public class PlotCluster {
return (pos1.x <= this.pos2.x) && (pos2.x >= this.pos1.x) && (pos1.y <= this.pos2.y) && (pos2.y >= this.pos1.y); return (pos1.x <= this.pos2.x) && (pos2.x >= this.pos1.x) && (pos1.y <= this.pos2.y) && (pos2.y >= this.pos1.y);
} }
public void setArea(PlotArea plotarea) {
if (this.area != null) {
this.area.removeCluster(this);
}
this.area = plotarea;
plotarea.addCluster(this);
}
public boolean contains(final PlotId id) { public boolean contains(final PlotId id) {
return (pos1.x <= id.x) && (pos1.y <= id.y) && (pos2.x >= id.x) && (pos2.y >= id.y); return (pos1.x <= id.x) && (pos1.y <= id.y) && (pos2.x >= id.x) && (pos2.y >= id.y);
} }

View File

@ -7,7 +7,14 @@ import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotMessage;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.RunnableVal2;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -20,7 +27,7 @@ public class ExpireManager {
public static ExpireManager IMP; public static ExpireManager IMP;
private static HashSet<Plot> plotsToDelete; private static HashSet<Plot> plotsToDelete;
private ConcurrentHashMap<UUID, Long> dates_cache = new ConcurrentHashMap<>(); private final ConcurrentHashMap<UUID, Long> dates_cache = new ConcurrentHashMap<>();
/** /**
* 0 = stopped, 1 = stopping, 2 = running * 0 = stopped, 1 = stopping, 2 = running
*/ */
@ -154,7 +161,7 @@ public class ExpireManager {
} }
return; return;
} }
if (plots.size() == 0) { if (plots.isEmpty()) {
running = 3; running = 3;
TaskManager.runTaskLater(new Runnable() { TaskManager.runTaskLater(new Runnable() {
@Override @Override
@ -165,7 +172,6 @@ public class ExpireManager {
} }
} }
}, 86400000); }, 86400000);
return;
} else { } else {
TaskManager.runTaskLaterAsync(task, Settings.CLEAR_INTERVAL * 20); TaskManager.runTaskLaterAsync(task, Settings.CLEAR_INTERVAL * 20);
} }

View File

@ -1,24 +1,56 @@
package com.intellectualcrafters.plot.util; package com.intellectualcrafters.plot.util;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.intellectualcrafters.jnbt.*; 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.json.JSONArray;
import com.intellectualcrafters.json.JSONException; import com.intellectualcrafters.json.JSONException;
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.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.generator.ClassicPlotWorld; import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.intellectualcrafters.plot.object.schematic.PlotItem;
import java.io.*; import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.channels.Channels; import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel; import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
@ -35,7 +67,7 @@ public abstract class SchematicHandler {
return false; return false;
} }
exportAll = true; exportAll = true;
final ArrayList<Plot> plots = new ArrayList<Plot>(collection); final ArrayList<Plot> plots = new ArrayList<>(collection);
TaskManager.runTask(new Runnable() { TaskManager.runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -661,14 +693,14 @@ public abstract class SchematicHandler {
getCompoundTag(plot.getArea().worldname, plot.getRegions(), new RunnableVal<CompoundTag>() { getCompoundTag(plot.getArea().worldname, plot.getRegions(), new RunnableVal<CompoundTag>() {
@Override @Override
public void run(CompoundTag value) { public void run(CompoundTag value) {
if (plot.getFlags().size() > 0) { if (!plot.getFlags().isEmpty()) {
HashMap<String, Tag> flagMap = new HashMap<>(); HashMap<String, Tag> flagMap = new HashMap<>();
for (Map.Entry<String, Flag> entry : plot.getFlags().entrySet()) { for (Map.Entry<String, Flag> entry : plot.getFlags().entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
flagMap.put(key, new StringTag(key, entry.getValue().getValueString())); flagMap.put(key, new StringTag(key, entry.getValue().getValueString()));
} }
CompoundTag tag = new CompoundTag("Flags", flagMap); CompoundTag tag = new CompoundTag("Flags", flagMap);
HashMap<String, Tag> map = new HashMap<String, Tag>(value.getValue()); HashMap<String, Tag> map = new HashMap<>(value.getValue());
map.put("Flags", tag); map.put("Flags", tag);
value.setValue(map); value.setValue(map);
} }
@ -716,9 +748,8 @@ public abstract class SchematicHandler {
// Lossy but fast // Lossy but fast
private final short[] ids; private final short[] ids;
private final byte[] datas; private final byte[] datas;
private Map<String, Tag> flags;
private final Dimension schematicDimension; private final Dimension schematicDimension;
private Map<String, Tag> flags;
private HashSet<PlotItem> items; private HashSet<PlotItem> items;
public Schematic(final short[] i, final byte[] b, final Dimension d, Map<String, Tag> flags) { public Schematic(final short[] i, final byte[] b, final Dimension d, Map<String, Tag> flags) {

View File

@ -124,7 +124,7 @@ public class StringMan {
public static boolean isAlphanumericUnd(final String str) { public static boolean isAlphanumericUnd(final String str) {
for (int i = 0; i < str.length(); i++) { for (int i = 0; i < str.length(); i++) {
final char c = str.charAt(i); final char c = str.charAt(i);
if ((c < 0x30) || ((c >= 0x3a) && (c <= 0x40)) || ((c > 0x5a) && (c <= 0x60)) || (c > 0x7a) || (c == '_')) { if (c < 0x30 || (c >= 0x3a) && (c <= 0x40) || (c > 0x5a) && (c <= 0x60) || (c > 0x7a)) {
return false; return false;
} }
} }

View File

@ -7,15 +7,13 @@ import com.plotsquared.general.commands.Command;
public class HelpObject { public class HelpObject {
private final Command _command;
private final String _rendered; private final String _rendered;
public HelpObject(final Command command, final String label) { public HelpObject(final Command command, final String label) {
_command = command; _rendered = StringMan.replaceAll(C.HELP_ITEM.s(), "%usage%", command.getUsage().replaceAll("\\{label\\}", label), "[%alias%]",
_rendered = StringMan.replaceAll(C.HELP_ITEM.s(), "%usage%", _command.getUsage().replaceAll("\\{label\\}", label), "[%alias%]", !command.getAliases().isEmpty() ? "(" + StringMan.join(command.getAliases(), "|") + ")" : "", "%desc%", command.getDescription(),
!_command.getAliases().isEmpty() ? "(" + StringMan.join(_command.getAliases(), "|") + ")" : "", "%desc%", _command.getDescription(),
"%arguments%", "%arguments%",
buildArgumentList(_command.getRequiredArguments()), "{label}", label); buildArgumentList(command.getRequiredArguments()), "{label}", label);
} }
@Override @Override