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; UUIDWrapper wrapper;
if (Settings.OFFLINE_MODE) { if (Settings.OFFLINE_MODE) {
if (Settings.UUID_LOWERCASE) { if (Settings.UUID_LOWERCASE) {
wrapper = (new LowerOfflineUUIDWrapper()); wrapper = new LowerOfflineUUIDWrapper();
} else { } else {
wrapper = (new OfflineUUIDWrapper()); wrapper = new OfflineUUIDWrapper();
} }
Settings.OFFLINE_MODE = true; Settings.OFFLINE_MODE = true;
} else if (checkVersion) { } else if (checkVersion) {
wrapper = (new DefaultUUIDWrapper()); wrapper = new DefaultUUIDWrapper();
Settings.OFFLINE_MODE = false; Settings.OFFLINE_MODE = false;
} else { } else {
if (Settings.UUID_LOWERCASE) { if (Settings.UUID_LOWERCASE) {
wrapper = (new LowerOfflineUUIDWrapper()); wrapper = new LowerOfflineUUIDWrapper();
} else { } else {
wrapper = (new OfflineUUIDWrapper()); wrapper = new OfflineUUIDWrapper();
} }
Settings.OFFLINE_MODE = true; Settings.OFFLINE_MODE = true;
} }

View File

@ -70,7 +70,7 @@ public abstract class TextualComponent implements Cloneable {
} }
static boolean isTranslatableText(final TextualComponent component) { 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) { public Location getPlotTopLocAbs(final int path, final int plot, final PlotId plotid) {
final int px = plotid.x; final int px = plotid.x;
final int pz = plotid.y; final int pz = plotid.y;
final int x = (px * (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; final int z = (pz * (path + plot)) - (int) Math.floor(path / 2) - 1;
return new Location(null, x, 256, z); return new Location(null, x, 256, z);
} }
public Location getPlotBottomLocAbs(final int path, final int plot, final PlotId plotid) { public Location getPlotBottomLocAbs(final int path, final int plot, final PlotId plotid) {
final int px = plotid.x; final int px = plotid.x;
final int pz = plotid.y; final int pz = plotid.y;
final int x = (px * (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; final int z = (pz * (path + plot)) - plot - (int) Math.floor(path / 2) - 1;
return new Location(null, x, 1, z); return new Location(null, x, 1, z);
} }

View File

@ -20,16 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.listeners; 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.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; 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.events.PlayerEnterPlotEvent;
import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import 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 { public class ForceFieldListener implements Listener {
private Set<PlotPlayer> getNearbyPlayers(final Player player, final Plot plot) { private Set<PlotPlayer> getNearbyPlayers(final Player player, final Plot plot) {
@ -73,17 +73,19 @@ public class ForceFieldListener implements Listener {
Location oPlayerLocation = e.getLocation(); Location oPlayerLocation = e.getLocation();
final double playerX = playerLocation.getX(), playerY = playerLocation.getY(), playerZ = playerLocation.getZ(), oPlayerX = oPlayerLocation.getX(), oPlayerY = oPlayerLocation.getY(), oPlayerZ = oPlayerLocation final double playerX = playerLocation.getX(), playerY = playerLocation.getY(), playerZ = playerLocation.getZ(), oPlayerX = oPlayerLocation.getX(), oPlayerY = oPlayerLocation.getY(), oPlayerZ = oPlayerLocation
.getZ(); .getZ();
double x = 0d, y = 0d, z = 0d; double x = 0d;
if (playerX < oPlayerX) { if (playerX < oPlayerX) {
x = 1.0d; x = 1.0d;
} else if (playerX > oPlayerX) { } else if (playerX > oPlayerX) {
x = -1.0d; x = -1.0d;
} }
double y = 0d;
if (playerY < oPlayerY) { if (playerY < oPlayerY) {
y = 0.5d; y = 0.5d;
} else if (playerY > oPlayerY) { } else if (playerY > oPlayerY) {
y = -0.5d; y = -0.5d;
} }
double z = 0d;
if (playerZ < oPlayerZ) { if (playerZ < oPlayerZ) {
z = 1.0d; z = 1.0d;
} else if (playerZ > oPlayerZ) { } else if (playerZ > oPlayerZ) {

View File

@ -2,19 +2,64 @@ package com.plotsquared.bukkit.util;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.AugmentedUtils; 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.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 com.plotsquared.bukkit.object.entity.EntityWrapper;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.block.*; 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.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.InventoryHolder;
import org.bukkit.inventory.ItemStack; 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.Map.Entry;
import java.util.Set;
public class BukkitChunkManager extends ChunkManager { public class BukkitChunkManager extends ChunkManager {
@ -595,7 +640,6 @@ public class BukkitChunkManager extends ChunkManager {
} }
} }
while (SetQueue.IMP.forceChunkSet()) { while (SetQueue.IMP.forceChunkSet()) {
;
} }
restoreBlocks(world1, 0, 0); restoreBlocks(world1, 0, 0);
restoreEntities(world1, 0, 0); restoreEntities(world1, 0, 0);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -318,7 +318,7 @@ public class Area extends SubCommand {
region = area.getRegion().toString(); region = area.getRegion().toString();
} else { } else {
name = area.worldname; name = area.worldname;
percent = claimed == 0 ? 0 : (100d * claimed) / (Integer.MAX_VALUE); percent = claimed == 0 ? 0 : (100d * claimed) / Integer.MAX_VALUE;
region = "N/A"; region = "N/A";
} }
String value = "&r$1NAME: " + name String value = "&r$1NAME: " + name

View File

@ -109,7 +109,7 @@ public class Auto extends SubCommand {
final int diff = currentPlots - plr.getAllowedPlots(); final int diff = currentPlots - plr.getAllowedPlots();
if ((diff + (size_x * size_z)) > 0) { if ((diff + (size_x * size_z)) > 0) {
if (diff < 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; return false;
} else if (plr.hasPersistentMeta("grantedPlots")) { } else if (plr.hasPersistentMeta("grantedPlots")) {
int grantedPlots = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("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 i = start.x; i <= end.x; i++) {
for (int j = start.y; j <= end.y; j++) { for (int j = start.y; j <= end.y; j++) {
Plot plot = plotarea.getPlotAbs(new PlotId(i, 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); plot.claim(plr, teleport, null);
} }
} }

View File

@ -14,6 +14,6 @@ public class Chat extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer player, final String... args) { 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]"); MainUtil.sendMessage(player, "/plot database import [sqlite file] [prefix]");
return false; 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()) { if (!file.exists()) {
MainUtil.sendMessage(player, "&6Database does not exist: " + file); MainUtil.sendMessage(player, "&6Database does not exist: " + file);
return false; 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); CmdConfirm.addPending(plr, "/plot delete " + plot.getId(), run);
} else { } else {
TaskManager.runTask(run); TaskManager.runTask(run);

View File

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

View File

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

View File

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

View File

@ -52,7 +52,7 @@ public class SetHome extends SetCommand {
Plot base = plot.getBasePlot(false); Plot base = plot.getBasePlot(false);
Location bot = base.getBottomAbs(); Location bot = base.getBottomAbs();
Location loc = plr.getLocationFull(); 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); base.setHome(rel);
return MainUtil.sendMessage(plr, C.POSITION_SET); return MainUtil.sendMessage(plr, C.POSITION_SET);
} }

View File

@ -66,7 +66,7 @@ public class Setup extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { public boolean onCommand(final PlotPlayer plr, final String[] args) {
// going through setup // going through setup
SetupObject object = (SetupObject) plr.getMeta("setup"); SetupObject object = plr.getMeta("setup");
if (object == null) { if (object == null) {
object = new SetupObject(); object = new SetupObject();
plr.setMeta("setup", object); 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) + 4, 4); // custom_time
stmt.setNull((i * 10) + 5, 4); // time stmt.setNull((i * 10) + 5, 4); // time
stmt.setNull((i * 10) + 6, 4); // deny_entry stmt.setNull((i * 10) + 6, 4); // deny_entry
if (pair.settings.getAlias().equals("")) { if (pair.settings.getAlias().isEmpty()) {
stmt.setNull((i * 10) + 7, 4); stmt.setNull((i * 10) + 7, 4);
} else { } else {
stmt.setString((i * 10) + 7, pair.settings.getAlias()); stmt.setString((i * 10) + 7, pair.settings.getAlias());
@ -909,7 +909,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void setMySQL(final PreparedStatement stmt, final int i, final Integer id) throws SQLException { public void setMySQL(final PreparedStatement stmt, final int i, final Integer id) throws SQLException {
stmt.setInt((i) + 1, id); stmt.setInt(i + 1, id);
} }
@Override @Override
@ -1467,7 +1467,7 @@ public class SQLManager implements AbstractDB {
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
} }
public void updateTables(int[] oldVersion) { @Override public void updateTables(int[] oldVersion) {
try { try {
if (MYSQL && !PS.get().checkVersion(oldVersion, 3, 3, 2)) { if (MYSQL && !PS.get().checkVersion(oldVersion, 3, 3, 2)) {
try (Statement stmt = connection.createStatement()) { try (Statement stmt = connection.createStatement()) {
@ -1575,12 +1575,12 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void setMySQL(PreparedStatement stmt, int i, Integer obj) throws SQLException { public void setMySQL(PreparedStatement stmt, int i, Integer obj) throws SQLException {
stmt.setInt((i) + 1, obj); stmt.setInt(i + 1, obj);
} }
@Override @Override
public void setSQLite(PreparedStatement stmt, int i, Integer obj) throws SQLException { public void setSQLite(PreparedStatement stmt, int i, Integer obj) throws SQLException {
stmt.setInt((i) + 1, obj); stmt.setInt(i + 1, obj);
} }
@Override @Override
@ -2584,7 +2584,7 @@ public class SQLManager implements AbstractDB {
final Integer m = r.getInt("merged"); final Integer m = r.getInt("merged");
final boolean[] merged = new boolean[4]; final boolean[] merged = new boolean[4];
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
merged[3 - i] = ((m) & (1 << i)) != 0; merged[3 - i] = (m & (1 << i)) != 0;
} }
cluster.settings.setMerged(merged); cluster.settings.setMerged(merged);
String[] flags_string; String[] flags_string;

View File

@ -1,7 +1,5 @@
package com.intellectualcrafters.plot.generator; package com.intellectualcrafters.plot.generator;
import java.util.ArrayList;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea; 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.MainUtil;
import com.intellectualcrafters.plot.util.SetQueue; 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) * 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 @Override
public boolean unclaimPlot(final PlotArea plotworld, final Plot plot, final Runnable whenDone) { 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 }); 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 }); setWall(dpw, plot.getId(), new PlotBlock[] { dpw.WALL_BLOCK });
@ -142,7 +142,7 @@ public class ClassicPlotManager extends SquarePlotManager {
final PseudoRandom random = new PseudoRandom(); final PseudoRandom random = new PseudoRandom();
if (!plot.getMerged(0)) { if (!plot.getMerged(0)) {
int z = bottom.getZ(); 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++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); 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)) { if (!plot.getMerged(3)) {
int x = bottom.getX(); 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++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); 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)) { if (!plot.getMerged(2)) {
int z = top.getZ(); 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++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); 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)) { if (!plot.getMerged(1)) {
int x = top.getX(); 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++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); 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(); final PseudoRandom random = new PseudoRandom();
if (!plot.getMerged(0)) { if (!plot.getMerged(0)) {
int z = bot.getZ(); 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++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); 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)) { if (!plot.getMerged(3)) {
int x = bot.getX(); 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++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); 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; final int y = dpw.WALL_HEIGHT + 1;
if (!plot.getMerged(0)) { if (!plot.getMerged(0)) {
int z = bot.getZ(); 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)]); SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
} }
} }
if (!plot.getMerged(3)) { if (!plot.getMerged(3)) {
int x = bot.getX(); 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)]); 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; import com.intellectualcrafters.plot.object.PlotArea;
public interface GeneratorWrapper<T> { 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 boolean isFull();
public String toString();
@Override @Override String toString();
public boolean equals(Object obj);
@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.config.C;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.util.*; 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.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.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public abstract class HybridUtils { public abstract class HybridUtils {
@ -188,7 +208,7 @@ public abstract class HybridUtils {
if ((count.intValue() % 20) == 0) { if ((count.intValue() % 20) == 0) {
PS.debug("PROGRESS: " + ((100 * (2048 - chunks.size())) / 2048) + "%"); PS.debug("PROGRESS: " + ((100 * (2048 - chunks.size())) / 2048) + "%");
} }
if ((regions.isEmpty()) && (chunks.isEmpty())) { if (regions.isEmpty() && chunks.isEmpty()) {
HybridUtils.UPDATE = false; HybridUtils.UPDATE = false;
PS.debug(C.PREFIX.s() + "Finished road conversion"); PS.debug(C.PREFIX.s() + "Finished road conversion");
// CANCEL TASK // CANCEL TASK
@ -230,8 +250,8 @@ public abstract class HybridUtils {
TaskManager.runTaskLater(task, 600); TaskManager.runTaskLater(task, 600);
return; return;
} }
if ((((System.currentTimeMillis() - baseTime) - last.get()) < 1500) && (last.get() != 0)) { if (((System.currentTimeMillis() - baseTime - last.get()) < 1500) && (last.get() != 0)) {
while ((System.currentTimeMillis() < diff) && (!chunks.isEmpty())) { while ((System.currentTimeMillis() < diff) && !chunks.isEmpty()) {
Iterator<ChunkLoc> iter = chunks.iterator(); Iterator<ChunkLoc> iter = chunks.iterator();
final ChunkLoc chunk = iter.next(); final ChunkLoc chunk = iter.next();
iter.remove(); iter.remove();
@ -374,12 +394,12 @@ public abstract class HybridUtils {
final boolean gz = absZ > plotworld.PATH_WIDTH_LOWER; final boolean gz = absZ > plotworld.PATH_WIDTH_LOWER;
final boolean lx = absX < plotworld.PATH_WIDTH_UPPER; final boolean lx = absX < plotworld.PATH_WIDTH_UPPER;
final boolean lz = absZ < plotworld.PATH_WIDTH_UPPER; final boolean lz = absZ < plotworld.PATH_WIDTH_UPPER;
condition = (!gx || !gz || !lx || !lz); condition = !gx || !gz || !lx || !lz;
} }
if (condition) { if (condition) {
final int sy = plotworld.ROAD_HEIGHT; final int sy = plotworld.ROAD_HEIGHT;
final HashMap<Integer, PlotBlock> blocks = plotworld.G_SCH.get(MathMan.pair(absX, absZ)); 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); SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, y, z + Z + plotworld.ROAD_OFFSET_Z, 0);
} }
if (blocks != null) { if (blocks != null) {

View File

@ -41,17 +41,17 @@ public abstract class SquarePlotManager extends GridPlotManager {
@Override @Override
public Location getPlotTopLocAbs(final PlotArea plotworld, final PlotId plotid) { 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 px = plotid.x;
final int pz = plotid.y; 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 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 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); return new Location(plotworld.worldname, x, Math.min(plotworld.MAX_BUILD_HEIGHT, 255), z);
} }
@Override @Override
public PlotId getPlotIdAbs(final PlotArea plotworld, int x, final int y, int z) { 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) { if (dpw.ROAD_OFFSET_X != 0) {
x -= dpw.ROAD_OFFSET_X; x -= dpw.ROAD_OFFSET_X;
} }
@ -73,20 +73,20 @@ public abstract class SquarePlotManager extends GridPlotManager {
} }
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH; final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
int idx; int idx;
int idz;
if (x < 0) { if (x < 0) {
idx = (x / size); idx = x / size;
x = size + (x % size); x = size + (x % size);
} else { } else {
idx = (x / size) + 1; idx = (x / size) + 1;
x = (x % size); x = x % size;
} }
int idz;
if (z < 0) { if (z < 0) {
idz = (z / size); idz = z / size;
z = size + (z % size); z = size + (z % size);
} else { } else {
idz = (z / size) + 1; idz = (z / size) + 1;
z = (z % size); z = z % size;
} }
return ((z <= pathWidthLower) || (z > end) || (x <= pathWidthLower) || (x > end)) ? null : new PlotId(idx, idz); 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 @Override
public PlotId getPlotId(final PlotArea plotworld, int x, final int y, int z) { public PlotId getPlotId(final PlotArea plotworld, int x, final int y, int z) {
try { try {
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); final SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
if (plotworld == null) { if (plotworld == null) {
return null; return null;
} }
@ -117,23 +117,23 @@ public abstract class SquarePlotManager extends GridPlotManager {
int dx; int dx;
int rx; int rx;
if (x < 0) { if (x < 0) {
dx = (x / size); dx = x / size;
rx = size + (x % size); rx = size + (x % size);
} else { } else {
dx = (x / size) + 1; dx = (x / size) + 1;
rx = (x % size); rx = x % size;
} }
int dz; int dz;
int rz; int rz;
if (z < 0) { if (z < 0) {
dz = (z / size); dz = z / size;
rz = size + (z % size); rz = size + (z % size);
} else { } else {
dz = (z / size) + 1; dz = (z / size) + 1;
rz = (z % size); rz = z % size;
} }
PlotId id = new PlotId(dx, dz); 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); int hash = MainUtil.hash(merged);
// Not merged, and no need to check if it is // Not merged, and no need to check if it is
if (hash == 0) { if (hash == 0) {
@ -182,11 +182,11 @@ public abstract class SquarePlotManager extends GridPlotManager {
*/ */
@Override @Override
public Location getPlotBottomLocAbs(final PlotArea plotworld, final PlotId plotid) { 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 px = plotid.x;
final int pz = plotid.y; 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 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 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); 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) { public boolean clear(final boolean checkRunning, final boolean isDelete, final Runnable whenDone) {
if (checkRunning && (this.getRunning() != 0)) { if (checkRunning && (this.getRunning() != 0) || !EventUtil.manager.callClear(this)) {
return false;
}
if (!EventUtil.manager.callClear(this)) {
return false; return false;
} }
final HashSet<RegionWrapper> regions = this.getRegions(); 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"); PS.debug(" - $1Reducing " + plots.size() + " plots to those with sufficient data");
while (iter.hasNext()) { while (iter.hasNext()) {
final Plot plot = iter.next(); 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(); iter.remove();
} else { } else {
plot.addRunning(); plot.addRunning();
@ -126,7 +126,7 @@ public class PlotAnalysis {
final int i = mi.intValue(); final int i = mi.intValue();
final Plot plot = plots.get(i); final Plot plot = plots.get(i);
ratings[i] = (int) ((plot.getAverageRating() + plot.getSettings().getRatings().size()) * 100); 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[] variance_air = square(sd_air);
final int sum_air = sum(variance_air); final int sum_air = sum(variance_air);
final double factor_air = getCC(n, sum_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); PS.debug(" - | air " + factor_air);
final int[] rank_variety = rank(variety); final int[] rank_variety = rank(variety);
@ -244,7 +244,7 @@ public class PlotAnalysis {
final int[] variance_variety = square(sd_variety); final int[] variance_variety = square(sd_variety);
final int sum_variety = sum(variance_variety); final int sum_variety = sum(variance_variety);
final double factor_variety = getCC(n, sum_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); PS.debug(" - | variety " + factor_variety);
final int[] rank_changes_sd = rank(changes_sd); final int[] rank_changes_sd = rank(changes_sd);
@ -303,7 +303,7 @@ public class PlotAnalysis {
} }
} }
int optimal_complexity = Integer.MAX_VALUE; 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); final int[] rank_complexity = rank(complexity, max + 1);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
if (rank_complexity[i] == optimal_index) { if (rank_complexity[i] == optimal_index) {
@ -542,16 +542,16 @@ public class PlotAnalysis {
if (complexity != 0) { if (complexity != 0) {
return complexity; return complexity;
} }
complexity = ((changes) * MODIFIERS.changes) complexity = (changes * MODIFIERS.changes)
+ ((faces) * MODIFIERS.faces) + (faces * MODIFIERS.faces)
+ ((data) * MODIFIERS.data) + (data * MODIFIERS.data)
+ ((air) * MODIFIERS.air) + (air * MODIFIERS.air)
+ ((variety) * MODIFIERS.variety) + (variety * MODIFIERS.variety)
+ ((changes_sd) * MODIFIERS.changes_sd) + (changes_sd * MODIFIERS.changes_sd)
+ ((faces_sd) * MODIFIERS.faces_sd) + (faces_sd * MODIFIERS.faces_sd)
+ ((data_sd) * MODIFIERS.data_sd) + (data_sd * MODIFIERS.data_sd)
+ ((air_sd) * MODIFIERS.air_sd) + (air_sd * MODIFIERS.air_sd)
+ ((variety_sd) * MODIFIERS.variety_sd); + (variety_sd * MODIFIERS.variety_sd);
return complexity; return complexity;
} }
} }

View File

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

View File

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

View File

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

View File

@ -54,20 +54,22 @@ public class ExpireManager {
public void confirmExpiry(final PlotPlayer pp) { public void confirmExpiry(final PlotPlayer pp) {
if (Settings.AUTO_CLEAR_CONFIRMATION && plotsToDelete != null && !plotsToDelete.isEmpty() && pp.hasPermission("plots.admin.command.autoclear")) { if (Settings.AUTO_CLEAR_CONFIRMATION && plotsToDelete != null && !plotsToDelete.isEmpty() && pp.hasPermission("plots.admin.command.autoclear")) {
final int num = plotsToDelete.size(); final int num = plotsToDelete.size();
Iterator<Plot> iter = plotsToDelete.iterator(); for (final Plot current : plotsToDelete) {
while (iter.hasNext()) {
final Plot current = iter.next();
if (isExpired(current)) { if (isExpired(current)) {
TaskManager.runTask(new Runnable() { TaskManager.runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
pp.teleport(current.getCenter()); pp.teleport(current.getCenter());
PlotMessage msg = new PlotMessage() 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 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("Delete this (/plot delete)").color("$2").command("/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") .tooltip("/plot delete")
.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("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); msg.send(pp);
} }
}); });
@ -75,7 +77,6 @@ public class ExpireManager {
} }
} }
plotsToDelete.clear(); plotsToDelete.clear();
return;
} }
} }
@ -247,7 +248,7 @@ public class ExpireManager {
return false; return false;
} }
final long compared = System.currentTimeMillis() - last; 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; return true;
} }
} }
@ -266,7 +267,7 @@ public class ExpireManager {
return false; return false;
} }
} else if (value instanceof Long) { } else if (value instanceof Long) {
if (((Long) value) > System.currentTimeMillis()) { if ((Long) value > System.currentTimeMillis()) {
return false; return false;
} }
} else { // Invalid? } else { // Invalid?

View File

@ -1,12 +1,12 @@
package com.intellectualcrafters.plot.util; package com.intellectualcrafters.plot.util;
import java.util.HashMap;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.general.commands.CommandCaller; import com.plotsquared.general.commands.CommandCaller;
import java.util.HashMap;
/** /**
* The Permissions class handles checking user permissions.<br> * 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> * - 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) { if (!Settings.PERMISSION_CACHING) {
return hasPermission((CommandCaller) player, perm); 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) { if (map != null) {
Boolean result = map.get(perm); Boolean result = map.get(perm);
if (result != null) { if (result != null) {
@ -63,7 +63,7 @@ public class Permissions {
final String[] nodes = perm.split("\\."); final String[] nodes = perm.split("\\.");
final StringBuilder n = new StringBuilder(); final StringBuilder n = new StringBuilder();
for (int i = 0; i <= (nodes.length - 1); i++) { 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 (!perm.equals(n + C.PERMISSION_STAR.s())) {
if (player.hasPermission(n + C.PERMISSION_STAR.s())) { if (player.hasPermission(n + C.PERMISSION_STAR.s())) {
return true; return true;
@ -106,7 +106,7 @@ public class Permissions {
final String[] nodes = stub.split("\\."); final String[] nodes = stub.split("\\.");
final StringBuilder n = new StringBuilder(); final StringBuilder n = new StringBuilder();
for (int i = 0; i < (nodes.length - 1); i++) { 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 (!stub.equals(n + C.PERMISSION_STAR.s())) {
if (player.hasPermission(n + C.PERMISSION_STAR.s())) { if (player.hasPermission(n + C.PERMISSION_STAR.s())) {
return Integer.MAX_VALUE; return Integer.MAX_VALUE;

View File

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

View File

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

View File

@ -179,7 +179,7 @@ public class SetQueue {
return false; return false;
} }
final ChunkWrapper other = (ChunkWrapper) obj; 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 @Override

View File

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

View File

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

View File

@ -19,7 +19,8 @@ public class SpongeAugmentedGenerator implements GenerationPopulator {
private static SpongeAugmentedGenerator generator; private static SpongeAugmentedGenerator generator;
private SpongeAugmentedGenerator() {}; private SpongeAugmentedGenerator() {
}
public static SpongeAugmentedGenerator get(World world) { public static SpongeAugmentedGenerator get(World world) {
WorldGenerator wg = world.getWorldGenerator(); 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.toString());
System.out.println(method + ": " + cause.getClass()); System.out.println(method + ": " + cause.getClass());
System.out.println(method + ": " + StringMan.getString(cause.all())); System.out.println(method + ": " + StringMan.getString(cause.all()));
System.out.println(method + ": " + (cause.root())); System.out.println(method + ": " + cause.root());
} }
public static void initBiomeCache() { public static void initBiomeCache() {
@ -291,7 +291,7 @@ public class SpongeUtil extends WorldUtil {
id = Short.parseShort(split[0]); id = Short.parseShort(split[0]);
match = 0; match = 0;
} else { } else {
List<BlockType> types = ReflectionUtils.<BlockType>getStaticFields(BlockTypes.class); List<BlockType> types = ReflectionUtils.getStaticFields(BlockTypes.class);
final StringComparison<BlockType>.ComparisonResult comparison = final StringComparison<BlockType>.ComparisonResult comparison =
new StringComparison<BlockType>(name, types.toArray(new BlockType[types.size()])) { new StringComparison<BlockType>(name, types.toArray(new BlockType[types.size()])) {
@Override @Override