mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Inject PlotAreaManager
This commit is contained in:
parent
c37cc40ad9
commit
2dab7c8dda
@ -180,9 +180,10 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
private boolean metricsStarted;
|
private boolean metricsStarted;
|
||||||
@Getter private BackupManager backupManager;
|
@Getter private BackupManager backupManager;
|
||||||
@Getter private PlatformWorldManager<World> worldManager;
|
@Getter private PlatformWorldManager<World> worldManager;
|
||||||
private final BukkitPlayerManager playerManager = new BukkitPlayerManager();
|
private BukkitPlayerManager playerManager;
|
||||||
private EconHandler econ;
|
private EconHandler econ;
|
||||||
private PermHandler perm;
|
private PermHandler perm;
|
||||||
|
private PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
@Override public int[] getServerVersion() {
|
@Override public int[] getServerVersion() {
|
||||||
if (this.version == null) {
|
if (this.version == null) {
|
||||||
@ -213,7 +214,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
this.pluginName = getDescription().getName();
|
this.pluginName = getDescription().getName();
|
||||||
PlotPlayer.registerConverter(Player.class, BukkitUtil::getPlayer);
|
PlotPlayer.registerConverter(Player.class, BukkitUtil::getPlayer);
|
||||||
|
|
||||||
new PlotSquared(this, "Bukkit");
|
final PlotSquared plotSquared = new PlotSquared(this, "Bukkit");
|
||||||
|
this.plotAreaManager = plotSquared.getPlotAreaManager();
|
||||||
|
this.playerManager = new BukkitPlayerManager(this.plotAreaManager);
|
||||||
|
|
||||||
if (PlotSquared.platform().getServerVersion()[1] < 13) {
|
if (PlotSquared.platform().getServerVersion()[1] < 13) {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
@ -427,10 +430,10 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
event.printStackTrace();
|
event.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
|
|
||||||
if (manager instanceof SinglePlotAreaManager) {
|
if (this.plotAreaManager instanceof SinglePlotAreaManager) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
final SinglePlotArea area = ((SinglePlotAreaManager) manager).getArea();
|
final SinglePlotArea area = ((SinglePlotAreaManager) this.plotAreaManager).getArea();
|
||||||
|
|
||||||
outer:
|
outer:
|
||||||
for (final World world : Bukkit.getWorlds()) {
|
for (final World world : Bukkit.getWorlds()) {
|
||||||
@ -624,7 +627,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().getPlotAreaManager().forEachPlotArea(plotArea -> {
|
TaskManager.runTaskRepeat(() -> this.plotAreaManager.forEachPlotArea(plotArea -> {
|
||||||
final World world = Bukkit.getWorld(plotArea.getWorldName());
|
final World world = Bukkit.getWorld(plotArea.getWorldName());
|
||||||
try {
|
try {
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
@ -883,7 +886,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
final String id) {
|
final String id) {
|
||||||
final IndependentPlotGenerator result;
|
final IndependentPlotGenerator result;
|
||||||
if (id != null && id.equalsIgnoreCase("single")) {
|
if (id != null && id.equalsIgnoreCase("single")) {
|
||||||
result = new SingleWorldGenerator();
|
result = new SingleWorldGenerator(this.plotAreaManager);
|
||||||
} else {
|
} else {
|
||||||
result = PlotSquared.platform().getDefaultGenerator();
|
result = PlotSquared.platform().getDefaultGenerator();
|
||||||
if (!PlotSquared.get().setupPlotWorld(worldName, id, result)) {
|
if (!PlotSquared.get().setupPlotWorld(worldName, id, result)) {
|
||||||
@ -894,11 +897,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void registerPlayerEvents() {
|
@Override public void registerPlayerEvents() {
|
||||||
final PlayerEvents main = new PlayerEvents();
|
final PlayerEvents main = new PlayerEvents(this.plotAreaManager);
|
||||||
getServer().getPluginManager().registerEvents(main, this);
|
getServer().getPluginManager().registerEvents(main, this);
|
||||||
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
|
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
|
||||||
if (PaperLib.isPaper() && Settings.Paper_Components.PAPER_LISTENERS) {
|
if (PaperLib.isPaper() && Settings.Paper_Components.PAPER_LISTENERS) {
|
||||||
getServer().getPluginManager().registerEvents(new PaperListener(), this);
|
getServer().getPluginManager().registerEvents(new PaperListener(this.plotAreaManager), this);
|
||||||
}
|
}
|
||||||
PlotListener.startRunnable();
|
PlotListener.startRunnable();
|
||||||
}
|
}
|
||||||
@ -982,18 +985,18 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
if (gen instanceof GeneratorWrapper<?>) {
|
if (gen instanceof GeneratorWrapper<?>) {
|
||||||
return (GeneratorWrapper<?>) gen;
|
return (GeneratorWrapper<?>) gen;
|
||||||
}
|
}
|
||||||
return new BukkitPlotGenerator(world, gen);
|
return new BukkitPlotGenerator(world, gen, this.plotAreaManager);
|
||||||
} else {
|
} else {
|
||||||
return new BukkitPlotGenerator(world, PlotSquared.platform().getDefaultGenerator());
|
return new BukkitPlotGenerator(world, PlotSquared.platform().getDefaultGenerator(), this.plotAreaManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public HybridUtils initHybridUtils() {
|
@Override public HybridUtils initHybridUtils() {
|
||||||
return new BukkitHybridUtils();
|
return new BukkitHybridUtils(this.plotAreaManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public SetupUtils initSetupUtils() {
|
@Override public SetupUtils initSetupUtils() {
|
||||||
return new BukkitSetupUtils();
|
return new BukkitSetupUtils(this.plotAreaManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void startMetrics() {
|
@Override public void startMetrics() {
|
||||||
@ -1011,7 +1014,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
}
|
}
|
||||||
map.put(plotAreaType.name().toLowerCase(), terrainTypes);
|
map.put(plotAreaType.name().toLowerCase(), terrainTypes);
|
||||||
}
|
}
|
||||||
for (final PlotArea plotArea : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) {
|
for (final PlotArea plotArea : this.plotAreaManager.getAllPlotAreas()) {
|
||||||
final Map<String, Integer> terrainTypeMap =
|
final Map<String, Integer> terrainTypeMap =
|
||||||
map.get(plotArea.getType().name().toLowerCase());
|
map.get(plotArea.getType().name().toLowerCase());
|
||||||
terrainTypeMap.put(plotArea.getTerrain().name().toLowerCase(),
|
terrainTypeMap.put(plotArea.getTerrain().name().toLowerCase(),
|
||||||
@ -1040,11 +1043,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void registerChunkProcessor() {
|
@Override public void registerChunkProcessor() {
|
||||||
getServer().getPluginManager().registerEvents(new ChunkListener(), this);
|
getServer().getPluginManager().registerEvents(new ChunkListener(this.plotAreaManager), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void registerWorldEvents() {
|
@Override public void registerWorldEvents() {
|
||||||
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
|
getServer().getPluginManager().registerEvents(new WorldEvents(this.plotAreaManager), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull @Override public IndependentPlotGenerator getDefaultGenerator() {
|
@NotNull @Override public IndependentPlotGenerator getDefaultGenerator() {
|
||||||
@ -1072,7 +1075,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
world = Bukkit.getWorld(worldName);
|
world = Bukkit.getWorld(worldName);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(worldName)) {
|
if (!this.plotAreaManager.hasPlotArea(worldName)) {
|
||||||
SetGenCB.setGenerator(BukkitUtil.getWorld(worldName));
|
SetGenCB.setGenerator(BukkitUtil.getWorld(worldName));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -1086,7 +1089,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
if (gen instanceof BukkitPlotGenerator) {
|
if (gen instanceof BukkitPlotGenerator) {
|
||||||
PlotSquared.get().loadWorld(worldName, (BukkitPlotGenerator) gen);
|
PlotSquared.get().loadWorld(worldName, (BukkitPlotGenerator) gen);
|
||||||
} else if (gen != null) {
|
} else if (gen != null) {
|
||||||
PlotSquared.get().loadWorld(worldName, new BukkitPlotGenerator(worldName, gen));
|
PlotSquared.get().loadWorld(worldName, new BukkitPlotGenerator(worldName, gen, this.plotAreaManager));
|
||||||
} else if (PlotSquared.get().worlds.contains("worlds." + worldName)) {
|
} else if (PlotSquared.get().worlds.contains("worlds." + worldName)) {
|
||||||
PlotSquared.get().loadWorld(worldName, null);
|
PlotSquared.get().loadWorld(worldName, null);
|
||||||
}
|
}
|
||||||
@ -1144,7 +1147,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
|
|
||||||
@Override public GeneratorWrapper<?> wrapPlotGenerator(@Nullable final String world,
|
@Override public GeneratorWrapper<?> wrapPlotGenerator(@Nullable final String world,
|
||||||
@NonNull final IndependentPlotGenerator generator) {
|
@NonNull final IndependentPlotGenerator generator) {
|
||||||
return new BukkitPlotGenerator(world, generator);
|
return new BukkitPlotGenerator(world, generator, this.plotAreaManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public List<Map.Entry<Map.Entry<String, String>, Boolean>> getPluginIds() {
|
@Override public List<Map.Entry<Map.Entry<String, String>, Boolean>> getPluginIds() {
|
||||||
|
@ -25,10 +25,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.generator;
|
package com.plotsquared.bukkit.generator;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||||
import com.plotsquared.core.location.ChunkWrapper;
|
import com.plotsquared.core.location.ChunkWrapper;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
||||||
@ -42,10 +42,14 @@ import java.util.Random;
|
|||||||
final class BlockStatePopulator extends BlockPopulator {
|
final class BlockStatePopulator extends BlockPopulator {
|
||||||
|
|
||||||
private final IndependentPlotGenerator plotGenerator;
|
private final IndependentPlotGenerator plotGenerator;
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
private LocalBlockQueue queue;
|
private LocalBlockQueue queue;
|
||||||
|
|
||||||
public BlockStatePopulator(IndependentPlotGenerator plotGenerator) {
|
public BlockStatePopulator(@NotNull final IndependentPlotGenerator plotGenerator,
|
||||||
|
@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
this.plotGenerator = plotGenerator;
|
this.plotGenerator = plotGenerator;
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,7 +58,7 @@ final class BlockStatePopulator extends BlockPopulator {
|
|||||||
if (this.queue == null) {
|
if (this.queue == null) {
|
||||||
this.queue = GlobalBlockQueue.IMP.getNewQueue(world.getName(), false);
|
this.queue = GlobalBlockQueue.IMP.getNewQueue(world.getName(), false);
|
||||||
}
|
}
|
||||||
final PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotArea(world.getName(), null);
|
final PlotArea area = this.plotAreaManager.getPlotArea(world.getName(), null);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,13 @@
|
|||||||
package com.plotsquared.bukkit.generator;
|
package com.plotsquared.bukkit.generator;
|
||||||
|
|
||||||
import com.plotsquared.core.generator.HybridUtils;
|
import com.plotsquared.core.generator.HybridUtils;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class BukkitHybridUtils extends HybridUtils {
|
public class BukkitHybridUtils extends HybridUtils {
|
||||||
|
|
||||||
|
public BukkitHybridUtils(@NotNull PlotAreaManager plotAreaManager) {
|
||||||
|
super(plotAreaManager);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import com.plotsquared.core.generator.IndependentPlotGenerator;
|
|||||||
import com.plotsquared.core.generator.SingleWorldGenerator;
|
import com.plotsquared.core.generator.SingleWorldGenerator;
|
||||||
import com.plotsquared.core.location.ChunkWrapper;
|
import com.plotsquared.core.location.ChunkWrapper;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
@ -54,6 +55,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
|
|
||||||
@SuppressWarnings("unused") public final boolean PAPER_ASYNC_SAFE = true;
|
@SuppressWarnings("unused") public final boolean PAPER_ASYNC_SAFE = true;
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
private final IndependentPlotGenerator plotGenerator;
|
private final IndependentPlotGenerator plotGenerator;
|
||||||
private final ChunkGenerator platformGenerator;
|
private final ChunkGenerator platformGenerator;
|
||||||
private final boolean full;
|
private final boolean full;
|
||||||
@ -62,24 +64,24 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
|
|
||||||
@Getter private final String levelName;
|
@Getter private final String levelName;
|
||||||
|
|
||||||
public BukkitPlotGenerator(String name, IndependentPlotGenerator generator) {
|
public BukkitPlotGenerator(@NotNull final String name,
|
||||||
if (generator == null) {
|
@NotNull final IndependentPlotGenerator generator, @NotNull final PlotAreaManager plotAreaManager) {
|
||||||
throw new IllegalArgumentException("Generator may not be null!");
|
this.plotAreaManager = plotAreaManager;
|
||||||
}
|
|
||||||
this.levelName = name;
|
this.levelName = name;
|
||||||
this.plotGenerator = generator;
|
this.plotGenerator = generator;
|
||||||
this.platformGenerator = this;
|
this.platformGenerator = this;
|
||||||
this.populators = new ArrayList<>();
|
this.populators = new ArrayList<>();
|
||||||
this.populators.add(new BlockStatePopulator(this.plotGenerator));
|
this.populators.add(new BlockStatePopulator(this.plotGenerator, this.plotAreaManager));
|
||||||
this.full = true;
|
this.full = true;
|
||||||
MainUtil.initCache();
|
MainUtil.initCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitPlotGenerator(final String world, final ChunkGenerator cg) {
|
public BukkitPlotGenerator(final String world, final ChunkGenerator cg, @NotNull final PlotAreaManager plotAreaManager) {
|
||||||
if (cg instanceof BukkitPlotGenerator) {
|
if (cg instanceof BukkitPlotGenerator) {
|
||||||
throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName()
|
throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName()
|
||||||
+ " is already a BukkitPlotGenerator!");
|
+ " is already a BukkitPlotGenerator!");
|
||||||
}
|
}
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
this.levelName = world;
|
this.levelName = world;
|
||||||
this.full = false;
|
this.full = false;
|
||||||
this.platformGenerator = cg;
|
this.platformGenerator = cg;
|
||||||
@ -108,7 +110,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
if (!this.loaded) {
|
if (!this.loaded) {
|
||||||
String name = world.getName();
|
String name = world.getName();
|
||||||
PlotSquared.get().loadWorld(name, this);
|
PlotSquared.get().loadWorld(name, this);
|
||||||
final Set<PlotArea> areas = PlotSquared.get().getPlotAreaManager().getPlotAreasSet(name);
|
final Set<PlotArea> areas = this.plotAreaManager.getPlotAreasSet(name);
|
||||||
if (!areas.isEmpty()) {
|
if (!areas.isEmpty()) {
|
||||||
PlotArea area = areas.iterator().next();
|
PlotArea area = areas.iterator().next();
|
||||||
if (!area.isMobSpawning()) {
|
if (!area.isMobSpawning()) {
|
||||||
@ -198,8 +200,8 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
if (ChunkManager.preProcessChunk(loc, result)) {
|
if (ChunkManager.preProcessChunk(loc, result)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotArea(world.getName(), null);
|
PlotArea area = this.plotAreaManager.getPlotArea(world.getName(), null);
|
||||||
if (area == null && (area = PlotSquared.get().getPlotAreaManager().getPlotArea(this.levelName, null)) == null) {
|
if (area == null && (area = this.plotAreaManager.getPlotArea(this.levelName, null)) == null) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Cannot regenerate chunk that does not belong to a plot area." + " Location: " + loc
|
"Cannot regenerate chunk that does not belong to a plot area." + " Location: " + loc
|
||||||
+ ", world: " + world);
|
+ ", world: " + world);
|
||||||
|
@ -29,6 +29,7 @@ import com.plotsquared.core.PlotSquared;
|
|||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.ReflectionUtils.RefClass;
|
import com.plotsquared.core.util.ReflectionUtils.RefClass;
|
||||||
import com.plotsquared.core.util.ReflectionUtils.RefField;
|
import com.plotsquared.core.util.ReflectionUtils.RefField;
|
||||||
import com.plotsquared.core.util.ReflectionUtils.RefMethod;
|
import com.plotsquared.core.util.ReflectionUtils.RefMethod;
|
||||||
@ -51,6 +52,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent;
|
|||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -60,12 +62,15 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class ChunkListener implements Listener {
|
public class ChunkListener implements Listener {
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
private RefMethod methodGetHandleChunk;
|
private RefMethod methodGetHandleChunk;
|
||||||
private RefField mustSave;
|
private RefField mustSave;
|
||||||
private Chunk lastChunk;
|
private Chunk lastChunk;
|
||||||
private boolean ignoreUnload = false;
|
private boolean ignoreUnload = false;
|
||||||
|
|
||||||
public ChunkListener() {
|
public ChunkListener(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
if (Settings.Chunk_Processor.AUTO_TRIM) {
|
if (Settings.Chunk_Processor.AUTO_TRIM) {
|
||||||
try {
|
try {
|
||||||
RefClass classChunk = getRefClass("{nms}.Chunk");
|
RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||||
@ -90,7 +95,7 @@ public class ChunkListener implements Listener {
|
|||||||
HashSet<Chunk> toUnload = new HashSet<>();
|
HashSet<Chunk> toUnload = new HashSet<>();
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
String worldName = world.getName();
|
String worldName = world.getName();
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(worldName)) {
|
if (!this.plotAreaManager.hasPlotArea(worldName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Object w = world.getClass().getDeclaredMethod("getHandle").invoke(world);
|
Object w = world.getClass().getDeclaredMethod("getHandle").invoke(world);
|
||||||
@ -177,7 +182,7 @@ public class ChunkListener implements Listener {
|
|||||||
Chunk chunk = event.getChunk();
|
Chunk chunk = event.getChunk();
|
||||||
if (Settings.Chunk_Processor.AUTO_TRIM) {
|
if (Settings.Chunk_Processor.AUTO_TRIM) {
|
||||||
String world = chunk.getWorld().getName();
|
String world = chunk.getWorld().getName();
|
||||||
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
if (this.plotAreaManager.hasPlotArea(world)) {
|
||||||
if (unloadChunk(world, chunk, true)) {
|
if (unloadChunk(world, chunk, true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -200,7 +205,7 @@ public class ChunkListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(chunk.getWorld().getName())) {
|
if (!this.plotAreaManager.hasPlotArea(chunk.getWorld().getName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Entity[] entities = chunk.getEntities();
|
Entity[] entities = chunk.getEntities();
|
||||||
@ -230,7 +235,7 @@ public class ChunkListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(chunk.getWorld().getName())) {
|
if (!this.plotAreaManager.hasPlotArea(chunk.getWorld().getName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Entity[] entities = chunk.getEntities();
|
Entity[] entities = chunk.getEntities();
|
||||||
@ -281,7 +286,7 @@ public class ChunkListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean processChunk(Chunk chunk, boolean unload) {
|
public boolean processChunk(Chunk chunk, boolean unload) {
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(chunk.getWorld().getName())) {
|
if (!this.plotAreaManager.hasPlotArea(chunk.getWorld().getName())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Entity[] entities = chunk.getEntities();
|
Entity[] entities = chunk.getEntities();
|
||||||
|
@ -33,7 +33,6 @@ import com.destroystokyo.paper.event.entity.SlimePathfindEvent;
|
|||||||
import com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent;
|
import com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent;
|
||||||
import com.destroystokyo.paper.event.server.AsyncTabCompleteEvent;
|
import com.destroystokyo.paper.event.server.AsyncTabCompleteEvent;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.command.Command;
|
import com.plotsquared.core.command.Command;
|
||||||
import com.plotsquared.core.command.MainCommand;
|
import com.plotsquared.core.command.MainCommand;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
@ -43,6 +42,7 @@ import com.plotsquared.core.player.PlotPlayer;
|
|||||||
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.flag.implementations.DoneFlag;
|
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.TileState;
|
import org.bukkit.block.TileState;
|
||||||
@ -58,6 +58,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -71,8 +72,13 @@ import java.util.regex.Pattern;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class PaperListener implements Listener {
|
public class PaperListener implements Listener {
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
private Chunk lastChunk;
|
private Chunk lastChunk;
|
||||||
|
|
||||||
|
public PaperListener(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler public void onEntityPathfind(EntityPathfindEvent event) {
|
@EventHandler public void onEntityPathfind(EntityPathfindEvent event) {
|
||||||
if (!Settings.Paper_Components.ENTITY_PATHING) {
|
if (!Settings.Paper_Components.ENTITY_PATHING) {
|
||||||
return;
|
return;
|
||||||
@ -305,7 +311,7 @@ public class PaperListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(entity);
|
Location location = BukkitUtil.getLocation(entity);
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotPlayer<?> pp = BukkitUtil.getPlayer((Player) shooter);
|
PlotPlayer<?> pp = BukkitUtil.getPlayer((Player) shooter);
|
||||||
|
@ -99,6 +99,7 @@ import com.plotsquared.core.plot.flag.implementations.VillagerInteractFlag;
|
|||||||
import com.plotsquared.core.plot.flag.implementations.VineGrowFlag;
|
import com.plotsquared.core.plot.flag.implementations.VineGrowFlag;
|
||||||
import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
|
import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
|
||||||
import com.plotsquared.core.plot.message.PlotMessage;
|
import com.plotsquared.core.plot.message.PlotMessage;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.EntityUtil;
|
import com.plotsquared.core.util.EntityUtil;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
@ -210,6 +211,7 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.projectiles.BlockProjectileSource;
|
import org.bukkit.projectiles.BlockProjectileSource;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -224,12 +226,13 @@ import java.util.regex.Pattern;
|
|||||||
/**
|
/**
|
||||||
* Player Events involving plots.
|
* Player Events involving plots.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused") public class PlayerEvents extends PlotListener implements Listener {
|
||||||
public class PlayerEvents extends PlotListener implements Listener {
|
|
||||||
|
|
||||||
public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE =
|
public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE =
|
||||||
new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
private boolean pistonBlocks = true;
|
private boolean pistonBlocks = true;
|
||||||
private float lastRadius;
|
private float lastRadius;
|
||||||
// To prevent recursion
|
// To prevent recursion
|
||||||
@ -238,7 +241,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
private PlayerMoveEvent moveTmp;
|
private PlayerMoveEvent moveTmp;
|
||||||
private String internalVersion;
|
private String internalVersion;
|
||||||
|
|
||||||
{
|
public PlayerEvents(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
try {
|
try {
|
||||||
fieldPlayer = PlayerEvent.class.getDeclaredField("player");
|
fieldPlayer = PlayerEvent.class.getDeclaredField("player");
|
||||||
fieldPlayer.setAccessible(true);
|
fieldPlayer.setAccessible(true);
|
||||||
@ -254,7 +258,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
int z = bloc.getBlockZ();
|
int z = bloc.getBlockZ();
|
||||||
int distance = Bukkit.getViewDistance() * 16;
|
int distance = Bukkit.getViewDistance() * 16;
|
||||||
|
|
||||||
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager()
|
||||||
|
.getPlayers()) {
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
if (location.getWorldName().equals(world)) {
|
if (location.getWorldName().equals(world)) {
|
||||||
if (16 * Math.abs(location.getX() - x) / 16 > distance
|
if (16 * Math.abs(location.getX() - x) / 16 > distance
|
||||||
@ -359,19 +364,21 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (plot.isMerged()) {
|
if (plot.isMerged()) {
|
||||||
disable = true;
|
disable = true;
|
||||||
for (UUID owner : plot.getOwners()) {
|
for (UUID owner : plot.getOwners()) {
|
||||||
if (PlotSquared.platform().getPlayerManager().getPlayerIfExists(owner) != null) {
|
if (PlotSquared.platform().getPlayerManager().getPlayerIfExists(owner)
|
||||||
|
!= null) {
|
||||||
disable = false;
|
disable = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
disable = PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs())
|
disable = PlotSquared.platform().getPlayerManager()
|
||||||
== null;
|
.getPlayerIfExists(plot.getOwnerAbs()) == null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (disable) {
|
if (disable) {
|
||||||
for (UUID trusted : plot.getTrusted()) {
|
for (UUID trusted : plot.getTrusted()) {
|
||||||
if (PlotSquared.platform().getPlayerManager().getPlayerIfExists(trusted) != null) {
|
if (PlotSquared.platform().getPlayerManager().getPlayerIfExists(trusted)
|
||||||
|
!= null) {
|
||||||
disable = false;
|
disable = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -385,7 +392,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Settings.Redstone.DISABLE_UNOCCUPIED) {
|
if (Settings.Redstone.DISABLE_UNOCCUPIED) {
|
||||||
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager()
|
||||||
|
.getPlayers()) {
|
||||||
if (plot.equals(player.getCurrentPlot())) {
|
if (plot.equals(player.getCurrentPlot())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -490,7 +498,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(entity);
|
Location location = BukkitUtil.getLocation(entity);
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotPlayer<Player> pp = BukkitUtil.getPlayer((Player) shooter);
|
PlotPlayer<Player> pp = BukkitUtil.getPlayer((Player) shooter);
|
||||||
@ -504,7 +512,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
@EventHandler public boolean onProjectileHit(ProjectileHitEvent event) {
|
@EventHandler public boolean onProjectileHit(ProjectileHitEvent event) {
|
||||||
Projectile entity = event.getEntity();
|
Projectile entity = event.getEntity();
|
||||||
Location location = BukkitUtil.getLocation(entity);
|
Location location = BukkitUtil.getLocation(entity);
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
@ -1078,7 +1086,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
boolean plotArea = location.isPlotArea();
|
boolean plotArea = location.isPlotArea();
|
||||||
if (!plotArea) {
|
if (!plotArea) {
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1174,7 +1182,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onEntityBlockForm(EntityBlockFormEvent event) {
|
public void onEntityBlockForm(EntityBlockFormEvent event) {
|
||||||
String world = event.getBlock().getWorld().getName();
|
String world = event.getBlock().getWorld().getName();
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
if (!this.plotAreaManager.hasPlotArea(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||||
@ -1505,7 +1513,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Block block1 : event.getBlocks()) {
|
for (Block block1 : event.getBlocks()) {
|
||||||
@ -1542,7 +1550,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.pistonBlocks) {
|
if (this.pistonBlocks) {
|
||||||
@ -1635,7 +1643,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onStructureGrow(StructureGrowEvent event) {
|
public void onStructureGrow(StructureGrowEvent event) {
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(event.getWorld().getName())) {
|
if (!this.plotAreaManager.hasPlotArea(event.getWorld().getName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<org.bukkit.block.BlockState> blocks = event.getBlocks();
|
List<org.bukkit.block.BlockState> blocks = event.getBlocks();
|
||||||
@ -1698,7 +1706,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
HumanEntity entity = event.getWhoClicked();
|
HumanEntity entity = event.getWhoClicked();
|
||||||
if (!(entity instanceof Player) || !PlotSquared.get().getPlotAreaManager()
|
if (!(entity instanceof Player) || !this.plotAreaManager
|
||||||
.hasPlotArea(entity.getWorld().getName())) {
|
.hasPlotArea(entity.getWorld().getName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1840,7 +1848,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
public void onPotionSplash(LingeringPotionSplashEvent event) {
|
public void onPotionSplash(LingeringPotionSplashEvent event) {
|
||||||
Projectile entity = event.getEntity();
|
Projectile entity = event.getEntity();
|
||||||
Location location = BukkitUtil.getLocation(entity);
|
Location location = BukkitUtil.getLocation(entity);
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.onProjectileHit(event)) {
|
if (!this.onProjectileHit(event)) {
|
||||||
@ -1863,8 +1871,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
Plot plot = location.getPlotAbs();
|
Plot plot = location.getPlotAbs();
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
BukkitPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class)
|
if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class) && !Permissions
|
||||||
&& !Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
.hasPermission(pp, "plots.admin.interact.road")) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road");
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -1908,7 +1916,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||||
String world = location.getWorldName();
|
String world = location.getWorldName();
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
if (!this.plotAreaManager.hasPlotArea(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
@ -2182,7 +2190,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
World world = block.getWorld();
|
World world = block.getWorld();
|
||||||
String worldName = world.getName();
|
String worldName = world.getName();
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(worldName)) {
|
if (!this.plotAreaManager.hasPlotArea(worldName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||||
@ -2600,8 +2608,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
Captions.PERMISSION_ADMIN_INTERACT_UNOWNED);
|
Captions.PERMISSION_ADMIN_INTERACT_UNOWNED);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if ((plot != null && !plot.isAdded(pp.getUUID())) || area
|
} else if ((plot != null && !plot.isAdded(pp.getUUID())) || area.isRoadFlags()) {
|
||||||
.isRoadFlags()) {
|
|
||||||
final Entity entity = event.getRightClicked();
|
final Entity entity = event.getRightClicked();
|
||||||
final com.sk89q.worldedit.world.entity.EntityType entityType =
|
final com.sk89q.worldedit.world.entity.EntityType entityType =
|
||||||
BukkitAdapter.adapt(entity.getType());
|
BukkitAdapter.adapt(entity.getType());
|
||||||
@ -2707,7 +2714,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
public void onPotionSplash(PotionSplashEvent event) {
|
public void onPotionSplash(PotionSplashEvent event) {
|
||||||
ThrownPotion damager = event.getPotion();
|
ThrownPotion damager = event.getPotion();
|
||||||
Location location = BukkitUtil.getLocation(damager);
|
Location location = BukkitUtil.getLocation(damager);
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -2737,7 +2744,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
||||||
Entity damager = event.getDamager();
|
Entity damager = event.getDamager();
|
||||||
Location location = BukkitUtil.getLocation(damager);
|
Location location = BukkitUtil.getLocation(damager);
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Entity victim = event.getEntity();
|
Entity victim = event.getEntity();
|
||||||
|
@ -36,17 +36,23 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.world.WorldInitEvent;
|
import org.bukkit.event.world.WorldInitEvent;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class WorldEvents implements Listener {
|
public class WorldEvents implements Listener {
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
|
public WorldEvents(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onWorldInit(WorldInitEvent event) {
|
public void onWorldInit(WorldInitEvent event) {
|
||||||
World world = event.getWorld();
|
World world = event.getWorld();
|
||||||
String name = world.getName();
|
String name = world.getName();
|
||||||
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
|
if (this.plotAreaManager instanceof SinglePlotAreaManager) {
|
||||||
if (manager instanceof SinglePlotAreaManager) {
|
final SinglePlotAreaManager single = (SinglePlotAreaManager) this.plotAreaManager;
|
||||||
SinglePlotAreaManager single = (SinglePlotAreaManager) manager;
|
|
||||||
if (single.isWorld(name)) {
|
if (single.isWorld(name)) {
|
||||||
world.setKeepSpawnInMemory(false);
|
world.setKeepSpawnInMemory(false);
|
||||||
return;
|
return;
|
||||||
@ -56,7 +62,7 @@ public class WorldEvents implements Listener {
|
|||||||
if (gen instanceof GeneratorWrapper) {
|
if (gen instanceof GeneratorWrapper) {
|
||||||
PlotSquared.get().loadWorld(name, (GeneratorWrapper<?>) gen);
|
PlotSquared.get().loadWorld(name, (GeneratorWrapper<?>) gen);
|
||||||
} else {
|
} else {
|
||||||
PlotSquared.get().loadWorld(name, new BukkitPlotGenerator(name, gen));
|
PlotSquared.get().loadWorld(name, new BukkitPlotGenerator(name, gen, this.plotAreaManager));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ import com.plotsquared.core.events.TeleportCause;
|
|||||||
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.PlotWeather;
|
import com.plotsquared.core.plot.PlotWeather;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
@ -76,15 +77,16 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
|||||||
*
|
*
|
||||||
* @param player Bukkit player instance
|
* @param player Bukkit player instance
|
||||||
*/
|
*/
|
||||||
public BukkitPlayer(@NotNull final Player player) {
|
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final Player player) {
|
||||||
this(player, false);
|
this(plotAreaManager, player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitPlayer(@NotNull final Player player, final boolean offline) {
|
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final Player player, final boolean offline) {
|
||||||
this(player, offline, true);
|
this(plotAreaManager, player, offline, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitPlayer(@NotNull final Player player, final boolean offline, final boolean realPlayer) {
|
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final Player player, final boolean offline, final boolean realPlayer) {
|
||||||
|
super(plotAreaManager);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.offline = offline;
|
this.offline = offline;
|
||||||
if (realPlayer) {
|
if (realPlayer) {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.player;
|
package com.plotsquared.bukkit.player;
|
||||||
|
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.PlayerManager;
|
import com.plotsquared.core.util.PlayerManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -38,11 +39,17 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class BukkitPlayerManager extends PlayerManager<BukkitPlayer, Player> {
|
public class BukkitPlayerManager extends PlayerManager<BukkitPlayer, Player> {
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
|
public BukkitPlayerManager(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull @Override public BukkitPlayer getPlayer(@NotNull final Player object) {
|
@NotNull @Override public BukkitPlayer getPlayer(@NotNull final Player object) {
|
||||||
try {
|
try {
|
||||||
return getPlayer(object.getUniqueId());
|
return getPlayer(object.getUniqueId());
|
||||||
} catch (final NoSuchPlayerException exception) {
|
} catch (final NoSuchPlayerException exception) {
|
||||||
return new BukkitPlayer(object, object.isOnline(), false);
|
return new BukkitPlayer(this.plotAreaManager, object, object.isOnline(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +58,7 @@ public class BukkitPlayerManager extends PlayerManager<BukkitPlayer, Player> {
|
|||||||
if (player == null || !player.isOnline()) {
|
if (player == null || !player.isOnline()) {
|
||||||
throw new NoSuchPlayerException(uuid);
|
throw new NoSuchPlayerException(uuid);
|
||||||
}
|
}
|
||||||
return new BukkitPlayer(player);
|
return new BukkitPlayer(this.plotAreaManager, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable @Override public BukkitOfflinePlayer getOfflinePlayer(@Nullable final UUID uuid) {
|
@Nullable @Override public BukkitOfflinePlayer getOfflinePlayer(@Nullable final UUID uuid) {
|
||||||
|
@ -33,6 +33,7 @@ import com.plotsquared.core.generator.GeneratorWrapper;
|
|||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotAreaType;
|
import com.plotsquared.core.plot.PlotAreaType;
|
||||||
import com.plotsquared.core.plot.SetupObject;
|
import com.plotsquared.core.plot.SetupObject;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||||
import com.plotsquared.core.util.SetupUtils;
|
import com.plotsquared.core.util.SetupUtils;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
@ -42,6 +43,7 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -50,6 +52,12 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class BukkitSetupUtils extends SetupUtils {
|
public class BukkitSetupUtils extends SetupUtils {
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
|
public BukkitSetupUtils(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public void updateGenerators() {
|
@Override public void updateGenerators() {
|
||||||
if (!SetupUtils.generators.isEmpty()) {
|
if (!SetupUtils.generators.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@ -66,7 +74,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
if (generator instanceof GeneratorWrapper<?>) {
|
if (generator instanceof GeneratorWrapper<?>) {
|
||||||
wrapped = (GeneratorWrapper<?>) generator;
|
wrapped = (GeneratorWrapper<?>) generator;
|
||||||
} else {
|
} else {
|
||||||
wrapped = new BukkitPlotGenerator(testWorld, generator);
|
wrapped = new BukkitPlotGenerator(testWorld, generator, this.plotAreaManager);
|
||||||
}
|
}
|
||||||
SetupUtils.generators.put(name, wrapped);
|
SetupUtils.generators.put(name, wrapped);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
final Player player = OfflinePlayerUtil.loadPlayer(op);
|
final Player player = OfflinePlayerUtil.loadPlayer(op);
|
||||||
player.loadData();
|
player.loadData();
|
||||||
return new BukkitPlayer(player, true);
|
return new BukkitPlayer(PlotSquared.get().getPlotAreaManager(), player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,7 +131,6 @@ import java.util.zip.ZipInputStream;
|
|||||||
@SuppressWarnings({"WeakerAccess"})
|
@SuppressWarnings({"WeakerAccess"})
|
||||||
public class PlotSquared {
|
public class PlotSquared {
|
||||||
|
|
||||||
private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
|
|
||||||
private static PlotSquared instance;
|
private static PlotSquared instance;
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
@ -285,7 +284,7 @@ public class PlotSquared {
|
|||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "&6" + this.platform.getPluginName()
|
PlotSquared.log(Captions.PREFIX.getTranslated() + "&6" + this.platform.getPluginName()
|
||||||
+ " hooked into WorldEdit.");
|
+ " hooked into WorldEdit.");
|
||||||
this.worldedit = WorldEdit.getInstance();
|
this.worldedit = WorldEdit.getInstance();
|
||||||
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
WorldEdit.getInstance().getEventBus().register(new WESubscriber(this.plotAreaManager));
|
||||||
if (Settings.Enabled_Components.COMMANDS) {
|
if (Settings.Enabled_Components.COMMANDS) {
|
||||||
new WE_Anywhere();
|
new WE_Anywhere();
|
||||||
}
|
}
|
||||||
@ -431,7 +430,7 @@ public class PlotSquared {
|
|||||||
ExpireManager.IMP = new ExpireManager();
|
ExpireManager.IMP = new ExpireManager();
|
||||||
ExpireManager.IMP.runAutomatedTask();
|
ExpireManager.IMP.runAutomatedTask();
|
||||||
for (Settings.Auto_Clear settings : Settings.AUTO_CLEAR.getInstances()) {
|
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);
|
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.PlotAreaType;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.plot.message.PlotMessage;
|
import com.plotsquared.core.plot.message.PlotMessage;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
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.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -85,6 +87,12 @@ import java.util.Set;
|
|||||||
confirmation = true)
|
confirmation = true)
|
||||||
public class Area extends SubCommand {
|
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) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||||
@ -104,7 +112,7 @@ public class Area extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NEEDS_NAME);
|
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NEEDS_NAME);
|
||||||
return false;
|
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])) {
|
if (existingArea != null && existingArea.getId().equalsIgnoreCase(args[1])) {
|
||||||
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NAME_TAKEN);
|
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NAME_TAKEN);
|
||||||
return false;
|
return false;
|
||||||
@ -126,7 +134,7 @@ public class Area extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NOT_SQUARE);
|
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NOT_SQUARE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (PlotSquared.get().getPlotAreaManager().getPlotAreas(
|
if (this.plotAreaManager.getPlotAreas(
|
||||||
Objects.requireNonNull(playerSelectedRegion.getWorld()).getName(), CuboidRegion.makeCuboid(playerSelectedRegion)).length != 0) {
|
Objects.requireNonNull(playerSelectedRegion.getWorld()).getName(), CuboidRegion.makeCuboid(playerSelectedRegion)).length != 0) {
|
||||||
MainUtil.sendMessage(player, Captions.SINGLE_AREA_OVERLAPPING);
|
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 offsetX = bx - (area.ROAD_WIDTH == 0 ? 0 : lower);
|
||||||
final int offsetZ = bz - (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 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);
|
.getPlotAreasSet(area.getWorldName(), region);
|
||||||
if (!areas.isEmpty()) {
|
if (!areas.isEmpty()) {
|
||||||
Captions.CLUSTER_INTERSECTION
|
Captions.CLUSTER_INTERSECTION
|
||||||
@ -342,12 +350,12 @@ public class Area extends SubCommand {
|
|||||||
builder.worldName(split[0]);
|
builder.worldName(split[0]);
|
||||||
final HybridPlotWorld pa = new HybridPlotWorld(builder.worldName(), id,
|
final HybridPlotWorld pa = new HybridPlotWorld(builder.worldName(), id,
|
||||||
PlotSquared.platform().getDefaultGenerator(), null, null);
|
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())) {
|
if (other != null && Objects.equals(pa.getId(), other.getId())) {
|
||||||
Captions.SETUP_WORLD_TAKEN.send(player, pa.toString());
|
Captions.SETUP_WORLD_TAKEN.send(player, pa.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Set<PlotArea> areas = PlotSquared.get().getPlotAreaManager().getPlotAreasSet(pa.getWorldName());
|
Set<PlotArea> areas = this.plotAreaManager.getPlotAreasSet(pa.getWorldName());
|
||||||
if (!areas.isEmpty()) {
|
if (!areas.isEmpty()) {
|
||||||
PlotArea area = areas.iterator().next();
|
PlotArea area = areas.iterator().next();
|
||||||
pa.setType(area.getType());
|
pa.setType(area.getType());
|
||||||
@ -492,7 +500,7 @@ public class Area extends SubCommand {
|
|||||||
area = player.getApplicablePlotArea();
|
area = player.getApplicablePlotArea();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[1]);
|
area = this.plotAreaManager.getPlotAreaByString(args[1]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Captions.COMMAND_SYNTAX.send(player, getCommandString() + " info [area]");
|
Captions.COMMAND_SYNTAX.send(player, getCommandString() + " info [area]");
|
||||||
@ -554,7 +562,7 @@ public class Area extends SubCommand {
|
|||||||
Captions.COMMAND_SYNTAX.send(player, getCommandString() + " list [#]");
|
Captions.COMMAND_SYNTAX.send(player, getCommandString() + " list [#]");
|
||||||
return false;
|
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,
|
paginate(player, areas, 8, page,
|
||||||
new RunnableVal3<Integer, PlotArea, PlotMessage>() {
|
new RunnableVal3<Integer, PlotArea, PlotMessage>() {
|
||||||
@Override public void run(Integer i, PlotArea area, PlotMessage message) {
|
@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]");
|
Captions.COMMAND_SYNTAX.send(player, "/plot visit [area]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[1]);
|
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
Captions.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
Captions.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||||
return false;
|
return false;
|
||||||
|
@ -40,6 +40,7 @@ import com.plotsquared.core.plot.Plot;
|
|||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotAreaType;
|
import com.plotsquared.core.plot.PlotAreaType;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
import com.plotsquared.core.util.Expression;
|
import com.plotsquared.core.util.Expression;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
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.AutoClaimFinishTask;
|
||||||
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 org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -61,6 +63,12 @@ import java.util.Set;
|
|||||||
usage = "/plot auto [length,width]")
|
usage = "/plot auto [length,width]")
|
||||||
public class Auto extends SubCommand {
|
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) {
|
@Deprecated public static PlotId getNextPlotId(PlotId id, int step) {
|
||||||
return id.getNextId(step);
|
return id.getNextId(step);
|
||||||
}
|
}
|
||||||
@ -158,7 +166,7 @@ public class Auto extends SubCommand {
|
|||||||
PlotArea plotarea = player.getApplicablePlotArea();
|
PlotArea plotarea = player.getApplicablePlotArea();
|
||||||
if (plotarea == null) {
|
if (plotarea == null) {
|
||||||
if (EconHandler.getEconHandler() != null) {
|
if (EconHandler.getEconHandler() != null) {
|
||||||
for (PlotArea area : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) {
|
for (PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
||||||
if (EconHandler.getEconHandler()
|
if (EconHandler.getEconHandler()
|
||||||
.hasPermission(area.getWorldName(), player.getName(), "plots.auto")) {
|
.hasPermission(area.getWorldName(), player.getName(), "plots.auto")) {
|
||||||
if (plotarea != null) {
|
if (plotarea != null) {
|
||||||
@ -169,8 +177,8 @@ public class Auto extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PlotSquared.get().getPlotAreaManager().getAllPlotAreas().length == 1) {
|
if (this.plotAreaManager.getAllPlotAreas().length == 1) {
|
||||||
plotarea = PlotSquared.get().getPlotAreaManager().getAllPlotAreas()[0];
|
plotarea = this.plotAreaManager.getAllPlotAreas()[0];
|
||||||
}
|
}
|
||||||
if (plotarea == null) {
|
if (plotarea == null) {
|
||||||
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||||
|
@ -25,15 +25,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
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.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -54,12 +55,18 @@ public class Condense extends SubCommand {
|
|||||||
|
|
||||||
public static boolean TASK = false;
|
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) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
if (args.length != 2 && args.length != 3) {
|
if (args.length != 2 && args.length != 3) {
|
||||||
MainUtil.sendMessage(player, getUsage());
|
MainUtil.sendMessage(player, getUsage());
|
||||||
return false;
|
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())) {
|
if (area == null || !WorldUtil.IMP.isWorld(area.getWorldName())) {
|
||||||
MainUtil.sendMessage(player, "INVALID AREA");
|
MainUtil.sendMessage(player, "INVALID AREA");
|
||||||
return false;
|
return false;
|
||||||
|
@ -35,10 +35,12 @@ import com.plotsquared.core.player.PlotPlayer;
|
|||||||
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.PlotId;
|
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.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.query.PlotQuery;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -57,6 +59,12 @@ import java.util.Map.Entry;
|
|||||||
usage = "/plot database [area] <sqlite|mysql|import>")
|
usage = "/plot database [area] <sqlite|mysql|import>")
|
||||||
public class DatabaseCommand extends SubCommand {
|
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,
|
public static void insertPlots(final SQLManager manager, final List<Plot> plots,
|
||||||
final PlotPlayer player) {
|
final PlotPlayer player) {
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
@ -81,7 +89,7 @@ public class DatabaseCommand extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
List<Plot> plots;
|
List<Plot> plots;
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[0]);
|
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]);
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
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);
|
||||||
@ -117,7 +125,7 @@ public class DatabaseCommand extends SubCommand {
|
|||||||
plots = new ArrayList<>();
|
plots = new ArrayList<>();
|
||||||
for (Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
for (Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
||||||
String areaName = entry.getKey();
|
String areaName = entry.getKey();
|
||||||
PlotArea pa = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(areaName);
|
PlotArea pa = this.plotAreaManager.getPlotAreaByString(areaName);
|
||||||
if (pa != null) {
|
if (pa != null) {
|
||||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||||
Plot plot = entry2.getValue();
|
Plot plot = entry2.getValue();
|
||||||
|
@ -28,6 +28,7 @@ package com.plotsquared.core.command;
|
|||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.RegionManager;
|
import com.plotsquared.core.util.RegionManager;
|
||||||
import com.plotsquared.core.util.StringMan;
|
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.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;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -49,6 +51,12 @@ import java.util.Map;
|
|||||||
permission = "plots.admin")
|
permission = "plots.admin")
|
||||||
public class Debug extends SubCommand {
|
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) {
|
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
if ("player".equalsIgnoreCase(args[0])) {
|
if ("player".equalsIgnoreCase(args[0])) {
|
||||||
@ -119,7 +127,7 @@ public class Debug extends SubCommand {
|
|||||||
information.append(header);
|
information.append(header);
|
||||||
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(this.plotAreaManager.getAllPlotAreas(), ", ")));
|
||||||
information.append(getLine(line, "Owned Plots", PlotQuery.newQuery().allPlots().count()));
|
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));
|
||||||
|
@ -44,6 +44,7 @@ import com.plotsquared.core.plot.expiration.PlotAnalysis;
|
|||||||
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
import com.plotsquared.core.plot.message.PlotMessage;
|
import com.plotsquared.core.plot.message.PlotMessage;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
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.RunnableVal3;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.script.Bindings;
|
import javax.script.Bindings;
|
||||||
import javax.script.ScriptContext;
|
import javax.script.ScriptContext;
|
||||||
@ -81,10 +83,13 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
aliases = {"exec", "$"},
|
aliases = {"exec", "$"},
|
||||||
category = CommandCategory.DEBUG)
|
category = CommandCategory.DEBUG)
|
||||||
public class DebugExec extends SubCommand {
|
public class DebugExec extends SubCommand {
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
private ScriptEngine engine;
|
private ScriptEngine engine;
|
||||||
private Bindings scope;
|
private Bindings scope;
|
||||||
|
|
||||||
public DebugExec() {
|
public DebugExec(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
init();
|
init();
|
||||||
/*
|
/*
|
||||||
try {
|
try {
|
||||||
@ -259,7 +264,7 @@ public class DebugExec extends SubCommand {
|
|||||||
"&cInvalid syntax: /plot debugexec start-rgar <world>");
|
"&cInvalid syntax: /plot debugexec start-rgar <world>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[1]);
|
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD, args[1]);
|
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD, args[1]);
|
||||||
return false;
|
return false;
|
||||||
|
@ -36,6 +36,7 @@ import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
|||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -47,8 +48,12 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
requiredType = RequiredType.CONSOLE,
|
requiredType = RequiredType.CONSOLE,
|
||||||
category = CommandCategory.TELEPORT)
|
category = CommandCategory.TELEPORT)
|
||||||
public class DebugImportWorlds extends Command {
|
public class DebugImportWorlds extends Command {
|
||||||
public DebugImportWorlds() {
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
|
public DebugImportWorlds(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
super(MainCommand.getInstance(), true);
|
super(MainCommand.getInstance(), true);
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,12 +61,11 @@ public class DebugImportWorlds extends Command {
|
|||||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||||
// UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8))
|
// UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8))
|
||||||
PlotAreaManager pam = PlotSquared.get().getPlotAreaManager();
|
if (!(this.plotAreaManager instanceof SinglePlotAreaManager)) {
|
||||||
if (!(pam instanceof SinglePlotAreaManager)) {
|
|
||||||
player.sendMessage("Must be a single plot area!");
|
player.sendMessage("Must be a single plot area!");
|
||||||
return CompletableFuture.completedFuture(false);
|
return CompletableFuture.completedFuture(false);
|
||||||
}
|
}
|
||||||
SinglePlotArea area = ((SinglePlotAreaManager) pam).getArea();
|
SinglePlotArea area = ((SinglePlotAreaManager) this.plotAreaManager).getArea();
|
||||||
PlotId id = new PlotId(0, 0);
|
PlotId id = new PlotId(0, 0);
|
||||||
File container = PlotSquared.platform().getWorldContainer();
|
File container = PlotSquared.platform().getWorldContainer();
|
||||||
if (container.equals(new File("."))) {
|
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.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.plot.world.PlotAreaManager;
|
||||||
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.TabCompletions;
|
import com.plotsquared.core.util.TabCompletions;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -50,8 +52,11 @@ import java.util.concurrent.TimeoutException;
|
|||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.PLAYER)
|
||||||
public class Deny extends SubCommand {
|
public class Deny extends SubCommand {
|
||||||
|
|
||||||
public Deny() {
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
|
public Deny(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
super(Argument.PlayerName);
|
super(Argument.PlayerName);
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||||
@ -136,8 +141,7 @@ public class Deny extends SubCommand {
|
|||||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorldName());
|
Location spawn = WorldUtil.IMP.getSpawn(location.getWorldName());
|
||||||
MainUtil.sendMessage(player, Captions.YOU_GOT_DENIED);
|
MainUtil.sendMessage(player, Captions.YOU_GOT_DENIED);
|
||||||
if (plot.equals(spawn.getPlot())) {
|
if (plot.equals(spawn.getPlot())) {
|
||||||
Location newSpawn =
|
Location newSpawn = WorldUtil.IMP.getSpawn(this.plotAreaManager.getAllWorlds()[0]);
|
||||||
WorldUtil.IMP.getSpawn(PlotSquared.get().getPlotAreaManager().getAllWorlds()[0]);
|
|
||||||
if (plot.equals(newSpawn.getPlot())) {
|
if (plot.equals(newSpawn.getPlot())) {
|
||||||
// Kick from server if you can't be teleported to spawn
|
// Kick from server if you can't be teleported to spawn
|
||||||
player.kick(Captions.YOU_GOT_DENIED.getTranslated());
|
player.kick(Captions.YOU_GOT_DENIED.getTranslated());
|
||||||
|
@ -25,12 +25,12 @@
|
|||||||
*/
|
*/
|
||||||
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.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
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.plot.flag.implementations.DoneFlag;
|
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.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
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.WorldUtil;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
@ -50,9 +51,15 @@ import java.net.URL;
|
|||||||
permission = "plots.download")
|
permission = "plots.download")
|
||||||
public class Download extends SubCommand {
|
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) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
String world = player.getLocation().getWorldName();
|
String world = player.getLocation().getWorldName();
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
if (!this.plotAreaManager.hasPlotArea(world)) {
|
||||||
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||||
}
|
}
|
||||||
final Plot plot = player.getCurrentPlot();
|
final Plot plot = player.getCurrentPlot();
|
||||||
|
@ -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.events.TeleportCause;
|
import com.plotsquared.core.events.TeleportCause;
|
||||||
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.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
@ -55,8 +55,12 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
requiredType = RequiredType.PLAYER,
|
requiredType = RequiredType.PLAYER,
|
||||||
category = CommandCategory.TELEPORT)
|
category = CommandCategory.TELEPORT)
|
||||||
public class HomeCommand extends Command {
|
public class HomeCommand extends Command {
|
||||||
public HomeCommand() {
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
|
public HomeCommand(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
super(MainCommand.getInstance(), true);
|
super(MainCommand.getInstance(), true);
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void home(@NotNull final PlotPlayer<?> player,
|
private void home(@NotNull final PlotPlayer<?> player,
|
||||||
@ -132,7 +136,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().getPlotAreaManager().getPlotAreaByString(args[0]);
|
final PlotArea plotArea = this.plotAreaManager.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
|
||||||
|
@ -31,10 +31,12 @@ import com.plotsquared.core.database.DBFunc;
|
|||||||
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.plot.world.PlotAreaManager;
|
||||||
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.TabCompletions;
|
import com.plotsquared.core.util.TabCompletions;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -52,8 +54,11 @@ import java.util.concurrent.TimeoutException;
|
|||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.PLAYER)
|
||||||
public class Kick extends SubCommand {
|
public class Kick extends SubCommand {
|
||||||
|
|
||||||
public Kick() {
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
|
public Kick(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
super(Argument.PlayerName);
|
super(Argument.PlayerName);
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||||
@ -108,8 +113,7 @@ public class Kick extends SubCommand {
|
|||||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorldName());
|
Location spawn = WorldUtil.IMP.getSpawn(location.getWorldName());
|
||||||
Captions.YOU_GOT_KICKED.send(player2);
|
Captions.YOU_GOT_KICKED.send(player2);
|
||||||
if (plot.equals(spawn.getPlot())) {
|
if (plot.equals(spawn.getPlot())) {
|
||||||
Location newSpawn = WorldUtil.IMP
|
Location newSpawn = WorldUtil.IMP.getSpawn(this.plotAreaManager.getAllWorlds()[0]);
|
||||||
.getSpawn(PlotSquared.get().getPlotAreaManager().getAllWorlds()[0]);
|
|
||||||
if (plot.equals(newSpawn.getPlot())) {
|
if (plot.equals(newSpawn.getPlot())) {
|
||||||
// Kick from server if you can't be teleported to spawn
|
// Kick from server if you can't be teleported to spawn
|
||||||
player2.kick(Captions.YOU_GOT_KICKED.getTranslated());
|
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.DoneFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.PriceFlag;
|
import com.plotsquared.core.plot.flag.implementations.PriceFlag;
|
||||||
import com.plotsquared.core.plot.message.PlotMessage;
|
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.EconHandler;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
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.query.SortingStrategy;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
import com.plotsquared.core.uuid.UUIDMapping;
|
import com.plotsquared.core.uuid.UUIDMapping;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
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...>> [#]")
|
usage = "/plot list <forsale|mine|shared|world|top|all|unowned|player|world|done|fuzzy <search...>> [#]")
|
||||||
public class ListCmd extends SubCommand {
|
public class ListCmd extends SubCommand {
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
|
public ListCmd(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
}
|
||||||
|
|
||||||
private String[] getArgumentList(PlotPlayer player) {
|
private String[] getArgumentList(PlotPlayer player) {
|
||||||
List<String> args = new ArrayList<>();
|
List<String> args = new ArrayList<>();
|
||||||
if (EconHandler.getEconHandler() != null && Permissions
|
if (EconHandler.getEconHandler() != null && Permissions
|
||||||
@ -297,7 +305,7 @@ public class ListCmd extends SubCommand {
|
|||||||
plotConsumer.accept(PlotQuery.newQuery().plotsBySearch(term));
|
plotConsumer.accept(PlotQuery.newQuery().plotsBySearch(term));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(args[0])) {
|
if (this.plotAreaManager.hasPlotArea(args[0])) {
|
||||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_WORLD)) {
|
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_WORLD)) {
|
||||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||||
Captions.PERMISSION_LIST_WORLD);
|
Captions.PERMISSION_LIST_WORLD);
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
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.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
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.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.plot.schematic.Schematic;
|
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.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
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 org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -52,9 +53,15 @@ import java.util.List;
|
|||||||
usage = "/plot load")
|
usage = "/plot load")
|
||||||
public class Load extends SubCommand {
|
public class Load extends SubCommand {
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
private final PlotAreaManager plotAreaManager;
|
||||||
String world = player.getLocation().getWorldName();
|
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
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);
|
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||||
}
|
}
|
||||||
final Plot plot = player.getCurrentPlot();
|
final Plot plot = player.getCurrentPlot();
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
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.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.location.Location;
|
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.player.PlotPlayer;
|
||||||
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.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
import com.plotsquared.core.util.Expression;
|
import com.plotsquared.core.util.Expression;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
@ -60,61 +62,62 @@ public class MainCommand extends Command {
|
|||||||
public static MainCommand getInstance() {
|
public static MainCommand getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new MainCommand();
|
instance = new MainCommand();
|
||||||
|
final PlotAreaManager plotAreaManager = PlotSquared.get().getPlotAreaManager();
|
||||||
new Caps();
|
new Caps();
|
||||||
new Buy();
|
new Buy();
|
||||||
new Save();
|
new Save(plotAreaManager);
|
||||||
new Load();
|
new Load(plotAreaManager);
|
||||||
new Confirm();
|
new Confirm();
|
||||||
new Template();
|
new Template(plotAreaManager);
|
||||||
new Download();
|
new Download(plotAreaManager);
|
||||||
new Template();
|
new Template(plotAreaManager);
|
||||||
new Setup();
|
new Setup();
|
||||||
new Area();
|
new Area(plotAreaManager);
|
||||||
new DebugSaveTest();
|
new DebugSaveTest();
|
||||||
new DebugLoadTest();
|
new DebugLoadTest();
|
||||||
new CreateRoadSchematic();
|
new CreateRoadSchematic();
|
||||||
new DebugAllowUnsafe();
|
new DebugAllowUnsafe();
|
||||||
new RegenAllRoads();
|
new RegenAllRoads(plotAreaManager);
|
||||||
new Claim();
|
new Claim();
|
||||||
new Auto();
|
new Auto(plotAreaManager);
|
||||||
new HomeCommand();
|
new HomeCommand(plotAreaManager);
|
||||||
new Visit();
|
new Visit(plotAreaManager);
|
||||||
new Set();
|
new Set();
|
||||||
new Clear();
|
new Clear();
|
||||||
new Delete();
|
new Delete();
|
||||||
new Trust();
|
new Trust();
|
||||||
new Add();
|
new Add();
|
||||||
new Leave();
|
new Leave();
|
||||||
new Deny();
|
new Deny(plotAreaManager);
|
||||||
new Remove();
|
new Remove();
|
||||||
new Info();
|
new Info();
|
||||||
new Near();
|
new Near();
|
||||||
new ListCmd();
|
new ListCmd(plotAreaManager);
|
||||||
new Debug();
|
new Debug(plotAreaManager);
|
||||||
new SchematicCmd();
|
new SchematicCmd(plotAreaManager);
|
||||||
new PluginCmd();
|
new PluginCmd();
|
||||||
new Purge();
|
new Purge(plotAreaManager);
|
||||||
new Reload();
|
new Reload(plotAreaManager);
|
||||||
new Relight();
|
new Relight();
|
||||||
new Merge();
|
new Merge();
|
||||||
new DebugPaste();
|
new DebugPaste();
|
||||||
new Unlink();
|
new Unlink();
|
||||||
new Kick();
|
new Kick(plotAreaManager);
|
||||||
new Inbox();
|
new Inbox();
|
||||||
new Comment();
|
new Comment();
|
||||||
new DatabaseCommand();
|
new DatabaseCommand(plotAreaManager);
|
||||||
new Swap();
|
new Swap();
|
||||||
new Music();
|
new Music();
|
||||||
new DebugRoadRegen();
|
new DebugRoadRegen();
|
||||||
new Trust();
|
new Trust();
|
||||||
new DebugExec();
|
new DebugExec(plotAreaManager);
|
||||||
new FlagCommand();
|
new FlagCommand();
|
||||||
new Target();
|
new Target();
|
||||||
new Move();
|
new Move(plotAreaManager);
|
||||||
new Condense();
|
new Condense(plotAreaManager);
|
||||||
new Copy();
|
new Copy();
|
||||||
new Chat();
|
new Chat();
|
||||||
new Trim();
|
new Trim(plotAreaManager);
|
||||||
new Done();
|
new Done();
|
||||||
new Continue();
|
new Continue();
|
||||||
new Middle();
|
new Middle();
|
||||||
@ -126,7 +129,7 @@ public class MainCommand extends Command {
|
|||||||
new Alias();
|
new Alias();
|
||||||
new SetHome();
|
new SetHome();
|
||||||
new Cluster();
|
new Cluster();
|
||||||
new DebugImportWorlds();
|
new DebugImportWorlds(plotAreaManager);
|
||||||
new Backup();
|
new Backup();
|
||||||
|
|
||||||
if (Settings.Ratings.USE_LIKES) {
|
if (Settings.Ratings.USE_LIKES) {
|
||||||
@ -143,7 +146,7 @@ public class MainCommand extends Command {
|
|||||||
return instance;
|
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(":")) {
|
if (args.length >= 1 && args[0].contains(":")) {
|
||||||
String[] split2 = args[0].split(":");
|
String[] split2 = args[0].split(":");
|
||||||
if (split2.length == 2) {
|
if (split2.length == 2) {
|
||||||
|
@ -25,16 +25,17 @@
|
|||||||
*/
|
*/
|
||||||
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.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
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.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@ -46,6 +47,12 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.PLAYER)
|
||||||
public class Move extends SubCommand {
|
public class Move extends SubCommand {
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
|
public Move(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||||
@ -70,7 +77,7 @@ public class Move extends SubCommand {
|
|||||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||||
return CompletableFuture.completedFuture(false);
|
return CompletableFuture.completedFuture(false);
|
||||||
}
|
}
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[0]);
|
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]);
|
||||||
Plot plot2;
|
Plot plot2;
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
plot2 = MainUtil.getPlotFromString(player, args[0], true);
|
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.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -53,6 +55,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
confirmation = true)
|
confirmation = true)
|
||||||
public class Purge extends SubCommand {
|
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) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||||
@ -78,7 +86,7 @@ public class Purge extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
case "area":
|
case "area":
|
||||||
case "a":
|
case "a":
|
||||||
area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(split[1]);
|
area = this.plotAreaManager.getPlotAreaByString(split[1]);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
Captions.NOT_VALID_PLOT_WORLD.send(player, split[1]);
|
Captions.NOT_VALID_PLOT_WORLD.send(player, split[1]);
|
||||||
return false;
|
return false;
|
||||||
|
@ -25,14 +25,15 @@
|
|||||||
*/
|
*/
|
||||||
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.generator.HybridPlotManager;
|
import com.plotsquared.core.generator.HybridPlotManager;
|
||||||
import com.plotsquared.core.generator.HybridUtils;
|
import com.plotsquared.core.generator.HybridUtils;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotManager;
|
import com.plotsquared.core.plot.PlotManager;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@CommandDeclaration(command = "regenallroads",
|
@CommandDeclaration(command = "regenallroads",
|
||||||
description = "Regenerate all roads in the map using the set road schematic",
|
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")
|
permission = "plots.regenallroads")
|
||||||
public class RegenAllRoads extends SubCommand {
|
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) {
|
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||||
int height = 0;
|
int height = 0;
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
@ -59,7 +66,7 @@ public class RegenAllRoads extends SubCommand {
|
|||||||
"/plot regenallroads <world> [height]");
|
"/plot regenallroads <world> [height]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[0]);
|
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
Captions.NOT_VALID_PLOT_WORLD.send(player, args[0]);
|
Captions.NOT_VALID_PLOT_WORLD.send(player, args[0]);
|
||||||
return false;
|
return false;
|
||||||
|
@ -32,7 +32,9 @@ import com.plotsquared.core.configuration.MemorySection;
|
|||||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.PlotAreaType;
|
import com.plotsquared.core.plot.PlotAreaType;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -45,13 +47,19 @@ import java.util.Objects;
|
|||||||
category = CommandCategory.ADMINISTRATION)
|
category = CommandCategory.ADMINISTRATION)
|
||||||
public class Reload extends SubCommand {
|
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) {
|
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||||
try {
|
try {
|
||||||
// The following won't affect world generation, as that has to be
|
// The following won't affect world generation, as that has to be
|
||||||
// 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().getPlotAreaManager().forEachPlotArea(area -> {
|
this.plotAreaManager.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,18 +25,19 @@
|
|||||||
*/
|
*/
|
||||||
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.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
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.SchematicHandler;
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
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.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -49,9 +50,15 @@ import java.util.UUID;
|
|||||||
permission = "plots.save")
|
permission = "plots.save")
|
||||||
public class Save extends SubCommand {
|
public class Save extends SubCommand {
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
private final PlotAreaManager plotAreaManager;
|
||||||
String world = player.getLocation().getWorldName();
|
|
||||||
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
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);
|
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||||
}
|
}
|
||||||
final Plot plot = player.getCurrentPlot();
|
final Plot plot = player.getCurrentPlot();
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.location.Location;
|
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.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.schematic.Schematic;
|
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.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
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 org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -55,8 +56,13 @@ import java.util.UUID;
|
|||||||
usage = "/plot schematic <save|saveall|paste>")
|
usage = "/plot schematic <save|saveall|paste>")
|
||||||
public class SchematicCmd extends SubCommand {
|
public class SchematicCmd extends SubCommand {
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
private boolean running = false;
|
private boolean running = false;
|
||||||
|
|
||||||
|
public SchematicCmd(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
sendMessage(player, Captions.SCHEMATIC_MISSING_ARG);
|
sendMessage(player, Captions.SCHEMATIC_MISSING_ARG);
|
||||||
@ -150,7 +156,7 @@ public class SchematicCmd extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_WORLD_ARGS);
|
MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_WORLD_ARGS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(args[1]);
|
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
Captions.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
Captions.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||||
return false;
|
return false;
|
||||||
|
@ -36,6 +36,7 @@ import com.plotsquared.core.events.TeleportCause;
|
|||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotManager;
|
import com.plotsquared.core.plot.PlotManager;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||||
import com.plotsquared.core.setup.SettingsNodesWrapper;
|
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.SetupUtils;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -61,6 +63,12 @@ import java.util.zip.ZipOutputStream;
|
|||||||
category = CommandCategory.ADMINISTRATION)
|
category = CommandCategory.ADMINISTRATION)
|
||||||
public class Template extends SubCommand {
|
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) {
|
public static boolean extractAllFiles(String world, String template) {
|
||||||
try {
|
try {
|
||||||
File folder =
|
File folder =
|
||||||
@ -159,7 +167,7 @@ public class Template extends SubCommand {
|
|||||||
"/plot template import <world> <template>");
|
"/plot template import <world> <template>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
if (this.plotAreaManager.hasPlotArea(world)) {
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_WORLD_TAKEN, world);
|
MainUtil.sendMessage(player, Captions.SETUP_WORLD_TAKEN, world);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -203,7 +211,7 @@ public class Template extends SubCommand {
|
|||||||
"/plot template export <world>");
|
"/plot template export <world>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(world);
|
final PlotArea area = this.plotAreaManager.getPlotAreaByString(world);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD);
|
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD);
|
||||||
return false;
|
return false;
|
||||||
|
@ -31,6 +31,7 @@ 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.plot.expiration.ExpireManager;
|
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.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
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.plotsquared.core.util.task.TaskManager;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
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.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -64,60 +59,14 @@ import java.util.Set;
|
|||||||
category = CommandCategory.ADMINISTRATION)
|
category = CommandCategory.ADMINISTRATION)
|
||||||
public class Trim extends SubCommand {
|
public class Trim extends SubCommand {
|
||||||
|
|
||||||
public static ArrayList<Plot> expired = null;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
|
public Trim(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
}
|
||||||
|
|
||||||
private static volatile boolean TASK = false;
|
private static volatile boolean TASK = false;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the result task with the parameters (viable, nonViable).
|
* Runs the result task with the parameters (viable, nonViable).
|
||||||
*
|
*
|
||||||
@ -167,7 +116,7 @@ public class Trim extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final String world = args[0];
|
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);
|
MainUtil.sendMessage(player, Captions.NOT_VALID_WORLD);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import com.plotsquared.core.player.PlotPlayer;
|
|||||||
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.flag.implementations.UntrustedVisitFlag;
|
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.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
@ -59,8 +60,11 @@ import java.util.concurrent.TimeoutException;
|
|||||||
category = CommandCategory.TELEPORT)
|
category = CommandCategory.TELEPORT)
|
||||||
public class Visit extends Command {
|
public class Visit extends Command {
|
||||||
|
|
||||||
public Visit() {
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
|
public Visit(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
super(MainCommand.getInstance(), true);
|
super(MainCommand.getInstance(), true);
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void visit(@NotNull final PlotPlayer player, @NotNull final PlotQuery query, final PlotArea sortByArea,
|
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]
|
// /p v <name> [page]
|
||||||
case 2:
|
case 2:
|
||||||
if (page != Integer.MIN_VALUE || !MathMan.isInteger(args[1])) {
|
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) {
|
if (sortByArea == null) {
|
||||||
Captions.NOT_VALID_NUMBER.send(player, "(1, ∞)");
|
Captions.NOT_VALID_NUMBER.send(player, "(1, ∞)");
|
||||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
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) {
|
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();
|
final String areaName = area.getWorldName() + ";" + area.getId();
|
||||||
if (!areaName.toLowerCase().startsWith(arg.toLowerCase())) {
|
if (!areaName.toLowerCase().startsWith(arg.toLowerCase())) {
|
||||||
continue;
|
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.GlobalFlagContainer;
|
||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
|
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.ChunkBlockQueue;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
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.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
@ -83,6 +85,12 @@ public abstract class HybridUtils {
|
|||||||
public static PlotArea area;
|
public static PlotArea area;
|
||||||
public static boolean UPDATE = false;
|
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,
|
public void analyzeRegion(final String world, final CuboidRegion region,
|
||||||
final RunnableVal<PlotAnalysis> whenDone) {
|
final RunnableVal<PlotAnalysis> whenDone) {
|
||||||
// int diff, int variety, int vertices, int rotation, int height_sd
|
// 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 width = tx - bx + 1;
|
||||||
final int length = tz - bz + 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)) {
|
if (!(area instanceof HybridPlotWorld)) {
|
||||||
return;
|
return;
|
||||||
|
@ -25,15 +25,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.generator;
|
package com.plotsquared.core.generator;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
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.PlotId;
|
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.SinglePlotArea;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class SingleWorldGenerator extends IndependentPlotGenerator {
|
public class SingleWorldGenerator extends IndependentPlotGenerator {
|
||||||
|
|
||||||
@ -44,6 +45,12 @@ public class SingleWorldGenerator extends IndependentPlotGenerator {
|
|||||||
private static final Location grass1 = Location.at("", 0, 3, 0);
|
private static final Location grass1 = Location.at("", 0, 3, 0);
|
||||||
private static final Location grass2 = Location.at("", 15, 3, 15);
|
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() {
|
@Override public String getName() {
|
||||||
return "PlotSquared:single";
|
return "PlotSquared:single";
|
||||||
}
|
}
|
||||||
@ -64,10 +71,10 @@ public class SingleWorldGenerator extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
@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) {
|
@Override public void initialize(PlotArea area) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.listener;
|
package com.plotsquared.core.listener;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
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.plot.world.PlotAreaManager;
|
||||||
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.WEManager;
|
import com.plotsquared.core.util.WEManager;
|
||||||
@ -43,11 +43,18 @@ import com.sk89q.worldedit.util.Location;
|
|||||||
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
|
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
|
||||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class WESubscriber {
|
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) {
|
@Subscribe(priority = Priority.VERY_EARLY) public void onEditSession(EditSessionEvent event) {
|
||||||
if (!Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
|
if (!Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
|
||||||
WorldEdit.getInstance().getEventBus().unregister(this);
|
WorldEdit.getInstance().getEventBus().unregister(this);
|
||||||
@ -82,19 +89,19 @@ public class WESubscriber {
|
|||||||
if (Permissions.hasPermission(plotPlayer, "plots.worldedit.bypass")) {
|
if (Permissions.hasPermission(plotPlayer, "plots.worldedit.bypass")) {
|
||||||
MainUtil.sendMessage(plotPlayer, Captions.WORLDEDIT_BYPASS);
|
MainUtil.sendMessage(plotPlayer, Captions.WORLDEDIT_BYPASS);
|
||||||
}
|
}
|
||||||
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
if (this.plotAreaManager.hasPlotArea(world)) {
|
||||||
event.setExtent(new NullExtent());
|
event.setExtent(new NullExtent());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
|
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
|
||||||
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
if (this.plotAreaManager.hasPlotArea(world)) {
|
||||||
event.setExtent(
|
event.setExtent(
|
||||||
new ProcessedWEExtent(world, mask, event.getMaxBlocks(), event.getExtent(),
|
new ProcessedWEExtent(world, mask, event.getMaxBlocks(), event.getExtent(),
|
||||||
event.getExtent()));
|
event.getExtent()));
|
||||||
}
|
}
|
||||||
} else if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
|
} else if (this.plotAreaManager.hasPlotArea(world)) {
|
||||||
event.setExtent(new WEExtent(mask, event.getExtent()));
|
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.location.Location;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotWeather;
|
import com.plotsquared.core.plot.PlotWeather;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
@ -45,8 +46,9 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
|||||||
|
|
||||||
private static ConsolePlayer instance;
|
private static ConsolePlayer instance;
|
||||||
|
|
||||||
private ConsolePlayer() {
|
private ConsolePlayer(final PlotAreaManager plotAreaManager) {
|
||||||
final PlotArea[] areas = PlotSquared.get().getPlotAreaManager().getAllPlotAreas();
|
super(plotAreaManager);
|
||||||
|
final PlotArea[] areas = plotAreaManager.getAllPlotAreas();
|
||||||
final PlotArea area;
|
final PlotArea area;
|
||||||
if (areas.length > 0) {
|
if (areas.length > 0) {
|
||||||
area = areas[0];
|
area = areas[0];
|
||||||
@ -67,7 +69,7 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
|||||||
|
|
||||||
public static ConsolePlayer getConsole() {
|
public static ConsolePlayer getConsole() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new ConsolePlayer();
|
instance = new ConsolePlayer(PlotSquared.get().getPlotAreaManager());
|
||||||
instance.teleport(instance.getLocation());
|
instance.teleport(instance.getLocation());
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package com.plotsquared.core.player;
|
package com.plotsquared.core.player;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.plotsquared.core.PlotPlatform;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.command.CommandCaller;
|
import com.plotsquared.core.command.CommandCaller;
|
||||||
import com.plotsquared.core.command.RequiredType;
|
import com.plotsquared.core.command.RequiredType;
|
||||||
@ -88,6 +89,12 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
private ConcurrentHashMap<String, Object> meta;
|
private ConcurrentHashMap<String, Object> meta;
|
||||||
private int hash;
|
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) {
|
public static <T> PlotPlayer<T> from(@NonNull final T object) {
|
||||||
if (!converters.containsKey(object.getClass())) {
|
if (!converters.containsKey(object.getClass())) {
|
||||||
throw new IllegalArgumentException(String
|
throw new IllegalArgumentException(String
|
||||||
@ -270,7 +277,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().getPlotAreaManager().forEachPlotArea(value -> {
|
this.plotAreaManager.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 +296,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
return getClusterCount(getLocation().getWorldName());
|
return getClusterCount(getLocation().getWorldName());
|
||||||
}
|
}
|
||||||
final AtomicInteger count = new AtomicInteger(0);
|
final AtomicInteger count = new AtomicInteger(0);
|
||||||
PlotSquared.get().getPlotAreaManager().forEachPlotArea(value -> {
|
this.plotAreaManager.forEachPlotArea(value -> {
|
||||||
for (PlotCluster cluster : value.getClusters()) {
|
for (PlotCluster cluster : value.getClusters()) {
|
||||||
if (cluster.isOwner(getUUID())) {
|
if (cluster.isOwner(getUUID())) {
|
||||||
count.incrementAndGet();
|
count.incrementAndGet();
|
||||||
@ -308,7 +315,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
public int getPlotCount(String world) {
|
public int getPlotCount(String world) {
|
||||||
UUID uuid = getUUID();
|
UUID uuid = getUUID();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (PlotArea area : PlotSquared.get().getPlotAreaManager().getPlotAreasSet(world)) {
|
for (PlotArea area : this.plotAreaManager.getPlotAreasSet(world)) {
|
||||||
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
|
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
|
||||||
count +=
|
count +=
|
||||||
area.getPlotsAbs(uuid).stream().filter(plot -> !DoneFlag.isDone(plot)).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) {
|
public int getClusterCount(String world) {
|
||||||
UUID uuid = getUUID();
|
UUID uuid = getUUID();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (PlotArea area : PlotSquared.get().getPlotAreaManager().getPlotAreasSet(world)) {
|
for (PlotArea area : this.plotAreaManager.getPlotAreasSet(world)) {
|
||||||
for (PlotCluster cluster : area.getClusters()) {
|
for (PlotCluster cluster : area.getClusters()) {
|
||||||
if (cluster.isOwner(getUUID())) {
|
if (cluster.isOwner(getUUID())) {
|
||||||
count++;
|
count++;
|
||||||
@ -349,11 +356,11 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
* @return Plot area the player is currently in, or {@code null}
|
* @return Plot area the player is currently in, or {@code null}
|
||||||
*/
|
*/
|
||||||
@Nullable public PlotArea getPlotAreaAbs() {
|
@Nullable public PlotArea getPlotAreaAbs() {
|
||||||
return PlotSquared.get().getPlotAreaManager().getPlotArea(getLocation());
|
return this.plotAreaManager.getPlotArea(getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotArea getApplicablePlotArea() {
|
public PlotArea getApplicablePlotArea() {
|
||||||
return PlotSquared.get().getPlotAreaManager().getApplicablePlotArea(getLocation());
|
return this.plotAreaManager.getApplicablePlotArea(getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public RequiredType getSuperCaller() {
|
@Override public RequiredType getSuperCaller() {
|
||||||
@ -614,7 +621,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().getPlotAreaManager().forEachPlotArea(value -> count.addAndGet(value.getClusters().size()));
|
this.plotAreaManager.forEachPlotArea(value -> count.addAndGet(value.getClusters().size()));
|
||||||
return count.get();
|
return count.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,7 +652,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
if (!Settings.Teleport.ON_LOGIN) {
|
if (!Settings.Teleport.ON_LOGIN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
|
PlotAreaManager manager = PlotPlayer.this.plotAreaManager;
|
||||||
|
|
||||||
if (!(manager instanceof SinglePlotAreaManager)) {
|
if (!(manager instanceof SinglePlotAreaManager)) {
|
||||||
return;
|
return;
|
||||||
|
@ -25,11 +25,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot.expiration;
|
package com.plotsquared.core.plot.expiration;
|
||||||
|
|
||||||
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.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.query.PlotQuery;
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -41,11 +42,14 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ExpiryTask {
|
public class ExpiryTask {
|
||||||
|
|
||||||
private final Settings.Auto_Clear settings;
|
private final Settings.Auto_Clear settings;
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
private long cutoffThreshold = Long.MIN_VALUE;
|
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.settings = settings;
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Settings.Auto_Clear getSettings() {
|
public Settings.Auto_Clear getSettings() {
|
||||||
@ -122,7 +126,7 @@ public class ExpiryTask {
|
|||||||
|
|
||||||
public Set<Plot> getPlotsToCheck() {
|
public Set<Plot> getPlotsToCheck() {
|
||||||
final Collection<PlotArea> areas = new LinkedList<>();
|
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)) {
|
if (this.allowsArea(plotArea)) {
|
||||||
areas.add(plotArea);
|
areas.add(plotArea);
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,8 @@ public class SinglePlotArea extends GridPlotWorld {
|
|||||||
|
|
||||||
public boolean VOID = false;
|
public boolean VOID = false;
|
||||||
|
|
||||||
public SinglePlotArea() {
|
public SinglePlotArea(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
super("*", null, new SingleWorldGenerator(), null, null);
|
super("*", null, new SingleWorldGenerator(plotAreaManager), null, null);
|
||||||
this.setAllowSigns(false);
|
this.setAllowSigns(false);
|
||||||
this.setDefaultHome(new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE));
|
this.setDefaultHome(new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE));
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,11 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
|||||||
private PlotArea[] all;
|
private PlotArea[] all;
|
||||||
|
|
||||||
public SinglePlotAreaManager() {
|
public SinglePlotAreaManager() {
|
||||||
this.area = new SinglePlotArea();
|
this.area = new SinglePlotArea(this);
|
||||||
this.array = new SinglePlotArea[] {area};
|
this.array = new SinglePlotArea[] {area};
|
||||||
this.all = new PlotArea[] {area};
|
this.all = new PlotArea[] {area};
|
||||||
SetupUtils.generators.put("PlotSquared:single",
|
SetupUtils.generators.put("PlotSquared:single",
|
||||||
new SingleWorldGenerator().specify("CheckingPlotSquaredGenerator"));
|
new SingleWorldGenerator(this).specify("CheckingPlotSquaredGenerator"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SinglePlotArea getArea() {
|
public SinglePlotArea getArea() {
|
||||||
|
@ -25,17 +25,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.queue;
|
package com.plotsquared.core.queue;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.location.Location;
|
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.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue {
|
public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue {
|
||||||
private final int minX;
|
private final int minX;
|
||||||
@ -100,32 +94,4 @@ public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue {
|
|||||||
return Location.at(this.getWorld(), this.maxX, this.maxY, this.maxZ);
|
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;
|
package com.plotsquared.core.util.query;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
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.world.PlotAreaManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -35,9 +36,15 @@ import java.util.Set;
|
|||||||
|
|
||||||
class GlobalPlotProvider implements PlotProvider {
|
class GlobalPlotProvider implements PlotProvider {
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
|
GlobalPlotProvider(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public Collection<Plot> getPlots() {
|
@Override public Collection<Plot> getPlots() {
|
||||||
final Set<Plot> plots = new HashSet<>();
|
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());
|
plots.addAll(plotArea.getPlots());
|
||||||
}
|
}
|
||||||
return plots;
|
return plots;
|
||||||
|
@ -32,6 +32,7 @@ import com.plotsquared.core.plot.Plot;
|
|||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.Rating;
|
import com.plotsquared.core.plot.Rating;
|
||||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -59,12 +60,15 @@ import java.util.stream.Stream;
|
|||||||
public final class PlotQuery {
|
public final class PlotQuery {
|
||||||
|
|
||||||
private final Collection<PlotFilter> filters = new LinkedList<>();
|
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 SortingStrategy sortingStrategy = SortingStrategy.NO_SORTING;
|
||||||
private PlotArea priorityArea;
|
private PlotArea priorityArea;
|
||||||
private Comparator<Plot> plotComparator;
|
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
|
* @return New query
|
||||||
*/
|
*/
|
||||||
public static PlotQuery newQuery() {
|
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) {
|
@NotNull public PlotQuery inWorld(@NotNull final String world) {
|
||||||
Preconditions.checkNotNull(world, "World may not be null");
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +133,7 @@ public final class PlotQuery {
|
|||||||
* @return The query instance
|
* @return The query instance
|
||||||
*/
|
*/
|
||||||
@NotNull public PlotQuery allPlots() {
|
@NotNull public PlotQuery allPlots() {
|
||||||
this.plotProvider = new GlobalPlotProvider();
|
this.plotProvider = new GlobalPlotProvider(this.plotAreaManager);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user