Various changes

Plot class is now more reliable as most fields are private
Cleanup some classes.
Fixes #955
makes progress on #953
This commit is contained in:
Matt 2016-03-13 14:09:48 -04:00
parent 3fb686608b
commit dfd29f6713
10 changed files with 335 additions and 240 deletions

View File

@ -12,23 +12,74 @@ import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.ChatManager;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.ConsoleColors;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.InventoryUtil;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotQueue;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.commands.DebugUUID;
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
import com.plotsquared.bukkit.listeners.*;
import com.plotsquared.bukkit.listeners.ChunkListener;
import com.plotsquared.bukkit.listeners.ForceFieldListener;
import com.plotsquared.bukkit.listeners.PlayerEvents;
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8_3;
import com.plotsquared.bukkit.listeners.PlotPlusListener;
import com.plotsquared.bukkit.listeners.WorldEvents;
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
import com.plotsquared.bukkit.titles.DefaultTitle_19;
import com.plotsquared.bukkit.util.*;
import com.plotsquared.bukkit.util.block.*;
import com.plotsquared.bukkit.uuid.*;
import com.plotsquared.bukkit.util.BukkitChatManager;
import com.plotsquared.bukkit.util.BukkitChunkManager;
import com.plotsquared.bukkit.util.BukkitCommand;
import com.plotsquared.bukkit.util.BukkitEconHandler;
import com.plotsquared.bukkit.util.BukkitEventUtil;
import com.plotsquared.bukkit.util.BukkitHybridUtils;
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
import com.plotsquared.bukkit.util.BukkitPlainChatManager;
import com.plotsquared.bukkit.util.BukkitSchematicHandler;
import com.plotsquared.bukkit.util.BukkitSetupUtils;
import com.plotsquared.bukkit.util.BukkitTaskManager;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.Metrics;
import com.plotsquared.bukkit.util.SendChunk;
import com.plotsquared.bukkit.util.SetGenCB;
import com.plotsquared.bukkit.util.block.FastQueue_1_7;
import com.plotsquared.bukkit.util.block.FastQueue_1_8;
import com.plotsquared.bukkit.util.block.FastQueue_1_8_3;
import com.plotsquared.bukkit.util.block.FastQueue_1_9;
import com.plotsquared.bukkit.util.block.SlowQueue;
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
import com.plotsquared.bukkit.uuid.FileUUIDHandler;
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -42,7 +93,11 @@ import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@ -87,9 +142,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@Override
public void log(String message) {
if (message == null) {
return;
}
if ((THIS != null) && (Bukkit.getServer().getConsoleSender() != null)) {
try {
message = C.color(message);

View File

@ -27,16 +27,6 @@ import com.plotsquared.bukkit.object.BukkitLazyBlock;
import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlayerBlockEventType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -52,11 +42,13 @@ import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.Horse;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.ThrownPotion;
@ -115,6 +107,17 @@ import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
/**
* Player Events involving plots
*
@ -1307,9 +1310,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
public boolean checkEntity(final Entity entity, final Plot plot) {
if (plot == null || plot.owner == null || plot.settings == null || plot.getFlags().isEmpty() && plot.getArea().DEFAULT_FLAGS
.isEmpty
()) {
if (plot == null || plot.owner == null || plot.getFlags().isEmpty() && plot.getArea().DEFAULT_FLAGS.isEmpty()) {
return false;
}
switch (entity.getType()) {
@ -1324,6 +1325,10 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
case SNOWBALL:
case ENDER_PEARL:
case ARROW:
case TIPPED_ARROW:
case SPECTRAL_ARROW:
case SHULKER_BULLET:
case DRAGON_FIREBALL:
// projectile
case PRIMED_TNT:
case FALLING_BLOCK:
@ -1336,6 +1341,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
case LEASH_HITCH:
case FIREWORK:
case WEATHER:
case AREA_EFFECT_CLOUD:
case LIGHTNING:
case WITHER_SKULL:
case UNKNOWN:
@ -1360,7 +1366,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
case MUSHROOM_COW:
case OCELOT:
case PIG:
case HORSE:
case SQUID:
case VILLAGER:
case IRON_GOLEM:
@ -1389,26 +1394,30 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
case WITCH:
case WITHER:
case ZOMBIE:
case SHULKER:
// monster
return checkEntity(plot, "entity-cap", "mob-cap", "hostile-cap");
case HORSE:
Horse horse = ((Horse) entity);
if (horse.getVariant().equals(Horse.Variant.SKELETON_HORSE) && entity.getPassenger() instanceof Skeleton) {
return checkEntity(plot, "entity-cap", "mob-cap", "hostile-cap");
}
return checkEntity(plot, "entity-cap", "mob-cap", "animal-cap");
default:
String[] types;
if (entity instanceof LivingEntity) {
if (entity instanceof Animals) {
types = new String[] { "entity-cap", "mob-cap", "animal-cap" };
return checkEntity(plot, "entity-cap", "mob-cap", "animal-cap");
} else if (entity instanceof Monster) {
types = new String[] { "entity-cap", "mob-cap", "hostile-cap" };
return checkEntity(plot, "entity-cap", "mob-cap", "hostile-cap");
} else {
types = new String[] { "entity-cap", "mob-cap" };
return checkEntity(plot, "entity-cap", "mob-cap");
}
} else if (entity instanceof Vehicle) {
types = new String[] { "entity-cap", "vehicle-cap" };
return checkEntity(plot, "entity-cap", "vehicle-cap");
} else if (entity instanceof Hanging) {
types = new String[] { "entity-cap", "misc-cap" };
} else {
types = new String[] { "entity-cap" };
return checkEntity(plot, "entity-cap", "misc-cap");
}
return checkEntity(plot, types);
return checkEntity(plot, "entity-cap");
}
}
@ -1423,14 +1432,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
final Entity ent = e.getIgnitingEntity();
if (ent != null) {
loc = BukkitUtil.getLocation(ent);
} else {
if (player != null) {
} else if (player != null) {
loc = BukkitUtil.getLocation(player);
} else {
return;
}
}
}
PlotArea area = loc.getPlotArea();
if (area == null) {
return;
@ -1511,8 +1518,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
} else if (lastPlot != null && now.equals(lastPlot)) {
return;
} else {
if (!plotEntry(pp, now) && tmp_teleport) {
} else if (!plotEntry(pp, now) && tmp_teleport) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
tmp_teleport = false;
@ -1529,7 +1535,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
event.setCancelled(true);
return;
}
}
final Integer border = area.getBorder();
if (tmp_teleport) {
if (x2 > border) {
@ -1583,8 +1588,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
} else if (lastPlot != null && now.equals(lastPlot)) {
return;
} else {
if (!plotEntry(pp, now) && tmp_teleport) {
} else if (!plotEntry(pp, now) && tmp_teleport) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
tmp_teleport = false;
@ -1601,7 +1605,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
event.setCancelled(true);
return;
}
}
final Integer border = area.getBorder();
if (tmp_teleport) {
if (z2 > border) {
@ -1638,8 +1641,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
e.setCancelled(true);
} else {
if (!plot.hasOwner()) {
} else if (!plot.hasOwner()) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
return;
}
@ -1657,7 +1659,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
e.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryClick(final InventoryClickEvent event) {

View File

@ -8,7 +8,11 @@ import com.intellectualcrafters.plot.commands.WE_Anywhere;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.*;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.database.Database;
import com.intellectualcrafters.plot.database.MySQL;
import com.intellectualcrafters.plot.database.SQLManager;
import com.intellectualcrafters.plot.database.SQLite;
import com.intellectualcrafters.plot.flag.AbstractFlag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.flag.FlagValue;
@ -16,21 +20,67 @@ import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
import com.intellectualcrafters.plot.object.*;
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.PlotCluster;
import com.intellectualcrafters.plot.object.PlotFilter;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.ChatManager;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.CommentManager;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.InventoryUtil;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.ReflectionUtils;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.SetupUtils;
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.intellectualcrafters.plot.util.area.QuadMap;
import com.plotsquared.listener.WESubscriber;
import com.sk89q.worldedit.WorldEdit;
import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.sql.SQLException;
import java.util.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@ -46,12 +96,7 @@ public class PS {
// protected static:
private static PS instance;
private HashSet<Integer> plotareaHashCheck = new HashSet<>();
private boolean plotareaHasCollision = false;
/**
* All plot areas (quick global access)
*/
private PlotArea[] plotareas = new PlotArea[0];
private final HashSet<Integer> plotareaHashCheck = new HashSet<>();
/**
* All plot areas mapped by world (quick world access)
*/
@ -73,6 +118,11 @@ public class PS {
public TaskManager TASK;
public WorldEdit worldedit;
public URL update;
private boolean plotareaHasCollision = false;
/**
* All plot areas (quick global access)
*/
private PlotArea[] plotareas = new PlotArea[0];
// private:
private File storageFile;
private File FILE = null; // This file
@ -2312,7 +2362,7 @@ public class PS {
*/
private void setupStorage() {
storage.set("version", StringMan.join(VERSION, "."));
final Map<String, Object> options = new HashMap<>();
final Map<String, Object> options = new HashMap<>(9);
options.put("mysql.use", false);
options.put("sqlite.use", true);
options.put("sqlite.db", "storage");
@ -2343,7 +2393,7 @@ public class PS {
*/
private void showDebug() {
if (Settings.DEBUG) {
final Map<String, String> settings = new HashMap<>();
final Map<String, String> settings = new HashMap<>(9);
settings.put("Kill Road Mobs", "" + Settings.KILL_ROAD_MOBS);
settings.put("Use Metrics", "" + Settings.METRICS);
settings.put("Delete Plots On Ban", "" + Settings.DELETE_PLOTS_ON_BAN);

View File

@ -20,8 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
@ -32,8 +30,9 @@ import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "info", aliases = { "i" }, description = "Display plot info", usage = "/plot info <id>",
category = CommandCategory.INFO)
import java.util.UUID;
@CommandDeclaration(command = "info", aliases = "i", description = "Display plot info", usage = "/plot info <id>", category = CommandCategory.INFO)
public class Info extends SubCommand {
@Override
@ -73,7 +72,7 @@ public class Info extends SubCommand {
plot = player.getCurrentPlot();
}
if (plot == null) {
MainUtil.sendMessage(player, C.NOT_IN_PLOT);
MainUtil.sendMessage(player, C.NOT_IN_PLOT.s());
return false;
}
if (arg != null) {
@ -116,8 +115,8 @@ public class Info extends SubCommand {
boolean trustedEveryone;
// Wildcard player {added}
{
containsEveryone = (plot.getTrusted() != null) && plot.getTrusted().contains(DBFunc.everyone);
trustedEveryone = (plot.getMembers() != null) && plot.getMembers().contains(DBFunc.everyone);
containsEveryone = plot.getTrusted().contains(DBFunc.everyone);
trustedEveryone = plot.getMembers().contains(DBFunc.everyone);
}
// Unclaimed?
if (!hasOwner && !containsEveryone && !trustedEveryone) {

View File

@ -41,7 +41,6 @@ import com.plotsquared.general.commands.CommandManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -53,7 +52,6 @@ import java.util.List;
public class MainCommand extends CommandManager<PlotPlayer> {
private static MainCommand instance;
private HashMap<String, Command<PlotPlayer>> setCommands;
private MainCommand() {
super(null, new ArrayList<Command<PlotPlayer>>());
@ -282,8 +280,8 @@ public class MainCommand extends CommandManager<PlotPlayer> {
break;
}
// Save meta
loc = (Location) player.getMeta("location");
plot = (Plot) player.getMeta("lastplot");
loc = player.getMeta("location");
plot = player.getMeta("lastplot");
tp = true;
// Set loc
player.setMeta("location", newPlot.getBottomAbs());
@ -320,7 +318,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
public int getMatch(String[] args, Command<PlotPlayer> cmd) {
int count = 0;
String perm = cmd.getPermission();
HashSet<String> desc = new HashSet<String>();
HashSet<String> desc = new HashSet<>();
for (String alias : cmd.getAliases()) {
if (alias.startsWith(args[0])) {
count += 5;

View File

@ -122,18 +122,10 @@ public class Settings {
* Max allowed plots
*/
public static int MAX_PLOTS = 127;
/**
* WorldGuard region on claimed plots
*/
public static boolean WORLDGUARD = false;
/**
* metrics
*/
public static boolean METRICS = true;
/**
* plot specific resource pack
*/
public static String PLOT_SPECIFIC_RESOURCE_PACK = "";
/**
* Kill road mobs?
*/

View File

@ -25,15 +25,37 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotSettings;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.comment.PlotComment;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import java.sql.*;
import java.util.*;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
@ -1224,9 +1246,6 @@ public class SQLManager implements AbstractDB {
@Override
public void deleteSettings(final Plot plot) {
if (plot.settings == null) {
return;
}
addPlotTask(plot, new UniqueStatement("delete_plot_settings") {
@Override
public void set(final PreparedStatement stmt) throws SQLException {
@ -1669,10 +1688,7 @@ public class SQLManager implements AbstractDB {
}
final Plot plot = plots.get(id);
if (plot != null) {
if (plot.getSettings().ratings == null) {
plot.getSettings().ratings = new HashMap<>();
}
plot.getSettings().ratings.put(user, r.getInt("rating"));
plot.getSettings().getRatings().put(user, r.getInt("rating"));
} else if (Settings.AUTO_PURGE) {
toDelete.add(id);
} else {

View File

@ -115,9 +115,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
end = pathWidthLower + dpw.PLOT_WIDTH;
}
int dx;
int dz;
int rx;
int rz;
if (x < 0) {
dx = (x / size);
rx = size + (x % size);
@ -125,6 +123,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
dx = (x / size) + 1;
rx = (x % size);
}
int dz;
int rz;
if (z < 0) {
dz = (z / size);
rz = size + (z % size);

View File

@ -29,18 +29,34 @@ import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.BO3Handler;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.listener.PlotListener;
import java.awt.*;
import java.awt.Rectangle;
import java.awt.geom.Area;
import java.awt.geom.PathIterator;
import java.io.File;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
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;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
@ -61,11 +77,9 @@ public class Plot {
private static HashSet<Plot> connected_cache;
private static HashSet<RegionWrapper> regions_cache;
/**
* plot ID
* Direct access is Deprecated: use getId()
* The {@link PlotId}
*/
@Deprecated
public final PlotId id;
private final PlotId id;
/**
* plot owner
* (Merged plots can have multiple owners)
@ -73,39 +87,6 @@ public class Plot {
*/
@Deprecated
public UUID owner;
/**
* Plot creation timestamp (not accurate if the plot was created before this was implemented)<br>
* - Milliseconds since the epoch<br>
* Direct access is Deprecated: use {@link #getTimestamp() getTimestamp}
*/
@Deprecated
public long timestamp;
/**
* List of trusted (with plot permissions)
* Direct access is Deprecated: use getTrusted()
*/
@Deprecated
public HashSet<UUID> trusted;
/**
* List of members users (with plot permissions)
* Direct access is Deprecated: use getMembers()
*/
@Deprecated
public HashSet<UUID> members;
/**
* List of denied players
* Direct access is Deprecated: use getDenied()
*/
@Deprecated
public HashSet<UUID> denied;
/**
* External settings class<br>
* - Please favor the methods over direct access to this class<br>
* - The methods are more likely to be left unchanged from version changes<br>
* Direct access is Deprecated: use getSettings()
*/
@Deprecated
public PlotSettings settings;
/**
* Has the plot changed since the last save cycle?
*/
@ -119,8 +100,30 @@ public class Plot {
@Deprecated
public int temp;
/**
* plot world
* Direct access is Deprecated: use getWorld()
* Plot creation timestamp (not accurate if the plot was created before this was implemented)<br>
* - Milliseconds since the epoch<br>
*/
private long timestamp;
/**
* List of trusted (with plot permissions)
*/
private HashSet<UUID> trusted;
/**
* List of members users (with plot permissions)
*/
private HashSet<UUID> members;
/**
* List of denied players
*/
private HashSet<UUID> denied;
/**
* External settings class<br>
* - Please favor the methods over direct access to this class<br>
* - The methods are more likely to be left unchanged from version changes<br>
*/
private PlotSettings settings;
/**
* The {@link PlotArea}
*/
private PlotArea area;
/**
@ -486,10 +489,7 @@ public class Plot {
* @return
*/
public boolean isBasePlot() {
if ((this.settings == null) || !this.isMerged()) {
return true;
}
return this.equals(this.getBasePlot(false));
return !this.isMerged() || this.equals(this.getBasePlot(false));
}
/**
@ -530,10 +530,7 @@ public class Plot {
* @return
*/
public boolean isMerged() {
if (this.settings == null) {
return false;
}
return this.settings.getMerged(0) || this.settings.getMerged(2) || this.settings.getMerged(1) || this.settings.getMerged(3);
return getSettings().getMerged(0) || getSettings().getMerged(2) || getSettings().getMerged(1) || getSettings().getMerged(3);
}
/**
@ -567,20 +564,18 @@ public class Plot {
* @return true if merged in that direction
*/
public boolean getMerged(final int direction) {
if (this.settings == null) {
return false;
}
if (isMerged()) {
switch (direction) {
case 0:
case 1:
case 2:
case 3:
return this.settings.getMerged(direction);
return this.getSettings().getMerged(direction);
case 7:
int i = direction - 4;
int i2 = 0;
if (this.settings.getMerged(i2)) {
if (this.settings.getMerged(i)) {
if (this.getSettings().getMerged(i2)) {
if (this.getSettings().getMerged(i)) {
if (this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2)) {
if (this.area.getPlotAbs(this.id.getRelative(i2)).getMerged(i)) {
return true;
@ -594,13 +589,16 @@ public class Plot {
case 6:
i = direction - 4;
i2 = direction - 3;
return this.settings.getMerged(i2)
&& this.settings.getMerged(i)
return this.getSettings().getMerged(i2)
&& this.getSettings().getMerged(i)
&& this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2)
&& this.area.getPlotAbs(this.id.getRelative(i2)).getMerged(i);
}
return false;
} else {
return false;
}
}
/**
@ -1132,17 +1130,13 @@ public class Plot {
*/
public void setHome(final BlockLoc loc) {
final BlockLoc pos = this.getSettings().getPosition();
if ((((pos == null) || pos.equals(new BlockLoc(0, 0, 0))) && (loc == null)) || ((pos != null) && pos.equals(loc))) {
if (pos.equals(new BlockLoc(0, 0, 0)) && loc == null || pos.equals(loc)) {
return;
}
final Plot plot = this.getBasePlot(false);
plot.getSettings().setPosition(loc);
if (plot.getSettings().getPosition() == null) {
DBFunc.setPosition(plot, "");
} else {
DBFunc.setPosition(plot, this.getSettings().getPosition().toString());
}
}
/**
* Get the default home location for a plot<br>
@ -1240,11 +1234,7 @@ public class Plot {
public boolean hasRatings() {
Plot base = this.getBasePlot(false);
if (base.settings != null && base.settings.ratings != null) {
return true;
} else {
return false;
}
return base.settings != null && base.settings.ratings != null;
}
/**
@ -1368,7 +1358,7 @@ public class Plot {
this.getDenied().clear();
this.settings = new PlotSettings();
if (this.area.addPlot(this)) {
DBFunc.createPlotAndSettings(Plot.this, new Runnable() {
DBFunc.createPlotAndSettings(this, new Runnable() {
@Override
public void run() {
final PlotArea plotworld = Plot.this.area;
@ -1910,10 +1900,7 @@ public class Plot {
* @return boolean [ north, east, south, west ]
*/
public boolean[] getMerged() {
if (this.settings == null) {
return new boolean[] { false, false, false, false };
}
return this.settings.getMerged();
return this.getSettings().getMerged();
}
/**
@ -1948,10 +1935,7 @@ public class Plot {
* @return
*/
public BlockLoc getPosition() {
if (this.settings == null) {
return new BlockLoc(0, 0, 0);
}
return this.settings.getPosition();
return this.getSettings().getPosition();
}
/**
@ -2256,10 +2240,10 @@ public class Plot {
PS.debug("Fixing invalid merge: " + this);
if (tmp.isOwnerAbs(owner)) {
tmp.getSettings().setMerged(2, true);
DBFunc.setMerged(tmp, tmp.settings.getMerged());
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
} else {
this.getSettings().setMerged(0, false);
DBFunc.setMerged(this, this.settings.getMerged());
DBFunc.setMerged(this, this.getSettings().getMerged());
}
}
queuecache.add(tmp);
@ -2272,10 +2256,10 @@ public class Plot {
PS.debug("Fixing invalid merge: " + this);
if (tmp.isOwnerAbs(owner)) {
tmp.getSettings().setMerged(3, true);
DBFunc.setMerged(tmp, tmp.settings.getMerged());
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
} else {
this.getSettings().setMerged(1, false);
DBFunc.setMerged(this, this.settings.getMerged());
DBFunc.setMerged(this, this.getSettings().getMerged());
}
}
queuecache.add(tmp);
@ -2288,10 +2272,10 @@ public class Plot {
PS.debug("Fixing invalid merge: " + this);
if (tmp.isOwnerAbs(owner)) {
tmp.getSettings().setMerged(0, true);
DBFunc.setMerged(tmp, tmp.settings.getMerged());
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
} else {
this.getSettings().setMerged(2, false);
DBFunc.setMerged(this, this.settings.getMerged());
DBFunc.setMerged(this, this.getSettings().getMerged());
}
}
queuecache.add(tmp);
@ -2304,10 +2288,10 @@ public class Plot {
PS.debug("Fixing invalid merge: " + this);
if (tmp.isOwnerAbs(owner)) {
tmp.getSettings().setMerged(1, true);
DBFunc.setMerged(tmp, tmp.settings.getMerged());
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
} else {
this.getSettings().setMerged(3, false);
DBFunc.setMerged(this, this.settings.getMerged());
DBFunc.setMerged(this, this.getSettings().getMerged());
}
}
queuecache.add(tmp);
@ -2324,6 +2308,9 @@ public class Plot {
connected_cache.add(current);
queuecache.remove(current);
merged = current.getMerged();
for (int i = 0; i < 5; i++) {
}
if (merged[0]) {
tmp = current.area.getPlotAbs(current.id.getRelative(0));
if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
@ -2794,7 +2781,7 @@ public class Plot {
for (final Plot plot : plots) {
final Plot other = plot.getRelative(offset.x, offset.y);
other.create(other.owner, false);
if ((plot.getFlags() != null) && !plot.getFlags().isEmpty()) {
if (!plot.getFlags().isEmpty()) {
other.getSettings().flags = plot.getFlags();
DBFunc.setFlags(other, plot.getFlags().values());
}

View File

@ -44,7 +44,7 @@ public class StringMan {
if (obj == null) {
return "null";
}
if (obj.getClass() == String.class) {
if (obj instanceof String) {
return (String) obj;
}
if (obj.getClass().isArray()) {