mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Continue cleaning up PlotSquared.java
This commit is contained in:
parent
51bd21a464
commit
c36e311520
@ -623,7 +623,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
|
|
||||||
@Override @SuppressWarnings("deprecation") public void runEntityTask() {
|
@Override @SuppressWarnings("deprecation") public void runEntityTask() {
|
||||||
PlotSquared.log(Captions.PREFIX + "KillAllEntities started.");
|
PlotSquared.log(Captions.PREFIX + "KillAllEntities started.");
|
||||||
TaskManager.runTaskRepeat(() -> PlotSquared.get().forEachPlotArea(plotArea -> {
|
TaskManager.runTaskRepeat(() -> PlotSquared.get().getPlotAreaManager().forEachPlotArea(plotArea -> {
|
||||||
final World world = Bukkit.getWorld(plotArea.getWorldName());
|
final World world = Bukkit.getWorld(plotArea.getWorldName());
|
||||||
try {
|
try {
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
|
@ -49,14 +49,12 @@ import com.plotsquared.core.generator.IndependentPlotGenerator;
|
|||||||
import com.plotsquared.core.listener.WESubscriber;
|
import com.plotsquared.core.listener.WESubscriber;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.ConsolePlayer;
|
import com.plotsquared.core.player.ConsolePlayer;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
|
||||||
import com.plotsquared.core.plot.BlockBucket;
|
import com.plotsquared.core.plot.BlockBucket;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
||||||
import com.plotsquared.core.plot.PlotAreaType;
|
import com.plotsquared.core.plot.PlotAreaType;
|
||||||
import com.plotsquared.core.plot.PlotCluster;
|
import com.plotsquared.core.plot.PlotCluster;
|
||||||
import com.plotsquared.core.plot.PlotFilter;
|
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.plot.PlotManager;
|
import com.plotsquared.core.plot.PlotManager;
|
||||||
import com.plotsquared.core.plot.comment.CommentManager;
|
import com.plotsquared.core.plot.comment.CommentManager;
|
||||||
@ -88,7 +86,6 @@ import com.plotsquared.core.uuid.UUIDPipeline;
|
|||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -117,25 +114,21 @@ import java.util.Comparator;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of the core, with a static getter for easy access.
|
* An implementation of the core, with a static getter for easy access.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
@SuppressWarnings({"WeakerAccess"})
|
||||||
public class PlotSquared<P> {
|
public class PlotSquared<P> {
|
||||||
|
|
||||||
private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
|
private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
|
||||||
@ -481,18 +474,6 @@ public class PlotSquared<P> {
|
|||||||
return Settings.PLATFORM;
|
return Settings.PLATFORM;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotManager getPlotManager(Plot plot) {
|
|
||||||
return plot.getArea().getPlotManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable public PlotManager getPlotManager(@NotNull final Location location) {
|
|
||||||
final PlotArea plotArea = this.getPlotAreaManager().getPlotArea(location);
|
|
||||||
if (plotArea == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return plotArea.getPlotManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a global reference to a plot world.
|
* Add a global reference to a plot world.
|
||||||
*
|
*
|
||||||
@ -826,7 +807,7 @@ public class PlotSquared<P> {
|
|||||||
// group by world
|
// group by world
|
||||||
// sort each
|
// sort each
|
||||||
HashMap<PlotArea, Collection<Plot>> map = new HashMap<>();
|
HashMap<PlotArea, Collection<Plot>> map = new HashMap<>();
|
||||||
int totalSize = getPlotCount();
|
int totalSize = Arrays.stream(this.plotAreaManager.getAllPlotAreas()).mapToInt(PlotArea::getPlotCount).sum();
|
||||||
if (plots.size() == totalSize) {
|
if (plots.size() == totalSize) {
|
||||||
for (PlotArea area : plotAreaManager.getAllPlotAreas()) {
|
for (PlotArea area : plotAreaManager.getAllPlotAreas()) {
|
||||||
map.put(area, area.getPlots());
|
map.put(area, area.getPlots());
|
||||||
@ -880,45 +861,6 @@ public class PlotSquared<P> {
|
|||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A more generic way to filter plots - make your own method
|
|
||||||
* if you need complex filters.
|
|
||||||
*
|
|
||||||
* @param filters the filter
|
|
||||||
* @return a filtered set of plots
|
|
||||||
* @deprecated Use {@link PlotQuery}
|
|
||||||
*/
|
|
||||||
@Deprecated public Set<Plot> getPlots(final PlotFilter... filters) {
|
|
||||||
final List<PlotArea> areas = new LinkedList<>();
|
|
||||||
for (final PlotArea plotArea : this.getPlotAreaManager().getAllPlotAreas()) {
|
|
||||||
for (final PlotFilter filter : filters) {
|
|
||||||
if (filter.allowsArea(plotArea)) {
|
|
||||||
areas.add(plotArea);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PlotQuery.newQuery().inAreas(areas).thatPasses(plot -> {
|
|
||||||
for (final PlotFilter filter : filters) {
|
|
||||||
if (!filter.allowsPlot(plot)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}).asSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all the plots across all plotworlds in one {@code Set}.
|
|
||||||
*
|
|
||||||
* @return all the plots on the server loaded by this plugin
|
|
||||||
*/
|
|
||||||
public Set<Plot> getPlots() {
|
|
||||||
int size = getPlotCount();
|
|
||||||
final Set<Plot> result = new HashSet<>(size);
|
|
||||||
forEachPlotArea(value -> result.addAll(value.getPlots()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlots(@NotNull final Map<String, HashMap<PlotId, Plot>> plots) {
|
public void setPlots(@NotNull final Map<String, HashMap<PlotId, Plot>> plots) {
|
||||||
if (this.plots_tmp == null) {
|
if (this.plots_tmp == null) {
|
||||||
this.plots_tmp = new HashMap<>();
|
this.plots_tmp = new HashMap<>();
|
||||||
@ -938,129 +880,6 @@ public class PlotSquared<P> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all the plots owned by a player name.
|
|
||||||
*
|
|
||||||
* @param world the world
|
|
||||||
* @param player the plot owner
|
|
||||||
* @return Set of Plot
|
|
||||||
*/
|
|
||||||
public Set<Plot> getPlots(String world, String player) {
|
|
||||||
final UUID uuid = this.impromptuUUIDPipeline.getSingle(player, Settings.UUID.BLOCKING_TIMEOUT);
|
|
||||||
return getPlots(world, uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all the plots owned by a player name.
|
|
||||||
*
|
|
||||||
* @param area the PlotArea
|
|
||||||
* @param player the plot owner
|
|
||||||
* @return Set of Plot
|
|
||||||
*/
|
|
||||||
public Set<Plot> getPlots(PlotArea area, String player) {
|
|
||||||
final UUID uuid = this.impromptuUUIDPipeline.getSingle(player, Settings.UUID.BLOCKING_TIMEOUT);
|
|
||||||
return getPlots(area, uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all plots by a PlotPlayer.
|
|
||||||
*
|
|
||||||
* @param world the world
|
|
||||||
* @param player the plot owner
|
|
||||||
* @return Set of plot
|
|
||||||
*/
|
|
||||||
public Set<Plot> getPlots(String world, PlotPlayer<?> player) {
|
|
||||||
return PlotQuery.newQuery().inWorld(world).ownedBy(player).asSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all plots by a PlotPlayer.
|
|
||||||
*
|
|
||||||
* @param area the PlotArea
|
|
||||||
* @param player the plot owner
|
|
||||||
* @return Set of plot
|
|
||||||
*/
|
|
||||||
public Set<Plot> getPlots(PlotArea area, PlotPlayer<?> player) {
|
|
||||||
return PlotQuery.newQuery().inArea(area).ownedBy(player).asSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all plots by a UUID in a world.
|
|
||||||
*
|
|
||||||
* @param world the world
|
|
||||||
* @param uuid the plot owner
|
|
||||||
* @return Set of plot
|
|
||||||
*/
|
|
||||||
public Set<Plot> getPlots(String world, UUID uuid) {
|
|
||||||
return PlotQuery.newQuery().inWorld(world).ownedBy(uuid).asSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all plots by a UUID in an area.
|
|
||||||
*
|
|
||||||
* @param area the {@code PlotArea}
|
|
||||||
* @param uuid the plot owner
|
|
||||||
* @return Set of plots
|
|
||||||
*/
|
|
||||||
public Set<Plot> getPlots(PlotArea area, UUID uuid) {
|
|
||||||
return PlotQuery.newQuery().inArea(area).ownedBy(uuid).asSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<Plot> getPlots(String world) {
|
|
||||||
return PlotQuery.newQuery().inWorld(world).asCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the plots for a PlotPlayer.
|
|
||||||
*
|
|
||||||
* @param player the player to retrieve the plots for
|
|
||||||
* @return Set of Plot
|
|
||||||
*/
|
|
||||||
public Set<Plot> getPlots(PlotPlayer<?> player) {
|
|
||||||
return PlotQuery.newQuery().ownedBy(player).asSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<Plot> getPlots(PlotArea area) {
|
|
||||||
return area == null ? EMPTY_SET : area.getPlots();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Plot getPlot(PlotArea area, PlotId id) {
|
|
||||||
return area == null ? null : id == null ? null : area.getPlot(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Plot> getBasePlots(PlotPlayer<?> player) {
|
|
||||||
return getBasePlots(player.getUUID());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the plots for a UUID.
|
|
||||||
*
|
|
||||||
* @param uuid the plot owner
|
|
||||||
* @return Set of Plot's owned by the player
|
|
||||||
*/
|
|
||||||
public Set<Plot> getPlots(final UUID uuid) {
|
|
||||||
return PlotQuery.newQuery().ownedBy(uuid).asSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasPlot(final UUID uuid) {
|
|
||||||
return Arrays.stream(plotAreaManager.getAllPlotAreas())
|
|
||||||
.anyMatch(area -> area.hasPlot(uuid));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Plot> getBasePlots(final UUID uuid) {
|
|
||||||
return PlotQuery.newQuery().ownedBy(uuid).whereBasePlot().asSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the plots for a UUID.
|
|
||||||
*
|
|
||||||
* @param uuid the UUID of the owner
|
|
||||||
* @return Set of Plot
|
|
||||||
*/
|
|
||||||
public Set<Plot> getPlotsAbs(final UUID uuid) {
|
|
||||||
return PlotQuery.newQuery().ownedBy(uuid).asSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters a plot from local memory without calling the database.
|
* Unregisters a plot from local memory without calling the database.
|
||||||
*
|
*
|
||||||
@ -1464,17 +1283,6 @@ public class PlotSquared<P> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUpdate(@NonNull final String current, @NonNull final String other) {
|
|
||||||
final String s1 = normalisedVersion(current);
|
|
||||||
final String s2 = normalisedVersion(other);
|
|
||||||
return s1.compareTo(s2) < 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String normalisedVersion(@NonNull final String version) {
|
|
||||||
final String[] split = Pattern.compile(".", Pattern.LITERAL).split(version);
|
|
||||||
return Arrays.stream(split).map(s -> String.format("%4s", s)).collect(Collectors.joining());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies a file from inside the jar to a location
|
* Copies a file from inside the jar to a location
|
||||||
*
|
*
|
||||||
@ -1530,19 +1338,6 @@ public class PlotSquared<P> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Map<PlotId, Plot>> getPlotsRaw() {
|
|
||||||
HashMap<String, Map<PlotId, Plot>> map = new HashMap<>();
|
|
||||||
for (PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
|
||||||
Map<PlotId, Plot> map2 = map.get(area.toString());
|
|
||||||
if (map2 == null) {
|
|
||||||
map.put(area.toString(), area.getPlotsMap());
|
|
||||||
} else {
|
|
||||||
map2.putAll(area.getPlotsMap());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Safely closes the database connection.
|
* Safely closes the database connection.
|
||||||
*/
|
*/
|
||||||
@ -1885,37 +1680,6 @@ public class PlotSquared<P> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Java version.
|
|
||||||
*
|
|
||||||
* @return the java version
|
|
||||||
*/
|
|
||||||
private double getJavaVersion() {
|
|
||||||
return Double.parseDouble(System.getProperty("java.specification.version"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void forEachPlotArea(Consumer<? super PlotArea> action) {
|
|
||||||
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
|
||||||
action.accept(area);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void forEachPlotArea(@NonNull final String world, Consumer<PlotArea> consumer) {
|
|
||||||
final PlotArea[] array = this.plotAreaManager.getPlotAreas(world, null);
|
|
||||||
if (array == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (final PlotArea area : array) {
|
|
||||||
consumer.accept(area);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void forEachPlot(Consumer<Plot> consumer) {
|
|
||||||
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
|
||||||
area.getPlots().forEach(consumer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void forEachPlotRaw(Consumer<Plot> consumer) {
|
public void forEachPlotRaw(Consumer<Plot> consumer) {
|
||||||
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
||||||
area.getPlots().forEach(consumer);
|
area.getPlots().forEach(consumer);
|
||||||
@ -1927,21 +1691,6 @@ public class PlotSquared<P> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forEachBasePlot(Consumer<Plot> consumer) {
|
|
||||||
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
|
||||||
area.forEachBasePlot(consumer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPlotAreaCount() {
|
|
||||||
return this.plotAreaManager.getAllPlotAreas().length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPlotCount() {
|
|
||||||
return Arrays.stream(this.plotAreaManager.getAllPlotAreas())
|
|
||||||
.mapToInt(PlotArea::getPlotCount).sum();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the chunk uses vanilla/non-PlotSquared generation
|
* Check if the chunk uses vanilla/non-PlotSquared generation
|
||||||
*
|
*
|
||||||
@ -1959,23 +1708,6 @@ public class PlotSquared<P> {
|
|||||||
return area.getTerrain() != PlotAreaTerrainType.NONE;
|
return area.getTerrain() != PlotAreaTerrainType.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAugmented(@NonNull final String world) {
|
|
||||||
final PlotArea[] areas = plotAreaManager.getPlotAreas(world, null);
|
|
||||||
return areas != null && (areas.length > 1 || areas[0].getType() != PlotAreaType.NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets Plots based on alias
|
|
||||||
*
|
|
||||||
* @param alias to search plots
|
|
||||||
* @param worldname to filter alias to a specific world [optional] null means all worlds
|
|
||||||
* @return Set<{@link Plot }> empty if nothing found
|
|
||||||
*/
|
|
||||||
public Set<Plot> getPlotsByAlias(@Nullable final String alias,
|
|
||||||
@NonNull final String worldname) {
|
|
||||||
return PlotQuery.newQuery().inWorld(worldname).withAlias(alias).asSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public YamlConfiguration getConfig() {
|
public YamlConfiguration getConfig() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ import com.plotsquared.core.util.ChunkManager;
|
|||||||
import com.plotsquared.core.util.EventDispatcher;
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -64,10 +65,9 @@ import java.util.UUID;
|
|||||||
* Gets all plots.
|
* Gets all plots.
|
||||||
*
|
*
|
||||||
* @return all plots
|
* @return all plots
|
||||||
* @see PlotSquared#getPlots()
|
|
||||||
*/
|
*/
|
||||||
public Set<Plot> getAllPlots() {
|
public Set<Plot> getAllPlots() {
|
||||||
return PlotSquared.get().getPlots();
|
return PlotQuery.newQuery().allPlots().asSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,8 +76,8 @@ import java.util.UUID;
|
|||||||
* @param player Player, whose plots to search for
|
* @param player Player, whose plots to search for
|
||||||
* @return all plots that a player owns
|
* @return all plots that a player owns
|
||||||
*/
|
*/
|
||||||
public Set<Plot> getPlayerPlots(PlotPlayer player) {
|
public Set<Plot> getPlayerPlots(PlotPlayer<?> player) {
|
||||||
return PlotSquared.get().getPlots(player);
|
return PlotQuery.newQuery().ownedBy(player).asSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,8 +39,8 @@ import com.plotsquared.core.plot.PlotCluster;
|
|||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -453,8 +453,8 @@ public class Cluster extends SubCommand {
|
|||||||
MainUtil.sendMessage(player2, Captions.CLUSTER_REMOVED,
|
MainUtil.sendMessage(player2, Captions.CLUSTER_REMOVED,
|
||||||
cluster.getName());
|
cluster.getName());
|
||||||
}
|
}
|
||||||
for (Plot plot : new ArrayList<>(PlotSquared.get()
|
for (final Plot plot : PlotQuery.newQuery().inWorld(player2.getLocation()
|
||||||
.getPlots(player2.getLocation().getWorld(), uuid))) {
|
.getWorld()).ownedBy(uuid).asCollection()) {
|
||||||
PlotCluster current = plot.getCluster();
|
PlotCluster current = plot.getCluster();
|
||||||
if (current != null && current.equals(cluster)) {
|
if (current != null && current.equals(cluster)) {
|
||||||
plot.unclaim();
|
plot.unclaim();
|
||||||
@ -512,8 +512,8 @@ public class Cluster extends SubCommand {
|
|||||||
cluster.invited.remove(uuid);
|
cluster.invited.remove(uuid);
|
||||||
DBFunc.removeInvited(cluster, uuid);
|
DBFunc.removeInvited(cluster, uuid);
|
||||||
MainUtil.sendMessage(player, Captions.CLUSTER_REMOVED, cluster.getName());
|
MainUtil.sendMessage(player, Captions.CLUSTER_REMOVED, cluster.getName());
|
||||||
for (Plot plot : new ArrayList<>(
|
for (final Plot plot : PlotQuery.newQuery().inWorld(player.getLocation().getWorld())
|
||||||
PlotSquared.get().getPlots(player.getLocation().getWorld(), uuid))) {
|
.ownedBy(uuid).asCollection()) {
|
||||||
PlotCluster current = plot.getCluster();
|
PlotCluster current = plot.getCluster();
|
||||||
if (current != null && current.equals(cluster)) {
|
if (current != null && current.equals(cluster)) {
|
||||||
plot.unclaim();
|
plot.unclaim();
|
||||||
|
@ -80,7 +80,8 @@ public class Condense extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int radius = Integer.parseInt(args[2]);
|
int radius = Integer.parseInt(args[2]);
|
||||||
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots(area));
|
|
||||||
|
final List<Plot> plots = new ArrayList<>(area.getPlots());
|
||||||
// remove non base plots
|
// remove non base plots
|
||||||
Iterator<Plot> iterator = plots.iterator();
|
Iterator<Plot> iterator = plots.iterator();
|
||||||
int maxSize = 0;
|
int maxSize = 0;
|
||||||
|
@ -37,6 +37,7 @@ import com.plotsquared.core.plot.PlotArea;
|
|||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -85,7 +86,7 @@ public class DatabaseCommand extends SubCommand {
|
|||||||
plots = PlotSquared.get().sortPlotsByTemp(area.getPlots());
|
plots = PlotSquared.get().sortPlotsByTemp(area.getPlots());
|
||||||
args = Arrays.copyOfRange(args, 1, args.length);
|
args = Arrays.copyOfRange(args, 1, args.length);
|
||||||
} else {
|
} else {
|
||||||
plots = PlotSquared.get().sortPlotsByTemp(PlotSquared.get().getPlots());
|
plots = PlotSquared.get().sortPlotsByTemp(PlotQuery.newQuery().allPlots().asList());
|
||||||
}
|
}
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
MainUtil.sendMessage(player, getUsage());
|
MainUtil.sendMessage(player, getUsage());
|
||||||
|
@ -33,6 +33,7 @@ import com.plotsquared.core.util.RegionManager;
|
|||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.entity.EntityCategories;
|
import com.plotsquared.core.util.entity.EntityCategories;
|
||||||
import com.plotsquared.core.util.entity.EntityCategory;
|
import com.plotsquared.core.util.entity.EntityCategory;
|
||||||
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.plotsquared.core.uuid.UUIDMapping;
|
import com.plotsquared.core.uuid.UUIDMapping;
|
||||||
import com.sk89q.worldedit.world.entity.EntityType;
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
@ -119,7 +120,7 @@ public class Debug extends SubCommand {
|
|||||||
information.append(getSection(section, "PlotArea"));
|
information.append(getSection(section, "PlotArea"));
|
||||||
information.append(
|
information.append(
|
||||||
getLine(line, "Plot Worlds", StringMan.join(PlotSquared.get().getPlotAreaManager().getAllPlotAreas(), ", ")));
|
getLine(line, "Plot Worlds", StringMan.join(PlotSquared.get().getPlotAreaManager().getAllPlotAreas(), ", ")));
|
||||||
information.append(getLine(line, "Owned Plots", PlotSquared.get().getPlots().size()));
|
information.append(getLine(line, "Owned Plots", PlotQuery.newQuery().allPlots().count()));
|
||||||
information.append(getSection(section, "Messages"));
|
information.append(getSection(section, "Messages"));
|
||||||
information.append(getLine(line, "Total Messages", Captions.values().length));
|
information.append(getLine(line, "Total Messages", Captions.values().length));
|
||||||
information.append(getLine(line, "View all captions", "/plot debug msg"));
|
information.append(getLine(line, "View all captions", "/plot debug msg"));
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.database.DBFunc;
|
import com.plotsquared.core.database.DBFunc;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
@CommandDeclaration(command = "debugsavetest",
|
@CommandDeclaration(command = "debugsavetest",
|
||||||
permission = "plots.debugsavetest",
|
permission = "plots.debugsavetest",
|
||||||
@ -42,7 +42,7 @@ import java.util.ArrayList;
|
|||||||
public class DebugSaveTest extends SubCommand {
|
public class DebugSaveTest extends SubCommand {
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots());
|
final List<Plot> plots = PlotQuery.newQuery().allPlots().asList();
|
||||||
MainUtil.sendMessage(player, "&6Starting `DEBUGSAVETEST`");
|
MainUtil.sendMessage(player, "&6Starting `DEBUGSAVETEST`");
|
||||||
DBFunc.createPlotsAndData(plots,
|
DBFunc.createPlotsAndData(plots,
|
||||||
() -> MainUtil.sendMessage(player, "&6Database sync finished!"));
|
() -> MainUtil.sendMessage(player, "&6Database sync finished!"));
|
||||||
|
@ -132,7 +132,7 @@ public class HomeCommand extends Command {
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// we assume args[0] is a plot area and args[1] an identifier
|
// we assume args[0] is a plot area and args[1] an identifier
|
||||||
PlotArea plotArea = PlotSquared.get().getPlotAreaByString(args[0]);
|
PlotArea plotArea = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[0]);
|
||||||
identifier = args[1];
|
identifier = args[1];
|
||||||
if (plotArea == null) {
|
if (plotArea == null) {
|
||||||
// invalid command, therefore no plots
|
// invalid command, therefore no plots
|
||||||
|
@ -51,7 +51,7 @@ public class Reload extends SubCommand {
|
|||||||
// loaded during startup unfortunately.
|
// loaded during startup unfortunately.
|
||||||
PlotSquared.get().setupConfigs();
|
PlotSquared.get().setupConfigs();
|
||||||
Captions.load(PlotSquared.get().translationFile);
|
Captions.load(PlotSquared.get().translationFile);
|
||||||
PlotSquared.get().forEachPlotArea(area -> {
|
PlotSquared.get().getPlotAreaManager().forEachPlotArea(area -> {
|
||||||
ConfigurationSection worldSection = PlotSquared.get().worlds
|
ConfigurationSection worldSection = PlotSquared.get().worlds
|
||||||
.getConfigurationSection("worlds." + area.getWorldName());
|
.getConfigurationSection("worlds." + area.getWorldName());
|
||||||
if (worldSection == null) {
|
if (worldSection == null) {
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
|
|
||||||
@CommandDeclaration(command = "target",
|
@CommandDeclaration(command = "target",
|
||||||
usage = "/plot target <<plot>|nearest>",
|
usage = "/plot target <<plot>|nearest>",
|
||||||
@ -54,7 +54,7 @@ public class Target extends SubCommand {
|
|||||||
Plot target = null;
|
Plot target = null;
|
||||||
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
||||||
int distance = Integer.MAX_VALUE;
|
int distance = Integer.MAX_VALUE;
|
||||||
for (Plot plot : PlotSquared.get().getPlots(location.getWorld())) {
|
for (Plot plot : PlotQuery.newQuery().inWorld(location.getWorld()).asCollection()) {
|
||||||
double current = plot.getCenterSynchronous().getEuclideanDistanceSquared(location);
|
double current = plot.getCenterSynchronous().getEuclideanDistanceSquared(location);
|
||||||
if (current < distance) {
|
if (current < distance) {
|
||||||
distance = (int) current;
|
distance = (int) current;
|
||||||
|
@ -37,6 +37,7 @@ import com.plotsquared.core.util.MainUtil;
|
|||||||
import com.plotsquared.core.util.RegionManager;
|
import com.plotsquared.core.util.RegionManager;
|
||||||
import com.plotsquared.core.util.RegionUtil;
|
import com.plotsquared.core.util.RegionUtil;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
@ -52,6 +53,7 @@ import java.nio.file.attribute.BasicFileAttributes;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@CommandDeclaration(command = "trim",
|
@CommandDeclaration(command = "trim",
|
||||||
@ -129,7 +131,7 @@ public class Trim extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(null, "Collecting region data...");
|
MainUtil.sendMessage(null, "Collecting region data...");
|
||||||
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots(world));
|
final List<Plot> plots = PlotQuery.newQuery().inWorld(world).asList();
|
||||||
if (ExpireManager.IMP != null) {
|
if (ExpireManager.IMP != null) {
|
||||||
plots.removeAll(ExpireManager.IMP.getPendingExpired());
|
plots.removeAll(ExpireManager.IMP.getPendingExpired());
|
||||||
}
|
}
|
||||||
@ -206,7 +208,7 @@ public class Trim extends SubCommand {
|
|||||||
int bz = cbz << 4;
|
int bz = cbz << 4;
|
||||||
CuboidRegion region =
|
CuboidRegion region =
|
||||||
RegionUtil.createRegion(bx, bx + 511, bz, bz + 511);
|
RegionUtil.createRegion(bx, bx + 511, bz, bz + 511);
|
||||||
for (Plot plot : PlotSquared.get().getPlots(world)) {
|
for (Plot plot : PlotQuery.newQuery().inWorld(world).asCollection()) {
|
||||||
Location bot = plot.getBottomAbs();
|
Location bot = plot.getBottomAbs();
|
||||||
Location top = plot.getExtendedTopAbs();
|
Location top = plot.getExtendedTopAbs();
|
||||||
CuboidRegion plotReg = RegionUtil
|
CuboidRegion plotReg = RegionUtil
|
||||||
|
@ -198,7 +198,7 @@ public class Visit extends Command {
|
|||||||
if (throwable instanceof TimeoutException) {
|
if (throwable instanceof TimeoutException) {
|
||||||
// The request timed out
|
// The request timed out
|
||||||
MainUtil.sendMessage(player, Captions.FETCHING_PLAYERS_TIMEOUT);
|
MainUtil.sendMessage(player, Captions.FETCHING_PLAYERS_TIMEOUT);
|
||||||
} else if (uuid != null && !PlotSquared.get().hasPlot(uuid)) {
|
} else if (uuid != null && !PlotQuery.newQuery().ownedBy(uuid).anyMatch()) {
|
||||||
// It was a valid UUID but the player has no plots
|
// It was a valid UUID but the player has no plots
|
||||||
MainUtil.sendMessage(player, Captions.PLAYER_NO_PLOTS);
|
MainUtil.sendMessage(player, Captions.PLAYER_NO_PLOTS);
|
||||||
} else if (uuid == null) {
|
} else if (uuid == null) {
|
||||||
|
@ -47,6 +47,7 @@ import com.plotsquared.core.plot.world.SinglePlotArea;
|
|||||||
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
@ -67,7 +68,6 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The abstract class supporting {@code BukkitPlayer} and {@code SpongePlayer}.
|
* The abstract class supporting {@code BukkitPlayer} and {@code SpongePlayer}.
|
||||||
@ -270,7 +270,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
}
|
}
|
||||||
final AtomicInteger count = new AtomicInteger(0);
|
final AtomicInteger count = new AtomicInteger(0);
|
||||||
final UUID uuid = getUUID();
|
final UUID uuid = getUUID();
|
||||||
PlotSquared.get().forEachPlotArea(value -> {
|
PlotSquared.get().getPlotAreaManager().forEachPlotArea(value -> {
|
||||||
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
|
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
|
||||||
for (Plot plot : value.getPlotsAbs(uuid)) {
|
for (Plot plot : value.getPlotsAbs(uuid)) {
|
||||||
if (!DoneFlag.isDone(plot)) {
|
if (!DoneFlag.isDone(plot)) {
|
||||||
@ -289,7 +289,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
return getClusterCount(getLocation().getWorld());
|
return getClusterCount(getLocation().getWorld());
|
||||||
}
|
}
|
||||||
final AtomicInteger count = new AtomicInteger(0);
|
final AtomicInteger count = new AtomicInteger(0);
|
||||||
PlotSquared.get().forEachPlotArea(value -> {
|
PlotSquared.get().getPlotAreaManager().forEachPlotArea(value -> {
|
||||||
for (PlotCluster cluster : value.getClusters()) {
|
for (PlotCluster cluster : value.getClusters()) {
|
||||||
if (cluster.isOwner(getUUID())) {
|
if (cluster.isOwner(getUUID())) {
|
||||||
count.incrementAndGet();
|
count.incrementAndGet();
|
||||||
@ -340,7 +340,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
* @see #getPlotCount() for the number of plots
|
* @see #getPlotCount() for the number of plots
|
||||||
*/
|
*/
|
||||||
public Set<Plot> getPlots() {
|
public Set<Plot> getPlots() {
|
||||||
return PlotSquared.get().getPlots(this);
|
return PlotQuery.newQuery().ownedBy(this).asSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -614,7 +614,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
*/
|
*/
|
||||||
public int getPlayerClusterCount() {
|
public int getPlayerClusterCount() {
|
||||||
final AtomicInteger count = new AtomicInteger();
|
final AtomicInteger count = new AtomicInteger();
|
||||||
PlotSquared.get().forEachPlotArea(value -> count.addAndGet(value.getClusters().size()));
|
PlotSquared.get().getPlotAreaManager().forEachPlotArea(value -> count.addAndGet(value.getClusters().size()));
|
||||||
return count.get();
|
return count.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,9 +625,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
* @return a {@code Set} of plots this player owns in the provided world
|
* @return a {@code Set} of plots this player owns in the provided world
|
||||||
*/
|
*/
|
||||||
public Set<Plot> getPlots(String world) {
|
public Set<Plot> getPlots(String world) {
|
||||||
UUID uuid = getUUID();
|
return PlotQuery.newQuery().inWorld(world).ownedBy(getUUID()).asSet();
|
||||||
return PlotSquared.get().getPlots(world).stream().filter(plot -> plot.isOwner(uuid))
|
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populatePersistentMetaMap() {
|
public void populatePersistentMetaMap() {
|
||||||
|
@ -44,6 +44,7 @@ import com.plotsquared.core.plot.flag.implementations.KeepFlag;
|
|||||||
import com.plotsquared.core.plot.message.PlotMessage;
|
import com.plotsquared.core.plot.message.PlotMessage;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
@ -295,7 +296,7 @@ public class ExpireManager {
|
|||||||
}
|
}
|
||||||
this.running = 2;
|
this.running = 2;
|
||||||
final ConcurrentLinkedDeque<Plot> plots =
|
final ConcurrentLinkedDeque<Plot> plots =
|
||||||
new ConcurrentLinkedDeque<>(PlotSquared.get().getPlots());
|
new ConcurrentLinkedDeque<>(PlotQuery.newQuery().allPlots().asList());
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
final Runnable task = this;
|
final Runnable task = this;
|
||||||
|
@ -29,10 +29,12 @@ import com.plotsquared.core.PlotSquared;
|
|||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotFilter;
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -119,11 +121,13 @@ public class ExpiryTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<Plot> getPlotsToCheck() {
|
public Set<Plot> getPlotsToCheck() {
|
||||||
return PlotSquared.get().getPlots(new PlotFilter() {
|
final Collection<PlotArea> areas = new LinkedList<>();
|
||||||
@Override public boolean allowsArea(PlotArea area) {
|
for (final PlotArea plotArea : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) {
|
||||||
return ExpiryTask.this.allowsArea(area);
|
if (this.allowsArea(plotArea)) {
|
||||||
|
areas.add(plotArea);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
return PlotQuery.newQuery().inAreas(areas).asSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean applies(long diff) {
|
public boolean applies(long diff) {
|
||||||
|
@ -31,6 +31,7 @@ import com.plotsquared.core.generator.HybridUtils;
|
|||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
|
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
|
||||||
@ -101,7 +102,7 @@ public class PlotAnalysis {
|
|||||||
}
|
}
|
||||||
running = true;
|
running = true;
|
||||||
PlotSquared.debug(" - Fetching all plots");
|
PlotSquared.debug(" - Fetching all plots");
|
||||||
final ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots());
|
final List<Plot> plots = PlotQuery.newQuery().allPlots().asList();
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
Iterator<Plot> iterator = plots.iterator();
|
Iterator<Plot> iterator = plots.iterator();
|
||||||
|
@ -27,14 +27,17 @@ package com.plotsquared.core.plot.world;
|
|||||||
|
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
|
import com.plotsquared.core.plot.PlotAreaType;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import lombok.NonNull;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public interface PlotAreaManager {
|
public interface PlotAreaManager {
|
||||||
|
|
||||||
@ -200,4 +203,26 @@ public interface PlotAreaManager {
|
|||||||
return this.getPlotAreas(world, null).length != 0;
|
return this.getPlotAreas(world, null).length != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a given world is an augmented plot world
|
||||||
|
*
|
||||||
|
* @param world World name
|
||||||
|
* @return {@code true} if the world is augmented plot world, {@code false} if not
|
||||||
|
*/
|
||||||
|
default boolean isAugmented(@NonNull final String world) {
|
||||||
|
final PlotArea[] areas = this.getPlotAreas(world, null);
|
||||||
|
return areas != null && (areas.length > 1 || areas[0].getType() != PlotAreaType.NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform an action on each recognized plot area
|
||||||
|
*
|
||||||
|
* @param action Action to perform
|
||||||
|
*/
|
||||||
|
default void forEachPlotArea(@NotNull final Consumer<? super PlotArea> action) {
|
||||||
|
for (final PlotArea area : this.getAllPlotAreas()) {
|
||||||
|
action.accept(area);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public abstract class ChunkManager {
|
|||||||
public static void setChunkInPlotArea(RunnableVal<ScopedLocalBlockQueue> force,
|
public static void setChunkInPlotArea(RunnableVal<ScopedLocalBlockQueue> force,
|
||||||
RunnableVal<ScopedLocalBlockQueue> add, String world, BlockVector2 loc) {
|
RunnableVal<ScopedLocalBlockQueue> add, String world, BlockVector2 loc) {
|
||||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
||||||
if (PlotSquared.get().isAugmented(world) && PlotSquared.get().isNonStandardGeneration(world, loc)) {
|
if (PlotSquared.get().getPlotAreaManager().isAugmented(world) && PlotSquared.get().isNonStandardGeneration(world, loc)) {
|
||||||
int blockX = loc.getX() << 4;
|
int blockX = loc.getX() << 4;
|
||||||
int blockZ = loc.getZ() << 4;
|
int blockZ = loc.getZ() << 4;
|
||||||
ScopedLocalBlockQueue scoped =
|
ScopedLocalBlockQueue scoped =
|
||||||
|
@ -47,6 +47,7 @@ import com.plotsquared.core.plot.flag.implementations.DescriptionFlag;
|
|||||||
import com.plotsquared.core.plot.flag.implementations.ServerPlotFlag;
|
import com.plotsquared.core.plot.flag.implementations.ServerPlotFlag;
|
||||||
import com.plotsquared.core.plot.flag.types.DoubleFlag;
|
import com.plotsquared.core.plot.flag.types.DoubleFlag;
|
||||||
import com.plotsquared.core.util.net.AbstractDelegateOutputStream;
|
import com.plotsquared.core.util.net.AbstractDelegateOutputStream;
|
||||||
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.plotsquared.core.uuid.UUIDMapping;
|
import com.plotsquared.core.uuid.UUIDMapping;
|
||||||
@ -472,7 +473,7 @@ public class MainUtil {
|
|||||||
|
|
||||||
PlotArea area = null;
|
PlotArea area = null;
|
||||||
String alias = null;
|
String alias = null;
|
||||||
for (Plot plot : PlotSquared.get().getPlots()) {
|
for (Plot plot : PlotQuery.newQuery().allPlots().asList()) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (!uuids.isEmpty()) {
|
if (!uuids.isEmpty()) {
|
||||||
for (UUID uuid : uuids) {
|
for (UUID uuid : uuids) {
|
||||||
@ -516,7 +517,7 @@ public class MainUtil {
|
|||||||
* @param message If a message should be sent to the player if a plot cannot be found
|
* @param message If a message should be sent to the player if a plot cannot be found
|
||||||
* @return The plot if only 1 result is found, or null
|
* @return The plot if only 1 result is found, or null
|
||||||
*/
|
*/
|
||||||
@Nullable public static Plot getPlotFromString(PlotPlayer player, String arg, boolean message) {
|
@Nullable public static Plot getPlotFromString(PlotPlayer<?> player, String arg, boolean message) {
|
||||||
if (arg == null) {
|
if (arg == null) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
if (message) {
|
if (message) {
|
||||||
@ -548,7 +549,7 @@ public class MainUtil {
|
|||||||
} else {
|
} else {
|
||||||
Collection<Plot> plots;
|
Collection<Plot> plots;
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
plots = PlotSquared.get().getPlots();
|
plots = PlotQuery.newQuery().allPlots().asList();
|
||||||
} else {
|
} else {
|
||||||
plots = area.getPlots();
|
plots = area.getPlots();
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ public class TabCompletions {
|
|||||||
*/
|
*/
|
||||||
@NotNull public List<Command> completeAreas(@NotNull final String input) {
|
@NotNull public List<Command> completeAreas(@NotNull final String input) {
|
||||||
final List<Command> completions = new ArrayList<>();
|
final List<Command> completions = new ArrayList<>();
|
||||||
for (final PlotArea area : PlotSquared.get().getPlotAreas()) {
|
for (final PlotArea area : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) {
|
||||||
String areaName = area.getWorldName();
|
String areaName = area.getWorldName();
|
||||||
if (area.getId() != null) {
|
if (area.getId() != null) {
|
||||||
areaName += ";" + area.getId();
|
areaName += ";" + area.getId();
|
||||||
|
@ -27,13 +27,20 @@ package com.plotsquared.core.util.query;
|
|||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
class GlobalPlotProvider implements PlotProvider {
|
class GlobalPlotProvider implements PlotProvider {
|
||||||
|
|
||||||
@Override public Collection<Plot> getPlots() {
|
@Override public Collection<Plot> getPlots() {
|
||||||
return PlotSquared.get().getPlots();
|
final Set<Plot> plots = new HashSet<>();
|
||||||
|
for (final PlotArea plotArea : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) {
|
||||||
|
plots.addAll(plotArea.getPlots());
|
||||||
|
}
|
||||||
|
return plots;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -376,6 +377,25 @@ public final class PlotQuery {
|
|||||||
return this.asList();
|
return this.asList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform an action on each plot returned by the query
|
||||||
|
*
|
||||||
|
* @param consumer Plot consumer
|
||||||
|
*/
|
||||||
|
public void forEach(@NotNull final Consumer<Plot> consumer) {
|
||||||
|
Preconditions.checkNotNull(consumer, "Consumer may not be null");
|
||||||
|
this.asCollection().forEach(consumer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amount of plots contained in the query result
|
||||||
|
*
|
||||||
|
* @return Result count
|
||||||
|
*/
|
||||||
|
public int count() {
|
||||||
|
return this.asList().size();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether any provided plot matches the given filters.
|
* Get whether any provided plot matches the given filters.
|
||||||
* If no plot was provided, false will be returned.
|
* If no plot was provided, false will be returned.
|
||||||
|
Loading…
Reference in New Issue
Block a user