mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
stuff
This commit is contained in:
parent
76ca8a7376
commit
8e240b5274
@ -7,8 +7,6 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Array;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.file.Files;
|
||||
@ -23,12 +21,12 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
@ -115,7 +113,7 @@ public class PS {
|
||||
private int[] VERSION = null;
|
||||
private String LAST_VERSION;
|
||||
private boolean LOADING_WORLD = false;
|
||||
private LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
|
||||
private ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> plots;
|
||||
private Database database;
|
||||
private Connection connection;
|
||||
private Thread thread;
|
||||
@ -354,7 +352,7 @@ public class PS {
|
||||
public void updatePlot(final Plot plot) {
|
||||
final String world = plot.world;
|
||||
if (!plots.containsKey(world)) {
|
||||
plots.put(world, new HashMap<PlotId, Plot>());
|
||||
plots.put(world, new ConcurrentHashMap<PlotId, Plot>());
|
||||
}
|
||||
plots.get(world).put(plot.id, plot);
|
||||
}
|
||||
@ -386,7 +384,7 @@ public class PS {
|
||||
plotworlds.put(world, plotworld);
|
||||
plotmanagers.put(world, manager);
|
||||
if (!plots.containsKey(world)) {
|
||||
plots.put(world, new HashMap<PlotId, Plot>());
|
||||
plots.put(world, new ConcurrentHashMap<PlotId, Plot>());
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,7 +416,8 @@ public class PS {
|
||||
*
|
||||
* @return HashMap containing the world name, and another map with the plot id and the plot object
|
||||
*/
|
||||
public HashMap<String, HashMap<PlotId, Plot>> getAllPlotsRaw() {
|
||||
@Deprecated
|
||||
public ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> getAllPlotsRaw() {
|
||||
return plots;
|
||||
}
|
||||
|
||||
@ -429,7 +428,7 @@ public class PS {
|
||||
*/
|
||||
public Set<Plot> getPlots(PlotFilter... filters) {
|
||||
HashSet<Plot> set = new HashSet<>();
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
for (Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
for (PlotFilter filter : filters) {
|
||||
if (!filter.allowsWorld(entry.getKey())) {
|
||||
continue;
|
||||
@ -455,7 +454,8 @@ public class PS {
|
||||
* @see #getAllPlotsRaw() to get the raw plot object
|
||||
* @param plots
|
||||
*/
|
||||
public void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
|
||||
@Deprecated
|
||||
public void setAllPlotsRaw(final ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> plots) {
|
||||
this.plots = plots;
|
||||
}
|
||||
|
||||
@ -465,13 +465,19 @@ public class PS {
|
||||
* @return Set of Plot
|
||||
*/
|
||||
public Set<Plot> getPlots() {
|
||||
final ArrayList<Plot> newplots = new ArrayList<>();
|
||||
for (final Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
int size = 0;
|
||||
for (Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
if (isPlotWorld(entry.getKey())) {
|
||||
newplots.addAll(entry.getValue().values());
|
||||
size += entry.getValue().size();
|
||||
}
|
||||
}
|
||||
return new LinkedHashSet<>(newplots);
|
||||
Set<Plot> result = new HashSet<>(size);
|
||||
for (Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
if (isPlotWorld(entry.getKey())) {
|
||||
result.addAll(entry.getValue().values());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -480,12 +486,17 @@ public class PS {
|
||||
* @return set of plot
|
||||
* @see #setAllPlotsRaw(LinkedHashMap) to set the raw plot object
|
||||
*/
|
||||
@Deprecated
|
||||
public Set<Plot> getPlotsRaw() {
|
||||
final ArrayList<Plot> newplots = new ArrayList<>();
|
||||
for (final Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
newplots.addAll(entry.getValue().values());
|
||||
int size = 0;
|
||||
for (Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
size += entry.getValue().size();
|
||||
}
|
||||
return new LinkedHashSet<>(newplots);
|
||||
Set<Plot> result = new HashSet<>(size);
|
||||
for (Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
result.addAll(entry.getValue().values());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -493,17 +504,20 @@ public class PS {
|
||||
* Sort a collection of plots by the hashcode (assumes that all plots are in the same world)
|
||||
* @param plots
|
||||
* @return ArrayList of plot
|
||||
* @deprecated use sortPlot
|
||||
*/
|
||||
@Deprecated
|
||||
public ArrayList<Plot> sortPlots(Collection<Plot> plots) {
|
||||
return sortPlotsByWorld(plots);
|
||||
return sortPlots(plots, SortType.DISTANCE_FROM_ORIGIN, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort plots by hashcode
|
||||
* @param plots
|
||||
* @return
|
||||
* @deprecated Unchecked, please use {@link #sortPlots(Collection, SortType, String)} which has additional checks before calling this
|
||||
*/
|
||||
@Deprecated
|
||||
public ArrayList<Plot> sortPlotsByHash(Collection<Plot> plots) {
|
||||
int hardmax = 256000;
|
||||
int max = 0;
|
||||
@ -545,6 +559,13 @@ public class PS {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort plots by creation timestamp
|
||||
* @param input
|
||||
* @deprecated Unchecked, use {@link #sortPlots(Collection, SortType, String)} instead which will call this after checks
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static ArrayList<Plot> sortPlotsByTimestamp(Collection<Plot> input) {
|
||||
List<Plot> list;
|
||||
if (input instanceof ArrayList<?>) {
|
||||
@ -720,6 +741,10 @@ public class PS {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Unchecked, use {@link #sortPlots(Collection, SortType, String)} instead which will in turn call this
|
||||
* @param input
|
||||
*/
|
||||
public static void sortPlotsByHash(Plot[] input) {
|
||||
final int SIZE = 100;
|
||||
List<Plot>[] bucket = new ArrayList[SIZE];
|
||||
@ -748,6 +773,12 @@ public class PS {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort plots by timestamp
|
||||
* @param input
|
||||
* @deprecated Unchecked, use {@link #sortPlots(Collection, SortType, String)} instead which will in turn call this
|
||||
*/
|
||||
@Deprecated
|
||||
public static void sortPlotsByTimestamp(Plot[] input) {
|
||||
final int SIZE = 100;
|
||||
List<Plot>[] bucket = new ArrayList[SIZE];
|
||||
@ -776,25 +807,26 @@ public class PS {
|
||||
}
|
||||
}
|
||||
|
||||
public enum SortType { CREATION_DATE, DISTANCE_FROM_ORIGIN; }
|
||||
|
||||
/**
|
||||
* Sort a collection of plots by world (with a priority world), then by hashcode
|
||||
* @param plots
|
||||
* @param priorityWorld - Use "world" or "gibberish" if you don't care
|
||||
* @see #sortPlotsByWorld(Collection) to sort plots by world, then by hashcode
|
||||
* @see #sortPlots(Collection) to sort plots just by hashcode
|
||||
* @param type The sorting method to use for each world (timestamp, or hash)
|
||||
* @param priorityWorld - Use null, "world" or "gibberish" if you want default world order
|
||||
* @return ArrayList of plot
|
||||
*/
|
||||
public ArrayList<Plot> sortPlots(Collection<Plot> plots, final String priorityWorld) {
|
||||
public ArrayList<Plot> sortPlots(Collection<Plot> plots, final SortType type, final String priorityWorld) {
|
||||
// group by world
|
||||
// sort each
|
||||
HashMap<String, Collection<Plot>> map = new HashMap<>();
|
||||
ArrayList<String> worlds = new ArrayList<String>(getPlotWorlds());
|
||||
int totalSize = 0;
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : this.plots.entrySet()) {
|
||||
for (Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : this.plots.entrySet()) {
|
||||
totalSize += entry.getValue().size();
|
||||
}
|
||||
if (plots.size() == totalSize) {
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : this.plots.entrySet()) {
|
||||
for (Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : this.plots.entrySet()) {
|
||||
map.put(entry.getKey(), entry.getValue().values());
|
||||
}
|
||||
}
|
||||
@ -826,7 +858,17 @@ public class PS {
|
||||
});
|
||||
ArrayList<Plot> toReturn = new ArrayList<Plot>(plots.size());
|
||||
for (String world : worlds) {
|
||||
toReturn.addAll(sortPlotsByHash(map.get(world)));
|
||||
switch (type) {
|
||||
case CREATION_DATE:
|
||||
toReturn.addAll(sortPlotsByTimestamp(map.get(world)));
|
||||
break;
|
||||
case DISTANCE_FROM_ORIGIN:
|
||||
toReturn.addAll(sortPlotsByHash(map.get(world)));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
@ -835,10 +877,10 @@ public class PS {
|
||||
/**
|
||||
* Sort a collection of plots by world, then by hashcode
|
||||
* @param plots
|
||||
* @see #sortPlots(Collection, String) to sort with a specific priority world
|
||||
* @see #sortPlots(Collection) to sort plots just by hashcode
|
||||
* @deprecated Use #sortPlots(Collection, String) instead
|
||||
* @return ArrayList of plot
|
||||
*/
|
||||
@Deprecated
|
||||
public ArrayList<Plot> sortPlotsByWorld(Collection<Plot> plots) {
|
||||
ArrayList<Plot> newPlots = new ArrayList<>();
|
||||
ArrayList<String> worlds = new ArrayList<>(this.plots.keySet());
|
||||
@ -928,16 +970,25 @@ public class PS {
|
||||
}
|
||||
|
||||
|
||||
private String lastWorld;
|
||||
private Map<PlotId, Plot> lastMap;
|
||||
|
||||
/**
|
||||
* Get a map of the plots for a world
|
||||
* @param world
|
||||
* @return HashMap of PlotId to Plot
|
||||
*/
|
||||
public HashMap<PlotId, Plot> getPlots(final String world) {
|
||||
if (plots.containsKey(world)) {
|
||||
return plots.get(world);
|
||||
@Deprecated
|
||||
public Map<PlotId, Plot> getPlots(final String world) {
|
||||
if (world == lastWorld) {
|
||||
return lastMap;
|
||||
}
|
||||
return new HashMap<>();
|
||||
lastWorld = world;
|
||||
if (plots.containsKey(world)) {
|
||||
lastMap = plots.get(world);
|
||||
return lastMap;
|
||||
}
|
||||
return new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
|
||||
@ -984,7 +1035,7 @@ public class PS {
|
||||
if (callEvent) {
|
||||
EventUtil.manager.callDelete(world, id);
|
||||
}
|
||||
HashMap<PlotId, Plot> allPlots = plots.get(world);
|
||||
ConcurrentHashMap<PlotId, Plot> allPlots = plots.get(world);
|
||||
if (allPlots == null) {
|
||||
return false;
|
||||
}
|
||||
@ -1377,6 +1428,10 @@ public class PS {
|
||||
*/
|
||||
public void disable() {
|
||||
try {
|
||||
// Validate that all data in the db is correct
|
||||
DBFunc.validatePlots(getPlotsRaw());
|
||||
|
||||
// Close the connection
|
||||
database.closeConnection();
|
||||
UUIDHandler.handleShutdown();
|
||||
} catch (NullPointerException | SQLException e) {
|
||||
@ -1584,6 +1639,7 @@ public class PS {
|
||||
options.put("uuid.read-from-disk", Settings.UUID_FROM_DISK);
|
||||
|
||||
// Mob stuff
|
||||
options.put("kill_road_vehicles", Settings.KILL_ROAD_VEHICLES);
|
||||
options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT);
|
||||
options.put("mob_pathfinding", Settings.MOB_PATHFINDING_DEFAULT);
|
||||
|
||||
@ -1702,6 +1758,7 @@ public class PS {
|
||||
|
||||
// Mob stuff
|
||||
Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs");
|
||||
Settings.KILL_ROAD_VEHICLES = config.getBoolean("kill_road_vehicles");
|
||||
Settings.MOB_PATHFINDING = config.getBoolean("mob_pathfinding");
|
||||
|
||||
// Clearing + Expiry
|
||||
|
@ -225,7 +225,7 @@ public class Auto extends SubCommand {
|
||||
Claim.claimPlot(plr, plot, teleport, true);
|
||||
}
|
||||
}
|
||||
if (!MainUtil.mergePlots(worldname, MainUtil.getPlotSelectionIds(start, end), true)) {
|
||||
if (!MainUtil.mergePlots(worldname, MainUtil.getPlotSelectionIds(start, end), true, true)) {
|
||||
return false;
|
||||
}
|
||||
br = true;
|
||||
|
@ -40,8 +40,6 @@ import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import javax.script.SimpleScriptContext;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
|
@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.PS.SortType;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -51,7 +52,7 @@ public class Home extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
|
||||
final ArrayList<Plot> plots = PS.get().sortPlotsByWorld(PS.get().getPlots(plr));
|
||||
final ArrayList<Plot> plots = PS.get().sortPlots(PS.get().getPlots(plr), SortType.CREATION_DATE, null);
|
||||
if (plots.size() == 1) {
|
||||
MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0));
|
||||
return true;
|
||||
|
@ -20,21 +20,12 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
@ -38,7 +38,6 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -212,7 +211,7 @@ public class Merge extends SubCommand {
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
MainUtil.mergePlots(world, plots, true);
|
||||
MainUtil.mergePlots(world, plots, true, true);
|
||||
MainUtil.setSign(UUIDHandler.getName(plot.owner), plot);
|
||||
}
|
||||
MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
|
||||
@ -241,7 +240,7 @@ public class Merge extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
MainUtil.mergePlots(world, plots, true);
|
||||
MainUtil.mergePlots(world, plots, true, true);
|
||||
MainUtil.setSign(UUIDHandler.getName(plot.owner), plot);
|
||||
return true;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
@ -181,7 +181,7 @@ public class SchematicCmd extends SubCommand {
|
||||
MainUtil.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall <world>");
|
||||
return false;
|
||||
}
|
||||
final HashMap<PlotId, Plot> plotmap = PS.get().getPlots(args[1]);
|
||||
final Map<PlotId, Plot> plotmap = PS.get().getPlots(args[1]);
|
||||
if ((plotmap == null) || (plotmap.size() == 0)) {
|
||||
MainUtil.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall <world>");
|
||||
return false;
|
||||
|
@ -25,6 +25,7 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.PS.SortType;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -67,10 +68,10 @@ public class Visit extends SubCommand {
|
||||
UUID user = UUIDHandler.getCachedUUID(args[0], null);
|
||||
if (user != null ) {
|
||||
// do plots by username
|
||||
plots = PS.get().sortPlots(PS.get().getPlots(user), null);
|
||||
plots = PS.get().sortPlots(PS.get().getPlots(user), SortType.CREATION_DATE, null);
|
||||
} else if (PS.get().isPlotWorld(args[0])) {
|
||||
// do plots by world
|
||||
plots = PS.get().sortPlots(PS.get().getPlots(args[0]).values(), null);
|
||||
plots = PS.get().sortPlots(PS.get().getPlots(args[0]).values(), SortType.CREATION_DATE, null);
|
||||
}
|
||||
else {
|
||||
Plot plot = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
|
@ -20,7 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
@ -30,6 +30,7 @@ import java.util.UUID;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.PS.SortType;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
@ -303,7 +304,7 @@ public class list extends SubCommand {
|
||||
|
||||
public void displayPlots(PlotPlayer player, List<Plot> plots, int pageSize, int page, String world, String[] args, boolean sort) {
|
||||
if (sort) {
|
||||
plots = PS.get().sortPlots(plots, world);
|
||||
plots = PS.get().sortPlots(plots, SortType.CREATION_DATE, world);
|
||||
}
|
||||
if (page < 0) {
|
||||
page = 0;
|
||||
|
@ -25,9 +25,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -119,7 +119,12 @@ public interface AbstractDB {
|
||||
/**
|
||||
* @return A linked hashmap containing all plots
|
||||
*/
|
||||
LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots();
|
||||
ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> getPlots();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void validateAllPlots(Set<Plot> toValidate);
|
||||
|
||||
/**
|
||||
* @return A hashmap containing all plot clusters
|
||||
|
@ -27,9 +27,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -56,11 +56,16 @@ public class DBFunc {
|
||||
public static AbstractDB dbManager;
|
||||
|
||||
public static void movePlot(final Plot originalPlot, final Plot newPlot) {
|
||||
if (originalPlot.temp || newPlot.temp) {
|
||||
if (originalPlot.temp != -1 || newPlot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.movePlot(originalPlot, newPlot);
|
||||
}
|
||||
|
||||
public static void validatePlots(Set<Plot> plots) {
|
||||
dbManager.validateAllPlots(plots);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a resultset contains a column
|
||||
* @param rs
|
||||
@ -90,7 +95,7 @@ public class DBFunc {
|
||||
* @param uuid New Owner
|
||||
*/
|
||||
public static void setOwner(final Plot plot, final UUID uuid) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setOwner(plot, uuid);
|
||||
@ -111,7 +116,7 @@ public class DBFunc {
|
||||
* @param plot Plot to create
|
||||
*/
|
||||
public static void createPlot(final Plot plot) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.createPlot(plot);
|
||||
@ -123,7 +128,7 @@ public class DBFunc {
|
||||
* @param plot Plot to create
|
||||
*/
|
||||
public static void createPlotAndSettings(final Plot plot) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.createPlotAndSettings(plot);
|
||||
@ -144,7 +149,7 @@ public class DBFunc {
|
||||
* @param plot Plot to delete
|
||||
*/
|
||||
public static void delete(final Plot plot) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.delete(plot);
|
||||
@ -161,7 +166,7 @@ public class DBFunc {
|
||||
* @param plot Plot Object
|
||||
*/
|
||||
public static void createPlotSettings(final int id, final Plot plot) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.createPlotSettings(id, plot);
|
||||
@ -192,19 +197,19 @@ public class DBFunc {
|
||||
/**
|
||||
* @return Plots
|
||||
*/
|
||||
public static LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
||||
public static ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> getPlots() {
|
||||
return dbManager.getPlots();
|
||||
}
|
||||
|
||||
public static void setMerged(final Plot plot, final boolean[] merged) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setMerged(plot, merged);
|
||||
}
|
||||
|
||||
public static void setFlags(final Plot plot, final Collection<Flag> flags) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setFlags(plot, flags);
|
||||
@ -219,7 +224,7 @@ public class DBFunc {
|
||||
* @param alias
|
||||
*/
|
||||
public static void setAlias(final Plot plot, final String alias) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setAlias(plot, alias);
|
||||
@ -238,7 +243,7 @@ public class DBFunc {
|
||||
* @param position
|
||||
*/
|
||||
public static void setPosition(final Plot plot, final String position) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setPosition(plot, position);
|
||||
@ -258,14 +263,14 @@ public class DBFunc {
|
||||
* @param comment
|
||||
*/
|
||||
public static void removeComment(final Plot plot, final PlotComment comment) {
|
||||
if (plot != null && plot.temp) {
|
||||
if (plot != null && plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.removeComment(plot, comment);
|
||||
}
|
||||
|
||||
public static void clearInbox(final Plot plot, final String inbox) {
|
||||
if (plot != null && plot.temp) {
|
||||
if (plot != null && plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.clearInbox(plot, inbox);
|
||||
@ -276,7 +281,7 @@ public class DBFunc {
|
||||
* @param comment
|
||||
*/
|
||||
public static void setComment(final Plot plot, final PlotComment comment) {
|
||||
if (plot != null && plot.temp) {
|
||||
if (plot != null && plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setComment(plot, comment);
|
||||
@ -286,7 +291,7 @@ public class DBFunc {
|
||||
* @param plot
|
||||
*/
|
||||
public static void getComments(final Plot plot, final String inbox, RunnableVal whenDone) {
|
||||
if (plot != null && plot.temp) {
|
||||
if (plot != null && plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.getComments(plot, inbox, whenDone);
|
||||
@ -297,7 +302,7 @@ public class DBFunc {
|
||||
* @param uuid
|
||||
*/
|
||||
public static void removeTrusted(final Plot plot, final UUID uuid) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.removeTrusted(plot, uuid);
|
||||
@ -332,7 +337,7 @@ public class DBFunc {
|
||||
* @param uuid
|
||||
*/
|
||||
public static void removeMember(final Plot plot, final UUID uuid) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.removeMember(plot, uuid);
|
||||
@ -353,7 +358,7 @@ public class DBFunc {
|
||||
* @param uuid
|
||||
*/
|
||||
public static void setTrusted(final Plot plot, final UUID uuid) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setTrusted(plot, uuid);
|
||||
@ -369,7 +374,7 @@ public class DBFunc {
|
||||
* @param uuid
|
||||
*/
|
||||
public static void setMember(final Plot plot, final UUID uuid) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setMember(plot, uuid);
|
||||
@ -385,7 +390,7 @@ public class DBFunc {
|
||||
* @param uuid
|
||||
*/
|
||||
public static void removeDenied(final Plot plot, final UUID uuid) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.removeDenied(plot, uuid);
|
||||
@ -397,21 +402,21 @@ public class DBFunc {
|
||||
* @param uuid
|
||||
*/
|
||||
public static void setDenied(final Plot plot, final UUID uuid) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setDenied(plot, uuid);
|
||||
}
|
||||
|
||||
public static HashMap<UUID, Integer> getRatings(final Plot plot) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
return dbManager.getRatings(plot);
|
||||
}
|
||||
|
||||
public static void setRating(Plot plot, UUID rater, int value) {
|
||||
if (plot.temp) {
|
||||
if (plot.temp != -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setRating(plot, rater, value);
|
||||
|
@ -36,6 +36,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -909,8 +910,8 @@ public class SQLManager implements AbstractDB {
|
||||
* Load all plots, helpers, denied, trusted, and every setting from DB into a hashmap
|
||||
*/
|
||||
@Override
|
||||
public LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
||||
final LinkedHashMap<String, HashMap<PlotId, Plot>> newplots = new LinkedHashMap<>();
|
||||
public ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> getPlots() {
|
||||
final ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> newplots = new ConcurrentHashMap();
|
||||
final HashMap<Integer, Plot> plots = new HashMap<>();
|
||||
Statement stmt = null;
|
||||
try {
|
||||
@ -959,7 +960,7 @@ public class SQLManager implements AbstractDB {
|
||||
else {
|
||||
time = timestamp.getTime();
|
||||
}
|
||||
p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(), new HashSet<UUID>(), "", null, null, worldname, new boolean[]{false, false, false, false}, time);
|
||||
p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(), new HashSet<UUID>(), "", null, null, worldname, new boolean[]{false, false, false, false}, time, id);
|
||||
plots.put(id, p);
|
||||
}
|
||||
if (Settings.CACHE_RATINGS) {
|
||||
@ -1051,7 +1052,7 @@ public class SQLManager implements AbstractDB {
|
||||
if (plot != null) {
|
||||
plots.remove(id);
|
||||
if (!newplots.containsKey(plot.world)) {
|
||||
newplots.put(plot.world, new HashMap<PlotId, Plot>());
|
||||
newplots.put(plot.world, new ConcurrentHashMap<PlotId, Plot>());
|
||||
}
|
||||
newplots.get(plot.world).put(plot.id, plot);
|
||||
final String alias = r.getString("alias");
|
||||
@ -2263,4 +2264,49 @@ public class SQLManager implements AbstractDB {
|
||||
this.settings = settings;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateAllPlots(Set<Plot> toValidate) {
|
||||
// ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> database = getPlots();
|
||||
//
|
||||
// ArrayList<Plot> toCreate = new ArrayList<>();
|
||||
// ArrayList<UUID> toTrust1 = new ArrayList<>();
|
||||
// ArrayList<Plot> toTrust2 = new ArrayList<>();
|
||||
//
|
||||
// for (Plot plot : plots) {
|
||||
// if (plot.temp) {
|
||||
// continue;
|
||||
// }
|
||||
// ConcurrentHashMap<PlotId, Plot> worldplots = database.get(plot.world);
|
||||
// if (worldplots == null) {
|
||||
// toCreate.add(plot);
|
||||
// continue;
|
||||
// }
|
||||
// Plot dataplot = worldplots.get(plot.id);
|
||||
// if (dataplot == null) {
|
||||
// toCreate.add(plot);
|
||||
// continue;
|
||||
// }
|
||||
// // owner
|
||||
// if (!plot.owner.equals(dataplot)) {
|
||||
// toSet.add(plot);
|
||||
// continue;
|
||||
// }
|
||||
// plot.
|
||||
// // trusted
|
||||
// if (!plot.getTrusted().equals(dataplot.trusted)) {
|
||||
// toSet.add(plot);
|
||||
// continue;
|
||||
// }
|
||||
// if (!plot.getMembers().equals(dataplot.members)) {
|
||||
// toSet.add(plot);
|
||||
// continue;
|
||||
// }
|
||||
// if (!plot.getDenied().equals(dataplot.denied)) {
|
||||
// toSet.add(plot);
|
||||
// continue;
|
||||
// }
|
||||
// ssettings = plot.getSettings();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
|
@ -27,8 +27,6 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
@ -103,9 +101,13 @@ public class Plot {
|
||||
*/
|
||||
public boolean countsTowardsMax = true;
|
||||
/**
|
||||
* If this plot is temporary i.e. not stored in the DB
|
||||
* Represents whatever the database manager needs it to: <br>
|
||||
* - A value of -1 usually indicates the plot will not be stored in the DB<br>
|
||||
* - A value of 0 usually indicates that the DB manager hasn't set a value<br>
|
||||
* @deprecated magical
|
||||
*/
|
||||
public final boolean temp;
|
||||
@Deprecated
|
||||
public int temp;
|
||||
|
||||
/**
|
||||
* Constructor for a new plot
|
||||
@ -118,7 +120,6 @@ public class Plot {
|
||||
this.world = world;
|
||||
this.id = id;
|
||||
this.owner = owner;
|
||||
this.temp = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -129,7 +130,7 @@ public class Plot {
|
||||
* @param owner
|
||||
* @param temp
|
||||
*/
|
||||
public Plot(String world, PlotId id, UUID owner, boolean temp) {
|
||||
public Plot(String world, PlotId id, UUID owner, int temp) {
|
||||
this.world = world;
|
||||
this.id = id;
|
||||
this.owner = owner;
|
||||
@ -145,7 +146,7 @@ public class Plot {
|
||||
* @param denied
|
||||
* @param merged
|
||||
*/
|
||||
public Plot(final PlotId id, final UUID owner, final HashSet<UUID> trusted, final HashSet<UUID> members, final HashSet<UUID> denied, final String alias, final BlockLoc position, final Collection<Flag> flags, final String world, final boolean[] merged, final long timestamp) {
|
||||
public Plot(final PlotId id, final UUID owner, final HashSet<UUID> trusted, final HashSet<UUID> members, final HashSet<UUID> denied, final String alias, final BlockLoc position, final Collection<Flag> flags, final String world, final boolean[] merged, final long timestamp, final int temp) {
|
||||
this.id = id;
|
||||
this.world = world;
|
||||
this.owner = owner;
|
||||
@ -162,7 +163,6 @@ public class Plot {
|
||||
}
|
||||
}
|
||||
this.timestamp = timestamp;
|
||||
this.temp = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,7 +126,7 @@ public abstract class ChunkManager {
|
||||
*/
|
||||
public abstract boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone);
|
||||
|
||||
public abstract void clearAllEntities(final Plot plot);
|
||||
public abstract void clearAllEntities(final Location pos1, final Location pos2);
|
||||
|
||||
public abstract void swap(String world, PlotId id, PlotId plotid);
|
||||
|
||||
|
@ -3,7 +3,6 @@ package com.intellectualcrafters.plot.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -24,12 +24,12 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
@ -289,7 +289,7 @@ public class MainUtil {
|
||||
MainUtil.sendMessage(player, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
return MainUtil.mergePlots(world, plotIds, true);
|
||||
return MainUtil.mergePlots(world, plotIds, true, true);
|
||||
}
|
||||
|
||||
public static boolean unlinkPlot(final Plot plot) {
|
||||
@ -620,10 +620,13 @@ public class MainUtil {
|
||||
*
|
||||
* @return boolean (success)
|
||||
*/
|
||||
public static boolean mergePlots(final String world, final ArrayList<PlotId> plotIds, final boolean removeRoads) {
|
||||
public static boolean mergePlots(final String world, final ArrayList<PlotId> plotIds, final boolean removeRoads, final boolean updateDatabase) {
|
||||
if (plotIds.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// merged plots set db before finished merging
|
||||
|
||||
final PlotId pos1 = plotIds.get(0);
|
||||
final PlotId pos2 = plotIds.get(plotIds.size() - 1);
|
||||
final PlotManager manager = PS.get().getPlotManager(world);
|
||||
@ -676,14 +679,16 @@ public class MainUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final PlotId id = new PlotId(x, y);
|
||||
final Plot plot = PS.get().getPlots(world).get(id);
|
||||
DBFunc.setMerged(plot, plot.getSettings().getMerged());
|
||||
manager.finishPlotMerge(plotworld, plotIds);
|
||||
if (updateDatabase) {
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final PlotId id = new PlotId(x, y);
|
||||
final Plot plot = PS.get().getPlots(world).get(id);
|
||||
DBFunc.setMerged(plot, plot.getSettings().getMerged());
|
||||
}
|
||||
}
|
||||
}
|
||||
manager.finishPlotMerge(plotworld, plotIds);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -744,7 +749,7 @@ public class MainUtil {
|
||||
|
||||
/**
|
||||
* Merges 2 plots Removes the road inbetween <br> - Assumes the first plot parameter is lower <br> - Assumes neither
|
||||
* are a Mega-plot <br> - Assumes plots are directly next to each other <br> - Saves to DB
|
||||
* are a Mega-plot <br> - Assumes plots are directly next to each other <br> - Does not save to DB
|
||||
*
|
||||
* @param world
|
||||
* @param lesserPlot
|
||||
@ -840,6 +845,7 @@ public class MainUtil {
|
||||
ArrayList<PlotId> plots;
|
||||
boolean merge = true;
|
||||
int count = 0;
|
||||
ArrayList<PlotId> toUpdate = new ArrayList<>();
|
||||
while (merge) {
|
||||
if (count > 16) {
|
||||
break;
|
||||
@ -849,38 +855,46 @@ public class MainUtil {
|
||||
final PlotId top = getTopPlot(plot).id;
|
||||
plots = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
||||
if (ownsPlots(plot.world, plots, uuid, 0)) {
|
||||
final boolean result = mergePlots(plot.world, plots, removeRoads);
|
||||
final boolean result = mergePlots(plot.world, plots, removeRoads, false);
|
||||
if (result) {
|
||||
toUpdate.addAll(plots);
|
||||
merge = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
||||
if (ownsPlots(plot.world, plots, uuid, 1)) {
|
||||
final boolean result = mergePlots(plot.world, plots, removeRoads);
|
||||
final boolean result = mergePlots(plot.world, plots, removeRoads, false);
|
||||
if (result) {
|
||||
toUpdate.addAll(plots);
|
||||
merge = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
||||
if (ownsPlots(plot.world, plots, uuid, 2)) {
|
||||
final boolean result = mergePlots(plot.world, plots, removeRoads);
|
||||
final boolean result = mergePlots(plot.world, plots, removeRoads, false);
|
||||
if (result) {
|
||||
toUpdate.addAll(plots);
|
||||
merge = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
plots = getPlotSelectionIds(new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
||||
if (ownsPlots(plot.world, plots, uuid, 3)) {
|
||||
final boolean result = mergePlots(plot.world, plots, removeRoads);
|
||||
final boolean result = mergePlots(plot.world, plots, removeRoads, false);
|
||||
if (result) {
|
||||
toUpdate.addAll(plots);
|
||||
merge = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
merge = false;
|
||||
}
|
||||
for (PlotId id : toUpdate) {
|
||||
Plot update = getPlot(plot.world, id);
|
||||
DBFunc.setMerged(plot, plot.getSettings().getMerged());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean ownsPlots(final String world, final ArrayList<PlotId> plots, final UUID uuid, final int dir) {
|
||||
@ -944,7 +958,7 @@ public class MainUtil {
|
||||
*/
|
||||
public static Plot createPlotAbs(final UUID uuid, final Plot plot) {
|
||||
final String w = plot.world;
|
||||
HashMap<PlotId, Plot> plots = PS.get().getPlots(plot.world);
|
||||
Map<PlotId, Plot> plots = PS.get().getPlots(plot.world);
|
||||
Plot p = plots.get(plot.id);
|
||||
if (p != null) {
|
||||
return p;
|
||||
@ -985,9 +999,12 @@ public class MainUtil {
|
||||
if (runners.containsKey(plot)) {
|
||||
return false;
|
||||
}
|
||||
ChunkManager.manager.clearAllEntities(plot);
|
||||
long start = System.currentTimeMillis();
|
||||
ChunkManager.manager.clearAllEntities(plot.getBottom().add(1, 0, 1), plot.getTop());
|
||||
if (isDelete) {
|
||||
removeSign(plot);
|
||||
}
|
||||
clear(plot, isDelete, whenDone);
|
||||
removeSign(plot);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ public class SetBlockQueue {
|
||||
TaskManager.runTask(runnable);
|
||||
}
|
||||
}
|
||||
lastInt = -1;
|
||||
lastBlock = null;
|
||||
runnables = null;
|
||||
blocks = new HashMap<>();
|
||||
@ -75,8 +76,8 @@ public class SetBlockQueue {
|
||||
return;
|
||||
}
|
||||
long newLast = System.currentTimeMillis();
|
||||
last = Math.max(newLast - 100, last);
|
||||
while (blocks.size() > 0 && (System.currentTimeMillis() - last < 100 + allocate)) {
|
||||
last = Math.max(newLast - 50, last);
|
||||
while (blocks.size() > 0 && (System.currentTimeMillis() - last < 50 + allocate)) {
|
||||
if (locked) {
|
||||
return;
|
||||
}
|
||||
@ -129,7 +130,7 @@ public class SetBlockQueue {
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 2);
|
||||
}, 1);
|
||||
TaskManager.tasks.put(current, task);
|
||||
running = true;
|
||||
}
|
||||
|
@ -16,8 +16,6 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.metadata.MetadataValueAdapter;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -200,98 +198,107 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
for (final PlotWorld pw : PS.get().getPlotWorldObjects()) {
|
||||
world = Bukkit.getWorld(pw.worldname);
|
||||
try {
|
||||
for (Entity entity : world.getEntities()) {
|
||||
switch (entity.getType()) {
|
||||
case EGG:
|
||||
case ENDER_CRYSTAL:
|
||||
case COMPLEX_PART:
|
||||
case ARMOR_STAND:
|
||||
case FISHING_HOOK:
|
||||
case ENDER_SIGNAL:
|
||||
case EXPERIENCE_ORB:
|
||||
case LEASH_HITCH:
|
||||
case FIREWORK:
|
||||
case WEATHER:
|
||||
case LIGHTNING:
|
||||
case WITHER_SKULL:
|
||||
case UNKNOWN:
|
||||
case ITEM_FRAME:
|
||||
case PAINTING:
|
||||
case PLAYER: {
|
||||
// non moving / unremovable
|
||||
continue;
|
||||
}
|
||||
case THROWN_EXP_BOTTLE:
|
||||
case SPLASH_POTION:
|
||||
case SNOWBALL:
|
||||
case ENDER_PEARL:
|
||||
case ARROW: {
|
||||
// managed elsewhere | projectile
|
||||
continue;
|
||||
}
|
||||
case MINECART:
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_FURNACE:
|
||||
case MINECART_HOPPER:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
case MINECART_TNT:
|
||||
case BOAT: {
|
||||
// vehicle
|
||||
continue;
|
||||
}
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
case DROPPED_ITEM: {
|
||||
// dropped item
|
||||
continue;
|
||||
}
|
||||
case PRIMED_TNT:
|
||||
case FALLING_BLOCK: {
|
||||
// managed elsewhere
|
||||
continue;
|
||||
}
|
||||
case BAT:
|
||||
case BLAZE:
|
||||
case CAVE_SPIDER:
|
||||
case CHICKEN:
|
||||
case COW:
|
||||
case CREEPER:
|
||||
case ENDERMAN:
|
||||
case ENDERMITE:
|
||||
case ENDER_DRAGON:
|
||||
case GHAST:
|
||||
case GIANT:
|
||||
case GUARDIAN:
|
||||
case HORSE:
|
||||
case IRON_GOLEM:
|
||||
case MAGMA_CUBE:
|
||||
case MUSHROOM_COW:
|
||||
case OCELOT:
|
||||
case PIG:
|
||||
case PIG_ZOMBIE:
|
||||
case RABBIT:
|
||||
case SHEEP:
|
||||
case SILVERFISH:
|
||||
case SKELETON:
|
||||
case SLIME:
|
||||
case SNOWMAN:
|
||||
case SPIDER:
|
||||
case SQUID:
|
||||
case VILLAGER:
|
||||
case WITCH:
|
||||
case WITHER:
|
||||
case WOLF:
|
||||
case ZOMBIE:
|
||||
default: {
|
||||
Location loc = entity.getLocation();
|
||||
if (MainUtil.isPlotRoad(BukkitUtil.getLocation(loc))) {
|
||||
entity.remove();
|
||||
for (Entity entity : world.getEntities()) {
|
||||
switch (entity.getType()) {
|
||||
case EGG:
|
||||
case ENDER_CRYSTAL:
|
||||
case COMPLEX_PART:
|
||||
case ARMOR_STAND:
|
||||
case FISHING_HOOK:
|
||||
case ENDER_SIGNAL:
|
||||
case EXPERIENCE_ORB:
|
||||
case LEASH_HITCH:
|
||||
case FIREWORK:
|
||||
case WEATHER:
|
||||
case LIGHTNING:
|
||||
case WITHER_SKULL:
|
||||
case UNKNOWN:
|
||||
case ITEM_FRAME:
|
||||
case PAINTING:
|
||||
case PLAYER: {
|
||||
// non moving / unremovable
|
||||
continue;
|
||||
}
|
||||
case THROWN_EXP_BOTTLE:
|
||||
case SPLASH_POTION:
|
||||
case SNOWBALL:
|
||||
case ENDER_PEARL:
|
||||
case ARROW: {
|
||||
// managed elsewhere | projectile
|
||||
continue;
|
||||
}
|
||||
case MINECART:
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_FURNACE:
|
||||
case MINECART_HOPPER:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
case MINECART_TNT:
|
||||
case BOAT: {
|
||||
if (!Settings.KILL_ROAD_VEHICLES) {
|
||||
continue;
|
||||
}
|
||||
Location loc = entity.getLocation();
|
||||
if (MainUtil.isPlotRoad(BukkitUtil.getLocation(loc))) {
|
||||
entity.remove();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
case DROPPED_ITEM: {
|
||||
// dropped item
|
||||
continue;
|
||||
}
|
||||
case PRIMED_TNT:
|
||||
case FALLING_BLOCK: {
|
||||
// managed elsewhere
|
||||
continue;
|
||||
}
|
||||
case BAT:
|
||||
case BLAZE:
|
||||
case CAVE_SPIDER:
|
||||
case CHICKEN:
|
||||
case COW:
|
||||
case CREEPER:
|
||||
case ENDERMAN:
|
||||
case ENDERMITE:
|
||||
case ENDER_DRAGON:
|
||||
case GHAST:
|
||||
case GIANT:
|
||||
case GUARDIAN:
|
||||
case HORSE:
|
||||
case IRON_GOLEM:
|
||||
case MAGMA_CUBE:
|
||||
case MUSHROOM_COW:
|
||||
case OCELOT:
|
||||
case PIG:
|
||||
case PIG_ZOMBIE:
|
||||
case RABBIT:
|
||||
case SHEEP:
|
||||
case SILVERFISH:
|
||||
case SKELETON:
|
||||
case SLIME:
|
||||
case SNOWMAN:
|
||||
case SPIDER:
|
||||
case SQUID:
|
||||
case VILLAGER:
|
||||
case WITCH:
|
||||
case WITHER:
|
||||
case WOLF:
|
||||
case ZOMBIE:
|
||||
default: {
|
||||
if (!Settings.KILL_ROAD_MOBS) {
|
||||
continue;
|
||||
}
|
||||
Location loc = entity.getLocation();
|
||||
if (MainUtil.isPlotRoad(BukkitUtil.getLocation(loc))) {
|
||||
entity.remove();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Throwable e) {
|
||||
++this.error;
|
||||
} finally {
|
||||
|
@ -19,7 +19,6 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
@ -1,9 +1,5 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
@ -7,7 +7,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -44,7 +43,6 @@ import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
@ -63,7 +61,6 @@ import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||
import com.plotsquared.bukkit.object.entity.EntityWrapper;
|
||||
|
||||
@ -907,19 +904,28 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllEntities(final Plot plot) {
|
||||
final List<Entity> entities = BukkitUtil.getEntities(plot.world);
|
||||
public void clearAllEntities(final Location pos1, final Location pos2) {
|
||||
final String world = pos1.getWorld();
|
||||
final List<Entity> entities = BukkitUtil.getEntities(world);
|
||||
final int bx = pos1.getX();
|
||||
final int bz = pos1.getZ();
|
||||
final int tx = pos2.getX();
|
||||
final int tz = pos2.getZ();
|
||||
for (final Entity entity : entities) {
|
||||
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity));
|
||||
if (plot.id.equals(id)) {
|
||||
if (entity instanceof Player) {
|
||||
final Player player = (Player) entity;
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
if (entity instanceof Player) {
|
||||
final Player player = (Player) entity;
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
if (plot != null) {
|
||||
final Location plotHome = MainUtil.getDefaultHome(plot);
|
||||
if (pp.getLocation().getY() <= plotHome.getY()) {
|
||||
pp.teleport(plotHome);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
else {
|
||||
org.bukkit.Location loc = entity.getLocation();
|
||||
if (loc.getX() >= bx && loc.getX() <= tx && loc.getZ() >= bz && loc.getZ() <= tz) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
@ -997,8 +1003,13 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
final Location top2 = MainUtil.getPlotTopLoc(worldname, pos2);
|
||||
swap(worldname, bot1, top1, bot2, top2);
|
||||
|
||||
clearAllEntities(MainUtil.getPlot(worldname, pos1));
|
||||
clearAllEntities(MainUtil.getPlot(worldname, pos2));
|
||||
Plot plot1 = MainUtil.getPlot(worldname, pos1);
|
||||
Plot plot2 = MainUtil.getPlot(worldname, pos2);
|
||||
|
||||
// TODO clear all entities
|
||||
|
||||
clearAllEntities(plot1.getBottom().add(1, 0, 1), plot1.getTop());
|
||||
clearAllEntities(plot2.getBottom().add(1, 0, 1), plot2.getTop());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,10 +11,8 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.Cluster;
|
||||
import com.intellectualcrafters.plot.commands.DebugUUID;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
|
@ -7,12 +7,10 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.plotsquared.bukkit.object.BukkitOfflinePlayer;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
|
||||
public class BukkitEconHandler extends EconHandler {
|
||||
|
||||
|
@ -6,7 +6,6 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
|
@ -6,8 +6,6 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
||||
public class SetBlockSlow extends BukkitSetBlockManager {
|
||||
@Override
|
||||
public void set(final World world, final int x, final int y, final int z, final int id, final byte data) {
|
||||
|
@ -4,7 +4,6 @@ import java.io.File;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.plotsquared.sponge;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.block.BlockTypes;
|
||||
import org.spongepowered.api.world.World;
|
||||
@ -11,7 +10,6 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.sponge.util.SpongeUtil;
|
||||
|
||||
public class SpongeHybridUtils extends HybridUtils {
|
||||
|
@ -17,14 +17,12 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.api.CatalogType;
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.Platform;
|
||||
import org.spongepowered.api.Server;
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.block.BlockType;
|
||||
import org.spongepowered.api.block.BlockTypes;
|
||||
import org.spongepowered.api.data.manipulator.block.StoneData;
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.player.gamemode.GameModes;
|
||||
import org.spongepowered.api.event.Subscribe;
|
||||
import org.spongepowered.api.event.entity.player.PlayerChatEvent;
|
||||
import org.spongepowered.api.event.state.PreInitializationEvent;
|
||||
@ -521,7 +519,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
|
||||
@Override
|
||||
public void registerCommands() {
|
||||
getGame().getCommandDispatcher().register(plugin, new SpongeCommand(), "plots", "p", "plot", "ps", "plotsquared", "p2");
|
||||
getGame().getCommandDispatcher().register(plugin, new SpongeCommand(), "plots", "p", "plot", "ps", "plotsquared", "p2", "2");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,6 @@ import com.intellectualcrafters.jnbt.ListTag;
|
||||
import com.intellectualcrafters.jnbt.ShortTag;
|
||||
import com.intellectualcrafters.jnbt.StringTag;
|
||||
import com.intellectualcrafters.jnbt.Tag;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
|
@ -16,7 +16,6 @@ import org.spongepowered.api.world.gen.Populator;
|
||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
|
@ -7,7 +7,6 @@ import org.spongepowered.api.world.extent.MutableBlockVolume;
|
||||
import org.spongepowered.api.world.gen.GeneratorPopulator;
|
||||
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
|
@ -5,7 +5,6 @@ import org.spongepowered.api.world.WorldCreationSettings;
|
||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
|
@ -20,7 +20,6 @@ import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.entity.Entity;
|
||||
import org.spongepowered.api.entity.EntityType;
|
||||
import org.spongepowered.api.entity.EntityTypes;
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.event.Subscribe;
|
||||
|
@ -102,12 +102,6 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllEntities(Plot plot) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swap(String world, PlotId id, PlotId plotid) {
|
||||
// TODO Auto-generated method stub
|
||||
@ -120,4 +114,10 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllEntities(Location pos1, Location pos2) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ database: false
|
||||
commands:
|
||||
plots:
|
||||
description: PlotSquared PlotSquared command.
|
||||
aliases: [p,plot,ps,plotsquared,p2]
|
||||
aliases: [p,plot,ps,plotsquared,p2,2]
|
||||
permission: plots.use
|
||||
permission-message: "You are lacking the permission node 'plots.use'"
|
||||
permissions:
|
||||
|
Loading…
Reference in New Issue
Block a user