This commit is contained in:
MattBDev 2016-03-20 19:35:40 -04:00
parent 274d819f8c
commit bb4ecb94a1
43 changed files with 334 additions and 260 deletions

View File

@ -497,19 +497,19 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
UUIDWrapper wrapper;
if (Settings.OFFLINE_MODE) {
if (Settings.UUID_LOWERCASE) {
wrapper = (new LowerOfflineUUIDWrapper());
wrapper = new LowerOfflineUUIDWrapper();
} else {
wrapper = (new OfflineUUIDWrapper());
wrapper = new OfflineUUIDWrapper();
}
Settings.OFFLINE_MODE = true;
} else if (checkVersion) {
wrapper = (new DefaultUUIDWrapper());
wrapper = new DefaultUUIDWrapper();
Settings.OFFLINE_MODE = false;
} else {
if (Settings.UUID_LOWERCASE) {
wrapper = (new LowerOfflineUUIDWrapper());
wrapper = new LowerOfflineUUIDWrapper();
} else {
wrapper = (new OfflineUUIDWrapper());
wrapper = new OfflineUUIDWrapper();
}
Settings.OFFLINE_MODE = true;
}

View File

@ -70,7 +70,7 @@ public abstract class TextualComponent implements Cloneable {
}
static boolean isTranslatableText(final TextualComponent component) {
return (component instanceof ComplexTextTypeComponent) && ((ComplexTextTypeComponent) component).getKey().equals("translate");
return (component instanceof ComplexTextTypeComponent) && component.getKey().equals("translate");
}
/**

View File

@ -53,16 +53,16 @@ public abstract class APlotMeConnector {
public Location getPlotTopLocAbs(final int path, final int plot, final PlotId plotid) {
final int px = plotid.x;
final int pz = plotid.y;
final int x = (px * (path + plot)) - ((int) Math.floor(path / 2)) - 1;
final int z = (pz * (path + plot)) - ((int) Math.floor(path / 2)) - 1;
final int x = (px * (path + plot)) - (int) Math.floor(path / 2) - 1;
final int z = (pz * (path + plot)) - (int) Math.floor(path / 2) - 1;
return new Location(null, x, 256, z);
}
public Location getPlotBottomLocAbs(final int path, final int plot, final PlotId plotid) {
final int px = plotid.x;
final int pz = plotid.y;
final int x = (px * (path + plot)) - plot - ((int) Math.floor(path / 2)) - 1;
final int z = (pz * (path + plot)) - plot - ((int) Math.floor(path / 2)) - 1;
final int x = (px * (path + plot)) - plot - (int) Math.floor(path / 2) - 1;
final int z = (pz * (path + plot)) - plot - (int) Math.floor(path / 2) - 1;
return new Location(null, x, 1, z);
}

View File

@ -20,16 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.listeners;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.util.Vector;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
@ -37,8 +27,18 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.util.Vector;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*/
public class ForceFieldListener implements Listener {
private Set<PlotPlayer> getNearbyPlayers(final Player player, final Plot plot) {
@ -73,17 +73,19 @@ public class ForceFieldListener implements Listener {
Location oPlayerLocation = e.getLocation();
final double playerX = playerLocation.getX(), playerY = playerLocation.getY(), playerZ = playerLocation.getZ(), oPlayerX = oPlayerLocation.getX(), oPlayerY = oPlayerLocation.getY(), oPlayerZ = oPlayerLocation
.getZ();
double x = 0d, y = 0d, z = 0d;
double x = 0d;
if (playerX < oPlayerX) {
x = 1.0d;
} else if (playerX > oPlayerX) {
x = -1.0d;
}
double y = 0d;
if (playerY < oPlayerY) {
y = 0.5d;
} else if (playerY > oPlayerY) {
y = -0.5d;
}
double z = 0d;
if (playerZ < oPlayerZ) {
z = 1.0d;
} else if (playerZ > oPlayerZ) {

View File

@ -2,19 +2,64 @@ package com.plotsquared.bukkit.util;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.AugmentedUtils;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotLoc;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.bukkit.object.entity.EntityWrapper;
import org.bukkit.*;
import org.bukkit.block.*;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.Note;
import org.bukkit.SkullType;
import org.bukkit.World;
import org.bukkit.block.Banner;
import org.bukkit.block.Beacon;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand;
import org.bukkit.block.Chest;
import org.bukkit.block.CommandBlock;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.block.Dispenser;
import org.bukkit.block.Dropper;
import org.bukkit.block.Furnace;
import org.bukkit.block.Hopper;
import org.bukkit.block.Jukebox;
import org.bukkit.block.NoteBlock;
import org.bukkit.block.Sign;
import org.bukkit.block.Skull;
import org.bukkit.block.banner.Pattern;
import org.bukkit.entity.*;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
public class BukkitChunkManager extends ChunkManager {
@ -595,7 +640,6 @@ public class BukkitChunkManager extends ChunkManager {
}
}
while (SetQueue.IMP.forceChunkSet()) {
;
}
restoreBlocks(world1, 0, 0);
restoreEntities(world1, 0, 0);

View File

@ -1,18 +1,5 @@
package com.plotsquared.bukkit.util;
import java.util.HashSet;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.material.Directional;
import org.bukkit.material.MaterialData;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotAnalysis;
@ -23,6 +10,18 @@ import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.TaskManager;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.material.Directional;
import org.bukkit.material.MaterialData;
import java.util.HashSet;
import java.util.Random;
public class BukkitHybridUtils extends HybridUtils {
@ -90,8 +89,8 @@ public class BukkitHybridUtils extends HybridUtils {
final int X = value[0];
final int Z = value[1];
final short[][] result = gen.generateExtBlockSections(worldObj, r, X, Z, nullBiomeGrid);
final int xb = ((X) << 4) - bx;
final int zb = ((Z) << 4) - bz;
final int xb = (X << 4) - bx;
final int zb = (Z << 4) - bz;
for (int i = 0; i < result.length; i++) {
if (result[i] == null) {
for (int j = 0; j < 4096; j++) {
@ -196,11 +195,11 @@ public class BukkitHybridUtils extends HybridUtils {
analysis.air = (int) (MathMan.getMean(air) * 100);
analysis.variety = (int) (MathMan.getMean(variety) * 100);
analysis.changes_sd = (int) (MathMan.getSD(changes, analysis.changes));
analysis.faces_sd = (int) (MathMan.getSD(faces, analysis.faces));
analysis.data_sd = (int) (MathMan.getSD(data, analysis.data));
analysis.air_sd = (int) (MathMan.getSD(air, analysis.air));
analysis.variety_sd = (int) (MathMan.getSD(variety, analysis.variety));
analysis.changes_sd = (int) MathMan.getSD(changes, analysis.changes);
analysis.faces_sd = (int) MathMan.getSD(faces, analysis.faces);
analysis.data_sd = (int) MathMan.getSD(data, analysis.data);
analysis.air_sd = (int) MathMan.getSD(air, analysis.air);
analysis.variety_sd = (int) MathMan.getSD(variety, analysis.variety);
System.gc();
System.gc();
whenDone.value = analysis;
@ -222,24 +221,24 @@ public class BukkitHybridUtils extends HybridUtils {
final int Z = value[1];
worldObj.loadChunk(X, Z);
int minX;
int minZ;
int maxX;
int maxZ;
if (X == cbx) {
minX = bx & 15;
} else {
minX = 0;
}
int minZ;
if (Z == cbz) {
minZ = bz & 15;
} else {
minZ = 0;
}
int maxX;
if (X == ctx) {
maxX = tx & 15;
} else {
maxX = 16;
}
int maxZ;
if (Z == ctz) {
maxZ = tz & 15;
} else {
@ -249,8 +248,8 @@ public class BukkitHybridUtils extends HybridUtils {
final int cbx = X << 4;
final int cbz = Z << 4;
final int xb = (cbx) - bx;
final int zb = (cbz) - bz;
final int xb = cbx - bx;
final int zb = cbz - bz;
for (int x = minX; x <= maxX; x++) {
final int xx = cbx + x;
for (int z = minZ; z <= maxZ; z++) {

View File

@ -20,7 +20,13 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util;
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.ShortTag;
import com.intellectualcrafters.jnbt.StringTag;
import com.intellectualcrafters.jnbt.Tag;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.RegionWrapper;
@ -35,8 +41,13 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import java.util.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
/**
* Schematic Handler
@ -73,7 +84,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
// Arrays of data types
final List<Tag> tileEntities = new ArrayList<>();
final List<CompoundTag> tileEntities = new ArrayList<>();
final byte[] blocks = new byte[width * height * length];
final byte[] blockData = new byte[width * height * length];
// Queue
@ -126,7 +137,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
@Override
public void run() {
final long start = System.currentTimeMillis();
while ((!chunks.isEmpty()) && ((System.currentTimeMillis() - start) < 20)) {
while (!chunks.isEmpty() && ((System.currentTimeMillis() - start) < 20)) {
// save schematics
final ChunkLoc chunk = chunks.remove(0);
final Chunk bc = worldObj.getChunkAt(chunk.x, chunk.z);
@ -154,7 +165,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
}
for (int y = sy; y <= Math.min(255, ey); y++) {
final int ry = y - sy;
final int i1 = (ry * width * length);
final int i1 = ry * width * length;
for (int z = zzb; z <= zzt; z++) {
final int rz = z - bz;
final int i2 = i1 + (rz * width);
@ -275,7 +286,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
final StateWrapper wrapper = new StateWrapper(state);
final CompoundTag rawTag = wrapper.getTag();
if (rawTag != null) {
final Map<String, Tag> values = new HashMap<String, Tag>();
final Map<String, Tag> values = new HashMap<>();
for (final Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
values.put(entry.getKey(), entry.getValue());
}
@ -283,7 +294,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
values.put("x", new IntTag("x", x));
values.put("y", new IntTag("y", y));
values.put("z", new IntTag("z", z));
final CompoundTag tileEntityTag = new CompoundTag(values);
CompoundTag tileEntityTag = new CompoundTag(values);
tileEntities.add(tileEntityTag);
}
}

View File

@ -227,10 +227,8 @@ public class FastQueue_1_9 extends SlowQueue {
int x = MainUtil.x_loc[j][k];
int y = MainUtil.y_loc[j][k];
int z = MainUtil.z_loc[j][k];
int id = n;
Object iblock = methodGetByCombinedId.call((int) n);
setType.call(x, y & 15, z, iblock);
continue;
}
}
}
@ -317,7 +315,7 @@ public class FastQueue_1_9 extends SlowQueue {
methodInitLighting.of(c).call();
if ((bc.getTotalRelight() == 0 && !fixAll)) {
if (bc.getTotalRelight() == 0 && !fixAll) {
return true;
}

View File

@ -1,22 +1,5 @@
package com.plotsquared.bukkit.uuid;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayDeque;
import java.util.Collections;
import java.util.HashMap;
import java.util.UUID;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import com.google.common.collect.HashBiMap;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
@ -29,6 +12,22 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayDeque;
import java.util.Collections;
import java.util.HashMap;
import java.util.UUID;
public class SQLUUIDHandler extends UUIDHandlerImplementation {
@ -76,11 +75,9 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
final HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<StringWrapper, UUID>());
final PreparedStatement statement = getConnection().prepareStatement("SELECT `uuid`, `username` FROM `usercache`");
final ResultSet resultSet = statement.executeQuery();
StringWrapper username;
UUID uuid;
while (resultSet.next()) {
username = new StringWrapper(resultSet.getString("username"));
uuid = UUID.fromString(resultSet.getString("uuid"));
StringWrapper username = new StringWrapper(resultSet.getString("username"));
UUID uuid = UUID.fromString(resultSet.getString("uuid"));
toAdd.put(new StringWrapper(username.value), uuid);
}
statement.close();

View File

@ -76,7 +76,7 @@ public class MemorySection implements ConfigurationSection {
} catch (NumberFormatException ignored) {
}
} else if (obj instanceof List) {
final List<?> val = ((List<?>) obj);
final List<?> val = (List<?>) obj;
if (!val.isEmpty()) {
return toDouble(val.get(0), def);
}
@ -94,7 +94,7 @@ public class MemorySection implements ConfigurationSection {
} catch (NumberFormatException ignored) {
}
} else if (obj instanceof List) {
final List<?> val = ((List<?>) obj);
final List<?> val = (List<?>) obj;
if (!val.isEmpty()) {
return toInt(val.get(0), def);
}
@ -112,7 +112,7 @@ public class MemorySection implements ConfigurationSection {
} catch (NumberFormatException ignored) {
}
} else if (obj instanceof List) {
final List<?> val = ((List<?>) obj);
final List<?> val = (List<?>) obj;
if (!val.isEmpty()) {
return toLong(val.get(0), def);
}
@ -166,7 +166,7 @@ public class MemorySection implements ConfigurationSection {
builder.insert(0, parent.getName());
}
if ((key != null) && (!key.isEmpty())) {
if ((key != null) && !key.isEmpty()) {
if (builder.length() > 0) {
builder.append(separator);
}
@ -528,7 +528,7 @@ public class MemorySection implements ConfigurationSection {
final List<String> result = new ArrayList<>();
for (final Object object : list) {
if ((object instanceof String) || (isPrimitiveWrapper(object))) {
if ((object instanceof String) || isPrimitiveWrapper(object)) {
result.add(String.valueOf(object));
}
}
@ -819,7 +819,7 @@ public class MemorySection implements ConfigurationSection {
for (final Map.Entry<String, Object> entry : sec.map.entrySet()) {
output.add(createPath(section, entry.getKey(), this));
if ((deep) && (entry.getValue() instanceof ConfigurationSection)) {
if (deep && (entry.getValue() instanceof ConfigurationSection)) {
final ConfigurationSection subsection = (ConfigurationSection) entry.getValue();
mapChildrenKeys(output, subsection, deep);
}

View File

@ -159,7 +159,7 @@ public class YamlConfiguration extends FileConfiguration {
boolean readingHeader = true;
boolean foundHeader = false;
for (int i = 0; (i < lines.length) && (readingHeader); i++) {
for (int i = 0; (i < lines.length) && readingHeader; i++) {
final String line = lines[i];
if (line.startsWith(COMMENT_PREFIX)) {
@ -172,7 +172,7 @@ public class YamlConfiguration extends FileConfiguration {
}
foundHeader = true;
} else if ((foundHeader) && (line.isEmpty())) {
} else if (foundHeader && line.isEmpty()) {
result.append("\n");
} else if (foundHeader) {
readingHeader = false;
@ -189,11 +189,11 @@ public class YamlConfiguration extends FileConfiguration {
if (options().copyHeader()) {
final Configuration def = getDefaults();
if ((def != null) && (def instanceof FileConfiguration)) {
if (def != null && def instanceof FileConfiguration) {
final FileConfiguration filedefaults = (FileConfiguration) def;
final String defaultsHeader = filedefaults.buildHeader();
if ((defaultsHeader != null) && (!defaultsHeader.isEmpty())) {
if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) {
return defaultsHeader;
}
}
@ -210,7 +210,7 @@ public class YamlConfiguration extends FileConfiguration {
for (int i = lines.length - 1; i >= 0; i--) {
builder.insert(0, "\n");
if ((startedHeader) || (!lines[i].isEmpty())) {
if (startedHeader || !lines[i].isEmpty()) {
builder.insert(0, lines[i]);
builder.insert(0, COMMENT_PREFIX);
startedHeader = true;

View File

@ -363,7 +363,7 @@ public class JSONObject {
}
public static Writer quote(final String string, final Writer w) throws IOException {
if ((string == null) || (string.isEmpty())) {
if ((string == null) || string.isEmpty()) {
w.write("\"\"");
return w;
}
@ -427,7 +427,7 @@ public class JSONObject {
*/
public static Object stringToValue(final String string) {
Double d;
if (string.equals("")) {
if (string.isEmpty()) {
return string;
}
if (string.equalsIgnoreCase("true")) {
@ -1115,7 +1115,7 @@ public class JSONObject {
} else if (name.startsWith("is")) {
key = name.substring(2);
}
if ((!key.isEmpty()) && Character.isUpperCase(key.charAt(0)) && (method.getParameterTypes().length == 0)) {
if (!key.isEmpty() && Character.isUpperCase(key.charAt(0)) && (method.getParameterTypes().length == 0)) {
if (key.length() == 1) {
key = key.toLowerCase();
} else if (!Character.isUpperCase(key.charAt(1))) {

View File

@ -342,7 +342,7 @@ public class JSONTokener {
}
back();
string = sb.toString().trim();
if ("".equals(string)) {
if (string != null && string.isEmpty()) {
throw syntaxError("Missing value");
}
return JSONObject.stringToValue(string);

View File

@ -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

@ -109,7 +109,7 @@ public class Auto extends SubCommand {
final int diff = currentPlots - plr.getAllowedPlots();
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"));
@ -185,7 +185,7 @@ public class Auto extends SubCommand {
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);
}
}

View File

@ -14,6 +14,6 @@ public class Chat extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer player, final String... args) {
return MainCommand.onCommand(player, "plot", new String[] { "toggle", "chat" });
return MainCommand.onCommand(player, "plot", "toggle", "chat");
}
}

View File

@ -85,7 +85,7 @@ public class Database extends SubCommand {
MainUtil.sendMessage(player, "/plot database import [sqlite file] [prefix]");
return false;
}
File file = MainUtil.getFile(PS.get().IMP.getDirectory(), (args[1].endsWith(".db")) ? args[1] : args[1] + ".db");
File file = MainUtil.getFile(PS.get().IMP.getDirectory(), args[1].endsWith(".db") ? args[1] : args[1] + ".db");
if (!file.exists()) {
MainUtil.sendMessage(player, "&6Database does not exist: " + file);
return false;

View File

@ -90,7 +90,7 @@ public class Delete extends SubCommand {
}
}
};
if (Settings.CONFIRM_DELETE && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) {
if (Settings.CONFIRM_DELETE && !Permissions.hasPermission(plr, "plots.confirm.bypass")) {
CmdConfirm.addPending(plr, "/plot delete " + plot.getId(), run);
} else {
TaskManager.runTask(run);

View File

@ -17,7 +17,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class GenerateDocs {
public static void main(final String[] args) {
public static void main(String[] args) {
MainCommand.getInstance().addCommand(new WE_Anywhere());
MainCommand.getInstance().addCommand(new Cluster());
final ArrayList<Command<PlotPlayer>> commands = MainCommand.getInstance().getCommands();
@ -40,7 +41,7 @@ public class GenerateDocs {
}
}
public static void printCommand(final Command<PlotPlayer> command) {
public static void printCommand(Command<PlotPlayer> command) {
try {
final String clazz = command.getClass().getSimpleName();
final String name = command.getCommand();
@ -129,8 +130,8 @@ public class GenerateDocs {
return new ArrayList<>(usages);
}
public static List<String> getPerms(final String cmd, final List<String> lines) {
final HashSet<String> perms = new HashSet<String>();
public static List<String> getPerms(String cmd, List<String> lines) {
final HashSet<String> perms = new HashSet<>();
final Pattern p = Pattern.compile("\"([^\"]*)\"");
final Pattern p2 = Pattern.compile("C.PERMISSION_\\s*(\\w+)");
String last = null;
@ -203,12 +204,12 @@ public class GenerateDocs {
return new ArrayList<>(perms);
}
public static String getComments(final List<String> lines) {
public static String getComments(List<String> lines) {
final StringBuilder result = new StringBuilder();
for (String line : lines) {
line = line.trim();
if (line.startsWith("/** ") || line.startsWith("*/ ") || line.startsWith("* ")) {
line = (line.replaceAll("/[*][*] ", "").replaceAll("[*]/ ", "").replaceAll("[*] ", "")).trim();
line = line.replaceAll("/[*][*] ", "").replaceAll("[*]/ ", "").replaceAll("[*] ", "").trim();
result.append(line + "\n");
}
}

View File

@ -44,7 +44,7 @@ requiredType = RequiredType.NONE)
public class Inbox extends SubCommand {
public void displayComments(final PlotPlayer player, final List<PlotComment> oldComments, int page) {
if ((oldComments == null) || (oldComments.isEmpty())) {
if ((oldComments == null) || oldComments.isEmpty()) {
MainUtil.sendMessage(player, C.INBOX_EMPTY);
return;
}
@ -65,10 +65,10 @@ public class Inbox extends SubCommand {
}
final StringBuilder string = new StringBuilder();
string.append(StringMan.replaceAll(C.COMMENT_LIST_HEADER_PAGED.s(), "%amount%", comments.length, "%cur", page + 1, "%max", totalPages + 1, "%word", "all") + "\n");
PlotComment c;
// This might work xD
for (int x = (page * 12); x < max; x++) {
c = comments[x];
for (int x = page * 12; x < max; x++) {
PlotComment c = comments[x];
String color;
if (player.getName().equals(c.senderName)) {
color = "&a";
@ -152,12 +152,11 @@ public class Inbox extends SubCommand {
if (!inbox.getComments(plot, new RunnableVal<List<PlotComment>>() {
@Override
public void run(List<PlotComment> value) {
final List<PlotComment> comments = value;
if (index > comments.size()) {
if (index > value.size()) {
sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + "");
return;
}
final PlotComment comment = comments.get(index - 1);
final PlotComment comment = value.get(index - 1);
inbox.removeComment(plot, comment);
plot.getSettings().removeComment(comment);
MainUtil.sendMessage(player, C.COMMENT_REMOVED, comment.comment);
@ -199,8 +198,7 @@ public class Inbox extends SubCommand {
if (!inbox.getComments(plot, new RunnableVal<List<PlotComment>>() {
@Override
public void run(List<PlotComment> value) {
final List<PlotComment> comments = value;
displayComments(player, comments, page);
displayComments(player, value, page);
}
})) {
if (plot == null) {

View File

@ -1,9 +1,5 @@
package com.intellectualcrafters.plot.commands;
import java.net.URL;
import java.util.List;
import java.util.UUID;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
@ -19,6 +15,10 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration;
import java.net.URL;
import java.util.List;
import java.util.UUID;
@CommandDeclaration(command = "save", aliases = { "backup" }, description = "Save your plot", category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, permission = "plots.save")
public class Save extends SubCommand {
@ -73,7 +73,7 @@ public class Save extends SubCommand {
return;
}
MainUtil.sendMessage(plr, C.SAVE_SUCCESS);
final List<String> schematics = (List<String>) plr.getMeta("plot_schematics");
final List<String> schematics = plr.getMeta("plot_schematics");
if (schematics != null) {
schematics.add(file);
}

View File

@ -52,7 +52,7 @@ public class SetHome extends SetCommand {
Plot base = plot.getBasePlot(false);
Location bot = base.getBottomAbs();
Location loc = plr.getLocationFull();
BlockLoc rel = new BlockLoc(loc.getX() - bot.getX(), loc.getY(), loc.getZ() - bot.getZ(), loc.getYaw(), loc.getPitch());;
BlockLoc rel = new BlockLoc(loc.getX() - bot.getX(), loc.getY(), loc.getZ() - bot.getZ(), loc.getYaw(), loc.getPitch());
base.setHome(rel);
return MainUtil.sendMessage(plr, C.POSITION_SET);
}

View File

@ -66,7 +66,7 @@ public class Setup extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
// going through setup
SetupObject object = (SetupObject) plr.getMeta("setup");
SetupObject object = plr.getMeta("setup");
if (object == null) {
object = new SetupObject();
plr.setMeta("setup", object);

View File

@ -841,7 +841,7 @@ public class SQLManager implements AbstractDB {
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("")) {
if (pair.settings.getAlias().isEmpty()) {
stmt.setNull((i * 10) + 7, 4);
} else {
stmt.setString((i * 10) + 7, pair.settings.getAlias());
@ -909,7 +909,7 @@ public class SQLManager implements AbstractDB {
@Override
public void setMySQL(final PreparedStatement stmt, final int i, final Integer id) throws SQLException {
stmt.setInt((i) + 1, id);
stmt.setInt(i + 1, id);
}
@Override
@ -1467,7 +1467,7 @@ public class SQLManager implements AbstractDB {
return Integer.MAX_VALUE;
}
public void updateTables(int[] oldVersion) {
@Override public void updateTables(int[] oldVersion) {
try {
if (MYSQL && !PS.get().checkVersion(oldVersion, 3, 3, 2)) {
try (Statement stmt = connection.createStatement()) {
@ -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
@ -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,7 +57,7 @@ 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)) {
setWall(dpw, plot.getId(), new PlotBlock[] { dpw.WALL_BLOCK });
@ -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)]);
}
@ -239,13 +239,13 @@ 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)]);
}
}

View File

@ -23,17 +23,16 @@ package com.intellectualcrafters.plot.generator;
import com.intellectualcrafters.plot.object.PlotArea;
public interface GeneratorWrapper<T> {
public IndependentPlotGenerator getPlotGenerator();
public T getPlatformGenerator();
IndependentPlotGenerator getPlotGenerator();
public void augment(PlotArea area);
T getPlatformGenerator();
public boolean isFull();
void augment(PlotArea area);
@Override
public String toString();
boolean isFull();
@Override
public boolean equals(Object obj);
@Override String toString();
@Override boolean equals(Object obj);
}

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 {
@ -188,7 +208,7 @@ public abstract class HybridUtils {
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
@ -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();
@ -374,12 +394,12 @@ 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

@ -41,17 +41,17 @@ public abstract class SquarePlotManager extends GridPlotManager {
@Override
public Location getPlotTopLocAbs(final PlotArea plotworld, final PlotId plotid) {
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
final SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
final int px = plotid.x;
final int pz = plotid.y;
final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1;
final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1;
return new Location(plotworld.worldname, x, Math.min(plotworld.MAX_BUILD_HEIGHT, 255), z);
}
@Override
public PlotId getPlotIdAbs(final PlotArea plotworld, int x, final int y, int z) {
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
final SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
if (dpw.ROAD_OFFSET_X != 0) {
x -= dpw.ROAD_OFFSET_X;
}
@ -73,20 +73,20 @@ public abstract class SquarePlotManager extends GridPlotManager {
}
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
int idx;
int idz;
if (x < 0) {
idx = (x / size);
idx = x / size;
x = size + (x % size);
} else {
idx = (x / size) + 1;
x = (x % size);
x = x % size;
}
int idz;
if (z < 0) {
idz = (z / size);
idz = z / size;
z = size + (z % size);
} else {
idz = (z / size) + 1;
z = (z % size);
z = z % size;
}
return ((z <= pathWidthLower) || (z > end) || (x <= pathWidthLower) || (x > end)) ? null : new PlotId(idx, idz);
}
@ -94,7 +94,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
@Override
public PlotId getPlotId(final PlotArea plotworld, int x, final int y, int z) {
try {
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
final SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
if (plotworld == null) {
return null;
}
@ -117,23 +117,23 @@ public abstract class SquarePlotManager extends GridPlotManager {
int dx;
int rx;
if (x < 0) {
dx = (x / size);
dx = x / size;
rx = size + (x % size);
} else {
dx = (x / size) + 1;
rx = (x % size);
rx = x % size;
}
int dz;
int rz;
if (z < 0) {
dz = (z / size);
dz = z / size;
rz = size + (z % size);
} else {
dz = (z / size) + 1;
rz = (z % size);
rz = z % size;
}
PlotId id = new PlotId(dx, dz);
boolean[] merged = new boolean[] { (rz <= pathWidthLower), (rx > end), (rz > end), (rx <= pathWidthLower) };
boolean[] merged = new boolean[]{rz <= pathWidthLower, rx > end, rz > end, rx <= pathWidthLower};
int hash = MainUtil.hash(merged);
// Not merged, and no need to check if it is
if (hash == 0) {
@ -182,11 +182,11 @@ public abstract class SquarePlotManager extends GridPlotManager {
*/
@Override
public Location getPlotBottomLocAbs(final PlotArea plotworld, final PlotId plotid) {
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
final SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
final int px = plotid.x;
final int pz = plotid.y;
final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2));
final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2));
final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - (int) Math.floor(dpw.ROAD_WIDTH / 2);
final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - (int) Math.floor(dpw.ROAD_WIDTH / 2);
return new Location(plotworld.worldname, x, plotworld.MIN_BUILD_HEIGHT, z);
}
}

View File

@ -765,10 +765,7 @@ public class Plot {
}
public boolean clear(final boolean checkRunning, final boolean isDelete, final Runnable whenDone) {
if (checkRunning && (this.getRunning() != 0)) {
return false;
}
if (!EventUtil.manager.callClear(this)) {
if (checkRunning && (this.getRunning() != 0) || !EventUtil.manager.callClear(this)) {
return false;
}
final HashSet<RegionWrapper> regions = this.getRegions();

View File

@ -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]);
}
}
});
@ -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);
@ -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) {
@ -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

@ -1,8 +1,5 @@
package com.intellectualcrafters.plot.object.comment;
import java.util.ArrayList;
import java.util.List;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
@ -10,6 +7,9 @@ import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.TaskManager;
import java.util.ArrayList;
import java.util.List;
public class InboxOwner extends CommentInbox {
@Override
@ -17,10 +17,10 @@ public class InboxOwner extends CommentInbox {
if (plot == null) {
return Permissions.hasPermission(player, "plots.inbox.read." + toString());
}
return (Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
return Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.inbox.read."
+ toString()
+ ".other")));
+ ".other"));
}
@Override
@ -28,9 +28,10 @@ public class InboxOwner extends CommentInbox {
if (plot == null) {
return Permissions.hasPermission(player, "plots.inbox.write." + toString());
}
return (Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.write."
return Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.inbox.write."
+ toString()
+ ".other")));
+ ".other"));
}
@Override
@ -38,9 +39,10 @@ public class InboxOwner extends CommentInbox {
if (plot == null) {
return Permissions.hasPermission(player, "plots.inbox.modify." + toString());
}
return (Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify."
return Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.inbox.modify."
+ toString()
+ ".other")));
+ ".other"));
}
@Override
@ -59,7 +61,7 @@ public class InboxOwner extends CommentInbox {
public void run(List<PlotComment> value) {
whenDone.value = value;
if (value != null) {
for (final PlotComment comment : (ArrayList<PlotComment>) value) {
for (final PlotComment comment : value) {
plot.getSettings().addComment(comment);
}
} else {

View File

@ -1,8 +1,5 @@
package com.intellectualcrafters.plot.object.comment;
import java.util.ArrayList;
import java.util.List;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
@ -10,6 +7,9 @@ import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.TaskManager;
import java.util.ArrayList;
import java.util.List;
public class InboxPublic extends CommentInbox {
@Override
@ -17,10 +17,10 @@ public class InboxPublic extends CommentInbox {
if (plot == null) {
return Permissions.hasPermission(player, "plots.inbox.read." + toString());
}
return (Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
return Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.inbox.read."
+ toString()
+ ".other")));
+ ".other"));
}
@Override
@ -28,9 +28,10 @@ public class InboxPublic extends CommentInbox {
if (plot == null) {
return Permissions.hasPermission(player, "plots.inbox.write." + toString());
}
return (Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.write."
return Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.inbox.write."
+ toString()
+ ".other")));
+ ".other"));
}
@Override
@ -38,9 +39,10 @@ public class InboxPublic extends CommentInbox {
if (plot == null) {
return Permissions.hasPermission(player, "plots.inbox.modify." + toString());
}
return (Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify."
return Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.inbox.modify."
+ toString()
+ ".other")));
+ ".other"));
}
@Override
@ -59,7 +61,7 @@ public class InboxPublic extends CommentInbox {
public void run(List<PlotComment> value) {
whenDone.value = value;
if (value != null) {
for (final PlotComment comment : (ArrayList<PlotComment>) value) {
for (final PlotComment comment : value) {
plot.getSettings().addComment(comment);
}
}

View File

@ -6,7 +6,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
public class CmdConfirm {
public static CmdInstance getPending(final PlotPlayer player) {
return player.<CmdInstance>getMeta("cmdConfirm");
return player.getMeta("cmdConfirm");
}
public static void removePending(final PlotPlayer player) {

View File

@ -54,20 +54,22 @@ public class ExpireManager {
public void confirmExpiry(final PlotPlayer pp) {
if (Settings.AUTO_CLEAR_CONFIRMATION && plotsToDelete != null && !plotsToDelete.isEmpty() && pp.hasPermission("plots.admin.command.autoclear")) {
final int num = plotsToDelete.size();
Iterator<Plot> iter = plotsToDelete.iterator();
while (iter.hasNext()) {
final Plot current = iter.next();
for (final Plot current : plotsToDelete) {
if (isExpired(current)) {
TaskManager.runTask(new Runnable() {
@Override
public void run() {
pp.teleport(current.getCenter());
PlotMessage msg = new PlotMessage()
.text(num + " " + (num > 1 ? "plots are" : "plot is") + " expired:").color("$1").command("/plot list expired").tooltip("/plot list expired")
.text(num + " " + (num > 1 ? "plots are" : "plot is") + " expired:").color("$1").command("/plot list expired")
.tooltip("/plot list expired")
//.text("\n - ").color("$3").text("Delete all (/plot delete expired)").color("$2").command("/plot delete expired")
.text("\n - ").color("$3").text("Delete this (/plot delete)").color("$2").command("/plot delete").tooltip("/plot delete")
.text("\n - ").color("$3").text("Remind later (/plot set keep 1d)").color("$2").command("/plot set keep 1d").tooltip("/plot set keep 1d")
.text("\n - ").color("$3").text("Keep this (/plot set keep true)").color("$2").command("/plot set keep true").tooltip("/plot set keep true");
.text("\n - ").color("$3").text("Delete this (/plot delete)").color("$2").command("/plot delete")
.tooltip("/plot delete")
.text("\n - ").color("$3").text("Remind later (/plot set keep 1d)").color("$2").command("/plot set keep 1d")
.tooltip("/plot set keep 1d")
.text("\n - ").color("$3").text("Keep this (/plot set keep true)").color("$2").command("/plot set keep true")
.tooltip("/plot set keep true");
msg.send(pp);
}
});
@ -75,7 +77,6 @@ public class ExpireManager {
}
}
plotsToDelete.clear();
return;
}
}
@ -247,7 +248,7 @@ public class ExpireManager {
return false;
}
final long compared = System.currentTimeMillis() - last;
if (compared >= (TimeUnit.DAYS.toMillis(Settings.AUTO_CLEAR_DAYS))) {
if (compared >= TimeUnit.DAYS.toMillis(Settings.AUTO_CLEAR_DAYS)) {
return true;
}
}
@ -266,7 +267,7 @@ public class ExpireManager {
return false;
}
} else if (value instanceof Long) {
if (((Long) value) > System.currentTimeMillis()) {
if ((Long) value > System.currentTimeMillis()) {
return false;
}
} else { // Invalid?

View File

@ -1,12 +1,12 @@
package com.intellectualcrafters.plot.util;
import java.util.HashMap;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.general.commands.CommandCaller;
import java.util.HashMap;
/**
* The Permissions class handles checking user permissions.<br>
* - This will respect * nodes and plots.admin and can be used to check permission ranges (e.g. plots.plot.5)<br>
@ -34,7 +34,7 @@ public class Permissions {
if (!Settings.PERMISSION_CACHING) {
return hasPermission((CommandCaller) player, perm);
}
HashMap<String, Boolean> map = (HashMap<String, Boolean>) player.getMeta("perm");
HashMap<String, Boolean> map = player.getMeta("perm");
if (map != null) {
Boolean result = map.get(perm);
if (result != null) {
@ -63,7 +63,7 @@ public class Permissions {
final String[] nodes = perm.split("\\.");
final StringBuilder n = new StringBuilder();
for (int i = 0; i <= (nodes.length - 1); i++) {
n.append(nodes[i] + ("."));
n.append(nodes[i] + ".");
if (!perm.equals(n + C.PERMISSION_STAR.s())) {
if (player.hasPermission(n + C.PERMISSION_STAR.s())) {
return true;
@ -106,7 +106,7 @@ public class Permissions {
final String[] nodes = stub.split("\\.");
final StringBuilder n = new StringBuilder();
for (int i = 0; i < (nodes.length - 1); i++) {
n.append(nodes[i] + ("."));
n.append(nodes[i] + ".");
if (!stub.equals(n + C.PERMISSION_STAR.s())) {
if (player.hasPermission(n + C.PERMISSION_STAR.s())) {
return Integer.MAX_VALUE;

View File

@ -1,5 +1,5 @@
package com.intellectualcrafters.plot.util;
public enum PlotGamemode {
ADVENTURE, SURVIVAL, CREATIVE, SPECTATOR;
ADVENTURE, SURVIVAL, CREATIVE, SPECTATOR
}

View File

@ -1,5 +1,5 @@
package com.intellectualcrafters.plot.util;
public enum PlotWeather {
RAIN, CLEAR, RESET;
RAIN, CLEAR, RESET
}

View File

@ -24,6 +24,7 @@ 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 java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@ -166,7 +167,8 @@ public abstract class SchematicHandler {
final int HEIGHT = demensions.getY();
// Validate dimensions
RegionWrapper region = plot.getLargestRegion();
if ((((region.maxX - region.minX + x_offset) + 1) < WIDTH) || (((region.maxZ - region.minZ + z_offset) + 1) < LENGTH) || (HEIGHT > 256)) {
if (((region.maxX - region.minX + x_offset + 1) < WIDTH) || ((region.maxZ - region.minZ + z_offset + 1) < LENGTH) || (HEIGHT
> 256)) {
PS.debug("Schematic is too large");
PS.debug("(" + WIDTH + "," + LENGTH + "," + HEIGHT + ") is bigger than (" + (region.maxX - region.minX) + "," + (region.maxZ - region.minZ) + ",256)");
TaskManager.runTask(whenDone);
@ -451,7 +453,7 @@ public abstract class SchematicHandler {
final List<Tag> blockStates = ListTag.class.cast(tagMap.get("TileEntities")).getValue();
for (final Tag stateTag : blockStates) {
try {
final CompoundTag ct = ((CompoundTag) stateTag);
final CompoundTag ct = (CompoundTag) stateTag;
final Map<String, Tag> state = ct.getValue();
final short x = IntTag.class.cast(state.get("x")).getValue().shortValue();
final short y = IntTag.class.cast(state.get("y")).getValue().shortValue();
@ -782,15 +784,15 @@ public abstract class SchematicHandler {
int dz = schematicDimension.getZ();
for (int y = y1; y <= y2; y++) {
int yy = y >= 0 ? (y < dy ? y : y - dy) : y + dy;
int yy = y >= 0 ? y < dy ? y : y - dy : y + dy;
int i1 = yy * dx * dz;
int j1 = (y - y1) * width * length;
for (int z = z1; z <= z2; z++) {
int zz = z >= 0 ? (z < dz ? z : z - dz) : z + dz;
int zz = z >= 0 ? z < dz ? z : z - dz : z + dz;
int i2 = i1 + zz * dx;
int j2 = j1 + (z - z1) * width;
for (int x = x1; x <= x2; x++) {
int xx = x >= 0 ? (x < dx ? x : x - dx) : x + dx;
int xx = x >= 0 ? x < dx ? x : x - dx : x + dx;
int i3 = i2 + xx;
int j3 = j2 + (x - x1);
ids2[j3] = ids[i3];

View File

@ -179,7 +179,7 @@ public class SetQueue {
return false;
}
final ChunkWrapper other = (ChunkWrapper) obj;
return ((x == other.x) && (z == other.z) && (StringMan.isEqual(world, other.world)));
return (x == other.x) && (z == other.z) && StringMan.isEqual(world, other.world);
}
@Override

View File

@ -85,10 +85,14 @@ public class CommandManager<T extends CommandCaller> {
}
public int handle(final T plr, String input) {
if ((initialCharacter != null) && !input.startsWith(initialCharacter + "")) {
if (initialCharacter != null && !input.startsWith(initialCharacter + "")) {
return CommandHandlingOutput.NOT_COMMAND;
}
input = initialCharacter == null ? input : input.substring(1);
if (initialCharacter == null) {
input = input;
} else {
input = input.substring(1);
}
final String[] parts = input.split(" ");
String[] args;
final String command = parts[0].toLowerCase();

View File

@ -338,12 +338,8 @@ public class SpongeMain implements IPlotMain {
GenerationPopulator gen = wg.getBaseGenerationPopulator();
if (gen instanceof SpongePlotGenerator) {
PS.get().loadWorld(worldname, (SpongePlotGenerator) gen);
} else if (gen != null) {
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!");
} else {
if (PS.get().config.contains("worlds." + worldname)) {
PS.get().loadWorld(worldname, null);
}
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!");
}
}

View File

@ -19,7 +19,8 @@ public class SpongeAugmentedGenerator implements GenerationPopulator {
private static SpongeAugmentedGenerator generator;
private SpongeAugmentedGenerator() {};
private SpongeAugmentedGenerator() {
}
public static SpongeAugmentedGenerator get(World world) {
WorldGenerator wg = world.getWorldGenerator();

View File

@ -86,7 +86,7 @@ public class SpongeUtil extends WorldUtil {
System.out.println(method + ": " + cause.toString());
System.out.println(method + ": " + cause.getClass());
System.out.println(method + ": " + StringMan.getString(cause.all()));
System.out.println(method + ": " + (cause.root()));
System.out.println(method + ": " + cause.root());
}
public static void initBiomeCache() {
@ -291,7 +291,7 @@ public class SpongeUtil extends WorldUtil {
id = Short.parseShort(split[0]);
match = 0;
} else {
List<BlockType> types = ReflectionUtils.<BlockType>getStaticFields(BlockTypes.class);
List<BlockType> types = ReflectionUtils.getStaticFields(BlockTypes.class);
final StringComparison<BlockType>.ComparisonResult comparison =
new StringComparison<BlockType>(name, types.toArray(new BlockType[types.size()])) {
@Override