mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
Inject PlotAreaManager
This commit is contained in:
@ -131,7 +131,6 @@ import java.util.zip.ZipInputStream;
|
||||
@SuppressWarnings({"WeakerAccess"})
|
||||
public class PlotSquared {
|
||||
|
||||
private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
|
||||
private static PlotSquared instance;
|
||||
|
||||
// Implementation
|
||||
@ -285,7 +284,7 @@ public class PlotSquared {
|
||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "&6" + this.platform.getPluginName()
|
||||
+ " hooked into WorldEdit.");
|
||||
this.worldedit = WorldEdit.getInstance();
|
||||
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
||||
WorldEdit.getInstance().getEventBus().register(new WESubscriber(this.plotAreaManager));
|
||||
if (Settings.Enabled_Components.COMMANDS) {
|
||||
new WE_Anywhere();
|
||||
}
|
||||
@ -431,7 +430,7 @@ public class PlotSquared {
|
||||
ExpireManager.IMP = new ExpireManager();
|
||||
ExpireManager.IMP.runAutomatedTask();
|
||||
for (Settings.Auto_Clear settings : Settings.AUTO_CLEAR.getInstances()) {
|
||||
ExpiryTask task = new ExpiryTask(settings);
|
||||
ExpiryTask task = new ExpiryTask(settings, this.plotAreaManager);
|
||||
ExpireManager.IMP.addTask(task);
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ import com.plotsquared.core.plot.PlotAreaTerrainType;
|
||||
import com.plotsquared.core.plot.PlotAreaType;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.message.PlotMessage;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.MathMan;
|
||||
@ -65,6 +66,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@ -85,6 +87,12 @@ import java.util.Set;
|
||||
confirmation = true)
|
||||
public class Area extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Area(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
@ -104,7 +112,7 @@ public class Area extends SubCommand {
|
||||
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NEEDS_NAME);
|
||||
return false;
|
||||
}
|
||||
final PlotArea existingArea = PlotSquared.get().getPlotAreaManager().getPlotArea(player.getLocation().getWorldName(), args[1]);
|
||||
final PlotArea existingArea = this.plotAreaManager.getPlotArea(player.getLocation().getWorldName(), args[1]);
|
||||
if (existingArea != null && existingArea.getId().equalsIgnoreCase(args[1])) {
|
||||
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NAME_TAKEN);
|
||||
return false;
|
||||
@ -126,7 +134,7 @@ public class Area extends SubCommand {
|
||||
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NOT_SQUARE);
|
||||
return false;
|
||||
}
|
||||
if (PlotSquared.get().getPlotAreaManager().getPlotAreas(
|
||||
if (this.plotAreaManager.getPlotAreas(
|
||||
Objects.requireNonNull(playerSelectedRegion.getWorld()).getName(), CuboidRegion.makeCuboid(playerSelectedRegion)).length != 0) {
|
||||
MainUtil.sendMessage(player, Captions.SINGLE_AREA_OVERLAPPING);
|
||||
}
|
||||
@ -276,7 +284,7 @@ public class Area extends SubCommand {
|
||||
final int offsetX = bx - (area.ROAD_WIDTH == 0 ? 0 : lower);
|
||||
final int offsetZ = bz - (area.ROAD_WIDTH == 0 ? 0 : lower);
|
||||
final CuboidRegion region = RegionUtil.createRegion(bx, tx, bz, tz);
|
||||
final Set<PlotArea> areas = PlotSquared.get().getPlotAreaManager()
|
||||
final Set<PlotArea> areas = this.plotAreaManager
|
||||
.getPlotAreasSet(area.getWorldName(), region);
|
||||
if (!areas.isEmpty()) {
|
||||
Captions.CLUSTER_INTERSECTION
|
||||
@ -342,12 +350,12 @@ public class Area extends SubCommand {
|
||||
builder.worldName(split[0]);
|
||||
final HybridPlotWorld pa = new HybridPlotWorld(builder.worldName(), id,
|
||||
PlotSquared.platform().getDefaultGenerator(), null, null);
|
||||
PlotArea other = PlotSquared.get().getPlotAreaManager().getPlotArea(pa.getWorldName(), id);
|
||||
PlotArea other = this.plotAreaManager.getPlotArea(pa.getWorldName(), id);
|
||||
if (other != null && Objects.equals(pa.getId(), other.getId())) {
|
||||
Captions.SETUP_WORLD_TAKEN.send(player, pa.toString());
|
||||
return false;
|
||||
}
|
||||
Set<PlotArea> areas = PlotSquared.get().getPlotAreaManager().getPlotAreasSet(pa.getWorldName());
|
||||
Set<PlotArea> areas = this.plotAreaManager.getPlotAreasSet(pa.getWorldName());
|
||||
if (!areas.isEmpty()) {
|
||||
PlotArea area = areas.iterator().next();
|
||||
pa.setType(area.getType());
|
||||
@ -492,7 +500,7 @@ public class Area extends SubCommand {
|
||||
area = player.getApplicablePlotArea();
|
||||
break;
|
||||
case 2:
|
||||
area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[1]);
|
||||
area = this.plotAreaManager.getPlotAreaByString(args[1]);
|
||||
break;
|
||||
default:
|
||||
Captions.COMMAND_SYNTAX.send(player, getCommandString() + " info [area]");
|
||||
@ -554,7 +562,7 @@ public class Area extends SubCommand {
|
||||
Captions.COMMAND_SYNTAX.send(player, getCommandString() + " list [#]");
|
||||
return false;
|
||||
}
|
||||
final List<PlotArea> areas = new ArrayList<>(Arrays.asList(PlotSquared.get().getPlotAreaManager().getAllPlotAreas()));
|
||||
final List<PlotArea> areas = new ArrayList<>(Arrays.asList(this.plotAreaManager.getAllPlotAreas()));
|
||||
paginate(player, areas, 8, page,
|
||||
new RunnableVal3<Integer, PlotArea, PlotMessage>() {
|
||||
@Override public void run(Integer i, PlotArea area, PlotMessage message) {
|
||||
@ -637,7 +645,7 @@ public class Area extends SubCommand {
|
||||
Captions.COMMAND_SYNTAX.send(player, "/plot visit [area]");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[1]);
|
||||
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
|
||||
if (area == null) {
|
||||
Captions.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||
return false;
|
||||
|
@ -40,6 +40,7 @@ import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotAreaType;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.EconHandler;
|
||||
import com.plotsquared.core.util.Expression;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
@ -47,6 +48,7 @@ import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.task.AutoClaimFinishTask;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -61,6 +63,12 @@ import java.util.Set;
|
||||
usage = "/plot auto [length,width]")
|
||||
public class Auto extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Auto(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Deprecated public static PlotId getNextPlotId(PlotId id, int step) {
|
||||
return id.getNextId(step);
|
||||
}
|
||||
@ -158,7 +166,7 @@ public class Auto extends SubCommand {
|
||||
PlotArea plotarea = player.getApplicablePlotArea();
|
||||
if (plotarea == null) {
|
||||
if (EconHandler.getEconHandler() != null) {
|
||||
for (PlotArea area : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) {
|
||||
for (PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
||||
if (EconHandler.getEconHandler()
|
||||
.hasPermission(area.getWorldName(), player.getName(), "plots.auto")) {
|
||||
if (plotarea != null) {
|
||||
@ -169,8 +177,8 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PlotSquared.get().getPlotAreaManager().getAllPlotAreas().length == 1) {
|
||||
plotarea = PlotSquared.get().getPlotAreaManager().getAllPlotAreas()[0];
|
||||
if (this.plotAreaManager.getAllPlotAreas().length == 1) {
|
||||
plotarea = this.plotAreaManager.getAllPlotAreas()[0];
|
||||
}
|
||||
if (plotarea == null) {
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
|
@ -25,15 +25,16 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.MathMan;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -54,12 +55,18 @@ public class Condense extends SubCommand {
|
||||
|
||||
public static boolean TASK = false;
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Condense(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
MainUtil.sendMessage(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[0]);
|
||||
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]);
|
||||
if (area == null || !WorldUtil.IMP.isWorld(area.getWorldName())) {
|
||||
MainUtil.sendMessage(player, "INVALID AREA");
|
||||
return false;
|
||||
|
@ -35,10 +35,12 @@ import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.query.PlotQuery;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
@ -57,6 +59,12 @@ import java.util.Map.Entry;
|
||||
usage = "/plot database [area] <sqlite|mysql|import>")
|
||||
public class DatabaseCommand extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public DatabaseCommand(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
public static void insertPlots(final SQLManager manager, final List<Plot> plots,
|
||||
final PlotPlayer player) {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
@ -81,7 +89,7 @@ public class DatabaseCommand extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
List<Plot> plots;
|
||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[0]);
|
||||
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]);
|
||||
if (area != null) {
|
||||
plots = PlotSquared.get().sortPlotsByTemp(area.getPlots());
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
@ -117,7 +125,7 @@ public class DatabaseCommand extends SubCommand {
|
||||
plots = new ArrayList<>();
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
||||
String areaName = entry.getKey();
|
||||
PlotArea pa = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(areaName);
|
||||
PlotArea pa = this.plotAreaManager.getPlotAreaByString(areaName);
|
||||
if (pa != null) {
|
||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
Plot plot = entry2.getValue();
|
||||
|
@ -28,6 +28,7 @@ package com.plotsquared.core.command;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.RegionManager;
|
||||
import com.plotsquared.core.util.StringMan;
|
||||
@ -37,6 +38,7 @@ import com.plotsquared.core.util.query.PlotQuery;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.plotsquared.core.uuid.UUIDMapping;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
@ -49,6 +51,12 @@ import java.util.Map;
|
||||
permission = "plots.admin")
|
||||
public class Debug extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Debug(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
if (args.length > 0) {
|
||||
if ("player".equalsIgnoreCase(args[0])) {
|
||||
@ -119,7 +127,7 @@ public class Debug extends SubCommand {
|
||||
information.append(header);
|
||||
information.append(getSection(section, "PlotArea"));
|
||||
information.append(
|
||||
getLine(line, "Plot Worlds", StringMan.join(PlotSquared.get().getPlotAreaManager().getAllPlotAreas(), ", ")));
|
||||
getLine(line, "Plot Worlds", StringMan.join(this.plotAreaManager.getAllPlotAreas(), ", ")));
|
||||
information.append(getLine(line, "Owned Plots", PlotQuery.newQuery().allPlots().count()));
|
||||
information.append(getSection(section, "Messages"));
|
||||
information.append(getLine(line, "Total Messages", Captions.values().length));
|
||||
|
@ -44,6 +44,7 @@ import com.plotsquared.core.plot.expiration.PlotAnalysis;
|
||||
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||
import com.plotsquared.core.plot.message.PlotMessage;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||
import com.plotsquared.core.util.ChunkManager;
|
||||
import com.plotsquared.core.util.EconHandler;
|
||||
@ -59,6 +60,7 @@ import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import javax.script.ScriptContext;
|
||||
@ -81,10 +83,13 @@ import java.util.concurrent.CompletableFuture;
|
||||
aliases = {"exec", "$"},
|
||||
category = CommandCategory.DEBUG)
|
||||
public class DebugExec extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private ScriptEngine engine;
|
||||
private Bindings scope;
|
||||
|
||||
public DebugExec() {
|
||||
public DebugExec(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
init();
|
||||
/*
|
||||
try {
|
||||
@ -259,7 +264,7 @@ public class DebugExec extends SubCommand {
|
||||
"&cInvalid syntax: /plot debugexec start-rgar <world>");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[1]);
|
||||
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
|
||||
if (area == null) {
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD, args[1]);
|
||||
return false;
|
||||
|
@ -36,6 +36,7 @@ import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
@ -47,8 +48,12 @@ import java.util.concurrent.CompletableFuture;
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
category = CommandCategory.TELEPORT)
|
||||
public class DebugImportWorlds extends Command {
|
||||
public DebugImportWorlds() {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public DebugImportWorlds(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
super(MainCommand.getInstance(), true);
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,12 +61,11 @@ public class DebugImportWorlds extends Command {
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
// UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8))
|
||||
PlotAreaManager pam = PlotSquared.get().getPlotAreaManager();
|
||||
if (!(pam instanceof SinglePlotAreaManager)) {
|
||||
if (!(this.plotAreaManager instanceof SinglePlotAreaManager)) {
|
||||
player.sendMessage("Must be a single plot area!");
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
SinglePlotArea area = ((SinglePlotAreaManager) pam).getArea();
|
||||
SinglePlotArea area = ((SinglePlotAreaManager) this.plotAreaManager).getArea();
|
||||
PlotId id = new PlotId(0, 0);
|
||||
File container = PlotSquared.platform().getWorldContainer();
|
||||
if (container.equals(new File("."))) {
|
||||
|
@ -31,11 +31,13 @@ import com.plotsquared.core.database.DBFunc;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.TabCompletions;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -50,8 +52,11 @@ import java.util.concurrent.TimeoutException;
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Deny extends SubCommand {
|
||||
|
||||
public Deny() {
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Deny(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
super(Argument.PlayerName);
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
@ -136,8 +141,7 @@ public class Deny extends SubCommand {
|
||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorldName());
|
||||
MainUtil.sendMessage(player, Captions.YOU_GOT_DENIED);
|
||||
if (plot.equals(spawn.getPlot())) {
|
||||
Location newSpawn =
|
||||
WorldUtil.IMP.getSpawn(PlotSquared.get().getPlotAreaManager().getAllWorlds()[0]);
|
||||
Location newSpawn = WorldUtil.IMP.getSpawn(this.plotAreaManager.getAllWorlds()[0]);
|
||||
if (plot.equals(newSpawn.getPlot())) {
|
||||
// Kick from server if you can't be teleported to spawn
|
||||
player.kick(Captions.YOU_GOT_DENIED.getTranslated());
|
||||
|
@ -25,12 +25,12 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.SchematicHandler;
|
||||
@ -38,6 +38,7 @@ import com.plotsquared.core.util.StringMan;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
@ -50,9 +51,15 @@ import java.net.URL;
|
||||
permission = "plots.download")
|
||||
public class Download extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Download(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
String world = player.getLocation().getWorldName();
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
||||
if (!this.plotAreaManager.hasPlotArea(world)) {
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
|
@ -25,13 +25,13 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.events.TeleportCause;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.MathMan;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
@ -55,8 +55,12 @@ import java.util.concurrent.CompletableFuture;
|
||||
requiredType = RequiredType.PLAYER,
|
||||
category = CommandCategory.TELEPORT)
|
||||
public class HomeCommand extends Command {
|
||||
public HomeCommand() {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public HomeCommand(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
super(MainCommand.getInstance(), true);
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
private void home(@NotNull final PlotPlayer<?> player,
|
||||
@ -132,7 +136,7 @@ public class HomeCommand extends Command {
|
||||
break;
|
||||
case 2:
|
||||
// we assume args[0] is a plot area and args[1] an identifier
|
||||
PlotArea plotArea = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[0]);
|
||||
final PlotArea plotArea = this.plotAreaManager.getPlotAreaByString(args[0]);
|
||||
identifier = args[1];
|
||||
if (plotArea == null) {
|
||||
// invalid command, therefore no plots
|
||||
|
@ -31,10 +31,12 @@ import com.plotsquared.core.database.DBFunc;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.TabCompletions;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -52,8 +54,11 @@ import java.util.concurrent.TimeoutException;
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Kick extends SubCommand {
|
||||
|
||||
public Kick() {
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Kick(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
super(Argument.PlayerName);
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
@ -108,8 +113,7 @@ public class Kick extends SubCommand {
|
||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorldName());
|
||||
Captions.YOU_GOT_KICKED.send(player2);
|
||||
if (plot.equals(spawn.getPlot())) {
|
||||
Location newSpawn = WorldUtil.IMP
|
||||
.getSpawn(PlotSquared.get().getPlotAreaManager().getAllWorlds()[0]);
|
||||
Location newSpawn = WorldUtil.IMP.getSpawn(this.plotAreaManager.getAllWorlds()[0]);
|
||||
if (plot.equals(newSpawn.getPlot())) {
|
||||
// Kick from server if you can't be teleported to spawn
|
||||
player2.kick(Captions.YOU_GOT_KICKED.getTranslated());
|
||||
|
@ -36,6 +36,7 @@ import com.plotsquared.core.plot.expiration.ExpireManager;
|
||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.PriceFlag;
|
||||
import com.plotsquared.core.plot.message.PlotMessage;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.EconHandler;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.MathMan;
|
||||
@ -47,6 +48,7 @@ import com.plotsquared.core.util.query.PlotQuery;
|
||||
import com.plotsquared.core.util.query.SortingStrategy;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import com.plotsquared.core.uuid.UUIDMapping;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -69,6 +71,12 @@ import java.util.stream.Collectors;
|
||||
usage = "/plot list <forsale|mine|shared|world|top|all|unowned|player|world|done|fuzzy <search...>> [#]")
|
||||
public class ListCmd extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public ListCmd(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
private String[] getArgumentList(PlotPlayer player) {
|
||||
List<String> args = new ArrayList<>();
|
||||
if (EconHandler.getEconHandler() != null && Permissions
|
||||
@ -297,7 +305,7 @@ public class ListCmd extends SubCommand {
|
||||
plotConsumer.accept(PlotQuery.newQuery().plotsBySearch(term));
|
||||
break;
|
||||
default:
|
||||
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(args[0])) {
|
||||
if (this.plotAreaManager.hasPlotArea(args[0])) {
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_WORLD)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_WORLD);
|
||||
|
@ -25,7 +25,6 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
@ -33,11 +32,13 @@ import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.schematic.Schematic;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.SchematicHandler;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
@ -52,9 +53,15 @@ import java.util.List;
|
||||
usage = "/plot load")
|
||||
public class Load extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
String world = player.getLocation().getWorldName();
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Load(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, final String[] args) {
|
||||
final String world = player.getLocation().getWorldName();
|
||||
if (!this.plotAreaManager.hasPlotArea(world)) {
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.location.Location;
|
||||
@ -32,6 +33,7 @@ import com.plotsquared.core.player.ConsolePlayer;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.EconHandler;
|
||||
import com.plotsquared.core.util.Expression;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
@ -60,61 +62,62 @@ public class MainCommand extends Command {
|
||||
public static MainCommand getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new MainCommand();
|
||||
final PlotAreaManager plotAreaManager = PlotSquared.get().getPlotAreaManager();
|
||||
new Caps();
|
||||
new Buy();
|
||||
new Save();
|
||||
new Load();
|
||||
new Save(plotAreaManager);
|
||||
new Load(plotAreaManager);
|
||||
new Confirm();
|
||||
new Template();
|
||||
new Download();
|
||||
new Template();
|
||||
new Template(plotAreaManager);
|
||||
new Download(plotAreaManager);
|
||||
new Template(plotAreaManager);
|
||||
new Setup();
|
||||
new Area();
|
||||
new Area(plotAreaManager);
|
||||
new DebugSaveTest();
|
||||
new DebugLoadTest();
|
||||
new CreateRoadSchematic();
|
||||
new DebugAllowUnsafe();
|
||||
new RegenAllRoads();
|
||||
new RegenAllRoads(plotAreaManager);
|
||||
new Claim();
|
||||
new Auto();
|
||||
new HomeCommand();
|
||||
new Visit();
|
||||
new Auto(plotAreaManager);
|
||||
new HomeCommand(plotAreaManager);
|
||||
new Visit(plotAreaManager);
|
||||
new Set();
|
||||
new Clear();
|
||||
new Delete();
|
||||
new Trust();
|
||||
new Add();
|
||||
new Leave();
|
||||
new Deny();
|
||||
new Deny(plotAreaManager);
|
||||
new Remove();
|
||||
new Info();
|
||||
new Near();
|
||||
new ListCmd();
|
||||
new Debug();
|
||||
new SchematicCmd();
|
||||
new ListCmd(plotAreaManager);
|
||||
new Debug(plotAreaManager);
|
||||
new SchematicCmd(plotAreaManager);
|
||||
new PluginCmd();
|
||||
new Purge();
|
||||
new Reload();
|
||||
new Purge(plotAreaManager);
|
||||
new Reload(plotAreaManager);
|
||||
new Relight();
|
||||
new Merge();
|
||||
new DebugPaste();
|
||||
new Unlink();
|
||||
new Kick();
|
||||
new Kick(plotAreaManager);
|
||||
new Inbox();
|
||||
new Comment();
|
||||
new DatabaseCommand();
|
||||
new DatabaseCommand(plotAreaManager);
|
||||
new Swap();
|
||||
new Music();
|
||||
new DebugRoadRegen();
|
||||
new Trust();
|
||||
new DebugExec();
|
||||
new DebugExec(plotAreaManager);
|
||||
new FlagCommand();
|
||||
new Target();
|
||||
new Move();
|
||||
new Condense();
|
||||
new Move(plotAreaManager);
|
||||
new Condense(plotAreaManager);
|
||||
new Copy();
|
||||
new Chat();
|
||||
new Trim();
|
||||
new Trim(plotAreaManager);
|
||||
new Done();
|
||||
new Continue();
|
||||
new Middle();
|
||||
@ -126,7 +129,7 @@ public class MainCommand extends Command {
|
||||
new Alias();
|
||||
new SetHome();
|
||||
new Cluster();
|
||||
new DebugImportWorlds();
|
||||
new DebugImportWorlds(plotAreaManager);
|
||||
new Backup();
|
||||
|
||||
if (Settings.Ratings.USE_LIKES) {
|
||||
@ -143,7 +146,7 @@ public class MainCommand extends Command {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static boolean onCommand(final PlotPlayer player, String... args) {
|
||||
public static boolean onCommand(final PlotPlayer<?> player, String... args) {
|
||||
if (args.length >= 1 && args[0].contains(":")) {
|
||||
String[] split2 = args[0].split(":");
|
||||
if (split2.length == 2) {
|
||||
|
@ -25,16 +25,17 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@ -46,6 +47,12 @@ import java.util.concurrent.CompletableFuture;
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Move extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Move(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
@ -70,7 +77,7 @@ public class Move extends SubCommand {
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[0]);
|
||||
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]);
|
||||
Plot plot2;
|
||||
if (area == null) {
|
||||
plot2 = MainUtil.getPlotFromString(player, args[0], true);
|
||||
|
@ -34,8 +34,10 @@ import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.StringMan;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -53,6 +55,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
confirmation = true)
|
||||
public class Purge extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Purge(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
@ -78,7 +86,7 @@ public class Purge extends SubCommand {
|
||||
break;
|
||||
case "area":
|
||||
case "a":
|
||||
area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(split[1]);
|
||||
area = this.plotAreaManager.getPlotAreaByString(split[1]);
|
||||
if (area == null) {
|
||||
Captions.NOT_VALID_PLOT_WORLD.send(player, split[1]);
|
||||
return false;
|
||||
|
@ -25,14 +25,15 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.generator.HybridPlotManager;
|
||||
import com.plotsquared.core.generator.HybridUtils;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotManager;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandDeclaration(command = "regenallroads",
|
||||
description = "Regenerate all roads in the map using the set road schematic",
|
||||
@ -43,6 +44,12 @@ import com.plotsquared.core.util.MainUtil;
|
||||
permission = "plots.regenallroads")
|
||||
public class RegenAllRoads extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public RegenAllRoads(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
int height = 0;
|
||||
if (args.length == 2) {
|
||||
@ -59,7 +66,7 @@ public class RegenAllRoads extends SubCommand {
|
||||
"/plot regenallroads <world> [height]");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[0]);
|
||||
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]);
|
||||
if (area == null) {
|
||||
Captions.NOT_VALID_PLOT_WORLD.send(player, args[0]);
|
||||
return false;
|
||||
|
@ -32,7 +32,9 @@ import com.plotsquared.core.configuration.MemorySection;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.PlotAreaType;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
@ -45,13 +47,19 @@ import java.util.Objects;
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Reload extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Reload(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
try {
|
||||
// The following won't affect world generation, as that has to be
|
||||
// loaded during startup unfortunately.
|
||||
PlotSquared.get().setupConfigs();
|
||||
Captions.load(PlotSquared.get().translationFile);
|
||||
PlotSquared.get().getPlotAreaManager().forEachPlotArea(area -> {
|
||||
this.plotAreaManager.forEachPlotArea(area -> {
|
||||
ConfigurationSection worldSection = PlotSquared.get().worlds
|
||||
.getConfigurationSection("worlds." + area.getWorldName());
|
||||
if (worldSection == null) {
|
||||
|
@ -25,18 +25,19 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.SchematicHandler;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
@ -49,9 +50,15 @@ import java.util.UUID;
|
||||
permission = "plots.save")
|
||||
public class Save extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
String world = player.getLocation().getWorldName();
|
||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Save(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, final String[] args) {
|
||||
final String world = player.getLocation().getWorldName();
|
||||
if (!this.plotAreaManager.hasPlotArea(world)) {
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
|
@ -26,7 +26,6 @@
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.location.Location;
|
||||
@ -35,12 +34,14 @@ import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.schematic.Schematic;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.SchematicHandler;
|
||||
import com.plotsquared.core.util.StringMan;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@ -55,8 +56,13 @@ import java.util.UUID;
|
||||
usage = "/plot schematic <save|saveall|paste>")
|
||||
public class SchematicCmd extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private boolean running = false;
|
||||
|
||||
public SchematicCmd(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
if (args.length < 1) {
|
||||
sendMessage(player, Captions.SCHEMATIC_MISSING_ARG);
|
||||
@ -150,7 +156,7 @@ public class SchematicCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_WORLD_ARGS);
|
||||
return false;
|
||||
}
|
||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[1]);
|
||||
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
|
||||
if (area == null) {
|
||||
Captions.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||
return false;
|
||||
|
@ -36,6 +36,7 @@ import com.plotsquared.core.events.TeleportCause;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotManager;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||
import com.plotsquared.core.setup.SettingsNodesWrapper;
|
||||
@ -44,6 +45,7 @@ import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.SetupUtils;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -61,6 +63,12 @@ import java.util.zip.ZipOutputStream;
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Template extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Template(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
public static boolean extractAllFiles(String world, String template) {
|
||||
try {
|
||||
File folder =
|
||||
@ -159,7 +167,7 @@ public class Template extends SubCommand {
|
||||
"/plot template import <world> <template>");
|
||||
return false;
|
||||
}
|
||||
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
||||
if (this.plotAreaManager.hasPlotArea(world)) {
|
||||
MainUtil.sendMessage(player, Captions.SETUP_WORLD_TAKEN, world);
|
||||
return false;
|
||||
}
|
||||
@ -203,7 +211,7 @@ public class Template extends SubCommand {
|
||||
"/plot template export <world>");
|
||||
return false;
|
||||
}
|
||||
final PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(world);
|
||||
final PlotArea area = this.plotAreaManager.getPlotAreaByString(world);
|
||||
if (area == null) {
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD);
|
||||
return false;
|
||||
|
@ -31,6 +31,7 @@ import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.expiration.ExpireManager;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
@ -43,14 +44,8 @@ import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -64,60 +59,14 @@ import java.util.Set;
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Trim extends SubCommand {
|
||||
|
||||
public static ArrayList<Plot> expired = null;
|
||||
private static volatile boolean TASK = false;
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public static boolean getBulkRegions(final ArrayList<BlockVector2> empty, final String world,
|
||||
final Runnable whenDone) {
|
||||
if (Trim.TASK) {
|
||||
return false;
|
||||
}
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override public void run() {
|
||||
String directory = world + File.separator + "region";
|
||||
File folder = new File(PlotSquared.platform().getWorldContainer(), directory);
|
||||
File[] regionFiles = folder.listFiles();
|
||||
for (File file : regionFiles) {
|
||||
String name = file.getName();
|
||||
if (name.endsWith("mca")) {
|
||||
if (file.getTotalSpace() <= 8192) {
|
||||
checkMca(name);
|
||||
} else {
|
||||
Path path = Paths.get(file.getPath());
|
||||
try {
|
||||
BasicFileAttributes attr =
|
||||
Files.readAttributes(path, BasicFileAttributes.class);
|
||||
long creation = attr.creationTime().toMillis();
|
||||
long modification = file.lastModified();
|
||||
long diff = Math.abs(creation - modification);
|
||||
if (diff < 10000) {
|
||||
checkMca(name);
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Trim.TASK = false;
|
||||
TaskManager.runTaskAsync(whenDone);
|
||||
}
|
||||
|
||||
private void checkMca(String name) {
|
||||
try {
|
||||
String[] split = name.split("\\.");
|
||||
int x = Integer.parseInt(split[1]);
|
||||
int z = Integer.parseInt(split[2]);
|
||||
BlockVector2 loc = BlockVector2.at(x, z);
|
||||
empty.add(loc);
|
||||
} catch (NumberFormatException ignored) {
|
||||
PlotSquared.debug("INVALID MCA: " + name);
|
||||
}
|
||||
}
|
||||
});
|
||||
Trim.TASK = true;
|
||||
return true;
|
||||
public Trim(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
private static volatile boolean TASK = false;
|
||||
|
||||
/**
|
||||
* Runs the result task with the parameters (viable, nonViable).
|
||||
*
|
||||
@ -167,7 +116,7 @@ public class Trim extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final String world = args[0];
|
||||
if (!WorldUtil.IMP.isWorld(world) || !PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
||||
if (!WorldUtil.IMP.isWorld(world) || !this.plotAreaManager.hasPlotArea(world)) {
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_WORLD);
|
||||
return false;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.flag.implementations.UntrustedVisitFlag;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.MathMan;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
@ -59,8 +60,11 @@ import java.util.concurrent.TimeoutException;
|
||||
category = CommandCategory.TELEPORT)
|
||||
public class Visit extends Command {
|
||||
|
||||
public Visit() {
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Visit(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
super(MainCommand.getInstance(), true);
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
private void visit(@NotNull final PlotPlayer player, @NotNull final PlotQuery query, final PlotArea sortByArea,
|
||||
@ -164,7 +168,7 @@ public class Visit extends Command {
|
||||
// /p v <name> [page]
|
||||
case 2:
|
||||
if (page != Integer.MIN_VALUE || !MathMan.isInteger(args[1])) {
|
||||
sortByArea = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[1]);
|
||||
sortByArea = this.plotAreaManager.getPlotAreaByString(args[1]);
|
||||
if (sortByArea == null) {
|
||||
Captions.NOT_VALID_NUMBER.send(player, "(1, ∞)");
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
@ -275,7 +279,7 @@ public class Visit extends Command {
|
||||
}
|
||||
|
||||
private void completeAreas(final List<Command> commands, final String arg) {
|
||||
for (final PlotArea area : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) {
|
||||
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
||||
final String areaName = area.getWorldName() + ";" + area.getId();
|
||||
if (!areaName.toLowerCase().startsWith(arg.toLowerCase())) {
|
||||
continue;
|
||||
|
@ -40,6 +40,7 @@ import com.plotsquared.core.plot.expiration.PlotAnalysis;
|
||||
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.queue.ChunkBlockQueue;
|
||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||
@ -61,6 +62,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayDeque;
|
||||
@ -83,6 +85,12 @@ public abstract class HybridUtils {
|
||||
public static PlotArea area;
|
||||
public static boolean UPDATE = false;
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public HybridUtils(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
public void analyzeRegion(final String world, final CuboidRegion region,
|
||||
final RunnableVal<PlotAnalysis> whenDone) {
|
||||
// int diff, int variety, int vertices, int rotation, int height_sd
|
||||
@ -115,7 +123,7 @@ public abstract class HybridUtils {
|
||||
final int width = tx - bx + 1;
|
||||
final int length = tz - bz + 1;
|
||||
|
||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotArea(world, null);
|
||||
final PlotArea area = this.plotAreaManager.getPlotArea(world, null);
|
||||
|
||||
if (!(area instanceof HybridPlotWorld)) {
|
||||
return;
|
||||
|
@ -25,24 +25,31 @@
|
||||
*/
|
||||
package com.plotsquared.core.generator;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SingleWorldGenerator extends IndependentPlotGenerator {
|
||||
|
||||
private static final Location bedrock1 = Location.at("", 0, 0, 0);
|
||||
private static final Location bedrock2 = Location.at("", 15, 0, 15);
|
||||
private static final Location dirt1 = Location.at("", 0, 1, 0);
|
||||
private static final Location dirt2 = Location.at("", 15, 2, 15);
|
||||
private static final Location grass1 = Location.at("", 0, 3, 0);
|
||||
private static final Location grass2 = Location.at("", 15, 3, 15);
|
||||
private static final Location dirt1 = Location.at("", 0, 1, 0);
|
||||
private static final Location dirt2 = Location.at("", 15, 2, 15);
|
||||
private static final Location grass1 = Location.at("", 0, 3, 0);
|
||||
private static final Location grass2 = Location.at("", 15, 3, 15);
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public SingleWorldGenerator(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public String getName() {
|
||||
return "PlotSquared:single";
|
||||
@ -64,10 +71,10 @@ public class SingleWorldGenerator extends IndependentPlotGenerator {
|
||||
}
|
||||
|
||||
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
||||
return ((SinglePlotAreaManager) PlotSquared.get().getPlotAreaManager()).getArea();
|
||||
return ((SinglePlotAreaManager) this.plotAreaManager).getArea();
|
||||
}
|
||||
|
||||
@Override public void initialize(PlotArea area) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,11 +25,11 @@
|
||||
*/
|
||||
package com.plotsquared.core.listener;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.WEManager;
|
||||
@ -43,10 +43,17 @@ import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
|
||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class WESubscriber {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public WESubscriber(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Subscribe(priority = Priority.VERY_EARLY) public void onEditSession(EditSessionEvent event) {
|
||||
if (!Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
|
||||
@ -82,19 +89,19 @@ public class WESubscriber {
|
||||
if (Permissions.hasPermission(plotPlayer, "plots.worldedit.bypass")) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.WORLDEDIT_BYPASS);
|
||||
}
|
||||
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
||||
if (this.plotAreaManager.hasPlotArea(world)) {
|
||||
event.setExtent(new NullExtent());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
|
||||
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
||||
if (this.plotAreaManager.hasPlotArea(world)) {
|
||||
event.setExtent(
|
||||
new ProcessedWEExtent(world, mask, event.getMaxBlocks(), event.getExtent(),
|
||||
event.getExtent()));
|
||||
}
|
||||
} else if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
||||
} else if (this.plotAreaManager.hasPlotArea(world)) {
|
||||
event.setExtent(new WEExtent(mask, event.getExtent()));
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import com.plotsquared.core.events.TeleportCause;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotWeather;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
@ -45,8 +46,9 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
||||
|
||||
private static ConsolePlayer instance;
|
||||
|
||||
private ConsolePlayer() {
|
||||
final PlotArea[] areas = PlotSquared.get().getPlotAreaManager().getAllPlotAreas();
|
||||
private ConsolePlayer(final PlotAreaManager plotAreaManager) {
|
||||
super(plotAreaManager);
|
||||
final PlotArea[] areas = plotAreaManager.getAllPlotAreas();
|
||||
final PlotArea area;
|
||||
if (areas.length > 0) {
|
||||
area = areas[0];
|
||||
@ -67,7 +69,7 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
||||
|
||||
public static ConsolePlayer getConsole() {
|
||||
if (instance == null) {
|
||||
instance = new ConsolePlayer();
|
||||
instance = new ConsolePlayer(PlotSquared.get().getPlotAreaManager());
|
||||
instance.teleport(instance.getLocation());
|
||||
}
|
||||
return instance;
|
||||
|
@ -26,6 +26,7 @@
|
||||
package com.plotsquared.core.player;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.plotsquared.core.PlotPlatform;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.command.CommandCaller;
|
||||
import com.plotsquared.core.command.RequiredType;
|
||||
@ -87,6 +88,12 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
*/
|
||||
private ConcurrentHashMap<String, Object> meta;
|
||||
private int hash;
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public PlotPlayer(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
public static <T> PlotPlayer<T> from(@NonNull final T object) {
|
||||
if (!converters.containsKey(object.getClass())) {
|
||||
@ -270,7 +277,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
}
|
||||
final AtomicInteger count = new AtomicInteger(0);
|
||||
final UUID uuid = getUUID();
|
||||
PlotSquared.get().getPlotAreaManager().forEachPlotArea(value -> {
|
||||
this.plotAreaManager.forEachPlotArea(value -> {
|
||||
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
|
||||
for (Plot plot : value.getPlotsAbs(uuid)) {
|
||||
if (!DoneFlag.isDone(plot)) {
|
||||
@ -289,7 +296,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
return getClusterCount(getLocation().getWorldName());
|
||||
}
|
||||
final AtomicInteger count = new AtomicInteger(0);
|
||||
PlotSquared.get().getPlotAreaManager().forEachPlotArea(value -> {
|
||||
this.plotAreaManager.forEachPlotArea(value -> {
|
||||
for (PlotCluster cluster : value.getClusters()) {
|
||||
if (cluster.isOwner(getUUID())) {
|
||||
count.incrementAndGet();
|
||||
@ -308,7 +315,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
public int getPlotCount(String world) {
|
||||
UUID uuid = getUUID();
|
||||
int count = 0;
|
||||
for (PlotArea area : PlotSquared.get().getPlotAreaManager().getPlotAreasSet(world)) {
|
||||
for (PlotArea area : this.plotAreaManager.getPlotAreasSet(world)) {
|
||||
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
|
||||
count +=
|
||||
area.getPlotsAbs(uuid).stream().filter(plot -> !DoneFlag.isDone(plot)).count();
|
||||
@ -322,7 +329,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
public int getClusterCount(String world) {
|
||||
UUID uuid = getUUID();
|
||||
int count = 0;
|
||||
for (PlotArea area : PlotSquared.get().getPlotAreaManager().getPlotAreasSet(world)) {
|
||||
for (PlotArea area : this.plotAreaManager.getPlotAreasSet(world)) {
|
||||
for (PlotCluster cluster : area.getClusters()) {
|
||||
if (cluster.isOwner(getUUID())) {
|
||||
count++;
|
||||
@ -349,11 +356,11 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
* @return Plot area the player is currently in, or {@code null}
|
||||
*/
|
||||
@Nullable public PlotArea getPlotAreaAbs() {
|
||||
return PlotSquared.get().getPlotAreaManager().getPlotArea(getLocation());
|
||||
return this.plotAreaManager.getPlotArea(getLocation());
|
||||
}
|
||||
|
||||
public PlotArea getApplicablePlotArea() {
|
||||
return PlotSquared.get().getPlotAreaManager().getApplicablePlotArea(getLocation());
|
||||
return this.plotAreaManager.getApplicablePlotArea(getLocation());
|
||||
}
|
||||
|
||||
@Override public RequiredType getSuperCaller() {
|
||||
@ -614,7 +621,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
*/
|
||||
public int getPlayerClusterCount() {
|
||||
final AtomicInteger count = new AtomicInteger();
|
||||
PlotSquared.get().getPlotAreaManager().forEachPlotArea(value -> count.addAndGet(value.getClusters().size()));
|
||||
this.plotAreaManager.forEachPlotArea(value -> count.addAndGet(value.getClusters().size()));
|
||||
return count.get();
|
||||
}
|
||||
|
||||
@ -645,7 +652,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
if (!Settings.Teleport.ON_LOGIN) {
|
||||
return;
|
||||
}
|
||||
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
|
||||
PlotAreaManager manager = PlotPlayer.this.plotAreaManager;
|
||||
|
||||
if (!(manager instanceof SinglePlotAreaManager)) {
|
||||
return;
|
||||
|
@ -25,11 +25,12 @@
|
||||
*/
|
||||
package com.plotsquared.core.plot.expiration;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.query.PlotQuery;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -41,11 +42,14 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ExpiryTask {
|
||||
|
||||
private final Settings.Auto_Clear settings;
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private long cutoffThreshold = Long.MIN_VALUE;
|
||||
|
||||
public ExpiryTask(Settings.Auto_Clear settings) {
|
||||
|
||||
public ExpiryTask(@NotNull final Settings.Auto_Clear settings, @NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.settings = settings;
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
public Settings.Auto_Clear getSettings() {
|
||||
@ -122,7 +126,7 @@ public class ExpiryTask {
|
||||
|
||||
public Set<Plot> getPlotsToCheck() {
|
||||
final Collection<PlotArea> areas = new LinkedList<>();
|
||||
for (final PlotArea plotArea : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) {
|
||||
for (final PlotArea plotArea : this.plotAreaManager.getAllPlotAreas()) {
|
||||
if (this.allowsArea(plotArea)) {
|
||||
areas.add(plotArea);
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ public class SinglePlotArea extends GridPlotWorld {
|
||||
|
||||
public boolean VOID = false;
|
||||
|
||||
public SinglePlotArea() {
|
||||
super("*", null, new SingleWorldGenerator(), null, null);
|
||||
public SinglePlotArea(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
super("*", null, new SingleWorldGenerator(plotAreaManager), null, null);
|
||||
this.setAllowSigns(false);
|
||||
this.setDefaultHome(new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE));
|
||||
}
|
||||
|
@ -41,11 +41,11 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
||||
private PlotArea[] all;
|
||||
|
||||
public SinglePlotAreaManager() {
|
||||
this.area = new SinglePlotArea();
|
||||
this.area = new SinglePlotArea(this);
|
||||
this.array = new SinglePlotArea[] {area};
|
||||
this.all = new PlotArea[] {area};
|
||||
SetupUtils.generators.put("PlotSquared:single",
|
||||
new SingleWorldGenerator().specify("CheckingPlotSquaredGenerator"));
|
||||
new SingleWorldGenerator(this).specify("CheckingPlotSquaredGenerator"));
|
||||
}
|
||||
|
||||
public SinglePlotArea getArea() {
|
||||
|
@ -25,17 +25,11 @@
|
||||
*/
|
||||
package com.plotsquared.core.queue;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotManager;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue {
|
||||
private final int minX;
|
||||
@ -100,32 +94,4 @@ public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue {
|
||||
return Location.at(this.getWorld(), this.maxX, this.maxY, this.maxZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a task for each x,z value corresponding to the plot at that location<br>
|
||||
* - Plot: The plot at the x,z (may be null)<br>
|
||||
* - Location: The location in the chunk (y = 0)<br>
|
||||
* - PlotChunk: Reference to this chunk object<br>
|
||||
*
|
||||
* @param task
|
||||
*/
|
||||
public void mapByType2D(@NotNull final RunnableVal3<Plot, Integer, Integer> task) {
|
||||
final int bx = minX;
|
||||
final int bz = minZ;
|
||||
final PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotArea(getWorld(), null);
|
||||
final Location location = Location.at(getWorld(), bx, 0, bz);
|
||||
if (area != null) {
|
||||
PlotManager manager = area.getPlotManager();
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
task.run(area.getPlotAbs(location.withX(bx + x).withZ(bz + z)), x, z);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
task.run(location.withX(bx + x).withZ(bz + z).getPlotAbs(), x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,10 @@
|
||||
*/
|
||||
package com.plotsquared.core.util.query;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@ -35,9 +36,15 @@ import java.util.Set;
|
||||
|
||||
class GlobalPlotProvider implements PlotProvider {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
GlobalPlotProvider(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override public Collection<Plot> getPlots() {
|
||||
final Set<Plot> plots = new HashSet<>();
|
||||
for (final PlotArea plotArea : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) {
|
||||
for (final PlotArea plotArea : this.plotAreaManager.getAllPlotAreas()) {
|
||||
plots.addAll(plotArea.getPlots());
|
||||
}
|
||||
return plots;
|
||||
|
@ -32,6 +32,7 @@ import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.Rating;
|
||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MathMan;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -59,12 +60,15 @@ import java.util.stream.Stream;
|
||||
public final class PlotQuery {
|
||||
|
||||
private final Collection<PlotFilter> filters = new LinkedList<>();
|
||||
private PlotProvider plotProvider = new GlobalPlotProvider();
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private PlotProvider plotProvider;
|
||||
private SortingStrategy sortingStrategy = SortingStrategy.NO_SORTING;
|
||||
private PlotArea priorityArea;
|
||||
private Comparator<Plot> plotComparator;
|
||||
|
||||
private PlotQuery() {
|
||||
private PlotQuery(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.plotProvider = new GlobalPlotProvider(plotAreaManager);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,7 +77,7 @@ public final class PlotQuery {
|
||||
* @return New query
|
||||
*/
|
||||
public static PlotQuery newQuery() {
|
||||
return new PlotQuery();
|
||||
return new PlotQuery(PlotSquared.get().getPlotAreaManager());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,7 +100,7 @@ public final class PlotQuery {
|
||||
*/
|
||||
@NotNull public PlotQuery inWorld(@NotNull final String world) {
|
||||
Preconditions.checkNotNull(world, "World may not be null");
|
||||
this.plotProvider = new AreaLimitedPlotProvider(PlotSquared.get().getPlotAreaManager().getPlotAreasSet(world));
|
||||
this.plotProvider = new AreaLimitedPlotProvider(this.plotAreaManager.getPlotAreasSet(world));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -129,7 +133,7 @@ public final class PlotQuery {
|
||||
* @return The query instance
|
||||
*/
|
||||
@NotNull public PlotQuery allPlots() {
|
||||
this.plotProvider = new GlobalPlotProvider();
|
||||
this.plotProvider = new GlobalPlotProvider(this.plotAreaManager);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user