Code Style Cleanup

This commit is contained in:
Matt
2016-03-20 22:52:16 -04:00
parent 19b6df8268
commit 029241912b
24 changed files with 633 additions and 610 deletions

View File

@ -208,7 +208,7 @@ public class PS {
@Override
public void run() {
for (final Plot plot : getPlots()) {
if (plot.hasOwner() && (plot.temp != -1)) {
if (plot.hasOwner() && plot.temp != -1) {
if (UUIDHandler.getName(plot.owner) == null) {
UUIDHandler.implementation.unknown.add(plot.owner);
}
@ -376,8 +376,8 @@ public class PS {
* @return true if `version` is >= `version2`
*/
public boolean checkVersion(final int[] version, int... version2) {
return (version[0] > version2[0]) || ((version[0] == version2[0]) && (version[1] > version2[1])) || ((version[0] == version2[0]) && (version[1] == version2[1]) && (
version[2] >= version2[2]));
return version[0] > version2[0] || version[0] == version2[0] && version[1] > version2[1] || version[0] == version2[0]
&& version[1] == version2[1] && version[2] >= version2[2];
}
/**
@ -518,7 +518,7 @@ public class PS {
if (areas == null) {
for (PlotArea area : plotareas) {
if (area.worldname.equalsIgnoreCase(split[0])) {
if (area.id == null || (split.length == 2 && area.id.equalsIgnoreCase(split[1]))) {
if (area.id == null || split.length == 2 && area.id.equalsIgnoreCase(split[1])) {
return area;
}
}
@ -902,7 +902,7 @@ public class PS {
} else {
extra.add(plot);
}
} else if ((Math.abs(plot.getId().x) > 15446) || (Math.abs(plot.getId().y) > 15446)) {
} else if (Math.abs(plot.getId().x) > 15446 || Math.abs(plot.getId().y) > 15446) {
extra.add(plot);
} else {
overflow.add(plot);
@ -950,7 +950,7 @@ public class PS {
} else {
extra.add(plot);
}
} else if ((Math.abs(plot.getId().x) > 15446) || (Math.abs(plot.getId().y) > 15446)) {
} else if (Math.abs(plot.getId().x) > 15446 || Math.abs(plot.getId().y) > 15446) {
extra.add(plot);
} else {
overflow.add(plot);
@ -1011,7 +1011,7 @@ public class PS {
for (final Plot i : input) {
int tmp = MathMan.getPositiveId(i.hashCode()) / placement;
bucket[tmp & 31].add(i);
if (maxLength && (tmp > 0)) {
if (maxLength && tmp > 0) {
maxLength = false;
}
}
@ -1062,7 +1062,7 @@ public class PS {
Collections.sort(areas, new Comparator<PlotArea>() {
@Override
public int compare(final PlotArea a, final PlotArea b) {
if ((priorityArea != null) && StringMan.isEqual(a.toString(), b.toString())) {
if (priorityArea != null && StringMan.isEqual(a.toString(), b.toString())) {
return -1;
}
return a.hashCode() - b.hashCode();
@ -1229,7 +1229,7 @@ public class PS {
}
public Plot getPlot(PlotArea area, final PlotId id) {
return area == null ? null : (id == null ? null : area.getPlot(id));
return area == null ? null : id == null ? null : area.getPlot(id);
}
/**
@ -1338,7 +1338,7 @@ public class PS {
if (!plotareaHasCollision && !plotareaHashCheck.add(world.hashCode())) {
plotareaHasCollision = true;
}
final Set<String> worlds = (config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet<String>());
final Set<String> worlds = config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet<String>();
final String path = "worlds." + world;
ConfigurationSection worldSection = config.getConfigurationSection(path);
int type = worldSection != null ? worldSection.getInt("generator.type") : 0;
@ -1543,7 +1543,7 @@ public class PS {
* @return boolean | if valid arguments were provided
*/
public boolean setupPlotWorld(final String world, final String args, IndependentPlotGenerator generator) {
if ((args != null) && (!args.isEmpty())) {
if (args != null && !args.isEmpty()) {
// save configuration
final String[] split = args.split(",");
final HybridPlotWorld plotworld = new HybridPlotWorld(world, null, generator, null, null);
@ -1869,7 +1869,7 @@ public class PS {
case "false":
return false;
default:
return (MainUtil.timeToSec(value) * 1000) + System.currentTimeMillis();
return MainUtil.timeToSec(value) * 1000 + System.currentTimeMillis();
}
}
@Override
@ -1999,7 +1999,7 @@ public class PS {
final int keep = config.getInt("clear.keep-if-modified");
final int ignore = config.getInt("clear.ignore-if-modified");
if ((keep > 0) || (ignore > 0)) {
if (keep > 0 || ignore > 0) {
options.put("clear.auto.threshold", 1);
options.put("clear.auto.enabled", false);
log("&cIMPORTANT MESSAGE ABOUT THIS UPDATE!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

View File

@ -80,8 +80,8 @@ public class Area extends SubCommand {
Location pos2 = plr.getMeta("area_pos1");
int dx = Math.abs(pos1.getX() - pos2.getX());
int dz = Math.abs(pos1.getZ() - pos2.getZ());
int numx = Math.max(1, (dx + 1 + area.ROAD_WIDTH + (area.SIZE / 2)) / area.SIZE);
int numz = Math.max(1, (dz + 1 + area.ROAD_WIDTH + (area.SIZE / 2)) / area.SIZE);
int numx = Math.max(1, (dx + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
int numz = Math.max(1, (dz + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
final int ddx = dx - (numx * area.SIZE - area.ROAD_WIDTH);
final int ddz = dz - (numz * area.SIZE - area.ROAD_WIDTH);
int bx = Math.min(pos1.getX(), pos2.getX()) + ddx;
@ -318,7 +318,7 @@ public class Area extends SubCommand {
region = area.getRegion().toString();
} else {
name = area.worldname;
percent = claimed == 0 ? 0 : (100d * claimed) / (Integer.MAX_VALUE);
percent = claimed == 0 ? 0 : 100d * claimed / Integer.MAX_VALUE;
region = "N/A";
}
String value = "&r$1NAME: " + name

View File

@ -52,7 +52,7 @@ public class Auto extends SubCommand {
return new PlotId(id.x + 1, id.y);
}
} else {
if (id.x == id.y && (id.x > 0)) {
if (id.x == id.y && id.x > 0) {
return new PlotId(id.x, id.y + step);
}
if (id.x == absX) {
@ -81,7 +81,7 @@ public class Auto extends SubCommand {
final String[] split = args[0].split(",|;");
size_x = Integer.parseInt(split[0]);
size_z = Integer.parseInt(split[1]);
if ((size_x < 1) || (size_z < 1)) {
if (size_x < 1 || size_z < 1) {
MainUtil.sendMessage(plr, "&cError: size<=0");
}
if (args.length > 1) {
@ -101,15 +101,15 @@ public class Auto extends SubCommand {
// return false;
}
}
if ((size_x * size_z) > Settings.MAX_AUTO_SIZE) {
if (size_x * size_z > Settings.MAX_AUTO_SIZE) {
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + "");
return false;
}
final int currentPlots = Settings.GLOBAL_LIMIT ? plr.getPlotCount() : plr.getPlotCount(plotarea.worldname);
final int diff = currentPlots - plr.getAllowedPlots();
if ((diff + (size_x * size_z)) > 0) {
if (diff + size_x * size_z > 0) {
if (diff < 0) {
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + "");
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
return false;
} else if (plr.hasPersistentMeta("grantedPlots")) {
int grantedPlots = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots"));
@ -117,11 +117,10 @@ public class Auto extends SubCommand {
plr.removePersistentMeta("grantedPlots");
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
} else {
int left = grantedPlots - diff - (size_x * size_z);
int left = grantedPlots - diff - size_x * size_z;
if (left == 0) {
plr.removePersistentMeta("grantedPlots");
}
else {
} else {
plr.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(left));
}
sendMessage(plr, C.REMOVED_GRANTED_PLOT, "" + left, "" + (grantedPlots - left));
@ -131,7 +130,7 @@ public class Auto extends SubCommand {
return false;
}
}
if ((EconHandler.manager != null) && plotarea.USE_ECONOMY) {
if (EconHandler.manager != null && plotarea.USE_ECONOMY) {
double cost = plotarea.PRICES.get("claim");
cost = (size_x * size_z) * cost;
if (cost > 0d) {
@ -159,7 +158,7 @@ public class Auto extends SubCommand {
final PlotId top = plotarea.getMax();
final PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
PlotId id = new PlotId(0, 0);
final int width = Math.max((top.x - bot.x) + 1, (top.y - bot.y) + 1);
final int width = Math.max(top.x - bot.x + 1, top.y - bot.y + 1);
final int max = width * width;
//
for (int i = 0; i <= max; i++) {
@ -179,17 +178,17 @@ public class Auto extends SubCommand {
boolean br = false;
while (true) {
final PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
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);
plotarea.setMeta("lastPlot", start);
if (plotarea.canClaim(plr, start, end)) {
for (int i = start.x; i <= end.x; i++) {
for (int j = start.y; j <= end.y; j++) {
Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
final boolean teleport = ((i == end.x) && (j == end.y));
final boolean teleport = i == end.x && j == end.y;
plot.claim(plr, teleport, null);
}
}
if ((size_x != 1) || (size_z != 1)) {
if (size_x != 1 || size_z != 1) {
if (!plotarea.mergePlots(MainUtil.getPlotSelectionIds(start, end), Settings.MERGE_REMOVES_ROADS, true)) {
return false;
}

View File

@ -102,7 +102,7 @@ public class Cluster extends SubCommand {
// check pos1 / pos2
PlotId pos1 = PlotId.fromString(args[2]);
PlotId pos2 = PlotId.fromString(args[3]);
if ((pos1 == null) || (pos2 == null)) {
if (pos1 == null || pos2 == null) {
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
return false;
}
@ -112,7 +112,7 @@ public class Cluster extends SubCommand {
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
return false;
}
if ((pos2.x < pos1.x) || (pos2.y < pos1.y)) {
if (pos2.x < pos1.x || pos2.y < pos1.y) {
PlotId tmp = new PlotId(Math.min(pos1.x, pos2.x), Math.min(pos1.y, pos2.y));
pos2 = new PlotId(Math.max(pos1.x, pos2.x), Math.max(pos1.y, pos2.y));
pos1 = tmp;
@ -145,7 +145,7 @@ public class Cluster extends SubCommand {
current = plr.getPlayerClusterCount(plr.getLocation().getWorld());
}
final int allowed = Permissions.hasPermissionRange(plr, "plots.cluster", Settings.MAX_PLOTS);
if ((current + cluster.getArea()) > allowed) {
if (current + cluster.getArea() > allowed) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
return false;
}
@ -172,7 +172,7 @@ public class Cluster extends SubCommand {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete");
return false;
}
if ((args.length != 1) && (args.length != 2)) {
if (args.length != 1 && args.length != 2) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]");
return false;
}
@ -218,11 +218,11 @@ public class Cluster extends SubCommand {
// check pos1 / pos2
PlotId pos1 = PlotId.fromString(args[1]);
PlotId pos2 = PlotId.fromString(args[2]);
if ((pos1 == null) || (pos2 == null)) {
if (pos1 == null || pos2 == null) {
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
return false;
}
if ((pos2.x < pos1.x) || (pos2.y < pos1.y)) {
if (pos2.x < pos1.x || pos2.y < pos1.y) {
pos1 = new PlotId(Math.min(pos1.x, pos2.x), Math.min(pos1.y, pos2.y));
pos2 = new PlotId(Math.max(pos1.x, pos2.x), Math.max(pos1.y, pos2.y));
}
@ -251,7 +251,7 @@ public class Cluster extends SubCommand {
}
final HashSet<Plot> existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2());
final HashSet<Plot> newplots = area.getPlotSelectionOwned(pos1, pos2);
final HashSet<Plot> removed = ((HashSet<Plot>) existing.clone());
final HashSet<Plot> removed = (HashSet<Plot>) existing.clone();
removed.removeAll(newplots);
// Check expand / shrink
if (!removed.isEmpty()) {
@ -274,9 +274,9 @@ public class Cluster extends SubCommand {
} else {
current = plr.getPlayerClusterCount(plr.getLocation().getWorld());
}
current -= cluster.getArea() + (((1 + pos2.x) - pos1.x) * ((1 + pos2.y) - pos1.y));
current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
final int allowed = Permissions.hasPermissionRange(plr, "plots.cluster", Settings.MAX_PLOTS);
if ((current + cluster.getArea()) > allowed) {
if (current + cluster.getArea() > allowed) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
return false;
}
@ -379,7 +379,7 @@ public class Cluster extends SubCommand {
}
for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
final PlotCluster current = plot.getCluster();
if ((current != null) && current.equals(cluster)) {
if (current != null && current.equals(cluster)) {
plot.unclaim();
}
}
@ -392,7 +392,7 @@ public class Cluster extends SubCommand {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave");
return false;
}
if ((args.length != 1) && (args.length != 2)) {
if (args.length != 1 && args.length != 2) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]");
return false;
}
@ -432,7 +432,7 @@ public class Cluster extends SubCommand {
MainUtil.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName());
for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
final PlotCluster current = plot.getCluster();
if ((current != null) && current.equals(cluster)) {
if (current != null && current.equals(cluster)) {
plr.getLocation().getWorld();
plot.unclaim();
}
@ -515,7 +515,7 @@ public class Cluster extends SubCommand {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info");
return false;
}
if ((args.length != 1) && (args.length != 2)) {
if (args.length != 1 && args.length != 2) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]");
return false;
}
@ -543,7 +543,7 @@ public class Cluster extends SubCommand {
owner = "unknown";
}
final String name = cluster.getName();
final String size = ((cluster.getP2().x - cluster.getP1().x) + 1) + "x" + ((cluster.getP2().y - cluster.getP1().y) + 1);
final String size = (cluster.getP2().x - cluster.getP1().x + 1) + "x" + (cluster.getP2().y - cluster.getP1().y + 1);
final String rights = cluster.isAdded(plr.getUUID()) + "";
String message = C.CLUSTER_INFO.s();
message = message.replaceAll("%id%", id);
@ -561,7 +561,7 @@ public class Cluster extends SubCommand {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome");
return false;
}
if ((args.length != 1) && (args.length != 2)) {
if (args.length != 1 && args.length != 2) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome");
return false;
}

View File

@ -126,13 +126,13 @@ public class Configuration {
@Override
public boolean validateValue(final String string) {
final StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(string);
return !((value == null) || (value.match > 1));
return !(value == null || value.match > 1);
}
@Override
public PlotBlock parseString(final String string) {
final StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(string);
if ((value == null) || (value.match > 1)) {
if (value == null || value.match > 1) {
return null;
}
return value.best;
@ -149,7 +149,7 @@ public class Configuration {
block = split[1];
}
final StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(block);
if ((value == null) || (value.match > 1)) {
if (value == null || value.match > 1) {
return false;
}
}
@ -183,7 +183,7 @@ public class Configuration {
}
}
final StringComparison<PlotBlock>.ComparisonResult result = WorldUtil.IMP.getClosestBlock(blocks[i]);
if ((result != null) && (result.match < 2)) {
if (result != null && result.match < 2) {
values[i] = result.best;
}
} catch (NumberFormatException e) {
@ -192,7 +192,7 @@ public class Configuration {
final int gcd = gcd(counts);
for (int i = 0; i < counts.length; i++) {
final int num = counts[i];
for (int j = 0; j < (num / gcd); j++) {
for (int j = 0; j < num / gcd; j++) {
parsedvalues.add(values[i]);
}
}

View File

@ -136,7 +136,7 @@ public class SQLManager implements AbstractDB {
break;
}
// schedule reconnect
if (MYSQL && ((System.currentTimeMillis() - last) > 550000)) {
if (MYSQL && System.currentTimeMillis() - last > 550000) {
last = System.currentTimeMillis();
try {
close();
@ -573,14 +573,14 @@ public class SQLManager implements AbstractDB {
@Override
public void setMySQL(final PreparedStatement stmt, final int i, final UUIDPair pair) throws SQLException {
stmt.setInt((i * 2) + 1, pair.id);
stmt.setString((i * 2) + 2, pair.uuid.toString());
stmt.setInt(i * 2 + 1, pair.id);
stmt.setString(i * 2 + 2, pair.uuid.toString());
}
@Override
public void setSQLite(final PreparedStatement stmt, final int i, final UUIDPair pair) throws SQLException {
stmt.setInt((i * 2) + 1, pair.id);
stmt.setString((i * 2) + 2, pair.uuid.toString());
stmt.setInt(i * 2 + 1, pair.id);
stmt.setString(i * 2 + 2, pair.uuid.toString());
}
@Override
@ -617,29 +617,29 @@ public class SQLManager implements AbstractDB {
@Override
public void setMySQL(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException {
stmt.setInt((i * 5) + 1, plot.getId().x);
stmt.setInt((i * 5) + 2, plot.getId().y);
stmt.setInt(i * 5 + 1, plot.getId().x);
stmt.setInt(i * 5 + 2, plot.getId().y);
try {
stmt.setString((i * 5) + 3, plot.owner.toString());
stmt.setString(i * 5 + 3, plot.owner.toString());
} catch (SQLException e) {
stmt.setString((i * 5) + 3, everyone.toString());
stmt.setString(i * 5 + 3, everyone.toString());
}
stmt.setString((i * 5) + 4, plot.getArea().toString());
stmt.setTimestamp((i * 5) + 5, new Timestamp(plot.getTimestamp()));
stmt.setString(i * 5 + 4, plot.getArea().toString());
stmt.setTimestamp(i * 5 + 5, new Timestamp(plot.getTimestamp()));
}
@Override
public void setSQLite(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException {
stmt.setNull((i * 6) + 1, 4);
stmt.setInt((i * 6) + 2, plot.getId().x);
stmt.setInt((i * 6) + 3, plot.getId().y);
stmt.setNull(i * 6 + 1, 4);
stmt.setInt(i * 6 + 2, plot.getId().x);
stmt.setInt(i * 6 + 3, plot.getId().y);
try {
stmt.setString((i * 6) + 4, plot.owner.toString());
stmt.setString(i * 6 + 4, plot.owner.toString());
} catch (SQLException e1) {
stmt.setString((i * 6) + 4, everyone.toString());
stmt.setString(i * 6 + 4, everyone.toString());
}
stmt.setString((i * 6) + 5, plot.getArea().toString());
stmt.setTimestamp((i * 6) + 6, new Timestamp(plot.getTimestamp()));
stmt.setString(i * 6 + 5, plot.getArea().toString());
stmt.setTimestamp(i * 6 + 6, new Timestamp(plot.getTimestamp()));
}
@Override
@ -685,7 +685,7 @@ public class SQLManager implements AbstractDB {
statement = mod.getCreateMySQL(subList.size());
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.close();
statement = mod.getCreateMySQL(subList.size());
@ -728,7 +728,7 @@ public class SQLManager implements AbstractDB {
statement = mod.getCreateSQLite(subList.size());
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.clearParameters();
statement = mod.getCreateSQLite(subList.size());
@ -799,16 +799,16 @@ public class SQLManager implements AbstractDB {
@Override
public void setMySQL(final PreparedStatement stmt, final int i, final SettingsPair pair) throws SQLException {
stmt.setInt((i * 10) + 1, pair.id); // id
stmt.setNull((i * 10) + 2, 4); // biome
stmt.setNull((i * 10) + 3, 4); // rain
stmt.setNull((i * 10) + 4, 4); // custom_time
stmt.setNull((i * 10) + 5, 4); // time
stmt.setNull((i * 10) + 6, 4); // deny_entry
stmt.setInt(i * 10 + 1, pair.id); // id
stmt.setNull(i * 10 + 2, 4); // biome
stmt.setNull(i * 10 + 3, 4); // rain
stmt.setNull(i * 10 + 4, 4); // custom_time
stmt.setNull(i * 10 + 5, 4); // time
stmt.setNull(i * 10 + 6, 4); // deny_entry
if (pair.settings.getAlias().isEmpty()) {
stmt.setNull((i * 10) + 7, 4);
stmt.setNull(i * 10 + 7, 4);
} else {
stmt.setString((i * 10) + 7, pair.settings.getAlias());
stmt.setString(i * 10 + 7, pair.settings.getAlias());
}
final StringBuilder flag_string = new StringBuilder();
int k = 0;
@ -819,10 +819,10 @@ public class SQLManager implements AbstractDB {
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
k++;
}
stmt.setString((i * 10) + 8, flag_string.toString());
stmt.setString(i * 10 + 8, flag_string.toString());
final boolean[] merged = pair.settings.getMerged();
int hash = MainUtil.hash(merged);
stmt.setInt((i * 10) + 9, hash);
stmt.setInt(i * 10 + 9, hash);
final BlockLoc loc = pair.settings.getPosition();
String position;
if (loc.y == 0) {
@ -830,21 +830,21 @@ public class SQLManager implements AbstractDB {
} else {
position = loc.x + "," + loc.y + "," + loc.z;
}
stmt.setString((i * 10) + 10, position);
stmt.setString(i * 10 + 10, position);
}
@Override
public void setSQLite(final PreparedStatement stmt, final int i, final SettingsPair pair) throws SQLException {
stmt.setInt((i * 10) + 1, pair.id); // id
stmt.setNull((i * 10) + 2, 4); // biome
stmt.setNull((i * 10) + 3, 4); // rain
stmt.setNull((i * 10) + 4, 4); // custom_time
stmt.setNull((i * 10) + 5, 4); // time
stmt.setNull((i * 10) + 6, 4); // deny_entry
if (pair.settings.getAlias().equals("")) {
stmt.setNull((i * 10) + 7, 4);
stmt.setInt(i * 10 + 1, pair.id); // id
stmt.setNull(i * 10 + 2, 4); // biome
stmt.setNull(i * 10 + 3, 4); // rain
stmt.setNull(i * 10 + 4, 4); // custom_time
stmt.setNull(i * 10 + 5, 4); // time
stmt.setNull(i * 10 + 6, 4); // deny_entry
if (pair.settings.getAlias().isEmpty()) {
stmt.setNull(i * 10 + 7, 4);
} else {
stmt.setString((i * 10) + 7, pair.settings.getAlias());
stmt.setString(i * 10 + 7, pair.settings.getAlias());
}
final StringBuilder flag_string = new StringBuilder();
int k = 0;
@ -855,13 +855,13 @@ public class SQLManager implements AbstractDB {
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
k++;
}
stmt.setString((i * 10) + 8, flag_string.toString());
stmt.setString(i * 10 + 8, flag_string.toString());
final boolean[] merged = pair.settings.getMerged();
int n = 0;
for (int j = 0; j < 4; ++j) {
n = (n << 1) + (merged[j] ? 1 : 0);
}
stmt.setInt((i * 10) + 9, n);
stmt.setInt(i * 10 + 9, n);
final BlockLoc loc = pair.settings.getPosition();
String position;
if (loc.y == 0) {
@ -869,7 +869,7 @@ public class SQLManager implements AbstractDB {
} else {
position = loc.x + "," + loc.y + "," + loc.z;
}
stmt.setString((i * 10) + 10, position);
stmt.setString(i * 10 + 10, position);
}
@Override
@ -909,21 +909,21 @@ public class SQLManager implements AbstractDB {
@Override
public void setMySQL(final PreparedStatement stmt, final int i, final Integer id) throws SQLException {
stmt.setInt((i) + 1, id);
stmt.setInt(i + 1, id);
}
@Override
public void setSQLite(final PreparedStatement stmt, final int i, final Integer id) throws SQLException {
stmt.setInt((i * 10) + 1, id);
stmt.setNull((i * 10) + 2, 4);
stmt.setNull((i * 10) + 3, 4);
stmt.setNull((i * 10) + 4, 4);
stmt.setNull((i * 10) + 5, 4);
stmt.setNull((i * 10) + 6, 4);
stmt.setNull((i * 10) + 7, 4);
stmt.setNull((i * 10) + 8, 4);
stmt.setNull((i * 10) + 9, 4);
stmt.setString((i * 10) + 10, "DEFAULT");
stmt.setInt(i * 10 + 1, id);
stmt.setNull(i * 10 + 2, 4);
stmt.setNull(i * 10 + 3, 4);
stmt.setNull(i * 10 + 4, 4);
stmt.setNull(i * 10 + 5, 4);
stmt.setNull(i * 10 + 6, 4);
stmt.setNull(i * 10 + 7, 4);
stmt.setNull(i * 10 + 8, 4);
stmt.setNull(i * 10 + 9, 4);
stmt.setString(i * 10 + 10, "DEFAULT");
}
@Override
@ -1417,7 +1417,7 @@ public class SQLManager implements AbstractDB {
}
stmt.close();
r.close();
if ((c_id == Integer.MAX_VALUE) || (c_id == 0)) {
if (c_id == Integer.MAX_VALUE || c_id == 0) {
if (cluster.temp > 0) {
return cluster.temp;
}
@ -1453,7 +1453,7 @@ public class SQLManager implements AbstractDB {
}
r.close();
stmt.close();
if ((id == Integer.MAX_VALUE) || (id == 0)) {
if (id == Integer.MAX_VALUE || id == 0) {
if (plot.temp > 0) {
return plot.temp;
}
@ -1575,12 +1575,12 @@ public class SQLManager implements AbstractDB {
@Override
public void setMySQL(PreparedStatement stmt, int i, Integer obj) throws SQLException {
stmt.setInt((i) + 1, obj);
stmt.setInt(i + 1, obj);
}
@Override
public void setSQLite(PreparedStatement stmt, int i, Integer obj) throws SQLException {
stmt.setInt((i) + 1, obj);
stmt.setInt(i + 1, obj);
}
@Override
@ -1801,7 +1801,7 @@ public class SQLManager implements AbstractDB {
final Integer m = r.getInt("merged");
final boolean[] merged = new boolean[4];
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);
String[] flags_string;
@ -2584,7 +2584,7 @@ public class SQLManager implements AbstractDB {
final Integer m = r.getInt("merged");
final boolean[] merged = new boolean[4];
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);
String[] flags_string;

View File

@ -1,7 +1,5 @@
package com.intellectualcrafters.plot.generator;
import java.util.ArrayList;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
@ -12,6 +10,8 @@ import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.SetQueue;
import java.util.ArrayList;
/**
* A plot manager with square plots which tessellate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot)
*/
@ -57,9 +57,9 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override
public boolean unclaimPlot(final PlotArea plotworld, final Plot plot, final Runnable whenDone) {
final ClassicPlotWorld dpw = ((ClassicPlotWorld) plotworld);
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
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.getId(), new PlotBlock[] { dpw.WALL_BLOCK });
}
SetQueue.IMP.addTask(whenDone);
@ -142,7 +142,7 @@ public class ClassicPlotManager extends SquarePlotManager {
final PseudoRandom random = new PseudoRandom();
if (!plot.getMerged(0)) {
int z = bottom.getZ();
for (int x = bottom.getX(); x <= (top.getX()); x++) {
for (int x = bottom.getX(); x <= top.getX(); x++) {
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
}
@ -150,7 +150,7 @@ public class ClassicPlotManager extends SquarePlotManager {
}
if (!plot.getMerged(3)) {
int x = bottom.getX();
for (int z = bottom.getZ(); z <= (top.getZ()); z++) {
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
}
@ -159,7 +159,7 @@ public class ClassicPlotManager extends SquarePlotManager {
if (!plot.getMerged(2)) {
int z = top.getZ();
for (int x = bottom.getX(); x <= (top.getX()); x++) {
for (int x = bottom.getX(); x <= top.getX(); x++) {
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
}
@ -167,7 +167,7 @@ public class ClassicPlotManager extends SquarePlotManager {
}
if (!plot.getMerged(1)) {
int x = top.getX();
for (int z = bottom.getZ(); z <= (top.getZ()); z++) {
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
}
@ -194,7 +194,7 @@ public class ClassicPlotManager extends SquarePlotManager {
final PseudoRandom random = new PseudoRandom();
if (!plot.getMerged(0)) {
int z = bot.getZ();
for (int x = bot.getX(); x < (top.getX()); x++) {
for (int x = bot.getX(); x < top.getX(); x++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
}
@ -202,7 +202,7 @@ public class ClassicPlotManager extends SquarePlotManager {
}
if (!plot.getMerged(3)) {
int x = bot.getX();
for (int z = bot.getZ(); z < (top.getZ()); z++) {
for (int z = bot.getZ(); z < top.getZ(); z++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
}
@ -210,7 +210,7 @@ public class ClassicPlotManager extends SquarePlotManager {
}
if (!plot.getMerged(2)) {
int z = top.getZ();
for (int x = bot.getX(); x < (top.getX() + (plot.getMerged(1) ? 0 : 1)); x++) {
for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
}
@ -218,7 +218,7 @@ public class ClassicPlotManager extends SquarePlotManager {
}
if (!plot.getMerged(1)) {
int x = top.getX();
for (int z = bot.getZ(); z < (top.getZ() + (plot.getMerged(2) ? 0 : 1)); z++) {
for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
}
@ -239,25 +239,25 @@ public class ClassicPlotManager extends SquarePlotManager {
final int y = dpw.WALL_HEIGHT + 1;
if (!plot.getMerged(0)) {
int z = bot.getZ();
for (int x = bot.getX(); x < (top.getX()); x++) {
for (int x = bot.getX(); x < top.getX(); x++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
}
}
if (!plot.getMerged(3)) {
int x = bot.getX();
for (int z = bot.getZ(); z < (top.getZ()); z++) {
for (int z = bot.getZ(); z < top.getZ(); z++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
}
}
if (!plot.getMerged(2)) {
int z = top.getZ();
for (int x = bot.getX(); x < (top.getX() + (plot.getMerged(1) ? 0 : 1)); x++) {
for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
}
}
if (!plot.getMerged(1)) {
int x = top.getX();
for (int z = bot.getZ(); z < (top.getZ() + (plot.getMerged(2) ? 0 : 1)); z++) {
for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
}
}
@ -273,7 +273,7 @@ public class ClassicPlotManager extends SquarePlotManager {
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
final int sx = pos2.getX() + 1;
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
final int ex = sx + dpw.ROAD_WIDTH - 1;
final int sz = pos1.getZ() - 2;
final int ez = pos2.getZ() + 2;
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(plotworld.worldname, ex, 255, ez - 1), new PlotBlock((short) 0, (byte) 0));
@ -295,7 +295,7 @@ public class ClassicPlotManager extends SquarePlotManager {
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
final int sz = pos2.getZ() + 1;
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
final int ez = sz + dpw.ROAD_WIDTH - 1;
final int sx = pos1.getX() - 2;
final int ex = pos2.getX() + 2;
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex - 1, 255, ez), new PlotBlock((short) 0, (byte) 0));
@ -315,9 +315,9 @@ public class ClassicPlotManager extends SquarePlotManager {
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
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 ez = (sz + dpw.ROAD_WIDTH) - 1;
final int ez = sz + dpw.ROAD_WIDTH - 1;
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, ex - 1, 255, ez - 1), new PlotBlock(
(short) 0, (byte) 0));
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz + 1), new Location(plotworld.worldname, ex - 1, 0, ez - 1), new PlotBlock((short) 7, (byte) 0));
@ -331,7 +331,7 @@ public class ClassicPlotManager extends SquarePlotManager {
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
final int sx = pos2.getX() + 1;
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
final int ex = sx + dpw.ROAD_WIDTH - 1;
final int sz = pos1.getZ() - 1;
final int ez = pos2.getZ() + 1;
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
@ -346,7 +346,7 @@ public class ClassicPlotManager extends SquarePlotManager {
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
final int sz = pos2.getZ() + 1;
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
final int ez = sz + dpw.ROAD_WIDTH - 1;
final int sx = pos1.getX() - 1;
final int ex = pos2.getX() + 1;
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
@ -360,9 +360,9 @@ public class ClassicPlotManager extends SquarePlotManager {
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
final Location loc = getPlotTopLocAbs(dpw, plot.getId());
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 ez = (sz + dpw.ROAD_WIDTH) - 1;
final int ez = sz + dpw.ROAD_WIDTH - 1;
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT, sz), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT, ez), dpw.TOP_BLOCK);
@ -376,7 +376,7 @@ public class ClassicPlotManager extends SquarePlotManager {
public boolean finishPlotMerge(final PlotArea plotworld, final ArrayList<PlotId> plotIds) {
final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
if ((block.id != 0) || !block.equals(unclaim)) {
if (block.id != 0 || !block.equals(unclaim)) {
for (final PlotId id : plotIds) {
setWall(plotworld, id, new PlotBlock[] { block });
}
@ -389,7 +389,7 @@ public class ClassicPlotManager extends SquarePlotManager {
final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
for (final PlotId id : plotIds) {
if ((block.id != 0) || !block.equals(unclaim)) {
if (block.id != 0 || !block.equals(unclaim)) {
setWall(plotworld, id, new PlotBlock[] { block });
}
}
@ -410,7 +410,7 @@ public class ClassicPlotManager extends SquarePlotManager {
public boolean claimPlot(final PlotArea plotworld, final Plot plot) {
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).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.getId(), new PlotBlock[] { claim });
}
return true;

View File

@ -5,12 +5,32 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.TaskManager;
import java.io.File;
import java.util.*;
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.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
public abstract class HybridUtils {
@ -95,8 +115,8 @@ public abstract class HybridUtils {
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
final int sx = region.x << 5;
final int sz = region.z << 5;
for (int x = sx; x < (sx + 32); x++) {
for (int z = sz; z < (sz + 32); z++) {
for (int x = sx; x < sx + 32; x++) {
for (int z = sz; z < sz + 32; z++) {
chunks.add(new ChunkLoc(x, z));
}
}
@ -185,10 +205,10 @@ public abstract class HybridUtils {
return;
}
count.incrementAndGet();
if ((count.intValue() % 20) == 0) {
PS.debug("PROGRESS: " + ((100 * (2048 - chunks.size())) / 2048) + "%");
if (count.intValue() % 20 == 0) {
PS.debug("PROGRESS: " + 100 * (2048 - chunks.size()) / 2048 + "%");
}
if ((regions.isEmpty()) && (chunks.isEmpty())) {
if (regions.isEmpty() && chunks.isEmpty()) {
HybridUtils.UPDATE = false;
PS.debug(C.PREFIX.s() + "Finished road conversion");
// CANCEL TASK
@ -214,7 +234,7 @@ public abstract class HybridUtils {
}
if (!chunks.isEmpty()) {
final long diff = System.currentTimeMillis() + 1;
if (((System.currentTimeMillis() - baseTime - last.get()) > 2000) && (last.get() != 0)) {
if (System.currentTimeMillis() - baseTime - last.get() > 2000 && last.get() != 0) {
last.set(0);
PS.debug(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
Iterator<ChunkLoc> iter = chunks.iterator();
@ -230,8 +250,8 @@ public abstract class HybridUtils {
TaskManager.runTaskLater(task, 600);
return;
}
if ((((System.currentTimeMillis() - baseTime) - last.get()) < 1500) && (last.get() != 0)) {
while ((System.currentTimeMillis() < diff) && (!chunks.isEmpty())) {
if (System.currentTimeMillis() - baseTime - last.get() < 1500 && last.get() != 0) {
while (System.currentTimeMillis() < diff && !chunks.isEmpty()) {
Iterator<ChunkLoc> iter = chunks.iterator();
final ChunkLoc chunk = iter.next();
iter.remove();
@ -253,8 +273,8 @@ public abstract class HybridUtils {
PS.debug("&c[ERROR]&7 Could not update '" + area.worldname + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)");
final int sx = loc.x << 5;
final int sz = loc.z << 5;
for (int x = sx; x < (sx + 32); x++) {
for (int z = sz; z < (sz + 32); z++) {
for (int x = sx; x < sx + 32; x++) {
for (int z = sz; z < sz + 32; z++) {
ChunkManager.manager.unloadChunk(area.worldname, new ChunkLoc(x, z), true, true);
}
}
@ -280,7 +300,7 @@ public abstract class HybridUtils {
final Location bot = plot.getBottomAbs().subtract(1, 0, 1);
final Location top = plot.getTopAbs();
final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea();
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 sy = plotworld.ROAD_HEIGHT;
final int ex = bot.getX();
@ -339,18 +359,18 @@ public abstract class HybridUtils {
final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez);
x -= plotworld.ROAD_OFFSET_X;
z -= plotworld.ROAD_OFFSET_Z;
if ((id1 == null) || (id2 == null) || (id1 != id2)) {
if (id1 == null || id2 == null || id1 != id2) {
final boolean result = ChunkManager.manager.loadChunk(area.worldname, chunk, false);
if (result) {
if (id1 != null) {
final Plot p1 = area.getPlotAbs(id1);
if ((p1 != null) && p1.hasOwner() && p1.isMerged()) {
if (p1 != null && p1.hasOwner() && p1.isMerged()) {
toCheck = true;
}
}
if ((id2 != null) && !toCheck) {
if (id2 != null && !toCheck) {
final Plot p2 = area.getPlotAbs(id2);
if ((p2 != null) && p2.hasOwner() && p2.isMerged()) {
if (p2 != null && p2.hasOwner() && p2.isMerged()) {
toCheck = true;
}
}
@ -374,12 +394,11 @@ public abstract class HybridUtils {
final boolean gz = absZ > plotworld.PATH_WIDTH_LOWER;
final boolean lx = absX < plotworld.PATH_WIDTH_UPPER;
final boolean lz = absZ < plotworld.PATH_WIDTH_UPPER;
condition = (!gx || !gz || !lx || !lz);
condition = !gx || !gz || !lx || !lz;
}
if (condition) {
final int sy = plotworld.ROAD_HEIGHT;
final HashMap<Integer, PlotBlock> blocks = plotworld.G_SCH.get(MathMan.pair(absX, absZ));
for (short y = (short) (plotworld.ROAD_HEIGHT); y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT + extend); y++) {
for (short y = (short) plotworld.ROAD_HEIGHT; y <= plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT + extend; y++) {
SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, y, z + Z + plotworld.ROAD_OFFSET_Z, 0);
}
if (blocks != null) {

View File

@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.util.MainUtil;
import java.io.File;
public class BO3 {
@ -59,6 +60,6 @@ public class BO3 {
}
public String getFilename() {
return name + (((chunk.x == 0) && (chunk.z == 0)) ? "" : ("_" + chunk.x + "_" + chunk.z)) + ".bo3";
return name + (chunk.x == 0 && chunk.z == 0 ? "" : "_" + chunk.x + "_" + chunk.z) + ".bo3";
}
}

View File

@ -19,14 +19,35 @@ public class BlockLoc {
public BlockLoc(final int x, final int y, final int z) {
this(x, y, z, 0f, 0f);
}
public static BlockLoc fromString(final String string) {
final String[] parts = string.split(",");
float yaw, pitch;
if (parts.length == 3) {
yaw = 0f;
pitch = 0f;
}
if (parts.length == 5) {
yaw = Float.parseFloat(parts[3]);
pitch = Float.parseFloat(parts[4]);
} else {
return new BlockLoc(0, 0, 0);
}
final int x = Integer.parseInt(parts[0]);
final int y = Integer.parseInt(parts[1]);
final int z = Integer.parseInt(parts[2]);
return new BlockLoc(x, y, z, yaw, pitch);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result) + x;
result = (prime * result) + y;
result = (prime * result) + z;
result = prime * result + x;
result = prime * result + y;
result = prime * result + z;
return result;
}
@ -42,7 +63,7 @@ public class BlockLoc {
return false;
}
final BlockLoc other = (BlockLoc) obj;
return ((x == other.x) && (y == other.y) && (z == other.z));
return x == other.x && y == other.y && z == other.z;
}
@Override
@ -53,25 +74,4 @@ public class BlockLoc {
return x + "," + y + "," + z + "," + yaw + "," + pitch;
}
public static BlockLoc fromString(final String string) {
final String[] parts = string.split(",");
float yaw, pitch;
if (parts.length == 3) {
yaw = 0f;
pitch = 0f;
}
if (parts.length == 5) {
yaw = Float.parseFloat(parts[3]);
pitch = Float.parseFloat(parts[4]);
} else {
return new BlockLoc(0, 0, 0);
}
final int x = Integer.parseInt(parts[0]);
final int y = Integer.parseInt(parts[1]);
final int z = Integer.parseInt(parts[2]);
return new BlockLoc(x, y, z, yaw, pitch);
}
}

View File

@ -70,7 +70,7 @@ public class PlotAnalysis {
PS.debug("Calibration task already in progress!");
return;
}
if ((threshold <= 0) || (threshold >= 1)) {
if (threshold <= 0 || threshold >= 1) {
PS.debug("Invalid threshold provided! (Cannot be 0 or 100 as then there's no point calibrating)");
return;
}
@ -84,7 +84,7 @@ public class PlotAnalysis {
PS.debug(" - $1Reducing " + plots.size() + " plots to those with sufficient data");
while (iter.hasNext()) {
final Plot plot = iter.next();
if ((plot.getSettings().ratings == null) || (plot.getSettings().getRatings().isEmpty())) {
if (plot.getSettings().ratings == null || plot.getSettings().getRatings().isEmpty()) {
iter.remove();
} else {
plot.addRunning();
@ -126,7 +126,7 @@ public class PlotAnalysis {
final int i = mi.intValue();
final Plot plot = plots.get(i);
ratings[i] = (int) ((plot.getAverageRating() + plot.getSettings().getRatings().size()) * 100);
PS.debug(" | " + plot + " (rating) " + (ratings[i]));
PS.debug(" | " + plot + " (rating) " + ratings[i]);
}
}
});
@ -170,7 +170,7 @@ public class PlotAnalysis {
}
}
PS.debug(" - $1Waiting on plot rating thread: " + ((mi.intValue() * 100) / plots.size()) + "%");
PS.debug(" - $1Waiting on plot rating thread: " + mi.intValue() * 100 / plots.size() + "%");
try {
ratingAnalysis.join();
} catch (final InterruptedException e) {
@ -212,7 +212,7 @@ public class PlotAnalysis {
final int[] variance_changes = square(sd_changes);
final int sum_changes = sum(variance_changes);
final double factor_changes = getCC(n, sum_changes);
PlotAnalysis.MODIFIERS.changes = factor_changes == 1 ? 0 : (int) ((factor_changes * 1000) / MathMan.getMean(changes));
PlotAnalysis.MODIFIERS.changes = factor_changes == 1 ? 0 : (int) (factor_changes * 1000 / MathMan.getMean(changes));
PS.debug(" - | changes " + factor_changes);
final int[] rank_faces = rank(faces);
@ -220,7 +220,7 @@ public class PlotAnalysis {
final int[] variance_faces = square(sd_faces);
final int sum_faces = sum(variance_faces);
final double factor_faces = getCC(n, sum_faces);
PlotAnalysis.MODIFIERS.faces = factor_faces == 1 ? 0 : (int) ((factor_faces * 1000) / MathMan.getMean(faces));
PlotAnalysis.MODIFIERS.faces = factor_faces == 1 ? 0 : (int) (factor_faces * 1000 / MathMan.getMean(faces));
PS.debug(" - | faces " + factor_faces);
final int[] rank_data = rank(data);
@ -228,7 +228,7 @@ public class PlotAnalysis {
final int[] variance_data = square(sd_data);
final int sum_data = sum(variance_data);
final double factor_data = getCC(n, sum_data);
PlotAnalysis.MODIFIERS.data = factor_data == 1 ? 0 : (int) ((factor_data * 1000) / MathMan.getMean(data));
PlotAnalysis.MODIFIERS.data = factor_data == 1 ? 0 : (int) (factor_data * 1000 / MathMan.getMean(data));
PS.debug(" - | data " + factor_data);
final int[] rank_air = rank(air);
@ -236,7 +236,7 @@ public class PlotAnalysis {
final int[] variance_air = square(sd_air);
final int sum_air = sum(variance_air);
final double factor_air = getCC(n, sum_air);
PlotAnalysis.MODIFIERS.air = factor_air == 1 ? 0 : (int) ((factor_air * 1000) / MathMan.getMean(air));
PlotAnalysis.MODIFIERS.air = factor_air == 1 ? 0 : (int) (factor_air * 1000 / MathMan.getMean(air));
PS.debug(" - | air " + factor_air);
final int[] rank_variety = rank(variety);
@ -244,7 +244,7 @@ public class PlotAnalysis {
final int[] variance_variety = square(sd_variety);
final int sum_variety = sum(variance_variety);
final double factor_variety = getCC(n, sum_variety);
PlotAnalysis.MODIFIERS.variety = factor_variety == 1 ? 0 : (int) ((factor_variety * 1000) / MathMan.getMean(variety));
PlotAnalysis.MODIFIERS.variety = factor_variety == 1 ? 0 : (int) (factor_variety * 1000 / MathMan.getMean(variety));
PS.debug(" - | variety " + factor_variety);
final int[] rank_changes_sd = rank(changes_sd);
@ -252,7 +252,7 @@ public class PlotAnalysis {
final int[] variance_changes_sd = square(sd_changes_sd);
final int sum_changes_sd = sum(variance_changes_sd);
final double factor_changes_sd = getCC(n, sum_changes_sd);
PlotAnalysis.MODIFIERS.changes_sd = factor_changes_sd == 1 ? 0 : (int) ((factor_changes_sd * 1000) / MathMan.getMean(changes_sd));
PlotAnalysis.MODIFIERS.changes_sd = factor_changes_sd == 1 ? 0 : (int) (factor_changes_sd * 1000 / MathMan.getMean(changes_sd));
PS.debug(" - | changes_sd " + factor_changes_sd);
final int[] rank_faces_sd = rank(faces_sd);
@ -260,7 +260,7 @@ public class PlotAnalysis {
final int[] variance_faces_sd = square(sd_faces_sd);
final int sum_faces_sd = sum(variance_faces_sd);
final double factor_faces_sd = getCC(n, sum_faces_sd);
PlotAnalysis.MODIFIERS.faces_sd = factor_faces_sd == 1 ? 0 : (int) ((factor_faces_sd * 1000) / MathMan.getMean(faces_sd));
PlotAnalysis.MODIFIERS.faces_sd = factor_faces_sd == 1 ? 0 : (int) (factor_faces_sd * 1000 / MathMan.getMean(faces_sd));
PS.debug(" - | faces_sd " + factor_faces_sd);
final int[] rank_data_sd = rank(data_sd);
@ -268,7 +268,7 @@ public class PlotAnalysis {
final int[] variance_data_sd = square(sd_data_sd);
final int sum_data_sd = sum(variance_data_sd);
final double factor_data_sd = getCC(n, sum_data_sd);
PlotAnalysis.MODIFIERS.data_sd = factor_data_sd == 1 ? 0 : (int) ((factor_data_sd * 1000) / MathMan.getMean(data_sd));
PlotAnalysis.MODIFIERS.data_sd = factor_data_sd == 1 ? 0 : (int) (factor_data_sd * 1000 / MathMan.getMean(data_sd));
PS.debug(" - | data_sd " + factor_data_sd);
final int[] rank_air_sd = rank(air_sd);
@ -276,7 +276,7 @@ public class PlotAnalysis {
final int[] variance_air_sd = square(sd_air_sd);
final int sum_air_sd = sum(variance_air_sd);
final double factor_air_sd = getCC(n, sum_air_sd);
PlotAnalysis.MODIFIERS.air_sd = factor_air_sd == 1 ? 0 : (int) ((factor_air_sd * 1000) / MathMan.getMean(air_sd));
PlotAnalysis.MODIFIERS.air_sd = factor_air_sd == 1 ? 0 : (int) (factor_air_sd * 1000 / MathMan.getMean(air_sd));
PS.debug(" - | air_sd " + factor_air_sd);
final int[] rank_variety_sd = rank(variety_sd);
@ -284,7 +284,7 @@ public class PlotAnalysis {
final int[] variance_variety_sd = square(sd_variety_sd);
final int sum_variety_sd = sum(variance_variety_sd);
final double factor_variety_sd = getCC(n, sum_variety_sd);
PlotAnalysis.MODIFIERS.variety_sd = factor_variety_sd == 1 ? 0 : (int) ((factor_variety_sd * 1000) / MathMan.getMean(variety_sd));
PlotAnalysis.MODIFIERS.variety_sd = factor_variety_sd == 1 ? 0 : (int) (factor_variety_sd * 1000 / MathMan.getMean(variety_sd));
PS.debug(" - | variety_sd " + factor_variety_sd);
final int[] complexity = new int[n];
@ -303,7 +303,7 @@ public class PlotAnalysis {
}
}
int optimal_complexity = Integer.MAX_VALUE;
if ((min > 0) && (max < 102400)) { // If low size, use my fast ranking algorithm
if (min > 0 && max < 102400) { // If low size, use my fast ranking algorithm
final int[] rank_complexity = rank(complexity, max + 1);
for (int i = 0; i < n; i++) {
if (rank_complexity[i] == optimal_index) {
@ -396,7 +396,7 @@ public class PlotAnalysis {
* @return
*/
public static double getCC(final int n, final int sum) {
return 1 - ((6 * (double) sum) / (n * ((n * n) - 1)));
return 1 - 6 * (double) sum / (n * (n * n - 1));
}
/**
@ -519,7 +519,7 @@ public class PlotAnalysis {
for (final Integer i : input) {
tmp = i / placement;
bucket[tmp % SIZE].add(i);
if (maxLength && (tmp > 0)) {
if (maxLength && tmp > 0) {
maxLength = false;
}
}
@ -542,16 +542,16 @@ public class PlotAnalysis {
if (complexity != 0) {
return complexity;
}
complexity = ((changes) * MODIFIERS.changes)
+ ((faces) * MODIFIERS.faces)
+ ((data) * MODIFIERS.data)
+ ((air) * MODIFIERS.air)
+ ((variety) * MODIFIERS.variety)
+ ((changes_sd) * MODIFIERS.changes_sd)
+ ((faces_sd) * MODIFIERS.faces_sd)
+ ((data_sd) * MODIFIERS.data_sd)
+ ((air_sd) * MODIFIERS.air_sd)
+ ((variety_sd) * MODIFIERS.variety_sd);
complexity = changes * MODIFIERS.changes
+ faces * MODIFIERS.faces
+ data * MODIFIERS.data
+ air * MODIFIERS.air
+ variety * MODIFIERS.variety
+ changes_sd * MODIFIERS.changes_sd
+ faces_sd * MODIFIERS.faces_sd
+ data_sd * MODIFIERS.data_sd
+ air_sd * MODIFIERS.air_sd
+ variety_sd * MODIFIERS.variety_sd;
return complexity;
}
}

View File

@ -64,11 +64,12 @@ public class PlotCluster {
}
public boolean isAdded(final UUID uuid) {
return (owner.equals(uuid) || invited.contains(uuid) || invited.contains(DBFunc.everyone) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone));
return owner.equals(uuid) || invited.contains(uuid) || invited.contains(DBFunc.everyone) || helpers.contains(uuid) || helpers
.contains(DBFunc.everyone);
}
public boolean hasHelperRights(final UUID uuid) {
return (owner.equals(uuid) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone));
return owner.equals(uuid) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone);
}
public String getName() {
@ -80,7 +81,7 @@ public class PlotCluster {
* @return
*/
public int getArea() {
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) {
@ -159,10 +160,10 @@ public class PlotCluster {
}
public boolean intersects(PlotId pos1, PlotId pos2) {
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 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

@ -27,15 +27,15 @@ public class RegionWrapper {
}
public boolean isIn(final int x, final int y, final int z) {
return ((x >= minX) && (x <= maxX) && (z >= minZ) && (z <= maxZ) && (y >= minY) && (y <= maxY));
return x >= minX && x <= maxX && z >= minZ && z <= maxZ && y >= minY && y <= maxY;
}
public boolean isIn(final int x, final int z) {
return ((x >= minX) && (x <= maxX) && (z >= minZ) && (z <= maxZ));
return x >= minX && x <= maxX && z >= minZ && z <= maxZ;
}
public boolean intersects(RegionWrapper other) {
return (other.minX <= this.maxX) && (other.maxX >= this.minX) && (other.minY <= this.maxY) && (other.maxY >= this.minY);
return other.minX <= this.maxX && other.maxX >= this.minX && other.minY <= this.maxY && other.maxY >= this.minY;
}
@Override

View File

@ -10,7 +10,7 @@ public abstract class AbstractTitle {
if (ConsolePlayer.isConsole(player)) {
return;
}
if ((TITLE_CLASS != null) && !player.getAttribute("disabletitles")) {
if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) {
TITLE_CLASS.sendTitle(player, head, sub, 1, 2, 1);
}
}

View File

@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@ -72,7 +73,7 @@ public class BO3Handler {
throw new IllegalArgumentException("Save task cannot be null!");
}
final PlotArea plotworld = plot.getArea();
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.");
return false;
}
@ -106,10 +107,10 @@ public class BO3Handler {
Location pos1 = new Location(plotworld.worldname, region.minX, region.minY, region.minZ);
Location pos2 = new Location(plotworld.worldname, region.maxX, region.maxY, region.maxZ);
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
final int X = ((x + 7) - cx) >> 4;
final int X = x + 7 - cx >> 4;
final int xx = (x - cx) % 16;
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
final int Z = ((z + 7) - cz) >> 4;
final int Z = z + 7 - cz >> 4;
final int zz = (z - cz) % 16;
final ChunkLoc loc = new ChunkLoc(X, Z);
BO3 bo3 = map.get(loc);
@ -156,7 +157,7 @@ public class BO3Handler {
for (final Entry<ChunkLoc, BO3> entry : map.entrySet()) {
final ChunkLoc chunk = entry.getKey();
final BO3 bo3 = entry.getValue();
if ((chunk.x == 0) && (chunk.z == 0)) {
if (chunk.x == 0 && chunk.z == 0) {
continue;
}
int x = chunk.x;
@ -171,7 +172,7 @@ public class BO3Handler {
parentLoc = null;
for (final Entry<ChunkLoc, BO3> entry2 : map.entrySet()) {
final ChunkLoc other = entry2.getKey();
if (((other.x == (chunk.x - 1)) && (other.z == chunk.z)) || ((other.z == (chunk.z - 1)) && (other.x == chunk.x))) {
if (other.x == chunk.x - 1 && other.z == chunk.z || other.z == chunk.z - 1 && other.x == chunk.x) {
parentLoc = other;
}
}
@ -268,7 +269,7 @@ public class BO3Handler {
}
}
File bo3File;
if ((bo3.getLoc().x == 0) && (bo3.getLoc().z == 0)) {
if (bo3.getLoc().x == 0 && bo3.getLoc().z == 0) {
bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + ".bo3");
} else {
bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + "_" + bo3.getLoc().x + "_" + bo3.getLoc().z + ".bo3");