mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Database correction / Code cleanup, Fixes #490
This commit is contained in:
parent
5ea7403d2e
commit
46e48857bf
@ -417,7 +417,7 @@ public class PS {
|
|||||||
* @return HashMap containing the world name, and another map with the plot id and the plot object
|
* @return HashMap containing the world name, and another map with the plot id and the plot object
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> getAllPlotsRaw() {
|
public Map<String, ConcurrentHashMap<PlotId, Plot>> getAllPlotsRaw() {
|
||||||
return plots;
|
return plots;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -927,7 +927,7 @@ public class PS {
|
|||||||
*/
|
*/
|
||||||
public Set<Plot> getPlots(final String world, final UUID uuid) {
|
public Set<Plot> getPlots(final String world, final UUID uuid) {
|
||||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
final ArrayList<Plot> myplots = new ArrayList<>();
|
||||||
for (final Plot plot : getPlots(world).values()) {
|
for (final Plot plot : getPlotsInWorld(world)) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
if (PlotHandler.isOwner(plot, uuid)) {
|
if (PlotHandler.isOwner(plot, uuid)) {
|
||||||
myplots.add(plot);
|
myplots.add(plot);
|
||||||
@ -979,16 +979,37 @@ public class PS {
|
|||||||
* @return HashMap of PlotId to Plot
|
* @return HashMap of PlotId to Plot
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Map<PlotId, Plot> getPlots(final String world) {
|
public HashMap<PlotId, Plot> getPlots(final String world) {
|
||||||
|
if (plots.containsKey(world)) {
|
||||||
|
return new HashMap<>(lastMap);
|
||||||
|
}
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<Plot> getPlotsInWorld(final String world) {
|
||||||
|
ConcurrentHashMap<PlotId, Plot> map = plots.get(world);
|
||||||
|
if (map == null) {
|
||||||
|
return new HashSet<>();
|
||||||
|
}
|
||||||
|
return map.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Plot getPlot(final String world, final PlotId id) {
|
||||||
if (world == lastWorld) {
|
if (world == lastWorld) {
|
||||||
return lastMap;
|
if (lastMap != null) {
|
||||||
|
return lastMap.get(id);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
lastWorld = world;
|
lastWorld = world;
|
||||||
if (plots.containsKey(world)) {
|
if (plots.containsKey(world)) {
|
||||||
lastMap = plots.get(world);
|
lastMap = plots.get(world);
|
||||||
return lastMap;
|
if (lastMap != null) {
|
||||||
|
return lastMap.get(id);
|
||||||
}
|
}
|
||||||
return new ConcurrentHashMap<>();
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -474,7 +474,7 @@ import com.plotsquared.bukkit.util.BukkitUtil;
|
|||||||
*/
|
*/
|
||||||
public Plot[] getPlots(final World world, final Player plr, final boolean just_owner) {
|
public Plot[] getPlots(final World world, final Player plr, final boolean just_owner) {
|
||||||
final ArrayList<Plot> pPlots = new ArrayList<>();
|
final ArrayList<Plot> pPlots = new ArrayList<>();
|
||||||
for (final Plot plot : PS.get().getPlots(world.getName()).values()) {
|
for (final Plot plot : PS.get().getPlotsInWorld(world.getName())) {
|
||||||
if (just_owner) {
|
if (just_owner) {
|
||||||
if ((plot.owner != null) && (plot.owner.equals(UUIDHandler.getUUID(BukkitUtil.getPlayer(plr))))) {
|
if ((plot.owner != null) && (plot.owner.equals(UUIDHandler.getUUID(BukkitUtil.getPlayer(plr))))) {
|
||||||
pPlots.add(plot);
|
pPlots.add(plot);
|
||||||
@ -499,7 +499,7 @@ import com.plotsquared.bukkit.util.BukkitUtil;
|
|||||||
* @see com.intellectualcrafters.plot.object.Plot
|
* @see com.intellectualcrafters.plot.object.Plot
|
||||||
*/
|
*/
|
||||||
public Plot[] getPlots(final World world) {
|
public Plot[] getPlots(final World world) {
|
||||||
Collection<Plot> plots = PS.get().getPlots(world.getName()).values();
|
Collection<Plot> plots = PS.get().getPlotsInWorld(world.getName());
|
||||||
return plots.toArray(new Plot[plots.size()]);
|
return plots.toArray(new Plot[plots.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ public class Auto extends SubCommand {
|
|||||||
MainUtil.lastPlot.put(worldname, start);
|
MainUtil.lastPlot.put(worldname, start);
|
||||||
if (lastPlot) {
|
if (lastPlot) {
|
||||||
}
|
}
|
||||||
if ((PS.get().getPlots(worldname).get(start) != null) && (PS.get().getPlots(worldname).get(start).owner != null)) {
|
if ((PS.get().getPlot(worldname, start) != null) && (PS.get().getPlot(worldname, start).owner != null)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
lastPlot = false;
|
lastPlot = false;
|
||||||
|
@ -66,7 +66,7 @@ public class Claim extends SubCommand {
|
|||||||
}
|
}
|
||||||
final String world = plot.world;
|
final String world = plot.world;
|
||||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||||
final Plot plot2 = PS.get().getPlots(world).get(plot.id);
|
final Plot plot2 = PS.get().getPlot(world, plot.id);
|
||||||
if (plotworld.SCHEMATIC_ON_CLAIM) {
|
if (plotworld.SCHEMATIC_ON_CLAIM) {
|
||||||
Schematic sch;
|
Schematic sch;
|
||||||
if (schematic.equals("")) {
|
if (schematic.equals("")) {
|
||||||
|
@ -144,7 +144,7 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
ClusterManager.clusters.get(world).add(cluster);
|
ClusterManager.clusters.get(world).add(cluster);
|
||||||
// Add any existing plots to the current cluster
|
// Add any existing plots to the current cluster
|
||||||
for (final Plot plot : PS.get().getPlots(plr.getLocation().getWorld()).values()) {
|
for (final Plot plot : PS.get().getPlotsInWorld(plr.getLocation().getWorld())) {
|
||||||
final PlotCluster current = ClusterManager.getCluster(plot);
|
final PlotCluster current = ClusterManager.getCluster(plot);
|
||||||
if (cluster.equals(current) && !cluster.isAdded(plot.owner)) {
|
if (cluster.equals(current) && !cluster.isAdded(plot.owner)) {
|
||||||
cluster.invited.add(plot.owner);
|
cluster.invited.add(plot.owner);
|
||||||
@ -221,7 +221,7 @@ public class Cluster extends SubCommand {
|
|||||||
final PlotWorld plotworld = PS.get().getPlotWorld(plr.getLocation().getWorld());
|
final PlotWorld plotworld = PS.get().getPlotWorld(plr.getLocation().getWorld());
|
||||||
if (plotworld.TYPE == 2) {
|
if (plotworld.TYPE == 2) {
|
||||||
final ArrayList<Plot> toRemove = new ArrayList<>();
|
final ArrayList<Plot> toRemove = new ArrayList<>();
|
||||||
for (final Plot plot : PS.get().getPlots(plr.getLocation().getWorld()).values()) {
|
for (final Plot plot : PS.get().getPlotsInWorld(plr.getLocation().getWorld())) {
|
||||||
final PlotCluster other = ClusterManager.getCluster(plot);
|
final PlotCluster other = ClusterManager.getCluster(plot);
|
||||||
if (cluster.equals(other)) {
|
if (cluster.equals(other)) {
|
||||||
toRemove.add(plot);
|
toRemove.add(plot);
|
||||||
|
@ -76,7 +76,7 @@ public class Condense extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int radius = Integer.parseInt(args[2]);
|
final int radius = Integer.parseInt(args[2]);
|
||||||
final Collection<Plot> plots = PS.get().getPlots(worldname).values();
|
final Collection<Plot> plots = PS.get().getPlotsInWorld(worldname);
|
||||||
final int size = plots.size();
|
final int size = plots.size();
|
||||||
final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
||||||
if (radius < minimum_radius) {
|
if (radius < minimum_radius) {
|
||||||
@ -165,7 +165,7 @@ public class Condense extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int radius = Integer.parseInt(args[2]);
|
final int radius = Integer.parseInt(args[2]);
|
||||||
final Collection<Plot> plots = PS.get().getPlots(worldname).values();
|
final Collection<Plot> plots = PS.get().getPlotsInWorld(worldname);
|
||||||
final int size = plots.size();
|
final int size = plots.size();
|
||||||
final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
||||||
if (radius < minimum_radius) {
|
if (radius < minimum_radius) {
|
||||||
|
@ -93,8 +93,7 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
final ArrayList<Plot> plots = new ArrayList<>();
|
final ArrayList<Plot> plots = new ArrayList<>();
|
||||||
for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
|
for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
|
||||||
final Plot plot = MainUtil.getPlot(world, id);
|
final Plot plot = MainUtil.getPlot(world, id);
|
||||||
final boolean contains = PS.get().getPlots(world).containsKey(plot.id);
|
if (PS.get().getPlot(world, plot.id) != null) {
|
||||||
if (contains) {
|
|
||||||
MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id);
|
MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,8 @@ import com.intellectualcrafters.plot.util.StringMan;
|
|||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
||||||
|
import com.plotsquared.general.commands.Command;
|
||||||
|
import com.plotsquared.general.commands.CommandCaller;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
@ -86,6 +88,19 @@ public class DebugExec extends SubCommand {
|
|||||||
private ScriptEngine engine;
|
private ScriptEngine engine;
|
||||||
private Bindings scope;
|
private Bindings scope;
|
||||||
|
|
||||||
|
public DebugExec() {
|
||||||
|
File file = new File(PS.get().IMP.getDirectory(), "scripts" + File.separator + "start.js");
|
||||||
|
if (file.exists()) {
|
||||||
|
init();
|
||||||
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
onCommand(ConsolePlayer.getConsole(), new String[] {"runasync", "start.js"});
|
||||||
|
}
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
if (engine != null) {
|
if (engine != null) {
|
||||||
return;
|
return;
|
||||||
@ -350,6 +365,33 @@ public class DebugExec extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringMan.join(allowed_params, "|") + ">");
|
MainUtil.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringMan.join(allowed_params, "|") + ">");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case "addcmd": {
|
||||||
|
try {
|
||||||
|
final String cmd = StringMan.join(Files.readLines(new File(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]), StandardCharsets.UTF_8), System.getProperty("line.separator"));
|
||||||
|
Command<PlotPlayer> subcommand = new Command<PlotPlayer>(args[1].split("\\.")[0]) {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||||
|
try {
|
||||||
|
scope.put("PlotPlayer", plr);
|
||||||
|
scope.put("args", args);
|
||||||
|
engine.eval(cmd, scope);
|
||||||
|
return true;
|
||||||
|
} catch (ScriptException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
MainUtil.sendMessage(player, C.COMMAND_WENT_WRONG);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MainCommand.getInstance().addCommand(subcommand);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot debugexec addcmd <file>");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
case "runasync": {
|
case "runasync": {
|
||||||
async = true;
|
async = true;
|
||||||
}
|
}
|
||||||
@ -379,7 +421,7 @@ public class DebugExec extends SubCommand {
|
|||||||
}
|
}
|
||||||
init();
|
init();
|
||||||
scope.put("PlotPlayer", player);
|
scope.put("PlotPlayer", player);
|
||||||
System.out.print("> " + script);
|
PS.debug("> " + script);
|
||||||
try {
|
try {
|
||||||
if (async) {
|
if (async) {
|
||||||
final String toExec = script;
|
final String toExec = script;
|
||||||
|
@ -60,7 +60,7 @@ public class DebugFixFlags extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---");
|
MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---");
|
||||||
for (final Plot plot : PS.get().getPlots(world).values()) {
|
for (final Plot plot : PS.get().getPlotsInWorld(world)) {
|
||||||
final HashMap<String, Flag> flags = plot.getSettings().flags;
|
final HashMap<String, Flag> flags = plot.getSettings().flags;
|
||||||
Iterator<Entry<String, Flag>> i = flags.entrySet().iterator();
|
Iterator<Entry<String, Flag>> i = flags.entrySet().iterator();
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
@ -156,7 +156,7 @@ public class Merge extends SubCommand {
|
|||||||
HashSet<PlotId> multiPlots = new HashSet<>();
|
HashSet<PlotId> multiPlots = new HashSet<>();
|
||||||
final UUID u1 = plot.owner;
|
final UUID u1 = plot.owner;
|
||||||
for (final PlotId myid : plots) {
|
for (final PlotId myid : plots) {
|
||||||
final Plot myplot = PS.get().getPlots(world).get(myid);
|
final Plot myplot = PS.get().getPlot(world, myid);
|
||||||
if (myplot == null || myplot.owner == null) {
|
if (myplot == null || myplot.owner == null) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
|
MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
|
||||||
return false;
|
return false;
|
||||||
|
@ -46,6 +46,9 @@ public class MusicSubcommand extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||||
|
|
||||||
|
// TODO FIX PLOT MUSIC AS NPE FROM PLAYER.PLAYEFFECT
|
||||||
|
System.out.print("TODO MUSIC");
|
||||||
|
|
||||||
final Location loc = player.getLocation();
|
final Location loc = player.getLocation();
|
||||||
final Plot plot = MainUtil.getPlot(loc);
|
final Plot plot = MainUtil.getPlot(loc);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
|
@ -100,7 +100,7 @@ public class Purge extends SubCommand {
|
|||||||
final PlotId id = getId(arg);
|
final PlotId id = getId(arg);
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
final HashSet<Integer> ids = new HashSet<Integer>();
|
final HashSet<Integer> ids = new HashSet<Integer>();
|
||||||
final int DBid = DBFunc.getId(worldname, id);
|
final int DBid = DBFunc.getId(MainUtil.getPlot(worldname, id));
|
||||||
if (DBid != Integer.MAX_VALUE) {
|
if (DBid != Integer.MAX_VALUE) {
|
||||||
ids.add(DBid);
|
ids.add(DBid);
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ public class Purge extends SubCommand {
|
|||||||
return finishPurge(length);
|
return finishPurge(length);
|
||||||
}
|
}
|
||||||
if (arg.equals("unknown")) {
|
if (arg.equals("unknown")) {
|
||||||
final Collection<Plot> plots = PS.get().getPlots(worldname).values();
|
final Collection<Plot> plots = PS.get().getPlotsInWorld(worldname);
|
||||||
final Set<PlotId> ids = new HashSet<>();
|
final Set<PlotId> ids = new HashSet<>();
|
||||||
for (final Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
if (plot.owner != null) {
|
if (plot.owner != null) {
|
||||||
@ -135,7 +135,7 @@ public class Purge extends SubCommand {
|
|||||||
return finishPurge(length);
|
return finishPurge(length);
|
||||||
}
|
}
|
||||||
if (arg.equals("unowned")) {
|
if (arg.equals("unowned")) {
|
||||||
final Collection<Plot> plots = PS.get().getPlots(worldname).values();
|
final Collection<Plot> plots = PS.get().getPlotsInWorld(worldname);
|
||||||
final Set<PlotId> ids = new HashSet<>();
|
final Set<PlotId> ids = new HashSet<>();
|
||||||
for (final Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
if (plot.owner == null) {
|
if (plot.owner == null) {
|
||||||
|
@ -181,12 +181,11 @@ public class SchematicCmd extends SubCommand {
|
|||||||
MainUtil.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall <world>");
|
MainUtil.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall <world>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Map<PlotId, Plot> plotmap = PS.get().getPlots(args[1]);
|
Collection<Plot> plots = PS.get().getPlotsInWorld(args[1]);
|
||||||
if ((plotmap == null) || (plotmap.size() == 0)) {
|
if ((plots.size() == 0)) {
|
||||||
MainUtil.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall <world>");
|
MainUtil.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall <world>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Collection<Plot> plots = plotmap.values();
|
|
||||||
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -199,7 +198,7 @@ public class SchematicCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while.");
|
MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while.");
|
||||||
MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots...");
|
MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plots.size() + "&7 plots...");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ public class Set extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.ALIAS_TOO_LONG);
|
MainUtil.sendMessage(plr, C.ALIAS_TOO_LONG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (final Plot p : PS.get().getPlots(plr.getLocation().getWorld()).values()) {
|
for (final Plot p : PS.get().getPlotsInWorld(plr.getLocation().getWorld())) {
|
||||||
if (p.getSettings().getAlias().equalsIgnoreCase(alias)) {
|
if (p.getSettings().getAlias().equalsIgnoreCase(alias)) {
|
||||||
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||||
return false;
|
return false;
|
||||||
|
@ -107,7 +107,7 @@ public class SetOwner extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (final PlotId id : plots) {
|
for (final PlotId id : plots) {
|
||||||
Plot current = PS.get().getPlots(world).get(id);
|
Plot current = PS.get().getPlot(world, id);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
current = MainUtil.getPlot(world, id);
|
current = MainUtil.getPlot(world, id);
|
||||||
current.owner = uuid;
|
current.owner = uuid;
|
||||||
|
@ -98,7 +98,7 @@ public class TP extends SubCommand {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (final Plot p : PS.get().getPlots(world).values()) {
|
for (final Plot p : PS.get().getPlotsInWorld(world)) {
|
||||||
if ((p.getSettings().getAlias().length() > 0) && p.getSettings().getAlias().equalsIgnoreCase(a)) {
|
if ((p.getSettings().getAlias().length() > 0) && p.getSettings().getAlias().equalsIgnoreCase(a)) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public class Target extends SubCommand {
|
|||||||
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
||||||
Plot closest = null;
|
Plot closest = null;
|
||||||
int distance = Integer.MAX_VALUE;
|
int distance = Integer.MAX_VALUE;
|
||||||
for (Plot plot : PS.get().getPlots(ploc.getWorld()).values()) {
|
for (Plot plot : PS.get().getPlotsInWorld(ploc.getWorld())) {
|
||||||
double current = plot.getBottom().getEuclideanDistanceSquared(ploc);
|
double current = plot.getBottom().getEuclideanDistanceSquared(ploc);
|
||||||
if (current < distance) {
|
if (current < distance) {
|
||||||
distance = (int) current;
|
distance = (int) current;
|
||||||
|
@ -116,7 +116,7 @@ public class Trim extends SubCommand {
|
|||||||
System.currentTimeMillis();
|
System.currentTimeMillis();
|
||||||
sendMessage("Collecting region data...");
|
sendMessage("Collecting region data...");
|
||||||
final ArrayList<Plot> plots = new ArrayList<>();
|
final ArrayList<Plot> plots = new ArrayList<>();
|
||||||
plots.addAll(PS.get().getPlots(world).values());
|
plots.addAll(PS.get().getPlotsInWorld(world));
|
||||||
final HashSet<ChunkLoc> chunks = new HashSet<>(ChunkManager.manager.getChunkChunks(world));
|
final HashSet<ChunkLoc> chunks = new HashSet<>(ChunkManager.manager.getChunkChunks(world));
|
||||||
sendMessage(" - MCA #: " + chunks.size());
|
sendMessage(" - MCA #: " + chunks.size());
|
||||||
sendMessage(" - CHUNKS: " + (chunks.size() * 1024) + " (max)");
|
sendMessage(" - CHUNKS: " + (chunks.size() * 1024) + " (max)");
|
||||||
|
@ -71,7 +71,7 @@ public class Visit extends SubCommand {
|
|||||||
plots = PS.get().sortPlots(PS.get().getPlots(user), SortType.CREATION_DATE, null);
|
plots = PS.get().sortPlots(PS.get().getPlots(user), SortType.CREATION_DATE, null);
|
||||||
} else if (PS.get().isPlotWorld(args[0])) {
|
} else if (PS.get().isPlotWorld(args[0])) {
|
||||||
// do plots by world
|
// do plots by world
|
||||||
plots = PS.get().sortPlots(PS.get().getPlots(args[0]).values(), SortType.CREATION_DATE, null);
|
plots = PS.get().sortPlots(PS.get().getPlotsInWorld(args[0]), SortType.CREATION_DATE, null);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Plot plot = MainUtil.getPlotFromString(plr, args[0], true);
|
Plot plot = MainUtil.getPlotFromString(plr, args[0], true);
|
||||||
|
@ -163,7 +163,7 @@ public class list extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + world);
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + world);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plots = new ArrayList<>(PS.get().getPlots(world).values());
|
plots = new ArrayList<>(PS.get().getPlotsInWorld(world));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "all": {
|
case "all": {
|
||||||
@ -268,7 +268,7 @@ public class list extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + args[0]);
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plots = new ArrayList<>(PS.get().getPlots(args[0]).values());
|
plots = new ArrayList<>(PS.get().getPlotsInWorld(args[0]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
UUID uuid = UUIDHandler.getUUID(args[0], null);
|
UUID uuid = UUIDHandler.getUUID(args[0], null);
|
||||||
|
@ -104,7 +104,7 @@ public interface AbstractDB {
|
|||||||
*
|
*
|
||||||
* @return Integer = Plot Entry Id
|
* @return Integer = Plot Entry Id
|
||||||
*/
|
*/
|
||||||
int getId(final String world, final PlotId id2);
|
int getId(final Plot plot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the id of a given plot cluster
|
* Get the id of a given plot cluster
|
||||||
|
@ -56,7 +56,7 @@ public class DBFunc {
|
|||||||
public static AbstractDB dbManager;
|
public static AbstractDB dbManager;
|
||||||
|
|
||||||
public static void movePlot(final Plot originalPlot, final Plot newPlot) {
|
public static void movePlot(final Plot originalPlot, final Plot newPlot) {
|
||||||
if (originalPlot.temp != -1 || newPlot.temp != -1) {
|
if (originalPlot.temp == -1 || newPlot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.movePlot(originalPlot, newPlot);
|
dbManager.movePlot(originalPlot, newPlot);
|
||||||
@ -95,7 +95,7 @@ public class DBFunc {
|
|||||||
* @param uuid New Owner
|
* @param uuid New Owner
|
||||||
*/
|
*/
|
||||||
public static void setOwner(final Plot plot, final UUID uuid) {
|
public static void setOwner(final Plot plot, final UUID uuid) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setOwner(plot, uuid);
|
dbManager.setOwner(plot, uuid);
|
||||||
@ -116,7 +116,7 @@ public class DBFunc {
|
|||||||
* @param plot Plot to create
|
* @param plot Plot to create
|
||||||
*/
|
*/
|
||||||
public static void createPlot(final Plot plot) {
|
public static void createPlot(final Plot plot) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.createPlot(plot);
|
dbManager.createPlot(plot);
|
||||||
@ -128,7 +128,7 @@ public class DBFunc {
|
|||||||
* @param plot Plot to create
|
* @param plot Plot to create
|
||||||
*/
|
*/
|
||||||
public static void createPlotAndSettings(final Plot plot) {
|
public static void createPlotAndSettings(final Plot plot) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.createPlotAndSettings(plot);
|
dbManager.createPlotAndSettings(plot);
|
||||||
@ -149,7 +149,7 @@ public class DBFunc {
|
|||||||
* @param plot Plot to delete
|
* @param plot Plot to delete
|
||||||
*/
|
*/
|
||||||
public static void delete(final Plot plot) {
|
public static void delete(final Plot plot) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.delete(plot);
|
dbManager.delete(plot);
|
||||||
@ -166,7 +166,7 @@ public class DBFunc {
|
|||||||
* @param plot Plot Object
|
* @param plot Plot Object
|
||||||
*/
|
*/
|
||||||
public static void createPlotSettings(final int id, final Plot plot) {
|
public static void createPlotSettings(final int id, final Plot plot) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.createPlotSettings(id, plot);
|
dbManager.createPlotSettings(id, plot);
|
||||||
@ -190,8 +190,8 @@ public class DBFunc {
|
|||||||
* catch(SQLException e) { e.printStackTrace(); } return Integer.MAX_VALUE;
|
* catch(SQLException e) { e.printStackTrace(); } return Integer.MAX_VALUE;
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public static int getId(final String world, final PlotId id2) {
|
public static int getId(final Plot plot) {
|
||||||
return dbManager.getId(world, id2);
|
return dbManager.getId(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,14 +202,14 @@ public class DBFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setMerged(final Plot plot, final boolean[] merged) {
|
public static void setMerged(final Plot plot, final boolean[] merged) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setMerged(plot, merged);
|
dbManager.setMerged(plot, merged);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFlags(final Plot plot, final Collection<Flag> flags) {
|
public static void setFlags(final Plot plot, final Collection<Flag> flags) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setFlags(plot, flags);
|
dbManager.setFlags(plot, flags);
|
||||||
@ -224,7 +224,7 @@ public class DBFunc {
|
|||||||
* @param alias
|
* @param alias
|
||||||
*/
|
*/
|
||||||
public static void setAlias(final Plot plot, final String alias) {
|
public static void setAlias(final Plot plot, final String alias) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setAlias(plot, alias);
|
dbManager.setAlias(plot, alias);
|
||||||
@ -243,7 +243,7 @@ public class DBFunc {
|
|||||||
* @param position
|
* @param position
|
||||||
*/
|
*/
|
||||||
public static void setPosition(final Plot plot, final String position) {
|
public static void setPosition(final Plot plot, final String position) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setPosition(plot, position);
|
dbManager.setPosition(plot, position);
|
||||||
@ -263,14 +263,14 @@ public class DBFunc {
|
|||||||
* @param comment
|
* @param comment
|
||||||
*/
|
*/
|
||||||
public static void removeComment(final Plot plot, final PlotComment comment) {
|
public static void removeComment(final Plot plot, final PlotComment comment) {
|
||||||
if (plot != null && plot.temp != -1) {
|
if (plot != null && plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.removeComment(plot, comment);
|
dbManager.removeComment(plot, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearInbox(final Plot plot, final String inbox) {
|
public static void clearInbox(final Plot plot, final String inbox) {
|
||||||
if (plot != null && plot.temp != -1) {
|
if (plot != null && plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.clearInbox(plot, inbox);
|
dbManager.clearInbox(plot, inbox);
|
||||||
@ -281,7 +281,7 @@ public class DBFunc {
|
|||||||
* @param comment
|
* @param comment
|
||||||
*/
|
*/
|
||||||
public static void setComment(final Plot plot, final PlotComment comment) {
|
public static void setComment(final Plot plot, final PlotComment comment) {
|
||||||
if (plot != null && plot.temp != -1) {
|
if (plot != null && plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setComment(plot, comment);
|
dbManager.setComment(plot, comment);
|
||||||
@ -291,7 +291,7 @@ public class DBFunc {
|
|||||||
* @param plot
|
* @param plot
|
||||||
*/
|
*/
|
||||||
public static void getComments(final Plot plot, final String inbox, RunnableVal whenDone) {
|
public static void getComments(final Plot plot, final String inbox, RunnableVal whenDone) {
|
||||||
if (plot != null && plot.temp != -1) {
|
if (plot != null && plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.getComments(plot, inbox, whenDone);
|
dbManager.getComments(plot, inbox, whenDone);
|
||||||
@ -302,7 +302,7 @@ public class DBFunc {
|
|||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void removeTrusted(final Plot plot, final UUID uuid) {
|
public static void removeTrusted(final Plot plot, final UUID uuid) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.removeTrusted(plot, uuid);
|
dbManager.removeTrusted(plot, uuid);
|
||||||
@ -337,7 +337,7 @@ public class DBFunc {
|
|||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void removeMember(final Plot plot, final UUID uuid) {
|
public static void removeMember(final Plot plot, final UUID uuid) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.removeMember(plot, uuid);
|
dbManager.removeMember(plot, uuid);
|
||||||
@ -358,7 +358,7 @@ public class DBFunc {
|
|||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void setTrusted(final Plot plot, final UUID uuid) {
|
public static void setTrusted(final Plot plot, final UUID uuid) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setTrusted(plot, uuid);
|
dbManager.setTrusted(plot, uuid);
|
||||||
@ -374,7 +374,7 @@ public class DBFunc {
|
|||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void setMember(final Plot plot, final UUID uuid) {
|
public static void setMember(final Plot plot, final UUID uuid) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setMember(plot, uuid);
|
dbManager.setMember(plot, uuid);
|
||||||
@ -390,7 +390,7 @@ public class DBFunc {
|
|||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void removeDenied(final Plot plot, final UUID uuid) {
|
public static void removeDenied(final Plot plot, final UUID uuid) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.removeDenied(plot, uuid);
|
dbManager.removeDenied(plot, uuid);
|
||||||
@ -402,21 +402,21 @@ public class DBFunc {
|
|||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void setDenied(final Plot plot, final UUID uuid) {
|
public static void setDenied(final Plot plot, final UUID uuid) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setDenied(plot, uuid);
|
dbManager.setDenied(plot, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<UUID, Integer> getRatings(final Plot plot) {
|
public static HashMap<UUID, Integer> getRatings(final Plot plot) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
return dbManager.getRatings(plot);
|
return dbManager.getRatings(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setRating(Plot plot, UUID rater, int value) {
|
public static void setRating(Plot plot, UUID rater, int value) {
|
||||||
if (plot.temp != -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setRating(plot, rater, value);
|
dbManager.setRating(plot, rater, value);
|
||||||
|
@ -34,6 +34,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -51,6 +52,7 @@ import com.intellectualcrafters.plot.object.PlotSettings;
|
|||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
|
||||||
@ -672,7 +674,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
final int id = getId(plot.world, plot.id);
|
final int id = getId(plot);
|
||||||
stmt = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(" + "?)");
|
stmt = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(" + "?)");
|
||||||
stmt.setInt(1, id);
|
stmt.setInt(1, id);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
@ -760,7 +762,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
final int id = getId(plot.world, plot.id);
|
final int id = getId(plot);
|
||||||
try {
|
try {
|
||||||
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_settings` WHERE `plot_plot_id` = ?");
|
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_settings` WHERE `plot_plot_id` = ?");
|
||||||
stmt.setInt(1, id);
|
stmt.setInt(1, id);
|
||||||
@ -819,13 +821,16 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(final String world, final PlotId id2) {
|
public int getId(Plot plot) {
|
||||||
|
if (plot.temp > 0) {
|
||||||
|
return plot.temp;
|
||||||
|
}
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
stmt = this.connection.prepareStatement("SELECT `id` FROM `" + this.prefix + "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC");
|
stmt = this.connection.prepareStatement("SELECT `id` FROM `" + this.prefix + "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC");
|
||||||
stmt.setInt(1, id2.x);
|
stmt.setInt(1, plot.id.x);
|
||||||
stmt.setInt(2, id2.y);
|
stmt.setInt(2, plot.id.y);
|
||||||
stmt.setString(3, world);
|
stmt.setString(3, plot.world);
|
||||||
final ResultSet r = stmt.executeQuery();
|
final ResultSet r = stmt.executeQuery();
|
||||||
int id = Integer.MAX_VALUE;
|
int id = Integer.MAX_VALUE;
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
@ -833,6 +838,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
r.close();
|
r.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
plot.temp = id;
|
||||||
return id;
|
return id;
|
||||||
} catch (final SQLException e) {
|
} catch (final SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -1160,7 +1166,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `merged` = ? WHERE `plot_plot_id` = ?");
|
final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `merged` = ? WHERE `plot_plot_id` = ?");
|
||||||
stmt.setInt(1, n);
|
stmt.setInt(1, n);
|
||||||
stmt.setInt(2, getId(plot.world, plot.id));
|
stmt.setInt(2, getId(plot));
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (final SQLException e) {
|
} catch (final SQLException e) {
|
||||||
@ -1183,8 +1189,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
final String world = p1.world;
|
final String world = p1.world;
|
||||||
final int id1 = getId(world, p1.id);
|
final int id1 = getId(p1);
|
||||||
final int id2 = getId(world, p2.id);
|
final int id2 = getId(p2);
|
||||||
final PlotId pos1 = p1.getId();
|
final PlotId pos1 = p1.getId();
|
||||||
final PlotId pos2 = p2.getId();
|
final PlotId pos2 = p2.getId();
|
||||||
PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
|
PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
|
||||||
@ -1212,7 +1218,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
final int id = getId(original.world, original.id);
|
final int id = getId(original);
|
||||||
final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
|
final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
|
||||||
stmt.setInt(1, newPlot.id.x);
|
stmt.setInt(1, newPlot.id.x);
|
||||||
stmt.setInt(2, newPlot.id.y);
|
stmt.setInt(2, newPlot.id.y);
|
||||||
@ -1243,7 +1249,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?");
|
final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?");
|
||||||
stmt.setString(1, flag_string.toString());
|
stmt.setString(1, flag_string.toString());
|
||||||
stmt.setInt(2, getId(plot.world, plot.id));
|
stmt.setInt(2, getId(plot));
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (final SQLException e) {
|
} catch (final SQLException e) {
|
||||||
@ -1282,7 +1288,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `alias` = ? WHERE `plot_plot_id` = ?");
|
stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `alias` = ? WHERE `plot_plot_id` = ?");
|
||||||
stmt.setString(1, alias);
|
stmt.setString(1, alias);
|
||||||
stmt.setInt(2, getId(plot.world, plot.id));
|
stmt.setInt(2, getId(plot));
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (final SQLException e) {
|
} catch (final SQLException e) {
|
||||||
@ -1375,7 +1381,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `position` = ? WHERE `plot_plot_id` = ?");
|
stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `position` = ? WHERE `plot_plot_id` = ?");
|
||||||
stmt.setString(1, position);
|
stmt.setString(1, position);
|
||||||
stmt.setInt(2, getId(plot.world, plot.id));
|
stmt.setInt(2, getId(plot));
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (final SQLException e) {
|
} catch (final SQLException e) {
|
||||||
@ -1566,7 +1572,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
||||||
statement.setInt(1, getId(plot.world, plot.id));
|
statement.setInt(1, getId(plot));
|
||||||
statement.setString(2, uuid.toString());
|
statement.setString(2, uuid.toString());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
statement.close();
|
statement.close();
|
||||||
@ -1585,7 +1591,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_trusted` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_trusted` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
||||||
statement.setInt(1, getId(plot.world, plot.id));
|
statement.setInt(1, getId(plot));
|
||||||
statement.setString(2, uuid.toString());
|
statement.setString(2, uuid.toString());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
statement.close();
|
statement.close();
|
||||||
@ -1604,7 +1610,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
||||||
statement.setInt(1, getId(plot.world, plot.id));
|
statement.setInt(1, getId(plot));
|
||||||
statement.setString(2, uuid.toString());
|
statement.setString(2, uuid.toString());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
statement.close();
|
statement.close();
|
||||||
@ -1641,7 +1647,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_trusted` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_trusted` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
||||||
statement.setInt(1, getId(plot.world, plot.id));
|
statement.setInt(1, getId(plot));
|
||||||
statement.setString(2, uuid.toString());
|
statement.setString(2, uuid.toString());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
statement.close();
|
statement.close();
|
||||||
@ -1660,7 +1666,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
||||||
statement.setInt(1, getId(plot.world, plot.id));
|
statement.setInt(1, getId(plot));
|
||||||
statement.setString(2, uuid.toString());
|
statement.setString(2, uuid.toString());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
statement.close();
|
statement.close();
|
||||||
@ -1679,7 +1685,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
||||||
statement.setInt(1, getId(plot.world, plot.id));
|
statement.setInt(1, getId(plot));
|
||||||
statement.setString(2, uuid.toString());
|
statement.setString(2, uuid.toString());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
statement.close();
|
statement.close();
|
||||||
@ -1696,7 +1702,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
HashMap<UUID, Integer> map = new HashMap<UUID, Integer>();
|
HashMap<UUID, Integer> map = new HashMap<UUID, Integer>();
|
||||||
try {
|
try {
|
||||||
final PreparedStatement statement = this.connection.prepareStatement("SELECT `rating`, `player` FROM `" + this.prefix + "plot_rating` WHERE `plot_plot_id` = ? ");
|
final PreparedStatement statement = this.connection.prepareStatement("SELECT `rating`, `player` FROM `" + this.prefix + "plot_rating` WHERE `plot_plot_id` = ? ");
|
||||||
statement.setInt(1, getId(plot.world, plot.id));
|
statement.setInt(1, getId(plot));
|
||||||
final ResultSet set = statement.executeQuery();
|
final ResultSet set = statement.executeQuery();
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
UUID uuid = UUID.fromString(set.getString("player"));
|
UUID uuid = UUID.fromString(set.getString("player"));
|
||||||
@ -1719,7 +1725,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_rating` (`plot_plot_id`, `rating`, `player`) VALUES(?,?,?)");
|
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_rating` (`plot_plot_id`, `rating`, `player`) VALUES(?,?,?)");
|
||||||
statement.setInt(1, getId(plot.world, plot.id));
|
statement.setInt(1, getId(plot));
|
||||||
statement.setInt(2, value);
|
statement.setInt(2, value);
|
||||||
statement.setString(3, rater.toString());
|
statement.setString(3, rater.toString());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
@ -2267,46 +2273,127 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validateAllPlots(Set<Plot> toValidate) {
|
public void validateAllPlots(Set<Plot> toValidate) {
|
||||||
// ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> database = getPlots();
|
PS.debug("$1All DB transactions during this session are being validated (This may take a while if corrections need to be made)");
|
||||||
//
|
try {
|
||||||
// ArrayList<Plot> toCreate = new ArrayList<>();
|
connection.commit();
|
||||||
// ArrayList<UUID> toTrust1 = new ArrayList<>();
|
connection.setAutoCommit(false);
|
||||||
// ArrayList<Plot> toTrust2 = new ArrayList<>();
|
}
|
||||||
//
|
catch (SQLException e) {}
|
||||||
// for (Plot plot : plots) {
|
ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> database = getPlots();
|
||||||
// if (plot.temp) {
|
|
||||||
// continue;
|
ArrayList<Plot> toCreate = new ArrayList<>();
|
||||||
// }
|
ArrayList<UUID> toTrusted = new ArrayList<>();
|
||||||
// ConcurrentHashMap<PlotId, Plot> worldplots = database.get(plot.world);
|
ArrayList<Plot> toMember = new ArrayList<>();
|
||||||
// if (worldplots == null) {
|
ArrayList<Plot> toDenied = new ArrayList<>();
|
||||||
// toCreate.add(plot);
|
|
||||||
// continue;
|
for (Plot plot : PS.get().getPlotsRaw()) {
|
||||||
// }
|
if (plot.temp == -1) {
|
||||||
// Plot dataplot = worldplots.get(plot.id);
|
continue;
|
||||||
// if (dataplot == null) {
|
}
|
||||||
// toCreate.add(plot);
|
ConcurrentHashMap<PlotId, Plot> worldplots = database.get(plot.world);
|
||||||
// continue;
|
if (worldplots == null) {
|
||||||
// }
|
PS.debug("&8 - &7Creating plot (1): " + plot);
|
||||||
// // owner
|
toCreate.add(plot);
|
||||||
// if (!plot.owner.equals(dataplot)) {
|
continue;
|
||||||
// toSet.add(plot);
|
}
|
||||||
// continue;
|
Plot dataplot = worldplots.remove(plot.id);
|
||||||
// }
|
if (dataplot == null) {
|
||||||
// plot.
|
PS.debug("&8 - &7Creating plot (2): " + plot);
|
||||||
// // trusted
|
toCreate.add(plot);
|
||||||
// if (!plot.getTrusted().equals(dataplot.trusted)) {
|
continue;
|
||||||
// toSet.add(plot);
|
}
|
||||||
// continue;
|
// owner
|
||||||
// }
|
if (!plot.owner.equals(dataplot.owner)) {
|
||||||
// if (!plot.getMembers().equals(dataplot.members)) {
|
PS.debug("&8 - &7Setting owner: " + plot +" -> " + MainUtil.getName(plot.owner));
|
||||||
// toSet.add(plot);
|
setOwner(plot, plot.owner);
|
||||||
// continue;
|
}
|
||||||
// }
|
// trusted
|
||||||
// if (!plot.getDenied().equals(dataplot.denied)) {
|
if (!plot.getTrusted().equals(dataplot.trusted)) {
|
||||||
// toSet.add(plot);
|
HashSet<UUID> toAdd = (HashSet<UUID>) plot.getTrusted().clone();
|
||||||
// continue;
|
HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getTrusted().clone();
|
||||||
// }
|
toRemove.removeAll(plot.getTrusted());
|
||||||
// ssettings = plot.getSettings();
|
toAdd.removeAll(dataplot.getTrusted());
|
||||||
// }
|
PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " trusted for: " + plot);
|
||||||
|
if (toRemove.size() > 0) {
|
||||||
|
for (UUID uuid : toRemove) {
|
||||||
|
removeTrusted(plot, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (toAdd.size() > 0) {
|
||||||
|
for (UUID uuid : toAdd) {
|
||||||
|
setTrusted(plot, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!plot.getMembers().equals(dataplot.members)) {
|
||||||
|
HashSet<UUID> toAdd = (HashSet<UUID>) plot.getMembers().clone();
|
||||||
|
HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getMembers().clone();
|
||||||
|
toRemove.removeAll(plot.getMembers());
|
||||||
|
toAdd.removeAll(dataplot.getMembers());
|
||||||
|
PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " members for: " + plot);
|
||||||
|
if (toRemove.size() > 0) {
|
||||||
|
for (UUID uuid : toRemove) {
|
||||||
|
removeMember(plot, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (toAdd.size() > 0) {
|
||||||
|
for (UUID uuid : toAdd) {
|
||||||
|
setMember(plot, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!plot.getDenied().equals(dataplot.denied)) {
|
||||||
|
HashSet<UUID> toAdd = (HashSet<UUID>) plot.getDenied().clone();
|
||||||
|
HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getDenied().clone();
|
||||||
|
toRemove.removeAll(plot.getDenied());
|
||||||
|
toAdd.removeAll(dataplot.getDenied());
|
||||||
|
PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " denied for: " + plot);
|
||||||
|
if (toRemove.size() > 0) {
|
||||||
|
for (UUID uuid : toRemove) {
|
||||||
|
removeDenied(plot, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (toAdd.size() > 0) {
|
||||||
|
for (UUID uuid : toAdd) {
|
||||||
|
setDenied(plot, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlotSettings ps = plot.getSettings();
|
||||||
|
PlotSettings ds = dataplot.getSettings();
|
||||||
|
boolean[] pm = ps.getMerged();
|
||||||
|
boolean[] dm = ds.getMerged();
|
||||||
|
if (pm[0] != dm[0] || pm[1] != dm[1] || pm[1] != dm[1] || pm[1] != dm[1]) {
|
||||||
|
PS.debug("&8 - &7Correcting merge for: " + plot);
|
||||||
|
setMerged(dataplot, ps.getMerged());
|
||||||
|
}
|
||||||
|
HashMap<String, Flag> pf = ps.flags;
|
||||||
|
HashMap<String, Flag> df = ds.flags;
|
||||||
|
if (pf.size() != 0 && df.size() != 0) {
|
||||||
|
if (pf.size() != df.size() || !StringMan.isEqual(StringMan.joinOrdered(pf.values(), ","),StringMan.joinOrdered(df.values(), ","))) {
|
||||||
|
PS.debug("&8 - &7Correcting flags for: " + plot);
|
||||||
|
setFlags(plot, pf.values());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO comments
|
||||||
|
// TODO ratings
|
||||||
|
// TODO alias
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : database.entrySet()) {
|
||||||
|
ConcurrentHashMap<PlotId, Plot> map = entry.getValue();
|
||||||
|
if (map.size() > 0) {
|
||||||
|
for (Entry<PlotId, Plot> entry2 : map.entrySet()) {
|
||||||
|
PS.debug("$1Plot was deleted: " + entry.getValue() + "// TODO implement this when sure safe");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PS.debug("$4Done!");
|
||||||
|
try {
|
||||||
|
connection.commit();
|
||||||
|
connection.setAutoCommit(true);
|
||||||
|
}
|
||||||
|
catch (SQLException e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
// This means you are in the intersection
|
// This means you are in the intersection
|
||||||
final Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, 0, z + dpw.ROAD_WIDTH);
|
final Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, 0, z + dpw.ROAD_WIDTH);
|
||||||
final PlotId id = MainUtil.getPlotAbs(loc);
|
final PlotId id = MainUtil.getPlotAbs(loc);
|
||||||
final Plot plot = PS.get().getPlots(plotworld.worldname).get(id);
|
final Plot plot = PS.get().getPlot(plotworld.worldname, id);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
// You are on a road running West to East (yeah, I named the var poorly)
|
// You are on a road running West to East (yeah, I named the var poorly)
|
||||||
final Location loc = new Location(plotworld.worldname, x, 0, z + dpw.ROAD_WIDTH);
|
final Location loc = new Location(plotworld.worldname, x, 0, z + dpw.ROAD_WIDTH);
|
||||||
final PlotId id = MainUtil.getPlotAbs(loc);
|
final PlotId id = MainUtil.getPlotAbs(loc);
|
||||||
final Plot plot = PS.get().getPlots(plotworld.worldname).get(id);
|
final Plot plot = PS.get().getPlot(plotworld.worldname, id);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
// This is the road separating an Eastern and Western plot
|
// This is the road separating an Eastern and Western plot
|
||||||
final Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, 0, z);
|
final Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, 0, z);
|
||||||
final PlotId id = MainUtil.getPlotAbs(loc);
|
final PlotId id = MainUtil.getPlotAbs(loc);
|
||||||
final Plot plot = PS.get().getPlots(plotworld.worldname).get(id);
|
final Plot plot = PS.get().getPlot(plotworld.worldname, id);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final PlotId id = new PlotId(dx, dz);
|
final PlotId id = new PlotId(dx, dz);
|
||||||
final Plot plot = PS.get().getPlots(plotworld.worldname).get(id);
|
final Plot plot = PS.get().getPlot(plotworld.worldname, id);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ public class ExpireManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<Plot> getOldPlots(final String world) {
|
public static List<Plot> getOldPlots(final String world) {
|
||||||
final ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlots(world).values());
|
final ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlotsInWorld(world));
|
||||||
final List<Plot> toRemove = new ArrayList<>();
|
final List<Plot> toRemove = new ArrayList<>();
|
||||||
Iterator<Plot> iter = plots.iterator();
|
Iterator<Plot> iter = plots.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
|
@ -27,6 +27,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
@ -240,7 +241,7 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
worldname = PS.get().getPlotWorlds().iterator().next();
|
worldname = PS.get().getPlotWorlds().iterator().next();
|
||||||
}
|
}
|
||||||
for (Plot p : PS.get().getPlots(worldname).values()) {
|
for (Plot p : PS.get().getPlotsInWorld(worldname)) {
|
||||||
String name = p.getSettings().getAlias();
|
String name = p.getSettings().getAlias();
|
||||||
if (name.length() != 0 && name.equalsIgnoreCase(arg)) {
|
if (name.length() != 0 && name.equalsIgnoreCase(arg)) {
|
||||||
return p;
|
return p;
|
||||||
@ -248,7 +249,7 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
for (String world : PS.get().getPlotWorlds()) {
|
for (String world : PS.get().getPlotWorlds()) {
|
||||||
if (!world.endsWith(worldname)) {
|
if (!world.endsWith(worldname)) {
|
||||||
for (Plot p : PS.get().getPlots(world).values()) {
|
for (Plot p : PS.get().getPlotsInWorld(world)) {
|
||||||
String name = p.getSettings().getAlias();
|
String name = p.getSettings().getAlias();
|
||||||
if (name.length() != 0 && name.equalsIgnoreCase(arg)) {
|
if (name.length() != 0 && name.equalsIgnoreCase(arg)) {
|
||||||
return p;
|
return p;
|
||||||
@ -305,7 +306,7 @@ public class MainUtil {
|
|||||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||||
manager.startPlotUnlink(plotworld, ids);
|
manager.startPlotUnlink(plotworld, ids);
|
||||||
for (final PlotId id : ids) {
|
for (final PlotId id : ids) {
|
||||||
final Plot myplot = PS.get().getPlots(world).get(id);
|
final Plot myplot = PS.get().getPlot(world, id);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -395,8 +396,8 @@ public class MainUtil {
|
|||||||
|
|
||||||
public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
|
public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
|
||||||
|
|
||||||
final Plot plot1 = PS.get().getPlots(world).get(pos1);
|
final Plot plot1 = PS.get().getPlot(world, pos1);
|
||||||
final Plot plot2 = PS.get().getPlots(world).get(pos2);
|
final Plot plot2 = PS.get().getPlot(world, pos2);
|
||||||
|
|
||||||
if (plot1 != null) {
|
if (plot1 != null) {
|
||||||
pos1 = getBottomPlot(plot1).id;
|
pos1 = getBottomPlot(plot1).id;
|
||||||
@ -435,7 +436,7 @@ public class MainUtil {
|
|||||||
public static int getPlayerPlotCount(final String world, final PlotPlayer plr) {
|
public static int getPlayerPlotCount(final String world, final PlotPlayer plr) {
|
||||||
final UUID uuid = plr.getUUID();
|
final UUID uuid = plr.getUUID();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (final Plot plot : PS.get().getPlots(world).values()) {
|
for (final Plot plot : PS.get().getPlotsInWorld(world)) {
|
||||||
if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) {
|
if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
@ -536,7 +537,7 @@ public class MainUtil {
|
|||||||
if (!worldBorder.containsKey(world)) {
|
if (!worldBorder.containsKey(world)) {
|
||||||
worldBorder.put(world, 0);
|
worldBorder.put(world, 0);
|
||||||
}
|
}
|
||||||
for (final Plot plot : PS.get().getPlots(world).values()) {
|
for (final Plot plot : PS.get().getPlotsInWorld(world)) {
|
||||||
updateWorldBorder(plot);
|
updateWorldBorder(plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -641,7 +642,7 @@ public class MainUtil {
|
|||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||||
final PlotId id = new PlotId(x, y);
|
final PlotId id = new PlotId(x, y);
|
||||||
final Plot plot = PS.get().getPlots(world).get(id);
|
final Plot plot = PS.get().getPlot(world, id);
|
||||||
if (removeRoads) {
|
if (removeRoads) {
|
||||||
removeSign(plot);
|
removeSign(plot);
|
||||||
}
|
}
|
||||||
@ -652,7 +653,7 @@ public class MainUtil {
|
|||||||
final boolean lx = x < pos2.x;
|
final boolean lx = x < pos2.x;
|
||||||
final boolean ly = y < pos2.y;
|
final boolean ly = y < pos2.y;
|
||||||
final PlotId id = new PlotId(x, y);
|
final PlotId id = new PlotId(x, y);
|
||||||
final Plot plot = PS.get().getPlots(world).get(id);
|
final Plot plot = PS.get().getPlot(world, id);
|
||||||
Plot plot2 = null;
|
Plot plot2 = null;
|
||||||
if (lx) {
|
if (lx) {
|
||||||
if (ly) {
|
if (ly) {
|
||||||
@ -663,7 +664,7 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.getSettings().getMerged(1)) {
|
if (!plot.getSettings().getMerged(1)) {
|
||||||
plot2 = PS.get().getPlots(world).get(new PlotId(x + 1, y));
|
plot2 = PS.get().getPlot(world, new PlotId(x + 1, y));
|
||||||
mergePlot(world, plot, plot2, removeRoads);
|
mergePlot(world, plot, plot2, removeRoads);
|
||||||
plot.getSettings().setMerged(1, true);
|
plot.getSettings().setMerged(1, true);
|
||||||
plot2.getSettings().setMerged(3, true);
|
plot2.getSettings().setMerged(3, true);
|
||||||
@ -671,7 +672,7 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
if (ly) {
|
if (ly) {
|
||||||
if (!plot.getSettings().getMerged(2)) {
|
if (!plot.getSettings().getMerged(2)) {
|
||||||
plot2 = PS.get().getPlots(world).get(new PlotId(x, y + 1));
|
plot2 = PS.get().getPlot(world, new PlotId(x, y + 1));
|
||||||
mergePlot(world, plot, plot2, removeRoads);
|
mergePlot(world, plot, plot2, removeRoads);
|
||||||
plot.getSettings().setMerged(2, true);
|
plot.getSettings().setMerged(2, true);
|
||||||
plot2.getSettings().setMerged(0, true);
|
plot2.getSettings().setMerged(0, true);
|
||||||
@ -684,7 +685,7 @@ public class MainUtil {
|
|||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||||
final PlotId id = new PlotId(x, y);
|
final PlotId id = new PlotId(x, y);
|
||||||
final Plot plot = PS.get().getPlots(world).get(id);
|
final Plot plot = PS.get().getPlot(world, id);
|
||||||
DBFunc.setMerged(plot, plot.getSettings().getMerged());
|
DBFunc.setMerged(plot, plot.getSettings().getMerged());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -901,7 +902,7 @@ public class MainUtil {
|
|||||||
final PlotId id_min = plots.get(0);
|
final PlotId id_min = plots.get(0);
|
||||||
final PlotId id_max = plots.get(plots.size() - 1);
|
final PlotId id_max = plots.get(plots.size() - 1);
|
||||||
for (final PlotId myid : plots) {
|
for (final PlotId myid : plots) {
|
||||||
final Plot myplot = PS.get().getPlots(world).get(myid);
|
final Plot myplot = PS.get().getPlot(world, myid);
|
||||||
if ((myplot == null) || myplot.owner == null || !(myplot.owner.equals(uuid))) {
|
if ((myplot == null) || myplot.owner == null || !(myplot.owner.equals(uuid))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -958,8 +959,7 @@ public class MainUtil {
|
|||||||
*/
|
*/
|
||||||
public static Plot createPlotAbs(final UUID uuid, final Plot plot) {
|
public static Plot createPlotAbs(final UUID uuid, final Plot plot) {
|
||||||
final String w = plot.world;
|
final String w = plot.world;
|
||||||
Map<PlotId, Plot> plots = PS.get().getPlots(plot.world);
|
Plot p = PS.get().getPlot(plot.world, plot.id);
|
||||||
Plot p = plots.get(plot.id);
|
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -1250,7 +1250,7 @@ public class MainUtil {
|
|||||||
* @return Location top of mega plot
|
* @return Location top of mega plot
|
||||||
*/
|
*/
|
||||||
public static Location getPlotTopLoc(final String world, PlotId id) {
|
public static Location getPlotTopLoc(final String world, PlotId id) {
|
||||||
final Plot plot = PS.get().getPlots(world).get(id);
|
final Plot plot = PS.get().getPlot(world, id);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
id = getTopPlot(plot).id;
|
id = getTopPlot(plot).id;
|
||||||
}
|
}
|
||||||
@ -1269,7 +1269,7 @@ public class MainUtil {
|
|||||||
* @return Location bottom of mega plot
|
* @return Location bottom of mega plot
|
||||||
*/
|
*/
|
||||||
public static Location getPlotBottomLoc(final String world, PlotId id) {
|
public static Location getPlotBottomLoc(final String world, PlotId id) {
|
||||||
final Plot plot = PS.get().getPlots(world).get(id);
|
final Plot plot = PS.get().getPlot(world, id);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
id = getBottomPlot(plot).id;
|
id = getBottomPlot(plot).id;
|
||||||
}
|
}
|
||||||
@ -1310,8 +1310,8 @@ public class MainUtil {
|
|||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||||
final PlotId id = new PlotId(x, y);
|
final PlotId id = new PlotId(x, y);
|
||||||
if (PS.get().getPlots(world).get(id) != null) {
|
if (PS.get().getPlot(world, id) != null) {
|
||||||
if (PS.get().getPlots(world).get(id).owner != null) {
|
if (PS.get().getPlot(world, id).owner != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1321,8 +1321,8 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean swap(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
public static boolean swap(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
||||||
Plot p1 = PS.get().getPlots(world).get(current);
|
Plot p1 = PS.get().getPlot(world, current);
|
||||||
Plot p2 = PS.get().getPlots(world).get(newPlot);
|
Plot p2 = PS.get().getPlot(world, newPlot);
|
||||||
if (p1==null || p2 == null || p1.owner == null || !p1.owner.equals(p2.owner)) {
|
if (p1==null || p2 == null || p1.owner == null || !p1.owner.equals(p2.owner)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1334,20 +1334,21 @@ public class MainUtil {
|
|||||||
p1.id.y = p2.id.y.intValue();
|
p1.id.y = p2.id.y.intValue();
|
||||||
p2.id.x = temp.x;
|
p2.id.x = temp.x;
|
||||||
p2.id.y = temp.y;
|
p2.id.y = temp.y;
|
||||||
PS.get().getPlots(world).remove(p1.id);
|
Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
|
||||||
PS.get().getPlots(world).remove(p2.id);
|
raw.get(world).remove(p1.id);
|
||||||
|
raw.get(world).remove(p2.id);
|
||||||
p1.id.recalculateHash();
|
p1.id.recalculateHash();
|
||||||
p2.id.recalculateHash();
|
p2.id.recalculateHash();
|
||||||
PS.get().getPlots(world).put(p1.id, p1);
|
raw.get(world).put(p1.id, p1);
|
||||||
PS.get().getPlots(world).put(p2.id, p2);
|
raw.get(world).put(p2.id, p2);
|
||||||
// Swap database
|
// Swap database
|
||||||
DBFunc.dbManager.swapPlots(p2, p1);
|
DBFunc.dbManager.swapPlots(p2, p1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean swapData(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
public static boolean swapData(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
||||||
Plot p1 = PS.get().getPlots(world).get(current);
|
Plot p1 = PS.get().getPlot(world, current);
|
||||||
Plot p2 = PS.get().getPlots(world).get(newPlot);
|
Plot p2 = PS.get().getPlot(world, newPlot);
|
||||||
if (p1 == null || p1.owner == null) {
|
if (p1 == null || p1.owner == null) {
|
||||||
if (p2 != null && p2.owner != null) {
|
if (p2 != null && p2.owner != null) {
|
||||||
moveData(p2, p1, whenDone);
|
moveData(p2, p1, whenDone);
|
||||||
@ -1368,12 +1369,13 @@ public class MainUtil {
|
|||||||
p1.id.y = p2.id.y.intValue();
|
p1.id.y = p2.id.y.intValue();
|
||||||
p2.id.x = temp.x;
|
p2.id.x = temp.x;
|
||||||
p2.id.y = temp.y;
|
p2.id.y = temp.y;
|
||||||
PS.get().getPlots(world).remove(p1.id);
|
Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
|
||||||
PS.get().getPlots(world).remove(p2.id);
|
raw.get(world).remove(p1.id);
|
||||||
|
raw.get(world).remove(p2.id);
|
||||||
p1.id.recalculateHash();
|
p1.id.recalculateHash();
|
||||||
p2.id.recalculateHash();
|
p2.id.recalculateHash();
|
||||||
PS.get().getPlots(world).put(p1.id, p1);
|
raw.get(world).put(p1.id, p1);
|
||||||
PS.get().getPlots(world).put(p2.id, p2);
|
raw.get(world).put(p2.id, p2);
|
||||||
// Swap database
|
// Swap database
|
||||||
DBFunc.dbManager.swapPlots(p2, p1);
|
DBFunc.dbManager.swapPlots(p2, p1);
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
@ -1397,12 +1399,13 @@ public class MainUtil {
|
|||||||
final ArrayList<PlotId> selection = getPlotSelectionIds(pos1.id, pos2.id);
|
final ArrayList<PlotId> selection = getPlotSelectionIds(pos1.id, pos2.id);
|
||||||
for (final PlotId id : selection) {
|
for (final PlotId id : selection) {
|
||||||
DBFunc.movePlot(getPlot(plot1.world, new PlotId(id.x, id.y)), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
|
DBFunc.movePlot(getPlot(plot1.world, new PlotId(id.x, id.y)), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
|
||||||
final Plot plot = PS.get().getPlots(plot1.world).get(id);
|
final Plot plot = PS.get().getPlot(plot1.world, id);
|
||||||
PS.get().getPlots(plot1.world).remove(id);
|
Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
|
||||||
|
raw.get(plot1.world).remove(id);
|
||||||
plot.id.x += offset_x;
|
plot.id.x += offset_x;
|
||||||
plot.id.y += offset_y;
|
plot.id.y += offset_y;
|
||||||
plot.id.recalculateHash();
|
plot.id.recalculateHash();
|
||||||
PS.get().getPlots(plot2.world).put(plot.id, plot);
|
raw.get(plot2.world).put(plot.id, plot);
|
||||||
}
|
}
|
||||||
TaskManager.runTaskLater(whenDone, 1);
|
TaskManager.runTaskLater(whenDone, 1);
|
||||||
return true;
|
return true;
|
||||||
@ -1431,12 +1434,13 @@ public class MainUtil {
|
|||||||
for (final PlotId id : selection) {
|
for (final PlotId id : selection) {
|
||||||
String worldOriginal = plot1.world;
|
String worldOriginal = plot1.world;
|
||||||
PlotId idOriginal = new PlotId(id.x, id.y);
|
PlotId idOriginal = new PlotId(id.x, id.y);
|
||||||
final Plot plot = PS.get().getPlots(plot1.world).get(id);
|
final Plot plot = PS.get().getPlot(plot1.world, id);
|
||||||
PS.get().getPlots(plot1.world).remove(id);
|
Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
|
||||||
|
raw.get(plot1.world).remove(id);
|
||||||
plot.id.x += offset_x;
|
plot.id.x += offset_x;
|
||||||
plot.id.y += offset_y;
|
plot.id.y += offset_y;
|
||||||
plot.id.recalculateHash();
|
plot.id.recalculateHash();
|
||||||
PS.get().getPlots(plot2.world).put(plot.id, plot);
|
raw.get(plot2.world).put(plot.id, plot);
|
||||||
DBFunc.movePlot(getPlot(worldOriginal, idOriginal), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
|
DBFunc.movePlot(getPlot(worldOriginal, idOriginal), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
|
||||||
}
|
}
|
||||||
ChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() {
|
ChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() {
|
||||||
@ -1499,7 +1503,7 @@ public class MainUtil {
|
|||||||
DBFunc.setDenied(plot, denied);
|
DBFunc.setDenied(plot, denied);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PS.get().getPlots(world).put(plot.id, plot);
|
PS.get().updatePlot(plot);
|
||||||
}
|
}
|
||||||
ChunkManager.manager.copyRegion(bot1, top, bot2, whenDone);
|
ChunkManager.manager.copyRegion(bot1, top, bot2, whenDone);
|
||||||
return true;
|
return true;
|
||||||
@ -1628,14 +1632,14 @@ public class MainUtil {
|
|||||||
|
|
||||||
public static Plot getBottomPlot(final Plot plot) {
|
public static Plot getBottomPlot(final Plot plot) {
|
||||||
if (plot.getSettings().getMerged(0)) {
|
if (plot.getSettings().getMerged(0)) {
|
||||||
final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y - 1));
|
final Plot p = PS.get().getPlot(plot.world, new PlotId(plot.id.x, plot.id.y - 1));
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
return getBottomPlot(p);
|
return getBottomPlot(p);
|
||||||
}
|
}
|
||||||
if (plot.getSettings().getMerged(3)) {
|
if (plot.getSettings().getMerged(3)) {
|
||||||
final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x - 1, plot.id.y));
|
final Plot p = PS.get().getPlot(plot.world, new PlotId(plot.id.x - 1, plot.id.y));
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
@ -1646,14 +1650,14 @@ public class MainUtil {
|
|||||||
|
|
||||||
public static Plot getTopPlot(final Plot plot) {
|
public static Plot getTopPlot(final Plot plot) {
|
||||||
if (plot.getSettings().getMerged(2)) {
|
if (plot.getSettings().getMerged(2)) {
|
||||||
final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y + 1));
|
final Plot p = PS.get().getPlot(plot.world, new PlotId(plot.id.x, plot.id.y + 1));
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
return getTopPlot(p);
|
return getTopPlot(p);
|
||||||
}
|
}
|
||||||
if (plot.getSettings().getMerged(1)) {
|
if (plot.getSettings().getMerged(1)) {
|
||||||
final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x + 1, plot.id.y));
|
final Plot p = PS.get().getPlot(plot.world, new PlotId(plot.id.x + 1, plot.id.y));
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
@ -1679,8 +1683,9 @@ public class MainUtil {
|
|||||||
if (id == null) {
|
if (id == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (PS.get().getPlots(world).containsKey(id)) {
|
Plot plot = PS.get().getPlot(world, id);
|
||||||
return PS.get().getPlots(world).get(id);
|
if (plot != null) {
|
||||||
|
return plot;
|
||||||
}
|
}
|
||||||
return new Plot(world, id, null);
|
return new Plot(world, id, null);
|
||||||
}
|
}
|
||||||
|
@ -693,7 +693,7 @@ public abstract class SchematicHandler {
|
|||||||
* @return tag
|
* @return tag
|
||||||
*/
|
*/
|
||||||
public void getCompoundTag(final String world, final PlotId id, RunnableVal<CompoundTag> whenDone) {
|
public void getCompoundTag(final String world, final PlotId id, RunnableVal<CompoundTag> whenDone) {
|
||||||
if (!PS.get().getPlots(world).containsKey(id)) {
|
if (PS.get().getPlot(world, id) == null) {
|
||||||
whenDone.run();
|
whenDone.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.intellectualcrafters.plot.util;
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@ -125,6 +127,18 @@ public class StringMan {
|
|||||||
return join(collection.toArray(), delimiter);
|
return join(collection.toArray(), delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String joinOrdered(Collection<?> collection, String delimiter) {
|
||||||
|
Object[] array = collection.toArray();
|
||||||
|
Arrays.sort(array, new Comparator<Object>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Object a, Object b) {
|
||||||
|
return a.hashCode() - b.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
return join(array, delimiter);
|
||||||
|
}
|
||||||
|
|
||||||
public static String join(Collection<?> collection, char delimiter) {
|
public static String join(Collection<?> collection, char delimiter) {
|
||||||
return join(collection.toArray(), delimiter + "");
|
return join(collection.toArray(), delimiter + "");
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ public class LikePlotMeConverter {
|
|||||||
for (final String world : plots.keySet()) {
|
for (final String world : plots.keySet()) {
|
||||||
int duplicate = 0;
|
int duplicate = 0;
|
||||||
for (final Plot plot : plots.get(world).values()) {
|
for (final Plot plot : plots.get(world).values()) {
|
||||||
if (!PS.get().getPlots(world).containsKey(plot.id)) {
|
if (PS.get().getPlot(world, plot.id) == null) {
|
||||||
createdPlots.add(plot);
|
createdPlots.add(plot);
|
||||||
} else {
|
} else {
|
||||||
duplicate++;
|
duplicate++;
|
||||||
|
@ -1618,8 +1618,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
WEManager.bypass.remove(pp.getName());
|
WEManager.bypass.remove(pp.getName());
|
||||||
}
|
}
|
||||||
if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) {
|
if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) {
|
||||||
final Collection<Plot> plots = PS.get().getPlots(pp.getName()).values();
|
for (final Plot plot : PS.get().getPlotsInWorld(pp.getName())) {
|
||||||
for (final Plot plot : plots) {
|
|
||||||
plot.deletePlot(null);
|
plot.deletePlot(null);
|
||||||
PS.debug(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
|
PS.debug(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class WEManager {
|
|||||||
public static HashSet<RegionWrapper> getMask(PlotPlayer player) {
|
public static HashSet<RegionWrapper> getMask(PlotPlayer player) {
|
||||||
HashSet<RegionWrapper> regions = new HashSet<>();
|
HashSet<RegionWrapper> regions = new HashSet<>();
|
||||||
UUID uuid = player.getUUID();
|
UUID uuid = player.getUUID();
|
||||||
for (Plot plot : PS.get().getPlots(player.getLocation().getWorld()).values()) {
|
for (Plot plot : PS.get().getPlotsInWorld(player.getLocation().getWorld())) {
|
||||||
if (!plot.getMerged(0) && !plot.getMerged(3)) {
|
if (!plot.getMerged(0) && !plot.getMerged(3)) {
|
||||||
if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) {
|
if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) {
|
||||||
Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||||
|
@ -222,7 +222,8 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playMusic(Location loc, int id) {
|
public void playMusic(Location loc, int id) {
|
||||||
player.playEffect(BukkitUtil.getLocation(loc), Effect.RECORD_PLAY, Material.getMaterial(id));
|
System.out.print("RECORD: " + id);
|
||||||
|
player.playEffect(BukkitUtil.getLocation(loc), Effect.RECORD_PLAY, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,8 +87,8 @@ public class BukkitPlayerFunctions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
|
public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
|
||||||
final Plot plot1 = PS.get().getPlots(world).get(pos1);
|
final Plot plot1 = PS.get().getPlot(world, pos1);
|
||||||
final Plot plot2 = PS.get().getPlots(world).get(pos2);
|
final Plot plot2 = PS.get().getPlot(world, pos2);
|
||||||
if (plot1 != null) {
|
if (plot1 != null) {
|
||||||
pos1 = MainUtil.getBottomPlot(plot1).id;
|
pos1 = MainUtil.getBottomPlot(plot1).id;
|
||||||
}
|
}
|
||||||
@ -120,10 +120,7 @@ public class BukkitPlayerFunctions {
|
|||||||
if (id == null) {
|
if (id == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (PS.get().getPlots(world).containsKey(id)) {
|
return MainUtil.getPlot(world, id);
|
||||||
return PS.get().getPlots(world).get(id);
|
|
||||||
}
|
|
||||||
return new Plot(world, id, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user