Reformat it all.

This commit is contained in:
dordsor21 2020-04-30 11:01:52 +01:00
parent 4a16f9c1a7
commit 0091580ae0
101 changed files with 635 additions and 543 deletions

View File

@ -82,7 +82,8 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
public class BukkitChunkManager extends ChunkManager { public class BukkitChunkManager extends ChunkManager {
public static boolean isIn(CuboidRegion region, int x, int z) { public static boolean isIn(CuboidRegion region, int x, int z) {
return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX() && z >= region.getMinimumPoint().getZ() && z <= region.getMaximumPoint().getZ(); return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX()
&& z >= region.getMinimumPoint().getZ() && z <= region.getMaximumPoint().getZ();
} }
public static ContentMap swapChunk(World world1, World world2, Chunk pos1, Chunk pos2, public static ContentMap swapChunk(World world1, World world2, Chunk pos1, Chunk pos2,
@ -106,8 +107,10 @@ public class BukkitChunkManager extends ChunkManager {
LocalBlockQueue queue1 = GlobalBlockQueue.IMP.getNewQueue(worldName1, false); LocalBlockQueue queue1 = GlobalBlockQueue.IMP.getNewQueue(worldName1, false);
LocalBlockQueue queue2 = GlobalBlockQueue.IMP.getNewQueue(worldName2, false); LocalBlockQueue queue2 = GlobalBlockQueue.IMP.getNewQueue(worldName2, false);
for (int x = Math.max(r1.getMinimumPoint().getX(), sx); x <= Math.min(r1.getMaximumPoint().getX(), sx + 15); x++) { for (int x = Math.max(r1.getMinimumPoint().getX(), sx);
for (int z = Math.max(r1.getMinimumPoint().getZ(), sz); z <= Math.min(r1.getMaximumPoint().getZ(), sz + 15); z++) { x <= Math.min(r1.getMaximumPoint().getX(), sx + 15); x++) {
for (int z = Math.max(r1.getMinimumPoint().getZ(), sz);
z <= Math.min(r1.getMaximumPoint().getZ(), sz + 15); z++) {
for (int y = 0; y < 256; y++) { for (int y = 0; y < 256; y++) {
Block block1 = world1.getBlockAt(x, y, z); Block block1 = world1.getBlockAt(x, y, z);
BaseBlock baseBlock1 = bukkitWorld1.getFullBlock(BlockVector3.at(x, y, z)); BaseBlock baseBlock1 = bukkitWorld1.getFullBlock(BlockVector3.at(x, y, z));
@ -159,7 +162,8 @@ public class BukkitChunkManager extends ChunkManager {
+ " Will halt the calling thread until completed."); + " Will halt the calling thread until completed.");
semaphore.acquire(); semaphore.acquire();
Bukkit.getScheduler().runTask(BukkitMain.getPlugin(BukkitMain.class), () -> { Bukkit.getScheduler().runTask(BukkitMain.getPlugin(BukkitMain.class), () -> {
for (Chunk chunk : Objects.requireNonNull(Bukkit.getWorld(world)).getLoadedChunks()) { for (Chunk chunk : Objects.requireNonNull(Bukkit.getWorld(world))
.getLoadedChunks()) {
BlockVector2 loc = BlockVector2.at(chunk.getX() >> 5, chunk.getZ() >> 5); BlockVector2 loc = BlockVector2.at(chunk.getX() >> 5, chunk.getZ() >> 5);
chunks.add(loc); chunks.add(loc);
} }
@ -214,7 +218,7 @@ public class BukkitChunkManager extends ChunkManager {
if (doWhole) { if (doWhole) {
for (Entity entity : entities) { for (Entity entity : entities) {
org.bukkit.Location location = entity.getLocation(); org.bukkit.Location location = entity.getLocation();
PaperLib.getChunkAtAsync(location).thenAccept( chunk -> { PaperLib.getChunkAtAsync(location).thenAccept(chunk -> {
if (chunks.contains(chunk)) { if (chunks.contains(chunk)) {
int X = chunk.getX(); int X = chunk.getX();
int Z = chunk.getZ(); int Z = chunk.getZ();
@ -249,7 +253,8 @@ public class BukkitChunkManager extends ChunkManager {
return count; return count;
} }
@Override public boolean copyRegion(Location pos1, Location pos2, Location newPos, @Override
public boolean copyRegion(Location pos1, Location pos2, Location newPos,
final Runnable whenDone) { final Runnable whenDone) {
final int relX = newPos.getX() - pos1.getX(); final int relX = newPos.getX() - pos1.getX();
final int relZ = newPos.getZ() - pos1.getZ(); final int relZ = newPos.getZ() - pos1.getZ();
@ -303,7 +308,8 @@ public class BukkitChunkManager extends ChunkManager {
return true; return true;
} }
@Override public boolean regenerateRegion(final Location pos1, final Location pos2, @Override
public boolean regenerateRegion(final Location pos1, final Location pos2,
final boolean ignoreAugment, final Runnable whenDone) { final boolean ignoreAugment, final Runnable whenDone) {
final String world = pos1.getWorld(); final String world = pos1.getWorld();
@ -341,7 +347,8 @@ public class BukkitChunkManager extends ChunkManager {
if (chunkObj == null) { if (chunkObj == null) {
return; return;
} }
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false); final LocalBlockQueue queue =
GlobalBlockQueue.IMP.getNewQueue(world, false);
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) { if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
AugmentedUtils.bypass(ignoreAugment, AugmentedUtils.bypass(ignoreAugment,
() -> queue.regenChunkSafe(chunk.getX(), chunk.getZ())); () -> queue.regenChunkSafe(chunk.getX(), chunk.getZ()));
@ -406,11 +413,11 @@ public class BukkitChunkManager extends ChunkManager {
if (checkX2 && checkZ2) { if (checkX2 && checkZ2) {
map.saveRegion(bukkitWorldObj, xxt2, xxt, zzt2, zzt); // map.saveRegion(bukkitWorldObj, xxt2, xxt, zzt2, zzt); //
} }
CuboidRegion currentPlotClear = CuboidRegion currentPlotClear = RegionUtil
RegionUtil.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); .createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
map.saveEntitiesOut(chunkObj, currentPlotClear); map.saveEntitiesOut(chunkObj, currentPlotClear);
AugmentedUtils.bypass(ignoreAugment, AugmentedUtils.bypass(ignoreAugment, () -> setChunkInPlotArea(null,
() -> setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() { new RunnableVal<ScopedLocalBlockQueue>() {
@Override public void run(ScopedLocalBlockQueue value) { @Override public void run(ScopedLocalBlockQueue value) {
Location min = value.getMin(); Location min = value.getMin();
int bx = min.getX(); int bx = min.getX();
@ -420,12 +427,14 @@ public class BukkitChunkManager extends ChunkManager {
PlotLoc plotLoc = new PlotLoc(bx + x1, bz + z1); PlotLoc plotLoc = new PlotLoc(bx + x1, bz + z1);
BaseBlock[] ids = map.allBlocks.get(plotLoc); BaseBlock[] ids = map.allBlocks.get(plotLoc);
if (ids != null) { if (ids != null) {
for (int y = 0; y < Math.min(128, ids.length); y++) { for (int y = 0;
y < Math.min(128, ids.length); y++) {
BaseBlock id = ids[y]; BaseBlock id = ids[y];
if (id != null) { if (id != null) {
value.setBlock(x1, y, z1, id); value.setBlock(x1, y, z1, id);
} else { } else {
value.setBlock(x1, y, z1, BlockTypes.AIR.getDefaultState()); value.setBlock(x1, y, z1,
BlockTypes.AIR.getDefaultState());
} }
} }
for (int y = Math.min(128, ids.length); for (int y = Math.min(128, ids.length);
@ -454,15 +463,17 @@ public class BukkitChunkManager extends ChunkManager {
return true; return true;
} }
@Override public CompletableFuture<?> loadChunk(String world, BlockVector2 chunkLoc, boolean force) { @Override
return PaperLib.getChunkAtAsync(BukkitUtil.getWorld(world),chunkLoc.getX(), chunkLoc.getZ(), force); public CompletableFuture<?> loadChunk(String world, BlockVector2 chunkLoc, boolean force) {
return PaperLib
.getChunkAtAsync(BukkitUtil.getWorld(world), chunkLoc.getX(), chunkLoc.getZ(), force);
} }
@Override @Override
public void unloadChunk(final String world, final BlockVector2 chunkLoc, final boolean save) { public void unloadChunk(final String world, final BlockVector2 chunkLoc, final boolean save) {
if (!PlotSquared.get().isMainThread(Thread.currentThread())) { if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
TaskManager.runTask( TaskManager.runTask(() -> BukkitUtil.getWorld(world)
() -> BukkitUtil.getWorld(world).unloadChunk(chunkLoc.getX(), chunkLoc.getZ(), save)); .unloadChunk(chunkLoc.getX(), chunkLoc.getZ(), save));
} else { } else {
BukkitUtil.getWorld(world).unloadChunk(chunkLoc.getX(), chunkLoc.getZ(), save); BukkitUtil.getWorld(world).unloadChunk(chunkLoc.getX(), chunkLoc.getZ(), save);
} }
@ -489,7 +500,8 @@ public class BukkitChunkManager extends ChunkManager {
} }
} }
@Override public void swap(Location bot1, Location top1, Location bot2, Location top2, @Override
public void swap(Location bot1, Location top1, Location bot2, Location top2,
final Runnable whenDone) { final Runnable whenDone) {
CuboidRegion region1 = CuboidRegion region1 =
RegionUtil.createRegion(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ()); RegionUtil.createRegion(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
@ -497,8 +509,8 @@ public class BukkitChunkManager extends ChunkManager {
RegionUtil.createRegion(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ()); RegionUtil.createRegion(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ());
final World world1 = Bukkit.getWorld(bot1.getWorld()); final World world1 = Bukkit.getWorld(bot1.getWorld());
final World world2 = Bukkit.getWorld(bot2.getWorld()); final World world2 = Bukkit.getWorld(bot2.getWorld());
checkNotNull(world1,"Critical error during swap."); checkNotNull(world1, "Critical error during swap.");
checkNotNull(world2,"Critical error during swap."); checkNotNull(world2, "Critical error during swap.");
int relX = bot2.getX() - bot1.getX(); int relX = bot2.getX() - bot1.getX();
int relZ = bot2.getZ() - bot1.getZ(); int relZ = bot2.getZ() - bot1.getZ();
@ -525,13 +537,11 @@ public class BukkitChunkManager extends ChunkManager {
if (EntityCategories.PLAYER.contains(entityType)) { if (EntityCategories.PLAYER.contains(entityType)) {
return; return;
} else if (EntityCategories.PROJECTILE.contains(entityType) || } else if (EntityCategories.PROJECTILE.contains(entityType) || EntityCategories.OTHER
EntityCategories.OTHER.contains(entityType) || .contains(entityType) || EntityCategories.HANGING.contains(entityType)) {
EntityCategories.HANGING.contains(entityType)) {
count[CAP_MISC]++; count[CAP_MISC]++;
} else if (EntityCategories.ANIMAL.contains(entityType) || } else if (EntityCategories.ANIMAL.contains(entityType) || EntityCategories.VILLAGER
EntityCategories.VILLAGER.contains(entityType) || .contains(entityType) || EntityCategories.TAMEABLE.contains(entityType)) {
EntityCategories.TAMEABLE.contains(entityType)) {
count[CAP_MOB]++; count[CAP_MOB]++;
count[CAP_ANIMAL]++; count[CAP_ANIMAL]++;
} else if (EntityCategories.VEHICLE.contains(entityType)) { } else if (EntityCategories.VEHICLE.contains(entityType)) {

View File

@ -74,7 +74,8 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
if (args.length == 0) { if (args.length == 0) {
return Collections.singletonList("plots"); return Collections.singletonList("plots");
} }
Collection<com.plotsquared.core.command.Command> objects = MainCommand.getInstance().tab(player, args, s.endsWith(" ")); Collection<com.plotsquared.core.command.Command> objects =
MainCommand.getInstance().tab(player, args, s.endsWith(" "));
if (objects == null) { if (objects == null) {
return null; return null;
} }

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.bukkit; package com.plotsquared.bukkit;
import com.plotsquared.bukkit.generator.BukkitHybridUtils;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator; import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
import com.plotsquared.bukkit.listener.ChunkListener; import com.plotsquared.bukkit.listener.ChunkListener;
import com.plotsquared.bukkit.listener.EntitySpawnListener; import com.plotsquared.bukkit.listener.EntitySpawnListener;
@ -33,42 +34,46 @@ import com.plotsquared.bukkit.listener.SingleWorldListener;
import com.plotsquared.bukkit.listener.WorldEvents; import com.plotsquared.bukkit.listener.WorldEvents;
import com.plotsquared.bukkit.placeholder.PlaceholderFormatter; import com.plotsquared.bukkit.placeholder.PlaceholderFormatter;
import com.plotsquared.bukkit.placeholder.Placeholders; import com.plotsquared.bukkit.placeholder.Placeholders;
import com.plotsquared.bukkit.queue.BukkitLocalQueue;
import com.plotsquared.bukkit.schematic.BukkitSchematicHandler;
import com.plotsquared.bukkit.util.BukkitChatManager; import com.plotsquared.bukkit.util.BukkitChatManager;
import com.plotsquared.bukkit.util.BukkitEconHandler; import com.plotsquared.bukkit.util.BukkitEconHandler;
import com.plotsquared.bukkit.generator.BukkitHybridUtils;
import com.plotsquared.bukkit.util.BukkitInventoryUtil; import com.plotsquared.bukkit.util.BukkitInventoryUtil;
import com.plotsquared.bukkit.schematic.BukkitSchematicHandler;
import com.plotsquared.bukkit.util.BukkitSetupUtils; import com.plotsquared.bukkit.util.BukkitSetupUtils;
import com.plotsquared.bukkit.util.BukkitTaskManager; import com.plotsquared.bukkit.util.BukkitTaskManager;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.SetGenCB; import com.plotsquared.bukkit.util.SetGenCB;
import com.plotsquared.bukkit.util.UpdateUtility; import com.plotsquared.bukkit.util.UpdateUtility;
import com.plotsquared.bukkit.queue.BukkitLocalQueue;
import com.plotsquared.bukkit.util.uuid.DefaultUUIDWrapper; import com.plotsquared.bukkit.util.uuid.DefaultUUIDWrapper;
import com.plotsquared.bukkit.util.uuid.FileUUIDHandler; import com.plotsquared.bukkit.util.uuid.FileUUIDHandler;
import com.plotsquared.bukkit.util.uuid.LowerOfflineUUIDWrapper; import com.plotsquared.bukkit.util.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.util.uuid.OfflineUUIDWrapper; import com.plotsquared.bukkit.util.uuid.OfflineUUIDWrapper;
import com.plotsquared.bukkit.util.uuid.SQLUUIDHandler; import com.plotsquared.bukkit.util.uuid.SQLUUIDHandler;
import com.plotsquared.core.configuration.*;
import com.plotsquared.core.IPlotMain; import com.plotsquared.core.IPlotMain;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ChatFormatter;
import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.generator.GeneratorWrapper; import com.plotsquared.core.generator.GeneratorWrapper;
import com.plotsquared.core.generator.HybridGen; import com.plotsquared.core.generator.HybridGen;
import com.plotsquared.core.generator.HybridUtils; import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.generator.IndependentPlotGenerator; import com.plotsquared.core.generator.IndependentPlotGenerator;
import com.plotsquared.core.generator.SingleWorldGenerator;
import com.plotsquared.core.listener.PlotListener; import com.plotsquared.core.listener.PlotListener;
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.PlotAreaTerrainType; 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.player.PlotPlayer;
import com.plotsquared.core.plot.SetupObject; import com.plotsquared.core.plot.SetupObject;
import com.plotsquared.core.plot.message.PlainChatManager; import com.plotsquared.core.plot.message.PlainChatManager;
import com.plotsquared.core.plot.world.PlotAreaManager; 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.generator.SingleWorldGenerator; import com.plotsquared.core.queue.QueueProvider;
import com.plotsquared.core.util.ChatManager; import com.plotsquared.core.util.ChatManager;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.ConsoleColors; import com.plotsquared.core.util.ConsoleColors;
@ -80,11 +85,10 @@ import com.plotsquared.core.util.ReflectionUtils;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
import com.plotsquared.core.util.uuid.UUIDHandlerImplementation; import com.plotsquared.core.util.uuid.UUIDHandlerImplementation;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.queue.QueueProvider;
import com.plotsquared.core.util.uuid.UUIDWrapper; import com.plotsquared.core.util.uuid.UUIDWrapper;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
@ -123,7 +127,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import static com.plotsquared.core.util.PremiumVerification.*; import static com.plotsquared.core.util.PremiumVerification.getDownloadID;
import static com.plotsquared.core.util.PremiumVerification.getResourceID;
import static com.plotsquared.core.util.PremiumVerification.getUserID;
import static com.plotsquared.core.util.ReflectionUtils.getRefClass; import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@ -191,8 +197,10 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
} }
if (PremiumVerification.isPremium()) { if (PremiumVerification.isPremium()) {
PlotSquared.log(Captions.PREFIX + "&6PlotSquared version licensed to Spigot user " + getUserID()); PlotSquared.log(
PlotSquared.log(Captions.PREFIX + "&6https://www.spigotmc.org/resources/" + getResourceID()); Captions.PREFIX + "&6PlotSquared version licensed to Spigot user " + getUserID());
PlotSquared
.log(Captions.PREFIX + "&6https://www.spigotmc.org/resources/" + getResourceID());
PlotSquared.log(Captions.PREFIX + "&6Download ID: " + getDownloadID()); PlotSquared.log(Captions.PREFIX + "&6Download ID: " + getDownloadID());
PlotSquared.log(Captions.PREFIX + "&6Thanks for supporting us :)"); PlotSquared.log(Captions.PREFIX + "&6Thanks for supporting us :)");
} else { } else {
@ -206,7 +214,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
} }
PlotSquared.log(Captions.PREFIX + "&6PlotSquared hooked into PlaceholderAPI"); PlotSquared.log(Captions.PREFIX + "&6PlotSquared hooked into PlaceholderAPI");
} else { } else {
PlotSquared.debug(Captions.PREFIX + "&6PlaceholderAPI is not in use. Hook deactivated."); PlotSquared
.debug(Captions.PREFIX + "&6PlaceholderAPI is not in use. Hook deactivated.");
} }
this.startMetrics(); this.startMetrics();
@ -409,8 +418,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
case MINECART_TNT: case MINECART_TNT:
case BOAT: case BOAT:
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) { if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
com.plotsquared.core.location.Location com.plotsquared.core.location.Location location =
location = BukkitUtil.getLocation(entity.getLocation()); BukkitUtil.getLocation(entity.getLocation());
Plot plot = location.getPlot(); Plot plot = location.getPlot();
if (plot == null) { if (plot == null) {
if (location.isPlotArea()) { if (location.isPlotArea()) {
@ -466,8 +475,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
PlotId originalPlotId = (PlotId) meta.get(0).value(); PlotId originalPlotId = (PlotId) meta.get(0).value();
if (originalPlotId != null) { if (originalPlotId != null) {
com.plotsquared.core.location.Location com.plotsquared.core.location.Location pLoc =
pLoc = BukkitUtil.getLocation(entity.getLocation()); BukkitUtil.getLocation(entity.getLocation());
PlotArea area = pLoc.getPlotArea(); PlotArea area = pLoc.getPlotArea();
if (area != null) { if (area != null) {
PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc)); PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
@ -485,13 +494,14 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
} }
} else { } else {
//This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java) //This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java)
com.plotsquared.core.location.Location com.plotsquared.core.location.Location pLoc =
pLoc = BukkitUtil.getLocation(entity.getLocation()); BukkitUtil.getLocation(entity.getLocation());
PlotArea area = pLoc.getPlotArea(); PlotArea area = pLoc.getPlotArea();
if (area != null) { if (area != null) {
PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc)); PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
if (currentPlotId != null) { if (currentPlotId != null) {
entity.setMetadata("shulkerPlot", new FixedMetadataValue( entity.setMetadata("shulkerPlot",
new FixedMetadataValue(
(Plugin) PlotSquared.get().IMP, currentPlotId)); (Plugin) PlotSquared.get().IMP, currentPlotId));
} }
} }
@ -668,7 +678,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
return new BukkitUtil(); return new BukkitUtil();
} }
@Override @Nullable public GeneratorWrapper<?> getGenerator(@NonNull final String world, @Override @Nullable
public GeneratorWrapper<?> getGenerator(@NonNull final String world,
@Nullable final String name) { @Nullable final String name) {
if (name == null) { if (name == null) {
return null; return null;
@ -709,7 +720,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
map.put(plotAreaType.name().toLowerCase(), terrainTypes); map.put(plotAreaType.name().toLowerCase(), terrainTypes);
} }
for (final PlotArea plotArea : PlotSquared.get().getPlotAreas()) { for (final PlotArea plotArea : PlotSquared.get().getPlotAreas()) {
final Map<String, Integer> terrainTypeMap = map.get(plotArea.getType().name().toLowerCase()); final Map<String, Integer> terrainTypeMap =
map.get(plotArea.getType().name().toLowerCase());
terrainTypeMap.put(plotArea.getTerrain().name().toLowerCase(), terrainTypeMap.put(plotArea.getTerrain().name().toLowerCase(),
terrainTypeMap.get(plotArea.getTerrain().name().toLowerCase()) + 1); terrainTypeMap.get(plotArea.getTerrain().name().toLowerCase()) + 1);
} }
@ -847,7 +859,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
} }
} }
@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);
} }
@ -855,7 +868,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
@Override public List<Map.Entry<Map.Entry<String, String>, Boolean>> getPluginIds() { @Override public List<Map.Entry<Map.Entry<String, String>, Boolean>> getPluginIds() {
List<Map.Entry<Map.Entry<String, String>, Boolean>> names = new ArrayList<>(); List<Map.Entry<Map.Entry<String, String>, Boolean>> names = new ArrayList<>();
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) { for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
Map.Entry<String, String> id = new AbstractMap.SimpleEntry<>(plugin.getName(), plugin.getDescription().getVersion()); Map.Entry<String, String> id = new AbstractMap.SimpleEntry<>(plugin.getName(),
plugin.getDescription().getVersion());
names.add(new AbstractMap.SimpleEntry<>(id, plugin.isEnabled())); names.add(new AbstractMap.SimpleEntry<>(id, plugin.isEnabled()));
} }
return names; return names;
@ -863,7 +877,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
@Override public Actor getConsole() { @Override public Actor getConsole() {
@NotNull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); @NotNull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
WorldEditPlugin wePlugin = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")); WorldEditPlugin wePlugin =
((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
return wePlugin.wrapCommandSender(console); return wePlugin.wrapCommandSender(console);
} }
} }

View File

@ -25,29 +25,29 @@
*/ */
package com.plotsquared.bukkit.command; package com.plotsquared.bukkit.command;
import com.google.common.collect.Sets;
import com.plotsquared.bukkit.util.uuid.DatFileFilter; import com.plotsquared.bukkit.util.uuid.DatFileFilter;
import com.plotsquared.bukkit.util.uuid.DefaultUUIDWrapper; import com.plotsquared.bukkit.util.uuid.DefaultUUIDWrapper;
import com.plotsquared.bukkit.util.uuid.LowerOfflineUUIDWrapper; import com.plotsquared.bukkit.util.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.util.uuid.OfflineUUIDWrapper; import com.plotsquared.bukkit.util.uuid.OfflineUUIDWrapper;
import com.plotsquared.core.command.Argument;
import com.plotsquared.core.command.CommandDeclaration;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.command.Argument;
import com.plotsquared.core.command.CommandCategory; import com.plotsquared.core.command.CommandCategory;
import com.plotsquared.core.command.CommandDeclaration;
import com.plotsquared.core.command.RequiredType; import com.plotsquared.core.command.RequiredType;
import com.plotsquared.core.command.SubCommand; import com.plotsquared.core.command.SubCommand;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.player.OfflinePlotPlayer; import com.plotsquared.core.player.OfflinePlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.StringWrapper; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.StringWrapper;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.uuid.UUIDWrapper; import com.plotsquared.core.util.uuid.UUIDWrapper;
import com.google.common.collect.Sets;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -60,10 +60,13 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "uuidconvert", permission = "plots.admin", @CommandDeclaration(command = "uuidconvert",
description = "Debug UUID conversion", usage = "/plot uuidconvert <lower|offline|online>", permission = "plots.admin",
requiredType = RequiredType.CONSOLE, category = CommandCategory.DEBUG) public class DebugUUID description = "Debug UUID conversion",
extends SubCommand { usage = "/plot uuidconvert <lower|offline|online>",
requiredType = RequiredType.CONSOLE,
category = CommandCategory.DEBUG)
public class DebugUUID extends SubCommand {
public DebugUUID() { public DebugUUID() {
super(Argument.String); super(Argument.String);

View File

@ -32,7 +32,8 @@ import org.bukkit.World;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@Getter public abstract class EntityWrapper { @Getter
public abstract class EntityWrapper {
protected final float yaw; protected final float yaw;
protected final float pitch; protected final float pitch;

View File

@ -32,12 +32,13 @@ import com.plotsquared.core.plot.PlotArea;
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;
import java.util.Random;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Random;
final class BlockStatePopulator extends BlockPopulator { final class BlockStatePopulator extends BlockPopulator {
private final IndependentPlotGenerator plotGenerator; private final IndependentPlotGenerator plotGenerator;
@ -47,13 +48,15 @@ final class BlockStatePopulator extends BlockPopulator {
this.plotGenerator = plotGenerator; this.plotGenerator = plotGenerator;
} }
@Override public void populate(@NotNull final World world, @NotNull final Random random, @Override
public void populate(@NotNull final World world, @NotNull final Random random,
@NotNull final Chunk source) { @NotNull final Chunk source) {
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().getPlotArea(world.getName(), null); final PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null);
final ChunkWrapper wrap = new ChunkWrapper(area.getWorldName(), source.getX(), source.getZ()); final ChunkWrapper wrap =
new ChunkWrapper(area.getWorldName(), source.getX(), source.getZ());
final ScopedLocalBlockQueue chunk = this.queue.getForChunk(wrap.x, wrap.z); final ScopedLocalBlockQueue chunk = this.queue.getForChunk(wrap.x, wrap.z);
if (this.plotGenerator.populateChunk(chunk, area)) { if (this.plotGenerator.populateChunk(chunk, area)) {
this.queue.flush(); this.queue.flush();

View File

@ -25,17 +25,17 @@
*/ */
package com.plotsquared.bukkit.generator; package com.plotsquared.bukkit.generator;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.queue.GenChunk; import com.plotsquared.bukkit.queue.GenChunk;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.generator.GeneratorWrapper; import com.plotsquared.core.generator.GeneratorWrapper;
import com.plotsquared.core.generator.IndependentPlotGenerator; import com.plotsquared.core.generator.IndependentPlotGenerator;
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.generator.SingleWorldGenerator; 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;
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import lombok.Getter; import lombok.Getter;
import org.bukkit.World; import org.bukkit.World;
@ -103,9 +103,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
return this.platformGenerator; return this.platformGenerator;
} }
@Override @Override @NotNull public List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
@NotNull
public List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
try { try {
if (!this.loaded) { if (!this.loaded) {
String name = world.getName(); String name = world.getName();
@ -149,8 +147,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
return toAdd; return toAdd;
} }
@Override @Override @NotNull
@NotNull
public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z,
@NotNull BiomeGrid biome) { @NotNull BiomeGrid biome) {
@ -203,8 +200,9 @@ public class BukkitPlotGenerator extends ChunkGenerator
} }
PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null); PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null);
if (area == null && (area = PlotSquared.get().getPlotArea(this.levelName, null)) == null) { if (area == null && (area = PlotSquared.get().getPlotArea(this.levelName, null)) == null) {
throw new IllegalStateException("Cannot regenerate chunk that does not belong to a plot area." throw new IllegalStateException(
+ " Location: " + loc + ", world: " + world); "Cannot regenerate chunk that does not belong to a plot area." + " Location: " + loc
+ ", world: " + world);
} }
try { try {
this.plotGenerator.generateChunk(result, area); this.plotGenerator.generateChunk(result, area);
@ -215,8 +213,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
ChunkManager.postProcessChunk(loc, result); ChunkManager.postProcessChunk(loc, result);
} }
@Override @Override public boolean canSpawn(@NotNull final World world, final int x, final int z) {
public boolean canSpawn(@NotNull final World world, final int x, final int z) {
return true; return true;
} }

View File

@ -31,10 +31,9 @@ import com.plotsquared.core.generator.IndependentPlotGenerator;
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.util.MathMan;
import com.plotsquared.core.queue.ScopedLocalBlockQueue; import com.plotsquared.core.queue.ScopedLocalBlockQueue;
import com.plotsquared.core.util.MathMan;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import java.util.Random;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
@ -42,6 +41,8 @@ import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Range; import org.jetbrains.annotations.Range;
import java.util.Random;
final class DelegatePlotGenerator extends IndependentPlotGenerator { final class DelegatePlotGenerator extends IndependentPlotGenerator {
private final ChunkGenerator chunkGenerator; private final ChunkGenerator chunkGenerator;
@ -71,7 +72,8 @@ final class DelegatePlotGenerator extends IndependentPlotGenerator {
Random random = new Random(MathMan.pair((short) chunkX, (short) chunkZ)); Random random = new Random(MathMan.pair((short) chunkX, (short) chunkZ));
try { try {
ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() { ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() {
@Override public void setBiome(@Range(from = 0, to = 15) int x, @Override
public void setBiome(@Range(from = 0, to = 15) int x,
@Range(from = 0, to = 15) int z, @NotNull Biome biome) { @Range(from = 0, to = 15) int z, @NotNull Biome biome) {
result.setBiome(x, z, BukkitAdapter.adapt(biome)); result.setBiome(x, z, BukkitAdapter.adapt(biome));
} }
@ -86,8 +88,7 @@ final class DelegatePlotGenerator extends IndependentPlotGenerator {
return Biome.FOREST; return Biome.FOREST;
} }
@Override @Override public @NotNull Biome getBiome(int x, int y, int z) {
public @NotNull Biome getBiome(int x, int y, int z) {
return Biome.FOREST; return Biome.FOREST;
} }
}; };

View File

@ -57,7 +57,8 @@ import java.util.HashSet;
import static com.plotsquared.core.util.ReflectionUtils.getRefClass; import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
@SuppressWarnings("unused") public class ChunkListener implements Listener { @SuppressWarnings("unused")
public class ChunkListener implements Listener {
private RefMethod methodGetHandleChunk; private RefMethod methodGetHandleChunk;
private RefField mustSave; private RefField mustSave;
@ -291,11 +292,15 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
ent.remove(); ent.remove();
} }
} }
PlotSquared.debug("PlotSquared detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4)); PlotSquared.debug(
"PlotSquared detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (
chunk.getX() << 4));
} }
if (tiles.length > Settings.Chunk_Processor.MAX_TILES) { if (tiles.length > Settings.Chunk_Processor.MAX_TILES) {
if (unload) { if (unload) {
PlotSquared.debug("PlotSquared detected unsafe chunk: " + (chunk.getX()<< 4) + "," + (chunk.getX() << 4)); PlotSquared.debug(
"PlotSquared detected unsafe chunk: " + (chunk.getX() << 4) + "," + (
chunk.getX() << 4));
cleanChunk(chunk); cleanChunk(chunk);
return true; return true;
} }

View File

@ -28,10 +28,10 @@ package com.plotsquared.bukkit.listener;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
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.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;

View File

@ -25,15 +25,15 @@
*/ */
package com.plotsquared.bukkit.listener; package com.plotsquared.bukkit.listener;
import com.google.common.collect.Iterables;
import com.plotsquared.bukkit.player.BukkitPlayer; import com.plotsquared.bukkit.player.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.implementations.ForcefieldFlag;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.implementations.ForcefieldFlag;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.google.common.collect.Iterables;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -41,7 +41,8 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@SuppressWarnings("unused") public class ForceFieldListener { @SuppressWarnings("unused")
public class ForceFieldListener {
private static Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) { private static Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) {
Set<PlotPlayer> players = new HashSet<>(); Set<PlotPlayer> players = new HashSet<>();

View File

@ -26,9 +26,6 @@
package com.plotsquared.bukkit.listener; package com.plotsquared.bukkit.listener;
import com.destroystokyo.paper.MaterialTags; import com.destroystokyo.paper.MaterialTags;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.stream.JsonReader;
import com.plotsquared.bukkit.player.BukkitPlayer; import com.plotsquared.bukkit.player.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.UpdateUtility; import com.plotsquared.bukkit.util.UpdateUtility;
@ -36,6 +33,15 @@ 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.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.listener.PlayerBlockEventType;
import com.plotsquared.core.listener.PlotListener;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotHandler;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.PlotInventory;
import com.plotsquared.core.plot.flag.implementations.AnimalAttackFlag; import com.plotsquared.core.plot.flag.implementations.AnimalAttackFlag;
import com.plotsquared.core.plot.flag.implementations.AnimalCapFlag; import com.plotsquared.core.plot.flag.implementations.AnimalCapFlag;
import com.plotsquared.core.plot.flag.implementations.AnimalInteractFlag; import com.plotsquared.core.plot.flag.implementations.AnimalInteractFlag;
@ -88,23 +94,14 @@ import com.plotsquared.core.plot.flag.implementations.VehicleUseFlag;
import com.plotsquared.core.plot.flag.implementations.VillagerInteractFlag; 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.listener.PlayerBlockEventType;
import com.plotsquared.core.listener.PlotListener;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotHandler;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.PlotInventory;
import com.plotsquared.core.plot.message.PlotMessage; import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.PremiumVerification;
import com.plotsquared.core.util.StringWrapper;
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;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PremiumVerification;
import com.plotsquared.core.util.RegExUtil; import com.plotsquared.core.util.RegExUtil;
import com.plotsquared.core.util.StringWrapper;
import com.plotsquared.core.util.entity.EntityCategories; import com.plotsquared.core.util.entity.EntityCategories;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
@ -209,12 +206,7 @@ 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 javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -275,31 +267,32 @@ public class PlayerEvents extends PlotListener implements Listener {
return false; return false;
} }
final com.sk89q.worldedit.world.entity.EntityType entityType = BukkitAdapter.adapt(entity.getType()); final com.sk89q.worldedit.world.entity.EntityType entityType =
BukkitAdapter.adapt(entity.getType());
if (EntityCategories.PLAYER.contains(entityType)) { if (EntityCategories.PLAYER.contains(entityType)) {
return false; return false;
} }
if (EntityCategories.PROJECTILE.contains(entityType) || if (EntityCategories.PROJECTILE.contains(entityType) || EntityCategories.OTHER
EntityCategories.OTHER.contains(entityType) || .contains(entityType) || EntityCategories.HANGING.contains(entityType)) {
EntityCategories.HANGING.contains(entityType)) {
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED, return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED,
MiscCapFlag.MISC_CAP_UNLIMITED); MiscCapFlag.MISC_CAP_UNLIMITED);
} }
// Has to go go before vehicle as horses are both // Has to go go before vehicle as horses are both
// animals and vehicles // animals and vehicles
if (EntityCategories.ANIMAL.contains(entityType) || if (EntityCategories.ANIMAL.contains(entityType) || EntityCategories.VILLAGER
EntityCategories.VILLAGER.contains(entityType) || .contains(entityType) || EntityCategories.TAMEABLE.contains(entityType)) {
EntityCategories.TAMEABLE.contains(entityType)) { return EntityUtil
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED, .checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED, MobCapFlag.MOB_CAP_UNLIMITED,
MobCapFlag.MOB_CAP_UNLIMITED, AnimalCapFlag.ANIMAL_CAP_UNLIMITED); AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
} }
if (EntityCategories.HOSTILE.contains(entityType)) { if (EntityCategories.HOSTILE.contains(entityType)) {
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED, return EntityUtil
MobCapFlag.MOB_CAP_UNLIMITED, HostileCapFlag.HOSTILE_CAP_UNLIMITED); .checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED, MobCapFlag.MOB_CAP_UNLIMITED,
HostileCapFlag.HOSTILE_CAP_UNLIMITED);
} }
if (EntityCategories.VEHICLE.contains(entityType)) { if (EntityCategories.VEHICLE.contains(entityType)) {
@ -763,10 +756,12 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
} }
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) { if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
final com.sk89q.worldedit.world.entity.EntityType entityType = BukkitAdapter.adapt(vehicle.getType()); final com.sk89q.worldedit.world.entity.EntityType entityType =
BukkitAdapter.adapt(vehicle.getType());
// Horses etc are vehicles, but they're also animals // Horses etc are vehicles, but they're also animals
// so this filters out all living entities // so this filters out all living entities
if (EntityCategories.VEHICLE.contains(entityType) && !EntityCategories.ANIMAL.contains(entityType)) { if (EntityCategories.VEHICLE.contains(entityType) && !EntityCategories.ANIMAL
.contains(entityType)) {
List<MetadataValue> meta = vehicle.getMetadata("plot"); List<MetadataValue> meta = vehicle.getMetadata("plot");
Plot toPlot = BukkitUtil.getLocation(to).getPlot(); Plot toPlot = BukkitUtil.getLocation(to).getPlot();
if (!meta.isEmpty()) { if (!meta.isEmpty()) {
@ -930,7 +925,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|| area.isForcingPlotChat())) { || area.isForcingPlotChat())) {
return; return;
} }
if (plot.isDenied(plotPlayer.getUUID()) && !Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_CHAT_BYPASS)) { if (plot.isDenied(plotPlayer.getUUID()) && !Permissions
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_CHAT_BYPASS)) {
return; return;
} }
event.setCancelled(true); event.setCancelled(true);
@ -990,9 +986,8 @@ public class PlayerEvents extends PlotListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else if ( } else if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area
(location.getY() > area.getMaxBuildHeight() || location.getY() < area.getMinBuildHeight()) .getMinBuildHeight()) && !Permissions
&& !Permissions
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true); event.setCancelled(true);
MainUtil.sendMessage(plotPlayer, Captions.HEIGHT_LIMIT.getTranslated() MainUtil.sendMessage(plotPlayer, Captions.HEIGHT_LIMIT.getTranslated()
@ -1372,7 +1367,8 @@ public class PlayerEvents extends PlotListener implements Listener {
final PlotArea fromArea = fLocation.getPlotArea(); final PlotArea fromArea = fLocation.getPlotArea();
if (fromArea != null) { if (fromArea != null) {
final Plot plot = fromArea.getOwnedPlot(fLocation); final Plot plot = fromArea.getOwnedPlot(fLocation);
if (plot != null && !plot.getFlag(LiquidFlowFlag.class) && event.getBlock().isLiquid()) { if (plot != null && !plot.getFlag(LiquidFlowFlag.class) && event.getBlock()
.isLiquid()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -2497,13 +2493,16 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
final Entity entity = event.getRightClicked(); final Entity entity = event.getRightClicked();
final com.sk89q.worldedit.world.entity.EntityType entityType = BukkitAdapter.adapt(entity.getType()); final com.sk89q.worldedit.world.entity.EntityType entityType =
BukkitAdapter.adapt(entity.getType());
if (EntityCategories.HOSTILE.contains(entityType) && plot.getFlag(HostileInteractFlag.class)) { if (EntityCategories.HOSTILE.contains(entityType) && plot
.getFlag(HostileInteractFlag.class)) {
return; return;
} }
if (EntityCategories.ANIMAL.contains(entityType) && plot.getFlag(AnimalInteractFlag.class)) { if (EntityCategories.ANIMAL.contains(entityType) && plot
.getFlag(AnimalInteractFlag.class)) {
return; return;
} }
@ -2514,20 +2513,23 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
if (EntityCategories.VEHICLE.contains(entityType) && plot.getFlag(VehicleUseFlag.class)) { if (EntityCategories.VEHICLE.contains(entityType) && plot
.getFlag(VehicleUseFlag.class)) {
return; return;
} }
if (EntityCategories.PLAYER.contains(entityType) && plot.getFlag(PlayerInteractFlag.class)) { if (EntityCategories.PLAYER.contains(entityType) && plot
.getFlag(PlayerInteractFlag.class)) {
return; return;
} }
if (EntityCategories.VILLAGER.contains(entityType) && plot.getFlag(VillagerInteractFlag.class)) { if (EntityCategories.VILLAGER.contains(entityType) && plot
.getFlag(VillagerInteractFlag.class)) {
return; return;
} }
if ((EntityCategories.HANGING.contains(entityType) || if ((EntityCategories.HANGING.contains(entityType) || EntityCategories.OTHER
EntityCategories.OTHER.contains(entityType)) && plot.getFlag(MiscInteractFlag.class)) { .contains(entityType)) && plot.getFlag(MiscInteractFlag.class)) {
return; return;
} }
@ -2809,7 +2811,8 @@ public class PlayerEvents extends PlotListener implements Listener {
"plots.admin.pve." + stub); "plots.admin.pve." + stub);
return false; return false;
} }
} else if (EntityCategories.VEHICLE.contains(entityType)) { // Vehicles are managed in vehicle destroy event } else if (EntityCategories.VEHICLE
.contains(entityType)) { // Vehicles are managed in vehicle destroy event
return true; return true;
} else { // victim is something else } else { // victim is something else
if (plot != null && (plot.getFlag(PveFlag.class) || plot if (plot != null && (plot.getFlag(PveFlag.class) || plot
@ -2880,8 +2883,9 @@ public class PlayerEvents extends PlotListener implements Listener {
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
if (plot != null) { if (plot != null) {
if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area.getMinBuildHeight()) if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area
&& !Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { .getMinBuildHeight()) && !Permissions
.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true); event.setCancelled(true);
MainUtil.sendMessage(pp, Captions.HEIGHT_LIMIT.getTranslated() MainUtil.sendMessage(pp, Captions.HEIGHT_LIMIT.getTranslated()
.replace("{limit}", String.valueOf(area.getMaxBuildHeight()))); .replace("{limit}", String.valueOf(area.getMaxBuildHeight())));

View File

@ -44,7 +44,8 @@ import java.lang.reflect.Method;
import static com.plotsquared.core.util.ReflectionUtils.getRefClass; import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
@SuppressWarnings("unused") public class SingleWorldListener implements Listener { @SuppressWarnings("unused")
public class SingleWorldListener implements Listener {
private Method methodGetHandleChunk; private Method methodGetHandleChunk;
private Field mustSave; private Field mustSave;

View File

@ -41,33 +41,27 @@ public class Placeholders extends PlaceholderExpansion {
public Placeholders() { public Placeholders() {
} }
@Override @Override public boolean persist() {
public boolean persist() {
return true; return true;
} }
@Override @Override public boolean canRegister() {
public boolean canRegister() {
return true; return true;
} }
@Override @Override public String getAuthor() {
public String getAuthor() {
return "NotMyFault"; return "NotMyFault";
} }
@Override @Override public String getIdentifier() {
public String getIdentifier() {
return "plotsquared"; return "plotsquared";
} }
@Override @Override public String getVersion() {
public String getVersion() {
return "2.4"; return "2.4";
} }
@Override @Override public String onPlaceholderRequest(Player p, String identifier) {
public String onPlaceholderRequest(Player p, String identifier) {
final PlotPlayer pl = PlotPlayer.get(p.getName()); final PlotPlayer pl = PlotPlayer.get(p.getName());
if (pl == null) { if (pl == null) {

View File

@ -28,12 +28,12 @@ package com.plotsquared.bukkit.player;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
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.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.events.TeleportCause; import com.plotsquared.core.plot.PlotWeather;
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.plot.PlotWeather;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
@ -211,8 +211,7 @@ public class BukkitPlayer extends PlotPlayer {
} }
@Override public void sendMessage(String message) { @Override public void sendMessage(String message) {
message = message.replace('\u2010', '%') message = message.replace('\u2010', '%').replace('\u2020', '&').replace('\u2030', '&');
.replace('\u2020', '&').replace('\u2030', '&');
if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || ( if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (
System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) { System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
setMeta("lastMessage", message); setMeta("lastMessage", message);
@ -221,11 +220,13 @@ public class BukkitPlayer extends PlotPlayer {
} }
} }
@Override public void teleport(@NotNull final Location location, @NotNull final TeleportCause cause) { @Override
public void teleport(@NotNull final Location location, @NotNull final TeleportCause cause) {
if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) { if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) {
return; return;
} }
final org.bukkit.Location bukkitLocation = new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX() + 0.5, final org.bukkit.Location bukkitLocation =
new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX() + 0.5,
location.getY(), location.getZ() + 0.5, location.getYaw(), location.getPitch()); location.getY(), location.getZ() + 0.5, location.getYaw(), location.getPitch());
PaperLib.teleportAsync(player, bukkitLocation, getTeleportCause(cause)); PaperLib.teleportAsync(player, bukkitLocation, getTeleportCause(cause));
} }
@ -280,7 +281,8 @@ public class BukkitPlayer extends PlotPlayer {
} }
} }
@Override public void setGameMode(@NotNull final com.sk89q.worldedit.world.gamemode.GameMode gameMode) { @Override
public void setGameMode(@NotNull final com.sk89q.worldedit.world.gamemode.GameMode gameMode) {
if (ADVENTURE.equals(gameMode)) { if (ADVENTURE.equals(gameMode)) {
this.player.setGameMode(GameMode.ADVENTURE); this.player.setGameMode(GameMode.ADVENTURE);
} else if (CREATIVE.equals(gameMode)) { } else if (CREATIVE.equals(gameMode)) {
@ -344,7 +346,8 @@ public class BukkitPlayer extends PlotPlayer {
return PlayerTeleportEvent.TeleportCause.COMMAND; return PlayerTeleportEvent.TeleportCause.COMMAND;
case PLUGIN: case PLUGIN:
return PlayerTeleportEvent.TeleportCause.PLUGIN; return PlayerTeleportEvent.TeleportCause.PLUGIN;
default: return PlayerTeleportEvent.TeleportCause.UNKNOWN; default:
return PlayerTeleportEvent.TeleportCause.UNKNOWN;
} }
} }
} }

View File

@ -28,9 +28,9 @@ package com.plotsquared.bukkit.queue;
import com.plotsquared.bukkit.schematic.StateWrapper; import com.plotsquared.bukkit.schematic.StateWrapper;
import com.plotsquared.bukkit.util.BukkitBlockUtil; import com.plotsquared.bukkit.util.BukkitBlockUtil;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.queue.BasicLocalBlockQueue; import com.plotsquared.core.queue.BasicLocalBlockQueue;
import com.plotsquared.core.util.BlockUtil; import com.plotsquared.core.util.BlockUtil;
import com.plotsquared.core.util.MainUtil;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -139,7 +139,8 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
BlockData blockData = BukkitAdapter.adapt(block); BlockData blockData = BukkitAdapter.adapt(block);
Block existing = chunk.getBlock(x, y, z); Block existing = chunk.getBlock(x, y, z);
final BlockState existingBaseBlock = BukkitAdapter.adapt(existing.getBlockData()); final BlockState existingBaseBlock =
BukkitAdapter.adapt(existing.getBlockData());
if (BukkitBlockUtil.get(existing).equals(existingBaseBlock) && existing if (BukkitBlockUtil.get(existing).equals(existingBaseBlock) && existing
.getBlockData().matches(blockData)) { .getBlockData().matches(blockData)) {
continue; continue;
@ -151,8 +152,8 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
CompoundTag tag = block.getNbtData(); CompoundTag tag = block.getNbtData();
StateWrapper sw = new StateWrapper(tag); StateWrapper sw = new StateWrapper(tag);
sw.restoreTag(worldObj.getName(), existing.getX(), sw.restoreTag(worldObj.getName(), existing.getX(), existing.getY(),
existing.getY(), existing.getZ()); existing.getZ());
} }
} }
} }
@ -162,7 +163,8 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
if (isForceSync()) { if (isForceSync()) {
chunkConsumer.accept(getChunk(worldObj, localChunk)); chunkConsumer.accept(getChunk(worldObj, localChunk));
} else { } else {
PaperLib.getChunkAtAsync(worldObj, localChunk.getX(), localChunk.getZ(), true).thenAccept(chunkConsumer); PaperLib.getChunkAtAsync(worldObj, localChunk.getX(), localChunk.getZ(), true)
.thenAccept(chunkConsumer);
} }
} }
@ -206,8 +208,8 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
BiomeType biomeType = biomeZ[z]; BiomeType biomeType = biomeZ[z];
Biome biome = BukkitAdapter.adapt(biomeType); Biome biome = BukkitAdapter.adapt(biomeType);
worldObj.setBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z, worldObj
biome); .setBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z, biome);
} }
} }
} }
@ -216,7 +218,8 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
if (this.isForceSync()) { if (this.isForceSync()) {
chunkConsumer.accept(getChunk(worldObj, lc)); chunkConsumer.accept(getChunk(worldObj, lc));
} else { } else {
PaperLib.getChunkAtAsync(worldObj, lc.getX(), lc.getZ(), true).thenAccept(chunkConsumer); PaperLib.getChunkAtAsync(worldObj, lc.getX(), lc.getZ(), true)
.thenAccept(chunkConsumer);
} }
} }

View File

@ -25,14 +25,14 @@
*/ */
package com.plotsquared.bukkit.queue; package com.plotsquared.bukkit.queue;
import com.google.common.base.Preconditions;
import com.plotsquared.bukkit.util.BukkitBlockUtil; import com.plotsquared.bukkit.util.BukkitBlockUtil;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.location.ChunkWrapper; import com.plotsquared.core.location.ChunkWrapper;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.queue.ScopedLocalBlockQueue; import com.plotsquared.core.queue.ScopedLocalBlockQueue;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.PatternUtil; import com.plotsquared.core.util.PatternUtil;
import com.google.common.base.Preconditions;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
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;
@ -119,7 +119,8 @@ public class GenChunk extends ScopedLocalBlockQueue {
int maxX = Math.max(pos1.getX(), pos2.getX()); int maxX = Math.max(pos1.getX(), pos2.getX());
int maxY = Math.max(pos1.getY(), pos2.getY()); int maxY = Math.max(pos1.getY(), pos2.getY());
int maxZ = Math.max(pos1.getZ(), pos2.getZ()); int maxZ = Math.max(pos1.getZ(), pos2.getZ());
chunkData.setRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1, BukkitAdapter.adapt(block)); chunkData
.setRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1, BukkitAdapter.adapt(block));
} }
@Override public boolean setBiome(int x, int z, BiomeType biomeType) { @Override public boolean setBiome(int x, int z, BiomeType biomeType) {
@ -135,7 +136,8 @@ public class GenChunk extends ScopedLocalBlockQueue {
} }
@Override public boolean setBlock(int x, int y, int z, @NotNull Pattern pattern) { @Override public boolean setBlock(int x, int y, int z, @NotNull Pattern pattern) {
return setBlock(x, y, z, PatternUtil.apply(Preconditions.checkNotNull(pattern, "Pattern may not be null"), x, y, z)); return setBlock(x, y, z, PatternUtil
.apply(Preconditions.checkNotNull(pattern, "Pattern may not be null"), x, y, z));
} }
@Override public boolean setBlock(int x, int y, int z, BlockState id) { @Override public boolean setBlock(int x, int y, int z, BlockState id) {

View File

@ -27,12 +27,19 @@ package com.plotsquared.bukkit.schematic;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.queue.LocalBlockQueue; import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.*; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntArrayTag;
import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.ShortTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
@ -42,7 +49,13 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.util.*; import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.IntStream; import java.util.stream.IntStream;
/** /**
@ -50,7 +63,8 @@ import java.util.stream.IntStream;
*/ */
public class BukkitSchematicHandler extends SchematicHandler { public class BukkitSchematicHandler extends SchematicHandler {
@Override public void getCompoundTag(final String world, final Set<CuboidRegion> regions, @Override
public void getCompoundTag(final String world, final Set<CuboidRegion> regions,
final RunnableVal<CompoundTag> whenDone) { final RunnableVal<CompoundTag> whenDone) {
// async // async
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@ -112,10 +126,12 @@ public class BukkitSchematicHandler extends SchematicHandler {
schematic.put("BiomePaletteMax", new IntTag(biomePalette.size())); schematic.put("BiomePaletteMax", new IntTag(biomePalette.size()));
Map<String, Tag> biomePaletteTag = new HashMap<>(); Map<String, Tag> biomePaletteTag = new HashMap<>();
biomePalette.forEach((key, value) -> biomePaletteTag.put(key, new IntTag(value))); biomePalette.forEach(
(key, value) -> biomePaletteTag.put(key, new IntTag(value)));
schematic.put("BiomePalette", new CompoundTag(biomePaletteTag)); schematic.put("BiomePalette", new CompoundTag(biomePaletteTag));
schematic.put("BiomeData", new ByteArrayTag(biomeBuffer.toByteArray())); schematic
.put("BiomeData", new ByteArrayTag(biomeBuffer.toByteArray()));
whenDone.value = new CompoundTag(schematic); whenDone.value = new CompoundTag(schematic);
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
}); });
@ -123,8 +139,10 @@ public class BukkitSchematicHandler extends SchematicHandler {
} }
final Runnable regionTask = this; final Runnable regionTask = this;
CuboidRegion region = queue.poll(); CuboidRegion region = queue.poll();
Location pos1 = new Location(world, region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ()); Location pos1 = new Location(world, region.getMinimumPoint().getX(),
Location pos2 = new Location(world, region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ()); region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
Location pos2 = new Location(world, region.getMaximumPoint().getX(),
region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
final int p1x = pos1.getX(); final int p1x = pos1.getX();
final int sy = pos1.getY(); final int sy = pos1.getY();
final int p1z = pos1.getZ(); final int p1z = pos1.getZ();

View File

@ -30,8 +30,8 @@ import com.plotsquared.bukkit.player.BukkitPlayer;
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.ConsolePlayer; import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.util.ChatManager; import com.plotsquared.core.util.ChatManager;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -26,9 +26,9 @@
package com.plotsquared.bukkit.util; package com.plotsquared.bukkit.util;
import com.plotsquared.bukkit.player.BukkitPlayer; import com.plotsquared.bukkit.player.BukkitPlayer;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotInventory; import com.plotsquared.core.plot.PlotInventory;
import com.plotsquared.core.plot.PlotItemStack; import com.plotsquared.core.plot.PlotItemStack;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.InventoryUtil; import com.plotsquared.core.util.InventoryUtil;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -26,10 +26,10 @@
package com.plotsquared.bukkit.util; package com.plotsquared.bukkit.util;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator; import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.generator.GeneratorWrapper; 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;
@ -88,7 +88,7 @@ public class BukkitSetupUtils extends SetupUtils {
} }
World dw = Bukkit.getWorlds().get(0); World dw = Bukkit.getWorlds().get(0);
for (Player player : world.getPlayers()) { for (Player player : world.getPlayers()) {
PaperLib.teleportAsync(player,dw.getSpawnLocation()); PaperLib.teleportAsync(player, dw.getSpawnLocation());
} }
if (save) { if (save) {
for (Chunk chunk : world.getLoadedChunks()) { for (Chunk chunk : world.getLoadedChunks()) {

View File

@ -337,15 +337,16 @@ public class BukkitUtil extends WorldUtil {
} }
@Override public void getBiome(String world, int x, int z, final Consumer<BiomeType> result) { @Override public void getBiome(String world, int x, int z, final Consumer<BiomeType> result) {
ensureLoaded(world, x, z, chunk -> ensureLoaded(world, x, z,
result.accept(BukkitAdapter.adapt(getWorld(world).getBiome(x, z)))); chunk -> result.accept(BukkitAdapter.adapt(getWorld(world).getBiome(x, z))));
} }
@Override public BiomeType getBiomeSynchronous(String world, int x, int z) { @Override public BiomeType getBiomeSynchronous(String world, int x, int z) {
return BukkitAdapter.adapt(getWorld(world).getBiome(x, z)); return BukkitAdapter.adapt(getWorld(world).getBiome(x, z));
} }
@Override public void getHighestBlock(@NonNull final String world, final int x, final int z, @Override
public void getHighestBlock(@NonNull final String world, final int x, final int z,
final IntConsumer result) { final IntConsumer result) {
ensureLoaded(world, x, z, chunk -> { ensureLoaded(world, x, z, chunk -> {
final World bukkitWorld = getWorld(world); final World bukkitWorld = getWorld(world);
@ -394,7 +395,8 @@ public class BukkitUtil extends WorldUtil {
return bukkitWorld.getMaxHeight() - 1; return bukkitWorld.getMaxHeight() - 1;
} }
@Override public void getSign(@NonNull final Location location, final Consumer<String[]> result) { @Override
public void getSign(@NonNull final Location location, final Consumer<String[]> result) {
ensureLoaded(location, chunk -> { ensureLoaded(location, chunk -> {
final Block block = chunk.getWorld().getBlockAt(getLocation(location)); final Block block = chunk.getWorld().getBlockAt(getLocation(location));
if (block.getState() instanceof Sign) { if (block.getState() instanceof Sign) {
@ -519,7 +521,8 @@ public class BukkitUtil extends WorldUtil {
return new BukkitWorld(Bukkit.getWorld(world)); return new BukkitWorld(Bukkit.getWorld(world));
} }
@Override public void getBlock(@NonNull final Location location, final Consumer<BlockState> result) { @Override
public void getBlock(@NonNull final Location location, final Consumer<BlockState> result) {
ensureLoaded(location, chunk -> { ensureLoaded(location, chunk -> {
final World world = getWorld(location.getWorld()); final World world = getWorld(location.getWorld());
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ()); final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
@ -554,7 +557,8 @@ public class BukkitUtil extends WorldUtil {
} }
@Override @Override
public Set<com.sk89q.worldedit.world.entity.EntityType> getTypesInCategory(final String category) { public Set<com.sk89q.worldedit.world.entity.EntityType> getTypesInCategory(
final String category) {
final Collection<Class<?>> allowedInterfaces = new HashSet<>(); final Collection<Class<?>> allowedInterfaces = new HashSet<>();
switch (category) { switch (category) {
case "animal": { case "animal": {
@ -563,13 +567,16 @@ public class BukkitUtil extends WorldUtil {
allowedInterfaces.add(Animals.class); allowedInterfaces.add(Animals.class);
allowedInterfaces.add(WaterMob.class); allowedInterfaces.add(WaterMob.class);
allowedInterfaces.add(Ambient.class); allowedInterfaces.add(Ambient.class);
} break; }
break;
case "tameable": { case "tameable": {
allowedInterfaces.add(Tameable.class); allowedInterfaces.add(Tameable.class);
} break; }
break;
case "vehicle": { case "vehicle": {
allowedInterfaces.add(Vehicle.class); allowedInterfaces.add(Vehicle.class);
} break; }
break;
case "hostile": { case "hostile": {
allowedInterfaces.add(Shulker.class); allowedInterfaces.add(Shulker.class);
allowedInterfaces.add(Monster.class); allowedInterfaces.add(Monster.class);
@ -578,16 +585,20 @@ public class BukkitUtil extends WorldUtil {
allowedInterfaces.add(Ghast.class); allowedInterfaces.add(Ghast.class);
allowedInterfaces.add(Phantom.class); allowedInterfaces.add(Phantom.class);
allowedInterfaces.add(EnderCrystal.class); allowedInterfaces.add(EnderCrystal.class);
} break; }
break;
case "hanging": { case "hanging": {
allowedInterfaces.add(Hanging.class); allowedInterfaces.add(Hanging.class);
} break; }
break;
case "villager": { case "villager": {
allowedInterfaces.add(NPC.class); allowedInterfaces.add(NPC.class);
} break; }
break;
case "projectile": { case "projectile": {
allowedInterfaces.add(Projectile.class); allowedInterfaces.add(Projectile.class);
} break; }
break;
case "other": { case "other": {
allowedInterfaces.add(ArmorStand.class); allowedInterfaces.add(ArmorStand.class);
allowedInterfaces.add(FallingBlock.class); allowedInterfaces.add(FallingBlock.class);
@ -599,16 +610,20 @@ public class BukkitUtil extends WorldUtil {
allowedInterfaces.add(ExperienceOrb.class); allowedInterfaces.add(ExperienceOrb.class);
allowedInterfaces.add(EnderSignal.class); allowedInterfaces.add(EnderSignal.class);
allowedInterfaces.add(Firework.class); allowedInterfaces.add(Firework.class);
} break; }
break;
case "player": { case "player": {
allowedInterfaces.add(Player.class); allowedInterfaces.add(Player.class);
} break; }
break;
default: { default: {
PlotSquared.log(Captions.PREFIX + "Unknown entity category requested: " + category); PlotSquared.log(Captions.PREFIX + "Unknown entity category requested: " + category);
} break; }
break;
} }
final Set<com.sk89q.worldedit.world.entity.EntityType> types = new HashSet<>(); final Set<com.sk89q.worldedit.world.entity.EntityType> types = new HashSet<>();
outer: for (final EntityType bukkitType : EntityType.values()) { outer:
for (final EntityType bukkitType : EntityType.values()) {
final Class<? extends Entity> entityClass = bukkitType.getEntityClass(); final Class<? extends Entity> entityClass = bukkitType.getEntityClass();
if (entityClass == null) { if (entityClass == null) {
continue; continue;
@ -623,22 +638,23 @@ public class BukkitUtil extends WorldUtil {
return types; return types;
} }
private static void ensureLoaded(final String world, final int x, final int z, final Consumer<Chunk> chunkConsumer) { private static void ensureLoaded(final String world, final int x, final int z,
PaperLib.getChunkAtAsync(getWorld(world), x >> 4, z >> 4, true).thenAccept(chunk -> final Consumer<Chunk> chunkConsumer) {
ensureMainThread(chunkConsumer, chunk)); PaperLib.getChunkAtAsync(getWorld(world), x >> 4, z >> 4, true)
.thenAccept(chunk -> ensureMainThread(chunkConsumer, chunk));
} }
private static void ensureLoaded(final Location location, final Consumer<Chunk> chunkConsumer) { private static void ensureLoaded(final Location location, final Consumer<Chunk> chunkConsumer) {
PaperLib.getChunkAtAsync(getLocation(location), true).thenAccept(chunk -> PaperLib.getChunkAtAsync(getLocation(location), true)
ensureMainThread(chunkConsumer, chunk)); .thenAccept(chunk -> ensureMainThread(chunkConsumer, chunk));
} }
private static <T> void ensureMainThread(final Consumer<T> consumer, final T value) { private static <T> void ensureMainThread(final Consumer<T> consumer, final T value) {
if (Bukkit.isPrimaryThread()) { if (Bukkit.isPrimaryThread()) {
consumer.accept(value); consumer.accept(value);
} else { } else {
Bukkit.getScheduler().runTask(BukkitMain.getPlugin(BukkitMain.class), () -> Bukkit.getScheduler()
consumer.accept(value)); .runTask(BukkitMain.getPlugin(BukkitMain.class), () -> consumer.accept(value));
} }
} }

View File

@ -99,7 +99,8 @@ public class OfflinePlayerUtil {
Class<?> minecraftServerClass = getNmsClass("MinecraftServer"); Class<?> minecraftServerClass = getNmsClass("MinecraftServer");
Class<?> dimensionManager = getNmsClass("DimensionManager"); Class<?> dimensionManager = getNmsClass("DimensionManager");
Object overworld = getField(makeField(dimensionManager, "OVERWORLD"), null); Object overworld = getField(makeField(dimensionManager, "OVERWORLD"), null);
Method getWorldServer = makeMethod(minecraftServerClass, "getWorldServer", dimensionManager); Method getWorldServer =
makeMethod(minecraftServerClass, "getWorldServer", dimensionManager);
return callMethod(getWorldServer, server, overworld); return callMethod(getWorldServer, server, overworld);
} }

View File

@ -28,8 +28,8 @@ package com.plotsquared.bukkit.util;
import com.plotsquared.bukkit.player.BukkitPlayer; import com.plotsquared.bukkit.player.BukkitPlayer;
import com.plotsquared.core.PlotSquared; 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.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.ReflectionUtils.RefClass; import com.plotsquared.core.util.ReflectionUtils.RefClass;
import com.plotsquared.core.util.ReflectionUtils.RefConstructor; import com.plotsquared.core.util.ReflectionUtils.RefConstructor;
import com.plotsquared.core.util.ReflectionUtils.RefField; import com.plotsquared.core.util.ReflectionUtils.RefField;

View File

@ -75,7 +75,8 @@ public class UpdateUtility implements Listener {
if (internalVersion.isLaterVersion(spigotVersion)) { if (internalVersion.isLaterVersion(spigotVersion)) {
PlotSquared PlotSquared
.log(Captions.PREFIX + "&6There appears to be a PlotSquared update available!"); .log(Captions.PREFIX + "&6There appears to be a PlotSquared update available!");
PlotSquared.log(Captions.PREFIX + "&6You are running version " + internalVersion.versionString() PlotSquared.log(
Captions.PREFIX + "&6You are running version " + internalVersion.versionString()
+ ", &6latest version is " + spigotVersion); + ", &6latest version is " + spigotVersion);
PlotSquared PlotSquared
.log(Captions.PREFIX + "&6https://www.spigotmc.org/resources/77506/updates"); .log(Captions.PREFIX + "&6https://www.spigotmc.org/resources/77506/updates");

View File

@ -25,9 +25,9 @@
*/ */
package com.plotsquared.bukkit.util.uuid; package com.plotsquared.bukkit.util.uuid;
import com.google.common.base.Charsets;
import com.plotsquared.core.player.OfflinePlotPlayer; import com.plotsquared.core.player.OfflinePlotPlayer;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.google.common.base.Charsets;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -37,7 +37,8 @@ import java.util.UUID;
public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper { public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
@NotNull @Override public UUID getUUID(PlotPlayer player) { @NotNull @Override public UUID getUUID(PlotPlayer player) {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8)); return UUID.nameUUIDFromBytes(
("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8));
} }
@Override public UUID getUUID(OfflinePlotPlayer player) { @Override public UUID getUUID(OfflinePlotPlayer player) {
@ -47,7 +48,8 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
@Override public UUID getUUID(OfflinePlayer player) { @Override public UUID getUUID(OfflinePlayer player) {
return UUID.nameUUIDFromBytes( return UUID.nameUUIDFromBytes(
("OfflinePlayer:" + Objects.requireNonNull(player.getName()).toLowerCase()).getBytes(Charsets.UTF_8)); ("OfflinePlayer:" + Objects.requireNonNull(player.getName()).toLowerCase())
.getBytes(Charsets.UTF_8));
} }
@Override public UUID getUUID(String name) { @Override public UUID getUUID(String name) {

View File

@ -25,6 +25,8 @@
*/ */
package com.plotsquared.bukkit.util.uuid; package com.plotsquared.bukkit.util.uuid;
import com.google.common.base.Charsets;
import com.google.common.collect.BiMap;
import com.plotsquared.bukkit.player.BukkitOfflinePlayer; import com.plotsquared.bukkit.player.BukkitOfflinePlayer;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.player.OfflinePlotPlayer; import com.plotsquared.core.player.OfflinePlotPlayer;
@ -32,8 +34,6 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.StringWrapper; import com.plotsquared.core.util.StringWrapper;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
import com.plotsquared.core.util.uuid.UUIDWrapper; import com.plotsquared.core.util.uuid.UUIDWrapper;
import com.google.common.base.Charsets;
import com.google.common.collect.BiMap;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.Server; import org.bukkit.Server;
@ -60,7 +60,8 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
} }
@NotNull @Override public UUID getUUID(PlotPlayer player) { @NotNull @Override public UUID getUUID(PlotPlayer player) {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8)); return UUID
.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
} }
@Override public UUID getUUID(OfflinePlotPlayer player) { @Override public UUID getUUID(OfflinePlotPlayer player) {

View File

@ -25,18 +25,18 @@
*/ */
package com.plotsquared.bukkit.util.uuid; package com.plotsquared.bukkit.util.uuid;
import com.google.common.collect.HashBiMap;
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.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.database.SQLite; import com.plotsquared.core.database.SQLite;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.StringWrapper;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.StringWrapper;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
import com.plotsquared.core.util.uuid.UUIDHandlerImplementation; import com.plotsquared.core.util.uuid.UUIDHandlerImplementation;
import com.plotsquared.core.util.uuid.UUIDWrapper; import com.plotsquared.core.util.uuid.UUIDWrapper;
import com.google.common.collect.HashBiMap;
import org.json.simple.JSONArray; import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser; import org.json.simple.parser.JSONParser;

View File

@ -25,14 +25,14 @@
*/ */
package com.plotsquared.core.api; package com.plotsquared.core.api;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Caption; import com.plotsquared.core.configuration.Caption;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
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.player.PlotPlayer;
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.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
@ -60,7 +60,9 @@ import java.util.UUID;
* *
* @version 5 * @version 5
*/ */
@SuppressWarnings({"unused", "WeakerAccess"}) @NoArgsConstructor public class PlotAPI { @SuppressWarnings({"unused", "WeakerAccess"})
@NoArgsConstructor
public class PlotAPI {
/** /**
* Gets all plots. * Gets all plots.

View File

@ -26,8 +26,8 @@
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.command.Claim; import com.plotsquared.core.command.Claim;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

View File

@ -26,8 +26,8 @@
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.command.Claim; import com.plotsquared.core.command.Claim;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import javax.annotation.Nullable; import javax.annotation.Nullable;

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
public class PlayerEnterPlotEvent extends PlotPlayerEvent { public class PlayerEnterPlotEvent extends PlotPlayerEvent {

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
/** /**
* *

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import java.util.UUID; import java.util.UUID;

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import java.util.UUID; import java.util.UUID;

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import java.util.UUID; import java.util.UUID;

View File

@ -58,13 +58,11 @@ public class PlayerTeleportToPlotEvent extends PlotPlayerEvent implements Cancel
return this.from; return this.from;
} }
@Override @Override public Result getEventResult() {
public Result getEventResult() {
return eventResult; return eventResult;
} }
@Override @Override public void setEventResult(Result e) {
public void setEventResult(Result e) {
this.eventResult = e; this.eventResult = e;
} }
} }

View File

@ -56,6 +56,7 @@ public final class PlotAutoMergeEvent extends PlotEvent implements CancellablePl
this.world = world; this.world = world;
this.plots = plots; this.plots = plots;
} }
/** /**
* Get the plots being added. * Get the plots being added.
* *
@ -65,13 +66,11 @@ public final class PlotAutoMergeEvent extends PlotEvent implements CancellablePl
return Collections.unmodifiableList(this.plots); return Collections.unmodifiableList(this.plots);
} }
@Override @Override public Result getEventResult() {
public Result getEventResult() {
return eventResult; return eventResult;
} }
@Override @Override public void setEventResult(Result e) {
public void setEventResult(Result e) {
this.eventResult = e; this.eventResult = e;
} }
} }

View File

@ -25,9 +25,9 @@
*/ */
package com.plotsquared.core.events; package com.plotsquared.core.events;
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.player.PlotPlayer;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.UUID; import java.util.UUID;

View File

@ -57,13 +57,11 @@ public class PlotClearEvent extends PlotEvent implements CancellablePlotEvent {
return getPlot().getWorldName(); return getPlot().getWorldName();
} }
@Override @Override public Result getEventResult() {
public Result getEventResult() {
return eventResult; return eventResult;
} }
@Override @Override public void setEventResult(Result e) {
public void setEventResult(Result e) {
this.eventResult = e; this.eventResult = e;
} }
} }

View File

@ -57,13 +57,11 @@ public class PlotDeleteEvent extends PlotEvent implements CancellablePlotEvent {
return getPlot().getWorldName(); return getPlot().getWorldName();
} }
@Override @Override public Result getEventResult() {
public Result getEventResult() {
return eventResult; return eventResult;
} }
@Override @Override public void setEventResult(Result e) {
public void setEventResult(Result e) {
this.eventResult = e; this.eventResult = e;
} }
} }

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.PlotFlag;
/** /**
* Called when a Flag is added to a plot. * Called when a Flag is added to a plot.
@ -45,13 +45,11 @@ public class PlotFlagAddEvent extends PlotFlagEvent implements CancellablePlotEv
super(plot, flag); super(plot, flag);
} }
@Override @Override public Result getEventResult() {
public Result getEventResult() {
return eventResult; return eventResult;
} }
@Override @Override public void setEventResult(Result e) {
public void setEventResult(Result e) {
this.eventResult = e; this.eventResult = e;
} }
} }

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.PlotFlag;
public abstract class PlotFlagEvent extends PlotEvent { public abstract class PlotFlagEvent extends PlotEvent {
private final PlotFlag<?, ?> flag; private final PlotFlag<?, ?> flag;

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.PlotFlag;
/** /**
* Called when a flag is removed from a plot * Called when a flag is removed from a plot
@ -45,13 +45,11 @@ public class PlotFlagRemoveEvent extends PlotFlagEvent implements CancellablePlo
super(plot, flag); super(plot, flag);
} }
@Override @Override public Result getEventResult() {
public Result getEventResult() {
return eventResult; return eventResult;
} }
@Override @Override public void setEventResult(Result e) {
public void setEventResult(Result e) {
this.eventResult = e; this.eventResult = e;
} }
} }

View File

@ -26,8 +26,8 @@
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.location.Direction; import com.plotsquared.core.location.Direction;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
public abstract class PlotPlayerEvent extends PlotEvent { public abstract class PlotPlayerEvent extends PlotEvent {

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.events; package com.plotsquared.core.events;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.Rating; import com.plotsquared.core.plot.Rating;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@ -25,13 +25,13 @@
*/ */
package com.plotsquared.core.plot; package com.plotsquared.core.plot;
import com.plotsquared.core.configuration.serialization.ConfigurationSerializable;
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.BlockUtil;
import com.plotsquared.core.util.PatternUtil;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.serialization.ConfigurationSerializable;
import com.plotsquared.core.util.BlockUtil;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.PatternUtil;
import com.plotsquared.core.util.StringMan;
import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -49,7 +49,8 @@ import java.util.regex.Matcher;
* A block bucket is a container of block types, where each block * A block bucket is a container of block types, where each block
* has a specified chance of being randomly picked * has a specified chance of being randomly picked
*/ */
@EqualsAndHashCode(of = {"input"}) @SuppressWarnings({"unused", "WeakerAccess"}) @EqualsAndHashCode(of = {"input"})
@SuppressWarnings({"unused", "WeakerAccess"})
public final class BlockBucket implements ConfigurationSerializable { public final class BlockBucket implements ConfigurationSerializable {
private static java.util.regex.Pattern regex = java.util.regex.Pattern.compile( private static java.util.regex.Pattern regex = java.util.regex.Pattern.compile(
"((?<namespace>[A-Za-z_]+):)?(?<block>([A-Za-z_]+(\\[?[\\S\\s]+\\])?))(:(?<chance>[0-9]{1,3}))?"); "((?<namespace>[A-Za-z_]+):)?(?<block>([A-Za-z_]+(\\[?[\\S\\s]+\\])?))(:(?<chance>[0-9]{1,3}))?");
@ -134,7 +135,8 @@ public final class BlockBucket implements ConfigurationSerializable {
String chanceStr = matcher.group("chance"); String chanceStr = matcher.group("chance");
String block = matcher.group("block"); String block = matcher.group("block");
//noinspection PointlessNullCheck //noinspection PointlessNullCheck
if (chanceStr != null && block != null && !MathMan.isInteger(block) && MathMan.isInteger(chanceStr)) { if (chanceStr != null && block != null && !MathMan.isInteger(block) && MathMan
.isInteger(chanceStr)) {
String namespace = matcher.group("namespace"); String namespace = matcher.group("namespace");
string = (namespace == null ? "" : namespace + ":") + block; string = (namespace == null ? "" : namespace + ":") + block;
} }
@ -191,7 +193,10 @@ public final class BlockBucket implements ConfigurationSerializable {
return ImmutableMap.of("blocks", this.toString()); return ImmutableMap.of("blocks", this.toString());
} }
@Getter @EqualsAndHashCode @RequiredArgsConstructor private static final class Range { @Getter
@EqualsAndHashCode
@RequiredArgsConstructor
private static final class Range {
private final int min; private final int min;
private final int max; private final int max;

View File

@ -25,13 +25,10 @@
*/ */
package com.plotsquared.core.plot; package com.plotsquared.core.plot;
import com.plotsquared.core.events.TeleportCause; import com.google.common.collect.BiMap;
import com.plotsquared.core.location.BlockLoc; import com.google.common.collect.ImmutableSet;
import com.plotsquared.core.location.Direction; import com.google.common.collect.Sets;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.location.PlotLoc;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationUtil; import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
@ -40,32 +37,35 @@ import com.plotsquared.core.events.PlotComponentSetEvent;
import com.plotsquared.core.events.PlotMergeEvent; import com.plotsquared.core.events.PlotMergeEvent;
import com.plotsquared.core.events.PlotUnlinkEvent; import com.plotsquared.core.events.PlotUnlinkEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.generator.SquarePlotWorld;
import com.plotsquared.core.listener.PlotListener;
import com.plotsquared.core.location.BlockLoc;
import com.plotsquared.core.location.Direction;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.location.PlotLoc;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.comment.PlotComment;
import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.expiration.PlotAnalysis;
import com.plotsquared.core.plot.flag.FlagContainer; import com.plotsquared.core.plot.flag.FlagContainer;
import com.plotsquared.core.plot.flag.GlobalFlagContainer; import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.InternalFlag; import com.plotsquared.core.plot.flag.InternalFlag;
import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.KeepFlag; import com.plotsquared.core.plot.flag.implementations.KeepFlag;
import com.plotsquared.core.generator.SquarePlotWorld;
import com.plotsquared.core.listener.PlotListener;
import com.plotsquared.core.plot.comment.PlotComment;
import com.plotsquared.core.plot.schematic.Schematic; import com.plotsquared.core.plot.schematic.Schematic;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.ChunkManager;
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;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.StringWrapper; import com.plotsquared.core.util.StringWrapper;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.expiration.PlotAnalysis;
import com.plotsquared.core.util.task.RunnableVal;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
@ -103,7 +103,12 @@ import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.plotsquared.core.command.SubCommand.sendMessage; import static com.plotsquared.core.command.SubCommand.sendMessage;
import static com.plotsquared.core.util.entity.EntityCategories.*; import static com.plotsquared.core.util.entity.EntityCategories.CAP_ANIMAL;
import static com.plotsquared.core.util.entity.EntityCategories.CAP_ENTITY;
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MISC;
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MOB;
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MONSTER;
import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
/** /**

View File

@ -31,10 +31,10 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.collection.QuadMap; import com.plotsquared.core.collection.QuadMap;
import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.generator.GridPlotWorld; import com.plotsquared.core.generator.GridPlotWorld;
import com.plotsquared.core.generator.IndependentPlotGenerator; import com.plotsquared.core.generator.IndependentPlotGenerator;
import com.plotsquared.core.location.Direction; import com.plotsquared.core.location.Direction;
@ -217,8 +217,8 @@ public abstract class PlotArea {
return false; return false;
} }
PlotArea plotarea = (PlotArea) obj; PlotArea plotarea = (PlotArea) obj;
return this.getWorldHash() == plotarea.getWorldHash() && this.getWorldName().equals(plotarea.getWorldName()) return this.getWorldHash() == plotarea.getWorldHash() && this.getWorldName()
&& StringMan.isEqual(this.getId(), plotarea.getId()); .equals(plotarea.getWorldName()) && StringMan.isEqual(this.getId(), plotarea.getId());
} }
public Set<PlotCluster> getClusters() { public Set<PlotCluster> getClusters() {
@ -359,8 +359,9 @@ public abstract class PlotArea {
String prefix = " "; String prefix = " ";
for (final PlotFlag<?, ?> flag : flagCollection) { for (final PlotFlag<?, ?> flag : flagCollection) {
Object value = flag.toString(); Object value = flag.toString();
flagBuilder.append(prefix).append(CaptionUtility.format(null, Captions.PLOT_FLAG_LIST.getTranslated(), flagBuilder.append(prefix).append(CaptionUtility
flag.getName(), CaptionUtility.formatRaw(null, value.toString(), ""))); .format(null, Captions.PLOT_FLAG_LIST.getTranslated(), flag.getName(),
CaptionUtility.formatRaw(null, value.toString(), "")));
prefix = ", "; prefix = ", ";
} }
} }
@ -543,8 +544,8 @@ public abstract class PlotArea {
} }
public boolean contains(@NotNull final Location location) { public boolean contains(@NotNull final Location location) {
return StringMan.isEqual(location.getWorld(), this.getWorldName()) && (getRegionAbs() == null return StringMan.isEqual(location.getWorld(), this.getWorldName()) && (
|| this.region.contains(location.getBlockVector3())); getRegionAbs() == null || this.region.contains(location.getBlockVector3()));
} }
@NotNull public Set<Plot> getPlotsAbs(final UUID uuid) { @NotNull public Set<Plot> getPlotsAbs(final UUID uuid) {
@ -599,6 +600,7 @@ public abstract class PlotArea {
public int getPlotCount(@Nullable final PlotPlayer player) { public int getPlotCount(@Nullable final PlotPlayer player) {
return player != null ? getPlotCount(player.getUUID()) : 0; return player != null ? getPlotCount(player.getUUID()) : 0;
} }
@Nullable public Plot getPlotAbs(@NotNull final PlotId id) { @Nullable public Plot getPlotAbs(@NotNull final PlotId id) {
Plot plot = getOwnedPlotAbs(id); Plot plot = getOwnedPlotAbs(id);
if (plot == null) { if (plot == null) {
@ -640,7 +642,8 @@ public abstract class PlotArea {
return this.clusters != null ? this.clusters.get(plot.getId().x, plot.getId().y) : null; return this.clusters != null ? this.clusters.get(plot.getId().x, plot.getId().y) : null;
} }
@Nullable public PlotCluster getFirstIntersectingCluster(@NotNull final PlotId pos1, @Nullable
public PlotCluster getFirstIntersectingCluster(@NotNull final PlotId pos1,
@NotNull final PlotId pos2) { @NotNull final PlotId pos2) {
if (this.clusters == null) { if (this.clusters == null) {
return null; return null;
@ -1051,13 +1054,14 @@ public abstract class PlotArea {
} else { } else {
split = key.split(":"); split = key.split(":");
} }
final PlotFlag<?, ?> flagInstance = GlobalFlagContainer.getInstance().getFlagFromString(split[0]); final PlotFlag<?, ?> flagInstance =
GlobalFlagContainer.getInstance().getFlagFromString(split[0]);
if (flagInstance != null) { if (flagInstance != null) {
try { try {
flags.add(flagInstance.parse(split[1])); flags.add(flagInstance.parse(split[1]));
} catch (final FlagParseException e) { } catch (final FlagParseException e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + PlotSquared.log(Captions.PREFIX.getTranslated() + String.format(
String.format("§cFailed to parse default flag with key §6'%s'§c and value: §6'%s'§c." "§cFailed to parse default flag with key §6'%s'§c and value: §6'%s'§c."
+ " Reason: %s. This flag will not be added as a default flag.", + " Reason: %s. This flag will not be added as a default flag.",
e.getFlag().getName(), e.getValue(), e.getErrorMessage())); e.getFlag().getName(), e.getValue(), e.getErrorMessage()));
} }

View File

@ -60,8 +60,7 @@ public enum PlotAreaTerrainType {
return Optional.ofNullable(types.get(typeString.toLowerCase())); return Optional.ofNullable(types.get(typeString.toLowerCase()));
} }
@Deprecated @Deprecated public static Optional<PlotAreaTerrainType> fromLegacyInt(int typeId) {
public static Optional<PlotAreaTerrainType> fromLegacyInt(int typeId) {
if (typeId < 0 || typeId >= values().length) { if (typeId < 0 || typeId >= values().length) {
return Optional.empty(); return Optional.empty();
} }

View File

@ -32,9 +32,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
public enum PlotAreaType { public enum PlotAreaType {
NORMAL, NORMAL, AUGMENTED, PARTIAL;
AUGMENTED,
PARTIAL;
private static final Map<String, PlotAreaType> types = Stream.of(values()) private static final Map<String, PlotAreaType> types = Stream.of(values())
.collect(Collectors.toMap(e -> e.toString().toLowerCase(), Function.identity())); .collect(Collectors.toMap(e -> e.toString().toLowerCase(), Function.identity()));
@ -43,8 +41,7 @@ public enum PlotAreaType {
return Optional.ofNullable(types.get(typeName.toLowerCase())); return Optional.ofNullable(types.get(typeName.toLowerCase()));
} }
@Deprecated @Deprecated public static Optional<PlotAreaType> fromLegacyInt(int typeId) {
public static Optional<PlotAreaType> fromLegacyInt(int typeId) {
if (typeId < 0 || typeId >= values().length) { if (typeId < 0 || typeId >= values().length) {
return Optional.empty(); return Optional.empty();
} }

View File

@ -25,9 +25,9 @@
*/ */
package com.plotsquared.core.plot; package com.plotsquared.core.plot;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.location.BlockLoc; import com.plotsquared.core.location.BlockLoc;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.RegionUtil; import com.plotsquared.core.util.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
@ -154,7 +154,8 @@ public class PlotCluster {
public void getHome(Consumer<Location> result) { public void getHome(Consumer<Location> result) {
BlockLoc home = this.settings.getPosition(); BlockLoc home = this.settings.getPosition();
Consumer<Location> locationConsumer = toReturn -> { Consumer<Location> locationConsumer = toReturn -> {
MainUtil.getHighestBlock(this.area.getWorldName(), toReturn.getX(), toReturn.getZ(), max -> { MainUtil.getHighestBlock(this.area.getWorldName(), toReturn.getX(), toReturn.getZ(),
max -> {
if (max > toReturn.getY()) { if (max > toReturn.getY()) {
toReturn.setY(1 + max); toReturn.setY(1 + max);
} }

View File

@ -31,10 +31,8 @@ import org.jetbrains.annotations.Nullable;
public class PlotId { public class PlotId {
@Deprecated @Deprecated public int x;
public int x; @Deprecated public int y;
@Deprecated
public int y;
private int hash; private int hash;
/** /**

View File

@ -25,9 +25,9 @@
*/ */
package com.plotsquared.core.plot; package com.plotsquared.core.plot;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.command.Template; import com.plotsquared.core.command.Template;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.util.FileBytes; import com.plotsquared.core.util.FileBytes;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;

View File

@ -25,10 +25,10 @@
*/ */
package com.plotsquared.core.plot; package com.plotsquared.core.plot;
import com.google.common.collect.ImmutableList;
import com.plotsquared.core.location.BlockLoc; import com.plotsquared.core.location.BlockLoc;
import com.plotsquared.core.location.Direction; import com.plotsquared.core.location.Direction;
import com.plotsquared.core.plot.comment.PlotComment; import com.plotsquared.core.plot.comment.PlotComment;
import com.google.common.collect.ImmutableList;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

View File

@ -26,10 +26,10 @@
package com.plotsquared.core.plot.comment; package com.plotsquared.core.plot.comment;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal;
import java.util.List; import java.util.List;

View File

@ -25,13 +25,13 @@
*/ */
package com.plotsquared.core.plot.comment; package com.plotsquared.core.plot.comment;
import com.google.common.annotations.Beta;
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.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
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.google.common.annotations.Beta;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;

View File

@ -32,21 +32,21 @@ import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.PlotFlagAddEvent; import com.plotsquared.core.events.PlotFlagAddEvent;
import com.plotsquared.core.events.PlotUnlinkEvent; import com.plotsquared.core.events.PlotUnlinkEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.player.OfflinePlotPlayer;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaType;
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.flag.implementations.KeepFlag; import com.plotsquared.core.plot.flag.implementations.KeepFlag;
import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.player.OfflinePlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.message.PlotMessage; import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
@ -337,8 +337,10 @@ public class ExpireManager {
} }
}, () -> { }, () -> {
PlotFlag<?, ?> plotFlag = GlobalFlagContainer.getInstance() PlotFlag<?, ?> plotFlag = GlobalFlagContainer.getInstance()
.getFlag(AnalysisFlag.class).createFlagInstance(changed.asList()); .getFlag(AnalysisFlag.class)
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, newPlot); .createFlagInstance(changed.asList());
PlotFlagAddEvent event =
new PlotFlagAddEvent(plotFlag, newPlot);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
return; return;
} }

View File

@ -51,8 +51,8 @@ public class ExpiryTask {
} }
public boolean allowsArea(PlotArea area) { public boolean allowsArea(PlotArea area) {
return settings.WORLDS.contains(area.toString()) || settings.WORLDS.contains(area.getWorldName()) return settings.WORLDS.contains(area.toString()) || settings.WORLDS
|| settings.WORLDS.contains("*"); .contains(area.getWorldName()) || settings.WORLDS.contains("*");
} }
public boolean applies(PlotArea area) { public boolean applies(PlotArea area) {

View File

@ -27,11 +27,11 @@ package com.plotsquared.core.plot.expiration;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
import com.plotsquared.core.generator.HybridUtils; import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import java.lang.reflect.Array; import java.lang.reflect.Array;

View File

@ -26,10 +26,10 @@
package com.plotsquared.core.plot.flag.implementations; package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.FlagParseException; import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@ -26,9 +26,9 @@
package com.plotsquared.core.plot.flag.implementations; package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.InternalFlag; import com.plotsquared.core.plot.flag.InternalFlag;
import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.Plot;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class DoneFlag extends PlotFlag<String, DoneFlag> implements InternalFlag { public class DoneFlag extends PlotFlag<String, DoneFlag> implements InternalFlag {

View File

@ -88,9 +88,7 @@ public class FlyFlag extends PlotFlag<FlyFlag.FlyStatus, FlyFlag> {
} }
public enum FlyStatus { public enum FlyStatus {
ENABLED, ENABLED, DISABLED, DEFAULT
DISABLED,
DEFAULT
} }
} }

View File

@ -51,8 +51,8 @@ public class MusicFlag extends PlotFlag<ItemType, MusicFlag> {
input = "music_disc_" + input; input = "music_disc_" + input;
} }
final ItemType itemType = ItemUtil.get(input); final ItemType itemType = ItemUtil.get(input);
if (itemType != null && itemType.getId() != null && if (itemType != null && itemType.getId() != null && (itemType == ItemTypes.AIR || itemType
(itemType == ItemTypes.AIR || itemType.getId().contains("music_disc_"))) { .getId().contains("music_disc_"))) {
return new MusicFlag(ItemUtil.get(input)); return new MusicFlag(ItemUtil.get(input));
} else { } else {
throw new FlagParseException(this, input, Captions.FLAG_ERROR_MUSIC); throw new FlagParseException(this, input, Captions.FLAG_ERROR_MUSIC);

View File

@ -83,9 +83,7 @@ public class TitlesFlag extends PlotFlag<TitlesFlag.TitlesFlagValue, TitlesFlag>
} }
public enum TitlesFlagValue { public enum TitlesFlagValue {
NONE, NONE, TRUE, FALSE;
TRUE,
FALSE;
@Nullable public static TitlesFlagValue fromString(final String value) { @Nullable public static TitlesFlagValue fromString(final String value) {
if (value.equalsIgnoreCase("true")) { if (value.equalsIgnoreCase("true")) {

View File

@ -26,8 +26,8 @@
package com.plotsquared.core.plot.flag.implementations; package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.PlotWeather; import com.plotsquared.core.plot.PlotWeather;
import com.plotsquared.core.plot.flag.PlotFlag;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Arrays; import java.util.Arrays;
@ -35,12 +35,9 @@ import java.util.Collection;
public class WeatherFlag extends PlotFlag<PlotWeather, WeatherFlag> { public class WeatherFlag extends PlotFlag<PlotWeather, WeatherFlag> {
public static final WeatherFlag PLOT_WEATHER_FLAG_RAIN = public static final WeatherFlag PLOT_WEATHER_FLAG_RAIN = new WeatherFlag(PlotWeather.RAIN);
new WeatherFlag(PlotWeather.RAIN); public static final WeatherFlag PLOT_WEATHER_FLAG_CLEAR = new WeatherFlag(PlotWeather.CLEAR);
public static final WeatherFlag PLOT_WEATHER_FLAG_CLEAR = public static final WeatherFlag PLOT_WEATHER_FLAG_OFF = new WeatherFlag(PlotWeather.RESET);
new WeatherFlag(PlotWeather.CLEAR);
public static final WeatherFlag PLOT_WEATHER_FLAG_OFF =
new WeatherFlag(PlotWeather.RESET);
/** /**
* Construct a new flag instance. * Construct a new flag instance.
@ -92,7 +89,8 @@ public class WeatherFlag extends PlotFlag<PlotWeather, WeatherFlag> {
} }
@Override public Collection<String> getTabCompletions() { @Override public Collection<String> getTabCompletions() {
return Arrays.asList("rain", "storm", "on", "lightning", "thunder", "clear", "off", "sun", "reset"); return Arrays
.asList("rain", "storm", "on", "lightning", "thunder", "clear", "off", "sun", "reset");
} }
} }

View File

@ -58,8 +58,11 @@ public abstract class BlockTypeListFlag<F extends ListFlag<BlockTypeWrapper, F>>
if (blockState == null) { if (blockState == null) {
// If it's not a block state, we assume it's a block category // If it's not a block state, we assume it's a block category
final BlockCategory blockCategory; final BlockCategory blockCategory;
if (!blockString.startsWith("#") || (blockCategory = BlockCategory.REGISTRY.get(blockString.substring(1))) == null) { if (!blockString.startsWith("#")
throw new FlagParseException(this, blockString, Captions.FLAG_ERROR_INVALID_BLOCK); || (blockCategory = BlockCategory.REGISTRY.get(blockString.substring(1)))
== null) {
throw new FlagParseException(this, blockString,
Captions.FLAG_ERROR_INVALID_BLOCK);
} else { } else {
blockTypeWrapper = BlockTypeWrapper.get(blockCategory); blockTypeWrapper = BlockTypeWrapper.get(blockCategory);
} }
@ -79,9 +82,11 @@ public abstract class BlockTypeListFlag<F extends ListFlag<BlockTypeWrapper, F>>
@Override public Collection<String> getTabCompletions() { @Override public Collection<String> getTabCompletions() {
final Collection<String> tabCompletions = new ArrayList<>(); final Collection<String> tabCompletions = new ArrayList<>();
tabCompletions.addAll(BlockType.REGISTRY.keySet().stream().map(val -> val.replace("minecraft:", "")) tabCompletions.addAll(
BlockType.REGISTRY.keySet().stream().map(val -> val.replace("minecraft:", ""))
.collect(Collectors.toList())); .collect(Collectors.toList()));
tabCompletions.addAll(BlockCategory.REGISTRY.keySet().stream().map(val -> "#" + val.replace("minecraft:", "")) tabCompletions.addAll(
BlockCategory.REGISTRY.keySet().stream().map(val -> "#" + val.replace("minecraft:", ""))
.collect(Collectors.toList())); .collect(Collectors.toList()));
return tabCompletions; return tabCompletions;
} }

View File

@ -40,7 +40,8 @@ import java.util.Map;
* Container that class either contains a {@link BlockType} * Container that class either contains a {@link BlockType}
* or a {@link BlockCategory} * or a {@link BlockCategory}
*/ */
@EqualsAndHashCode public class BlockTypeWrapper { @EqualsAndHashCode
public class BlockTypeWrapper {
@Nullable @Getter private final BlockType blockType; @Nullable @Getter private final BlockType blockType;
@Nullable @Getter private final BlockCategory blockCategory; @Nullable @Getter private final BlockCategory blockCategory;
@ -63,7 +64,7 @@ import java.util.Map;
} else { } else {
return key; return key;
} }
} else if(this.blockCategory != null) { } else if (this.blockCategory != null) {
final String key = this.blockCategory.toString(); final String key = this.blockCategory.toString();
if (key.startsWith("minecraft:")) { if (key.startsWith("minecraft:")) {
return '#' + key.substring(10); return '#' + key.substring(10);

View File

@ -26,8 +26,8 @@
package com.plotsquared.core.plot.message; package com.plotsquared.core.plot.message;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.ChatManager; import com.plotsquared.core.util.ChatManager;
public class PlotMessage { public class PlotMessage {

View File

@ -25,10 +25,10 @@
*/ */
package com.plotsquared.core.plot.world; package com.plotsquared.core.plot.world;
import com.plotsquared.core.collection.QuadMap;
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.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.collection.QuadMap;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -37,7 +37,7 @@ public interface PlotAreaManager {
* method assumes that the caller already knows that * method assumes that the caller already knows that
* the location belongs to a plot area, in which * the location belongs to a plot area, in which
* case it will return the appropriate plot area. * case it will return the appropriate plot area.
* * <p>
* If the location does not belong to a plot area, * If the location does not belong to a plot area,
* it may still return an area. * it may still return an area.
* *

View File

@ -25,12 +25,12 @@
*/ */
package com.plotsquared.core.plot.world; package com.plotsquared.core.plot.world;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.location.BlockLoc; import com.plotsquared.core.location.BlockLoc;
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.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.flag.PlotFlag;
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 org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -25,25 +25,25 @@
*/ */
package com.plotsquared.core.plot.world; package com.plotsquared.core.plot.world;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.generator.SingleWorldGenerator; import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.plot.flag.FlagContainer; import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.generator.GridPlotWorld; import com.plotsquared.core.generator.GridPlotWorld;
import com.plotsquared.core.generator.SingleWorldGenerator;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.location.PlotLoc;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
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.location.PlotLoc;
import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.plot.PlotSettings; import com.plotsquared.core.plot.PlotSettings;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.plot.SetupObject; import com.plotsquared.core.plot.SetupObject;
import com.plotsquared.core.plot.flag.FlagContainer;
import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.task.TaskManager;
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.TaskManager;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -197,8 +197,9 @@ public class SinglePlotArea extends GridPlotWorld {
PlotSettings s = p.getSettings(); PlotSettings s = p.getSettings();
final FlagContainer oldContainer = p.getFlagContainer(); final FlagContainer oldContainer = p.getFlagContainer();
p = new SinglePlot(p.getId(), p.getOwnerAbs(), p.getTrusted(), p.getMembers(), p.getDenied(), p = new SinglePlot(p.getId(), p.getOwnerAbs(), p.getTrusted(), p.getMembers(),
s.getAlias(), s.getPosition(), null, this, s.getMerged(), p.getTimestamp(), p.temp); p.getDenied(), s.getAlias(), s.getPosition(), null, this, s.getMerged(),
p.getTimestamp(), p.temp);
p.getFlagContainer().addAll(oldContainer); p.getFlagContainer().addAll(oldContainer);
return p; return p;

View File

@ -25,10 +25,10 @@
*/ */
package com.plotsquared.core.plot.world; package com.plotsquared.core.plot.world;
import com.plotsquared.core.collection.ArrayUtil;
import com.plotsquared.core.generator.SingleWorldGenerator; import com.plotsquared.core.generator.SingleWorldGenerator;
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.collection.ArrayUtil;
import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.SetupUtils;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -27,11 +27,11 @@ package com.plotsquared.core.queue;
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.util.PatternUtil;
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.uuid.UUIDHandler;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.PatternUtil; import com.plotsquared.core.util.uuid.UUIDHandler;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
@ -131,7 +131,8 @@ public abstract class LocalBlockQueue {
.equals(loc)) { .equals(loc)) {
continue; continue;
} }
pLoc.setY(WorldUtil.IMP.getHighestBlockSynchronous(getWorld(), pLoc.getX(), pLoc.getZ())); pLoc.setY(
WorldUtil.IMP.getHighestBlockSynchronous(getWorld(), pLoc.getX(), pLoc.getZ()));
pp.teleport(pLoc); pp.teleport(pLoc);
} }
} }

View File

@ -40,9 +40,8 @@ public class LocationOffsetDelegateLocalBlockQueue extends DelegateLocalBlockQue
private final int blockX; private final int blockX;
private final int blockZ; private final int blockZ;
public LocationOffsetDelegateLocalBlockQueue(final boolean[][] canPlace, public LocationOffsetDelegateLocalBlockQueue(final boolean[][] canPlace, final int blockX,
final int blockX, final int blockZ, final int blockZ, @Nullable LocalBlockQueue parent) {
@Nullable LocalBlockQueue parent) {
super(parent); super(parent);
this.canPlace = canPlace; this.canPlace = canPlace;
this.blockX = blockX; this.blockX = blockX;
@ -62,8 +61,10 @@ public class LocationOffsetDelegateLocalBlockQueue extends DelegateLocalBlockQue
return super.setBlock(x, y, z, id); return super.setBlock(x, y, z, id);
} }
} catch (final Exception e) { } catch (final Exception e) {
PlotSquared.debug(String.format("Failed to set block at: %d;%d;%d (to = %s) with offset %d;%d." PlotSquared.debug(String.format(
+ " Translated to: %d;%d", x, y, z, id, blockX, blockZ, x - blockX, z - blockZ)); "Failed to set block at: %d;%d;%d (to = %s) with offset %d;%d."
+ " Translated to: %d;%d", x, y, z, id, blockX, blockZ, x - blockX,
z - blockZ));
throw e; throw e;
} }
return false; return false;

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.util; package com.plotsquared.core.util;
import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.message.PlotMessage;
public abstract class ChatManager<T> { public abstract class ChatManager<T> {
public static ChatManager<?> manager; public static ChatManager<?> manager;

View File

@ -28,10 +28,10 @@ package com.plotsquared.core.util;
import com.plotsquared.core.PlotSquared; 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.Plot;
import com.plotsquared.core.util.task.RunnableVal;
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;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;

View File

@ -26,9 +26,9 @@
package com.plotsquared.core.util; package com.plotsquared.core.util;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.Plot;
import lombok.NonNull; import lombok.NonNull;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
@ -42,7 +42,8 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
/** /**
* Entity related general utility methods * Entity related general utility methods
*/ */
@UtilityClass public final class EntityUtil { @UtilityClass
public final class EntityUtil {
private static int capNumeral(@NonNull final String flagName) { private static int capNumeral(@NonNull final String flagName) {
int i; int i;

View File

@ -25,7 +25,11 @@
*/ */
package com.plotsquared.core.util; package com.plotsquared.core.util;
import com.google.common.eventbus.EventBus;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.events.PlayerAutoPlotEvent; import com.plotsquared.core.events.PlayerAutoPlotEvent;
import com.plotsquared.core.events.PlayerClaimPlotEvent; import com.plotsquared.core.events.PlayerClaimPlotEvent;
import com.plotsquared.core.events.PlayerEnterPlotEvent; import com.plotsquared.core.events.PlayerEnterPlotEvent;
@ -46,10 +50,15 @@ import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.PlotMergeEvent; import com.plotsquared.core.events.PlotMergeEvent;
import com.plotsquared.core.events.PlotRateEvent; import com.plotsquared.core.events.PlotRateEvent;
import com.plotsquared.core.events.PlotUnlinkEvent; import com.plotsquared.core.events.PlotUnlinkEvent;
import com.plotsquared.core.listener.PlayerBlockEventType;
import com.plotsquared.core.location.Direction;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.Rating;
import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.DeviceInteractFlag; import com.plotsquared.core.plot.flag.implementations.DeviceInteractFlag;
import com.plotsquared.core.plot.flag.implementations.MiscPlaceFlag; import com.plotsquared.core.plot.flag.implementations.MiscPlaceFlag;
@ -58,17 +67,8 @@ import com.plotsquared.core.plot.flag.implementations.PlaceFlag;
import com.plotsquared.core.plot.flag.implementations.UseFlag; import com.plotsquared.core.plot.flag.implementations.UseFlag;
import com.plotsquared.core.plot.flag.implementations.VehiclePlaceFlag; import com.plotsquared.core.plot.flag.implementations.VehiclePlaceFlag;
import com.plotsquared.core.plot.flag.types.BlockTypeWrapper; import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
import com.plotsquared.core.listener.PlayerBlockEventType;
import com.plotsquared.core.location.Direction;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.Rating;
import com.plotsquared.core.plot.world.SinglePlotArea; import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.google.common.eventbus.EventBus;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
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;
@ -241,7 +241,8 @@ public class EventDispatcher {
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (Settings.Teleport.ON_LOGIN && plot != null && !(plot if (Settings.Teleport.ON_LOGIN && plot != null && !(plot
.getArea() instanceof SinglePlotArea)) { .getArea() instanceof SinglePlotArea)) {
TaskManager.runTask(() -> plot.teleportPlayer(player, result -> {})); TaskManager.runTask(() -> plot.teleportPlayer(player, result -> {
}));
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
CaptionUtility.format(player, Captions.TELEPORTED_TO_ROAD.getTranslated()) CaptionUtility.format(player, Captions.TELEPORTED_TO_ROAD.getTranslated())
+ " (on-login) " + "(" + plot.getId().x + ";" + plot.getId().y + ")"); + " (on-login) " + "(" + plot.getId().x + ";" + plot.getId().y + ")");
@ -251,7 +252,8 @@ public class EventDispatcher {
public void doRespawnTask(final PlotPlayer player) { public void doRespawnTask(final PlotPlayer player) {
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (Settings.Teleport.ON_DEATH && plot != null) { if (Settings.Teleport.ON_DEATH && plot != null) {
TaskManager.runTask(() -> plot.teleportPlayer(player, result -> {})); TaskManager.runTask(() -> plot.teleportPlayer(player, result -> {
}));
MainUtil.sendMessage(player, Captions.TELEPORTED_TO_ROAD); MainUtil.sendMessage(player, Captions.TELEPORTED_TO_ROAD);
} }
} }

View File

@ -25,9 +25,9 @@
*/ */
package com.plotsquared.core.util; package com.plotsquared.core.util;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotInventory; import com.plotsquared.core.plot.PlotInventory;
import com.plotsquared.core.plot.PlotItemStack; import com.plotsquared.core.plot.PlotItemStack;
import com.plotsquared.core.player.PlotPlayer;
/** /**
* This class is only used by internal functions, for most cases use the PlotInventory class * This class is only used by internal functions, for most cases use the PlotInventory class

View File

@ -25,12 +25,12 @@
*/ */
package com.plotsquared.core.util; package com.plotsquared.core.util;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.BlockBucket; import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.player.ConsolePlayer; import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.plot.BlockBucket;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import lombok.NonNull; import lombok.NonNull;
@ -42,7 +42,8 @@ import java.util.Map;
/** /**
* Converts legacy configurations into the new (BlockBucket) format * Converts legacy configurations into the new (BlockBucket) format
*/ */
@SuppressWarnings("unused") public final class LegacyConverter { @SuppressWarnings("unused")
public final class LegacyConverter {
public static final String CONFIGURATION_VERSION = "post_flattening"; public static final String CONFIGURATION_VERSION = "post_flattening";
private static final HashMap<String, ConfigurationType> TYPE_MAP = new HashMap<>(); private static final HashMap<String, ConfigurationType> TYPE_MAP = new HashMap<>();
@ -109,7 +110,8 @@ import java.util.Map;
final BlockBucket bucket = this.blockToBucket(block); final BlockBucket bucket = this.blockToBucket(block);
this.setString(section, key, bucket); this.setString(section, key, bucket);
PlotSquared.log(CaptionUtility PlotSquared.log(CaptionUtility
.format(ConsolePlayer.getConsole(), Captions.LEGACY_CONFIG_REPLACED.getTranslated(), block, bucket.toString())); .format(ConsolePlayer.getConsole(), Captions.LEGACY_CONFIG_REPLACED.getTranslated(),
block, bucket.toString()));
} }
private void convertBlockList(@NonNull final ConfigurationSection section, private void convertBlockList(@NonNull final ConfigurationSection section,
@ -118,8 +120,8 @@ import java.util.Map;
final BlockBucket bucket = this.blockListToBucket(blocks); final BlockBucket bucket = this.blockListToBucket(blocks);
this.setString(section, key, bucket); this.setString(section, key, bucket);
PlotSquared.log(CaptionUtility PlotSquared.log(CaptionUtility
.format(ConsolePlayer.getConsole(), Captions.LEGACY_CONFIG_REPLACED.getTranslated(), plotBlockArrayString(blocks), .format(ConsolePlayer.getConsole(), Captions.LEGACY_CONFIG_REPLACED.getTranslated(),
bucket.toString())); plotBlockArrayString(blocks), bucket.toString()));
} }
private String plotBlockArrayString(@NonNull final BlockState[] blocks) { private String plotBlockArrayString(@NonNull final BlockState[] blocks) {

View File

@ -26,28 +26,27 @@
package com.plotsquared.core.util; package com.plotsquared.core.util;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.util.net.AbstractDelegateOutputStream;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.command.Like; import com.plotsquared.core.command.Like;
import com.plotsquared.core.configuration.Caption; import com.plotsquared.core.configuration.Caption;
import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.DescriptionFlag;
import com.plotsquared.core.plot.flag.implementations.ServerPlotFlag;
import com.plotsquared.core.plot.flag.types.DoubleFlag;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.ConsolePlayer;
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.PlotAreaTerrainType; 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.expiration.ExpireManager;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.DescriptionFlag;
import com.plotsquared.core.plot.flag.implementations.ServerPlotFlag;
import com.plotsquared.core.plot.flag.types.DoubleFlag;
import com.plotsquared.core.util.net.AbstractDelegateOutputStream;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
@ -59,11 +58,9 @@ import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.Reader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
@ -97,6 +94,7 @@ import java.util.stream.IntStream;
public class MainUtil { public class MainUtil {
private static final DecimalFormat FLAG_DECIMAL_FORMAT = new DecimalFormat("0"); private static final DecimalFormat FLAG_DECIMAL_FORMAT = new DecimalFormat("0");
static { static {
FLAG_DECIMAL_FORMAT.setMaximumFractionDigits(340); FLAG_DECIMAL_FORMAT.setMaximumFractionDigits(340);
} }
@ -252,9 +250,11 @@ public class MainUtil {
*/ */
public static boolean resetBiome(PlotArea area, Location pos1, Location pos2) { public static boolean resetBiome(PlotArea area, Location pos1, Location pos2) {
BiomeType biome = area.getPlotBiome(); BiomeType biome = area.getPlotBiome();
if (!Objects.equals(WorldUtil.IMP.getBiomeSynchronous(area.getWorldName(), (pos1.getX() + pos2.getX()) / 2, if (!Objects.equals(WorldUtil.IMP
.getBiomeSynchronous(area.getWorldName(), (pos1.getX() + pos2.getX()) / 2,
(pos1.getZ() + pos2.getZ()) / 2), biome)) { (pos1.getZ() + pos2.getZ()) / 2), biome)) {
MainUtil.setBiome(area.getWorldName(), pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(), MainUtil
.setBiome(area.getWorldName(), pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(),
biome); biome);
return true; return true;
} }
@ -656,8 +656,8 @@ public class MainUtil {
.format(null, (prefix ? Captions.PREFIX.getTranslated() : "") + msg); .format(null, (prefix ? Captions.PREFIX.getTranslated() : "") + msg);
PlotSquared.log(message); PlotSquared.log(message);
} else { } else {
player.sendMessage( player.sendMessage(CaptionUtility.format(player,
CaptionUtility.format(player, (prefix ? Captions.PREFIX.getTranslated() : "") + Captions.color(msg))); (prefix ? Captions.PREFIX.getTranslated() : "") + Captions.color(msg)));
} }
} }
return true; return true;
@ -776,8 +776,8 @@ public class MainUtil {
* @param full * @param full
* @param whenDone * @param whenDone
*/ */
public static void format(final String iInfo, final Plot plot, PlotPlayer player, final boolean full, public static void format(final String iInfo, final Plot plot, PlotPlayer player,
final RunnableVal<String> whenDone) { final boolean full, final RunnableVal<String> whenDone) {
int num = plot.getConnectedPlots().size(); int num = plot.getConnectedPlots().size();
String alias = !plot.getAlias().isEmpty() ? plot.getAlias() : Captions.NONE.getTranslated(); String alias = !plot.getAlias().isEmpty() ? plot.getAlias() : Captions.NONE.getTranslated();
Location bot = plot.getCorners()[0]; Location bot = plot.getCorners()[0];
@ -820,16 +820,19 @@ public class MainUtil {
} else { } else {
value = flag.toString(); value = flag.toString();
} }
flags.append(prefix).append(CaptionUtility.format(player, Captions.PLOT_FLAG_LIST.getTranslated(), flags.append(prefix).append(CaptionUtility
flag.getName(), CaptionUtility.formatRaw(player, value.toString(), ""))); .format(player, Captions.PLOT_FLAG_LIST.getTranslated(), flag.getName(),
CaptionUtility.formatRaw(player, value.toString(), "")));
prefix = ", "; prefix = ", ";
} }
} }
boolean build = plot.isAdded(player.getUUID()); boolean build = plot.isAdded(player.getUUID());
String owner = plot.getOwners().isEmpty() ? "unowned" : getPlayerList(plot.getOwners()); String owner = plot.getOwners().isEmpty() ? "unowned" : getPlayerList(plot.getOwners());
if (plot.getArea() != null) { if (plot.getArea() != null) {
info = info.replace("%area%", plot.getArea().getWorldName() + info = info.replace("%area%",
(plot.getArea().getId() == null ? "" : "(" + plot.getArea().getId() + ")")); plot.getArea().getWorldName() + (plot.getArea().getId() == null ?
"" :
"(" + plot.getArea().getId() + ")"));
} else { } else {
info = info.replace("%area%", Captions.NONE.getTranslated()); info = info.replace("%area%", Captions.NONE.getTranslated());
} }
@ -941,8 +944,7 @@ public class MainUtil {
} }
private static <T> T getValueFromConfig(ConfigurationSection config, String path, private static <T> T getValueFromConfig(ConfigurationSection config, String path,
IntFunction<Optional<T>> intParser, IntFunction<Optional<T>> intParser, Function<String, Optional<T>> textualParser,
Function<String, Optional<T>> textualParser,
Supplier<T> defaultValue) { Supplier<T> defaultValue) {
String value = config.getString(path); String value = config.getString(path);
if (value == null) { if (value == null) {
@ -955,16 +957,12 @@ public class MainUtil {
} }
public static PlotAreaType getType(ConfigurationSection config) { public static PlotAreaType getType(ConfigurationSection config) {
return getValueFromConfig(config, "generator.type", return getValueFromConfig(config, "generator.type", PlotAreaType::fromLegacyInt,
PlotAreaType::fromLegacyInt, PlotAreaType::fromString, () -> PlotAreaType.NORMAL);
PlotAreaType::fromString,
() -> PlotAreaType.NORMAL);
} }
public static PlotAreaTerrainType getTerrain(ConfigurationSection config) { public static PlotAreaTerrainType getTerrain(ConfigurationSection config) {
return getValueFromConfig(config, "generator.terrain", return getValueFromConfig(config, "generator.terrain", PlotAreaTerrainType::fromLegacyInt,
PlotAreaTerrainType::fromLegacyInt, PlotAreaTerrainType::fromString, () -> PlotAreaTerrainType.NONE);
PlotAreaTerrainType::fromString,
() -> PlotAreaTerrainType.NONE);
} }
} }

View File

@ -25,10 +25,10 @@
*/ */
package com.plotsquared.core.util; package com.plotsquared.core.util;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.ListeningExecutorService;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;

View File

@ -25,10 +25,10 @@
*/ */
package com.plotsquared.core.util; package com.plotsquared.core.util;
import com.google.common.base.Preconditions;
import com.plotsquared.core.command.Command; import com.plotsquared.core.command.Command;
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.google.common.base.Preconditions;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
@ -47,10 +47,8 @@ public class PatternUtil {
public static BaseBlock apply(@NotNull Pattern pattern, int x, int y, int z) { public static BaseBlock apply(@NotNull Pattern pattern, int x, int y, int z) {
Preconditions.checkNotNull(pattern, "Pattern may not be null"); Preconditions.checkNotNull(pattern, "Pattern may not be null");
if (pattern instanceof BlockPattern if (pattern instanceof BlockPattern || pattern instanceof RandomPattern
|| pattern instanceof RandomPattern || pattern instanceof BlockState || pattern instanceof BlockType
|| pattern instanceof BlockState
|| pattern instanceof BlockType
|| pattern instanceof BaseBlock) { || pattern instanceof BaseBlock) {
return pattern.apply(BlockVector3.ZERO); return pattern.apply(BlockVector3.ZERO);
} }

View File

@ -30,7 +30,8 @@ import lombok.RequiredArgsConstructor;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@RequiredArgsConstructor public class RuntimeExceptionRunnableVal<T> extends RunnableVal<RuntimeException> { @RequiredArgsConstructor
public class RuntimeExceptionRunnableVal<T> extends RunnableVal<RuntimeException> {
private final RunnableVal<T> function; private final RunnableVal<T> function;
private final AtomicBoolean running; private final AtomicBoolean running;

View File

@ -31,11 +31,11 @@ import com.plotsquared.core.generator.ClassicPlotWorld;
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.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.util.uuid.UUIDHandler;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.plot.schematic.Schematic; import com.plotsquared.core.plot.schematic.Schematic;
import com.plotsquared.core.queue.LocalBlockQueue; import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.jnbt.NBTOutputStream;
@ -205,7 +205,8 @@ public abstract class SchematicHandler {
if (pw instanceof ClassicPlotWorld) { if (pw instanceof ClassicPlotWorld) {
y_offset_actual = yOffset + ((ClassicPlotWorld) pw).PLOT_HEIGHT; y_offset_actual = yOffset + ((ClassicPlotWorld) pw).PLOT_HEIGHT;
} else { } else {
y_offset_actual = yOffset + 1 + WorldUtil.IMP.getHighestBlockSynchronous(plot.getWorldName(), y_offset_actual = yOffset + 1 + WorldUtil.IMP
.getHighestBlockSynchronous(plot.getWorldName(),
region.getMinimumPoint().getX() + 1, region.getMinimumPoint().getX() + 1,
region.getMinimumPoint().getZ() + 1); region.getMinimumPoint().getZ() + 1);
} }

View File

@ -27,12 +27,12 @@ package com.plotsquared.core.util;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.flag.implementations.NoWorldeditFlag;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
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.player.PlotPlayer; import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.flag.implementations.NoWorldeditFlag;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;

View File

@ -27,8 +27,8 @@ package com.plotsquared.core.util;
import com.plotsquared.core.PlotSquared; 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.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
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 com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.IntTag;
@ -70,8 +70,7 @@ public abstract class WorldUtil {
/** /**
* @deprecated May result in synchronous chunk loading * @deprecated May result in synchronous chunk loading
*/ */
@Deprecated @Deprecated public abstract String[] getSignSynchronous(Location location);
public abstract String[] getSignSynchronous(Location location);
public abstract Location getSpawn(String world); public abstract Location getSpawn(String world);
@ -90,24 +89,21 @@ public abstract class WorldUtil {
/** /**
* @deprecated May result in synchronous chunk loading * @deprecated May result in synchronous chunk loading
*/ */
@Deprecated @Deprecated public abstract BiomeType getBiomeSynchronous(String world, int x, int z);
public abstract BiomeType getBiomeSynchronous(String world, int x, int z);
public abstract void getBlock(Location location, Consumer<BlockState> result); public abstract void getBlock(Location location, Consumer<BlockState> result);
/** /**
* @deprecated May result in synchronous chunk loading * @deprecated May result in synchronous chunk loading
*/ */
@Deprecated @Deprecated public abstract BlockState getBlockSynchronous(Location location);
public abstract BlockState getBlockSynchronous(Location location);
public abstract void getHighestBlock(String world, int x, int z, final IntConsumer result); public abstract void getHighestBlock(String world, int x, int z, final IntConsumer result);
/** /**
* @deprecated May result in synchronous chunk loading * @deprecated May result in synchronous chunk loading
*/ */
@Deprecated @Deprecated public abstract int getHighestBlockSynchronous(String world, int x, int z);
public abstract int getHighestBlockSynchronous(String world, int x, int z);
public abstract void setSign(String world, int x, int y, int z, String[] lines); public abstract void setSign(String world, int x, int y, int z, String[] lines);
@ -115,7 +111,8 @@ public abstract class WorldUtil {
public abstract com.sk89q.worldedit.world.World getWeWorld(String world); public abstract com.sk89q.worldedit.world.World getWeWorld(String world);
public void upload(@NotNull final Plot plot, UUID uuid, String file, RunnableVal<URL> whenDone) { public void upload(@NotNull final Plot plot, UUID uuid, String file,
RunnableVal<URL> whenDone) {
plot.getHome(home -> MainUtil.upload(uuid, file, "zip", new RunnableVal<OutputStream>() { plot.getHome(home -> MainUtil.upload(uuid, file, "zip", new RunnableVal<OutputStream>() {
@Override public void run(OutputStream output) { @Override public void run(OutputStream output) {
try (final ZipOutputStream zos = new ZipOutputStream(output)) { try (final ZipOutputStream zos = new ZipOutputStream(output)) {

View File

@ -53,6 +53,7 @@ public class EntityCategories {
return entityCategory; return entityCategory;
} }
public static void init() {} public static void init() {
}
} }

View File

@ -38,7 +38,8 @@ import java.util.Set;
*/ */
public class EntityCategory extends Category<EntityType> implements Keyed { public class EntityCategory extends Category<EntityType> implements Keyed {
public static final NamespacedRegistry<EntityCategory> REGISTRY = new NamespacedRegistry<>("entity type"); public static final NamespacedRegistry<EntityCategory> REGISTRY =
new NamespacedRegistry<>("entity type");
private final String key; private final String key;

View File

@ -25,8 +25,8 @@
*/ */
package com.plotsquared.core.util.net; package com.plotsquared.core.util.net;
import com.plotsquared.core.PlotSquared;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.plotsquared.core.PlotSquared;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -44,7 +44,8 @@ import java.util.Locale;
/** /**
* Single class paster for the Incendo paste service * Single class paster for the Incendo paste service
*/ */
@SuppressWarnings({"unused", "WeakerAccess"}) public final class IncendoPaster { @SuppressWarnings({"unused", "WeakerAccess"})
public final class IncendoPaster {
/** /**
* Upload service URL * Upload service URL

View File

@ -32,14 +32,15 @@ import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.PlotMergeEvent; import com.plotsquared.core.events.PlotMergeEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.location.Direction; import com.plotsquared.core.location.Direction;
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.player.PlotPlayer;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import static com.plotsquared.core.util.MainUtil.sendMessage; import static com.plotsquared.core.util.MainUtil.sendMessage;
@RequiredArgsConstructor public final class AutoClaimFinishTask extends RunnableVal<Object> { @RequiredArgsConstructor
public final class AutoClaimFinishTask extends RunnableVal<Object> {
private final PlotPlayer player; private final PlotPlayer player;
private final Plot plot; private final Plot plot;
@ -62,8 +63,7 @@ import static com.plotsquared.core.util.MainUtil.sendMessage;
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
sendMessage(player, Captions.EVENT_DENIED, "Auto merge"); sendMessage(player, Captions.EVENT_DENIED, "Auto merge");
} else { } else {
plot.autoMerge(event.getDir(), event.getMax(), player.getUUID(), plot.autoMerge(event.getDir(), event.getMax(), player.getUUID(), true);
true);
} }
} }
} else { } else {

View File

@ -29,7 +29,8 @@ import lombok.RequiredArgsConstructor;
import java.util.Iterator; import java.util.Iterator;
@RequiredArgsConstructor public class ObjectTaskRunnable<T> implements Runnable { @RequiredArgsConstructor
public class ObjectTaskRunnable<T> implements Runnable {
private final Iterator<T> iterator; private final Iterator<T> iterator;
private final RunnableVal<T> task; private final RunnableVal<T> task;

View File

@ -131,8 +131,8 @@ public abstract class TaskManager {
return function.value; return function.value;
} }
final AtomicBoolean running = new AtomicBoolean(true); final AtomicBoolean running = new AtomicBoolean(true);
final RuntimeExceptionRunnableVal<T> final RuntimeExceptionRunnableVal<T> run =
run = new RuntimeExceptionRunnableVal<>(function, running); new RuntimeExceptionRunnableVal<>(function, running);
TaskManager.IMP.task(run); TaskManager.IMP.task(run);
try { try {
synchronized (function) { synchronized (function) {

View File

@ -25,14 +25,14 @@
*/ */
package com.plotsquared.core.util.uuid; package com.plotsquared.core.util.uuid;
import com.google.common.collect.BiMap;
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.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.player.OfflinePlotPlayer; import com.plotsquared.core.player.OfflinePlotPlayer;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.StringWrapper; import com.plotsquared.core.util.StringWrapper;
import com.google.common.collect.BiMap; import com.plotsquared.core.util.task.RunnableVal;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@ -25,20 +25,20 @@
*/ */
package com.plotsquared.core.util.uuid; package com.plotsquared.core.util.uuid;
import com.google.common.base.Charsets;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
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.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.player.OfflinePlotPlayer; import com.plotsquared.core.player.OfflinePlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.StringWrapper; import com.plotsquared.core.util.StringWrapper;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.google.common.base.Charsets;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;