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 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,
@ -106,8 +107,10 @@ public class BukkitChunkManager extends ChunkManager {
LocalBlockQueue queue1 = GlobalBlockQueue.IMP.getNewQueue(worldName1, 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 z = Math.max(r1.getMinimumPoint().getZ(), sz); z <= Math.min(r1.getMaximumPoint().getZ(), sz + 15); z++) {
for (int x = Math.max(r1.getMinimumPoint().getX(), sx);
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++) {
Block block1 = world1.getBlockAt(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.");
semaphore.acquire();
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);
chunks.add(loc);
}
@ -214,7 +218,7 @@ public class BukkitChunkManager extends ChunkManager {
if (doWhole) {
for (Entity entity : entities) {
org.bukkit.Location location = entity.getLocation();
PaperLib.getChunkAtAsync(location).thenAccept( chunk -> {
PaperLib.getChunkAtAsync(location).thenAccept(chunk -> {
if (chunks.contains(chunk)) {
int X = chunk.getX();
int Z = chunk.getZ();
@ -249,7 +253,8 @@ public class BukkitChunkManager extends ChunkManager {
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 int relX = newPos.getX() - pos1.getX();
final int relZ = newPos.getZ() - pos1.getZ();
@ -303,7 +308,8 @@ public class BukkitChunkManager extends ChunkManager {
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 String world = pos1.getWorld();
@ -341,7 +347,8 @@ public class BukkitChunkManager extends ChunkManager {
if (chunkObj == null) {
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) {
AugmentedUtils.bypass(ignoreAugment,
() -> queue.regenChunkSafe(chunk.getX(), chunk.getZ()));
@ -406,11 +413,11 @@ public class BukkitChunkManager extends ChunkManager {
if (checkX2 && checkZ2) {
map.saveRegion(bukkitWorldObj, xxt2, xxt, zzt2, zzt); //
}
CuboidRegion currentPlotClear =
RegionUtil.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
CuboidRegion currentPlotClear = RegionUtil
.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
map.saveEntitiesOut(chunkObj, currentPlotClear);
AugmentedUtils.bypass(ignoreAugment,
() -> setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() {
AugmentedUtils.bypass(ignoreAugment, () -> setChunkInPlotArea(null,
new RunnableVal<ScopedLocalBlockQueue>() {
@Override public void run(ScopedLocalBlockQueue value) {
Location min = value.getMin();
int bx = min.getX();
@ -420,12 +427,14 @@ public class BukkitChunkManager extends ChunkManager {
PlotLoc plotLoc = new PlotLoc(bx + x1, bz + z1);
BaseBlock[] ids = map.allBlocks.get(plotLoc);
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];
if (id != null) {
value.setBlock(x1, y, z1, id);
} 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);
@ -454,15 +463,17 @@ public class BukkitChunkManager extends ChunkManager {
return true;
}
@Override public CompletableFuture<?> loadChunk(String world, BlockVector2 chunkLoc, boolean force) {
return PaperLib.getChunkAtAsync(BukkitUtil.getWorld(world),chunkLoc.getX(), chunkLoc.getZ(), force);
@Override
public CompletableFuture<?> loadChunk(String world, BlockVector2 chunkLoc, boolean force) {
return PaperLib
.getChunkAtAsync(BukkitUtil.getWorld(world), chunkLoc.getX(), chunkLoc.getZ(), force);
}
@Override
public void unloadChunk(final String world, final BlockVector2 chunkLoc, final boolean save) {
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
TaskManager.runTask(
() -> BukkitUtil.getWorld(world).unloadChunk(chunkLoc.getX(), chunkLoc.getZ(), save));
TaskManager.runTask(() -> BukkitUtil.getWorld(world)
.unloadChunk(chunkLoc.getX(), chunkLoc.getZ(), save));
} else {
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) {
CuboidRegion region1 =
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());
final World world1 = Bukkit.getWorld(bot1.getWorld());
final World world2 = Bukkit.getWorld(bot2.getWorld());
checkNotNull(world1,"Critical error during swap.");
checkNotNull(world2,"Critical error during swap.");
checkNotNull(world1, "Critical error during swap.");
checkNotNull(world2, "Critical error during swap.");
int relX = bot2.getX() - bot1.getX();
int relZ = bot2.getZ() - bot1.getZ();
@ -525,13 +537,11 @@ public class BukkitChunkManager extends ChunkManager {
if (EntityCategories.PLAYER.contains(entityType)) {
return;
} else if (EntityCategories.PROJECTILE.contains(entityType) ||
EntityCategories.OTHER.contains(entityType) ||
EntityCategories.HANGING.contains(entityType)) {
} else if (EntityCategories.PROJECTILE.contains(entityType) || EntityCategories.OTHER
.contains(entityType) || EntityCategories.HANGING.contains(entityType)) {
count[CAP_MISC]++;
} else if (EntityCategories.ANIMAL.contains(entityType) ||
EntityCategories.VILLAGER.contains(entityType) ||
EntityCategories.TAMEABLE.contains(entityType)) {
} else if (EntityCategories.ANIMAL.contains(entityType) || EntityCategories.VILLAGER
.contains(entityType) || EntityCategories.TAMEABLE.contains(entityType)) {
count[CAP_MOB]++;
count[CAP_ANIMAL]++;
} else if (EntityCategories.VEHICLE.contains(entityType)) {

View File

@ -74,7 +74,8 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
if (args.length == 0) {
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) {
return null;
}

View File

@ -25,6 +25,7 @@
*/
package com.plotsquared.bukkit;
import com.plotsquared.bukkit.generator.BukkitHybridUtils;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
import com.plotsquared.bukkit.listener.ChunkListener;
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.placeholder.PlaceholderFormatter;
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.BukkitEconHandler;
import com.plotsquared.bukkit.generator.BukkitHybridUtils;
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
import com.plotsquared.bukkit.schematic.BukkitSchematicHandler;
import com.plotsquared.bukkit.util.BukkitSetupUtils;
import com.plotsquared.bukkit.util.BukkitTaskManager;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.SetGenCB;
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.FileUUIDHandler;
import com.plotsquared.bukkit.util.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.util.uuid.OfflineUUIDWrapper;
import com.plotsquared.bukkit.util.uuid.SQLUUIDHandler;
import com.plotsquared.core.configuration.*;
import com.plotsquared.core.IPlotMain;
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.HybridGen;
import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.generator.IndependentPlotGenerator;
import com.plotsquared.core.generator.SingleWorldGenerator;
import com.plotsquared.core.listener.PlotListener;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaTerrainType;
import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.SetupObject;
import com.plotsquared.core.plot.message.PlainChatManager;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
import com.plotsquared.core.generator.SingleWorldGenerator;
import com.plotsquared.core.queue.QueueProvider;
import com.plotsquared.core.util.ChatManager;
import com.plotsquared.core.util.ChunkManager;
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.SetupUtils;
import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler;
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.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
@ -123,7 +127,9 @@ import java.util.List;
import java.util.Map;
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;
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()) {
PlotSquared.log(Captions.PREFIX + "&6PlotSquared version licensed to Spigot user " + getUserID());
PlotSquared.log(Captions.PREFIX + "&6https://www.spigotmc.org/resources/" + getResourceID());
PlotSquared.log(
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 + "&6Thanks for supporting us :)");
} else {
@ -206,7 +214,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}
PlotSquared.log(Captions.PREFIX + "&6PlotSquared hooked into PlaceholderAPI");
} 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();
@ -409,8 +418,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
case MINECART_TNT:
case BOAT:
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
com.plotsquared.core.location.Location
location = BukkitUtil.getLocation(entity.getLocation());
com.plotsquared.core.location.Location location =
BukkitUtil.getLocation(entity.getLocation());
Plot plot = location.getPlot();
if (plot == null) {
if (location.isPlotArea()) {
@ -466,8 +475,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
PlotId originalPlotId = (PlotId) meta.get(0).value();
if (originalPlotId != null) {
com.plotsquared.core.location.Location
pLoc = BukkitUtil.getLocation(entity.getLocation());
com.plotsquared.core.location.Location pLoc =
BukkitUtil.getLocation(entity.getLocation());
PlotArea area = pLoc.getPlotArea();
if (area != null) {
PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
@ -485,14 +494,15 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}
} else {
//This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java)
com.plotsquared.core.location.Location
pLoc = BukkitUtil.getLocation(entity.getLocation());
com.plotsquared.core.location.Location pLoc =
BukkitUtil.getLocation(entity.getLocation());
PlotArea area = pLoc.getPlotArea();
if (area != null) {
PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
if (currentPlotId != null) {
entity.setMetadata("shulkerPlot", new FixedMetadataValue(
(Plugin) PlotSquared.get().IMP, currentPlotId));
entity.setMetadata("shulkerPlot",
new FixedMetadataValue(
(Plugin) PlotSquared.get().IMP, currentPlotId));
}
}
}
@ -668,7 +678,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
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) {
if (name == null) {
return null;
@ -709,7 +720,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
map.put(plotAreaType.name().toLowerCase(), terrainTypes);
}
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.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) {
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() {
List<Map.Entry<Map.Entry<String, String>, Boolean>> names = new ArrayList<>();
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()));
}
return names;
@ -863,7 +877,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
@Override public Actor getConsole() {
@NotNull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
WorldEditPlugin wePlugin = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
WorldEditPlugin wePlugin =
((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
return wePlugin.wrapCommandSender(console);
}
}

View File

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

View File

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

View File

@ -329,7 +329,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
}
storeLiving((LivingEntity) entity);
return;
// END LIVING //
// END LIVING //
default:
PlotSquared.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
}

View File

@ -32,12 +32,13 @@ import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.jetbrains.annotations.NotNull;
import java.util.Random;
final class BlockStatePopulator extends BlockPopulator {
private final IndependentPlotGenerator plotGenerator;
@ -47,13 +48,15 @@ final class BlockStatePopulator extends BlockPopulator {
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) {
if (this.queue == null) {
this.queue = GlobalBlockQueue.IMP.getNewQueue(world.getName(), false);
}
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);
if (this.plotGenerator.populateChunk(chunk, area)) {
this.queue.flush();

View File

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

View File

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

View File

@ -57,7 +57,8 @@ import java.util.HashSet;
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 RefField mustSave;
@ -291,11 +292,15 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
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 (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);
return true;
}

View File

@ -28,10 +28,10 @@ package com.plotsquared.bukkit.listener;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import io.papermc.lib.PaperLib;
import org.bukkit.Chunk;
import org.bukkit.World;

View File

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

View File

@ -26,9 +26,6 @@
package com.plotsquared.bukkit.listener;
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.util.BukkitUtil;
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.Settings;
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.AnimalCapFlag;
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.VineGrowFlag;
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.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.MainUtil;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PremiumVerification;
import com.plotsquared.core.util.RegExUtil;
import com.plotsquared.core.util.StringWrapper;
import com.plotsquared.core.util.entity.EntityCategories;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.uuid.UUIDHandler;
@ -209,12 +206,7 @@ import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource;
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.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
@ -275,31 +267,32 @@ public class PlayerEvents extends PlotListener implements Listener {
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)) {
return false;
}
if (EntityCategories.PROJECTILE.contains(entityType) ||
EntityCategories.OTHER.contains(entityType) ||
EntityCategories.HANGING.contains(entityType)) {
if (EntityCategories.PROJECTILE.contains(entityType) || EntityCategories.OTHER
.contains(entityType) || EntityCategories.HANGING.contains(entityType)) {
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED,
MiscCapFlag.MISC_CAP_UNLIMITED);
}
// Has to go go before vehicle as horses are both
// animals and vehicles
if (EntityCategories.ANIMAL.contains(entityType) ||
EntityCategories.VILLAGER.contains(entityType) ||
EntityCategories.TAMEABLE.contains(entityType)) {
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED,
MobCapFlag.MOB_CAP_UNLIMITED, AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
if (EntityCategories.ANIMAL.contains(entityType) || EntityCategories.VILLAGER
.contains(entityType) || EntityCategories.TAMEABLE.contains(entityType)) {
return EntityUtil
.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED, MobCapFlag.MOB_CAP_UNLIMITED,
AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
}
if (EntityCategories.HOSTILE.contains(entityType)) {
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED,
MobCapFlag.MOB_CAP_UNLIMITED, HostileCapFlag.HOSTILE_CAP_UNLIMITED);
return EntityUtil
.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED, MobCapFlag.MOB_CAP_UNLIMITED,
HostileCapFlag.HOSTILE_CAP_UNLIMITED);
}
if (EntityCategories.VEHICLE.contains(entityType)) {
@ -763,10 +756,12 @@ public class PlayerEvents extends PlotListener implements Listener {
}
}
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
// 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");
Plot toPlot = BukkitUtil.getLocation(to).getPlot();
if (!meta.isEmpty()) {
@ -930,7 +925,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|| area.isForcingPlotChat())) {
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;
}
event.setCancelled(true);
@ -990,10 +986,9 @@ public class PlayerEvents extends PlotListener implements Listener {
event.setCancelled(true);
return;
}
} else if (
(location.getY() > area.getMaxBuildHeight() || location.getY() < area.getMinBuildHeight())
&& !Permissions
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
} else if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area
.getMinBuildHeight()) && !Permissions
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true);
MainUtil.sendMessage(plotPlayer, Captions.HEIGHT_LIMIT.getTranslated()
.replace("{limit}", String.valueOf(area.getMaxBuildHeight())));
@ -1372,7 +1367,8 @@ public class PlayerEvents extends PlotListener implements Listener {
final PlotArea fromArea = fLocation.getPlotArea();
if (fromArea != null) {
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);
return;
}
@ -2497,13 +2493,16 @@ public class PlayerEvents extends PlotListener implements Listener {
}
} else if (!plot.isAdded(pp.getUUID())) {
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;
}
if (EntityCategories.ANIMAL.contains(entityType) && plot.getFlag(AnimalInteractFlag.class)) {
if (EntityCategories.ANIMAL.contains(entityType) && plot
.getFlag(AnimalInteractFlag.class)) {
return;
}
@ -2514,20 +2513,23 @@ public class PlayerEvents extends PlotListener implements Listener {
return;
}
if (EntityCategories.VEHICLE.contains(entityType) && plot.getFlag(VehicleUseFlag.class)) {
if (EntityCategories.VEHICLE.contains(entityType) && plot
.getFlag(VehicleUseFlag.class)) {
return;
}
if (EntityCategories.PLAYER.contains(entityType) && plot.getFlag(PlayerInteractFlag.class)) {
if (EntityCategories.PLAYER.contains(entityType) && plot
.getFlag(PlayerInteractFlag.class)) {
return;
}
if (EntityCategories.VILLAGER.contains(entityType) && plot.getFlag(VillagerInteractFlag.class)) {
if (EntityCategories.VILLAGER.contains(entityType) && plot
.getFlag(VillagerInteractFlag.class)) {
return;
}
if ((EntityCategories.HANGING.contains(entityType) ||
EntityCategories.OTHER.contains(entityType)) && plot.getFlag(MiscInteractFlag.class)) {
if ((EntityCategories.HANGING.contains(entityType) || EntityCategories.OTHER
.contains(entityType)) && plot.getFlag(MiscInteractFlag.class)) {
return;
}
@ -2809,7 +2811,8 @@ public class PlayerEvents extends PlotListener implements Listener {
"plots.admin.pve." + stub);
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;
} else { // victim is something else
if (plot != null && (plot.getFlag(PveFlag.class) || plot
@ -2880,8 +2883,9 @@ public class PlayerEvents extends PlotListener implements Listener {
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = area.getPlot(location);
if (plot != null) {
if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area.getMinBuildHeight())
&& !Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area
.getMinBuildHeight()) && !Permissions
.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true);
MainUtil.sendMessage(pp, Captions.HEIGHT_LIMIT.getTranslated()
.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;
@SuppressWarnings("unused") public class SingleWorldListener implements Listener {
@SuppressWarnings("unused")
public class SingleWorldListener implements Listener {
private Method methodGetHandleChunk;
private Field mustSave;

View File

@ -40,23 +40,23 @@ import org.bukkit.generator.ChunkGenerator;
@SuppressWarnings("unused")
public class WorldEvents implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onWorldInit(WorldInitEvent event) {
World world = event.getWorld();
String name = world.getName();
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
if (manager instanceof SinglePlotAreaManager) {
SinglePlotAreaManager single = (SinglePlotAreaManager) manager;
if (single.isWorld(name)) {
world.setKeepSpawnInMemory(false);
return;
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onWorldInit(WorldInitEvent event) {
World world = event.getWorld();
String name = world.getName();
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
if (manager instanceof SinglePlotAreaManager) {
SinglePlotAreaManager single = (SinglePlotAreaManager) manager;
if (single.isWorld(name)) {
world.setKeepSpawnInMemory(false);
return;
}
}
ChunkGenerator gen = world.getGenerator();
if (gen instanceof GeneratorWrapper) {
PlotSquared.get().loadWorld(name, (GeneratorWrapper<?>) gen);
} else {
PlotSquared.get().loadWorld(name, new BukkitPlotGenerator(name, gen));
}
}
ChunkGenerator gen = world.getGenerator();
if (gen instanceof GeneratorWrapper) {
PlotSquared.get().loadWorld(name, (GeneratorWrapper<?>) gen);
} else {
PlotSquared.get().loadWorld(name, new BukkitPlotGenerator(name, gen));
}
}
}

View File

@ -42,7 +42,7 @@ public class PlaceholderFormatter implements ChatFormatter {
final Player player = ((BukkitPlayer) recipient).player;
context.setMessage(PlaceholderAPI.setPlaceholders(player, context.getMessage()));
}
}
}
}
}

View File

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

View File

@ -28,12 +28,12 @@ package com.plotsquared.bukkit.player;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.location.Location;
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.MathMan;
import com.plotsquared.core.plot.PlotWeather;
import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.uuid.UUIDHandler;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
@ -167,7 +167,7 @@ public class BukkitPlayer extends PlotPlayer {
if (CHECK_EFFECTIVE) {
boolean hasAny = false;
String stubPlus = stub + ".";
final Set<PermissionAttachmentInfo> effective = player.getEffectivePermissions();
final Set<PermissionAttachmentInfo> effective = player.getEffectivePermissions();
if (!effective.isEmpty()) {
for (PermissionAttachmentInfo attach : effective) {
String permStr = attach.getPermission();
@ -211,8 +211,7 @@ public class BukkitPlayer extends PlotPlayer {
}
@Override public void sendMessage(String message) {
message = message.replace('\u2010', '%')
.replace('\u2020', '&').replace('\u2030', '&');
message = message.replace('\u2010', '%').replace('\u2020', '&').replace('\u2030', '&');
if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (
System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
setMeta("lastMessage", message);
@ -221,12 +220,14 @@ 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) {
return;
}
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());
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());
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)) {
this.player.setGameMode(GameMode.ADVENTURE);
} else if (CREATIVE.equals(gameMode)) {
@ -344,7 +346,8 @@ public class BukkitPlayer extends PlotPlayer {
return PlayerTeleportEvent.TeleportCause.COMMAND;
case 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.util.BukkitBlockUtil;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.queue.BasicLocalBlockQueue;
import com.plotsquared.core.util.BlockUtil;
import com.plotsquared.core.util.MainUtil;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
@ -139,7 +139,8 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
BlockData blockData = BukkitAdapter.adapt(block);
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
.getBlockData().matches(blockData)) {
continue;
@ -151,8 +152,8 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
CompoundTag tag = block.getNbtData();
StateWrapper sw = new StateWrapper(tag);
sw.restoreTag(worldObj.getName(), existing.getX(),
existing.getY(), existing.getZ());
sw.restoreTag(worldObj.getName(), existing.getX(), existing.getY(),
existing.getZ());
}
}
}
@ -162,7 +163,8 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
if (isForceSync()) {
chunkConsumer.accept(getChunk(worldObj, localChunk));
} 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];
Biome biome = BukkitAdapter.adapt(biomeType);
worldObj.setBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z,
biome);
worldObj
.setBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z, biome);
}
}
}
@ -216,7 +218,8 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
if (this.isForceSync()) {
chunkConsumer.accept(getChunk(worldObj, lc));
} 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;
import com.google.common.base.Preconditions;
import com.plotsquared.bukkit.util.BukkitBlockUtil;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.location.ChunkWrapper;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.PatternUtil;
import com.google.common.base.Preconditions;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.function.pattern.Pattern;
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 maxY = Math.max(pos1.getY(), pos2.getY());
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) {
@ -135,7 +136,8 @@ public class GenChunk extends ScopedLocalBlockQueue {
}
@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) {

View File

@ -27,12 +27,19 @@ package com.plotsquared.bukkit.schematic;
import com.plotsquared.bukkit.util.BukkitUtil;
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.SchematicHandler;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.queue.LocalBlockQueue;
import com.sk89q.jnbt.*;
import com.sk89q.jnbt.ByteArrayTag;
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.extension.platform.Capability;
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 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;
/**
@ -50,7 +63,8 @@ import java.util.stream.IntStream;
*/
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) {
// async
TaskManager.runTaskAsync(new Runnable() {
@ -112,10 +126,12 @@ public class BukkitSchematicHandler extends SchematicHandler {
schematic.put("BiomePaletteMax", new IntTag(biomePalette.size()));
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("BiomeData", new ByteArrayTag(biomeBuffer.toByteArray()));
schematic
.put("BiomeData", new ByteArrayTag(biomeBuffer.toByteArray()));
whenDone.value = new CompoundTag(schematic);
TaskManager.runTask(whenDone);
});
@ -123,8 +139,10 @@ public class BukkitSchematicHandler extends SchematicHandler {
}
final Runnable regionTask = this;
CuboidRegion region = queue.poll();
Location pos1 = new Location(world, region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
Location pos2 = new Location(world, region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
Location pos1 = new Location(world, region.getMinimumPoint().getX(),
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 sy = pos1.getY();
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.Settings;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.util.ChatManager;
import org.bukkit.ChatColor;

View File

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

View File

@ -26,10 +26,10 @@
package com.plotsquared.bukkit.util;
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.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.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaType;
@ -88,7 +88,7 @@ public class BukkitSetupUtils extends SetupUtils {
}
World dw = Bukkit.getWorlds().get(0);
for (Player player : world.getPlayers()) {
PaperLib.teleportAsync(player,dw.getSpawnLocation());
PaperLib.teleportAsync(player, dw.getSpawnLocation());
}
if (save) {
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) {
ensureLoaded(world, x, z, chunk ->
result.accept(BukkitAdapter.adapt(getWorld(world).getBiome(x, z))));
ensureLoaded(world, x, z,
chunk -> result.accept(BukkitAdapter.adapt(getWorld(world).getBiome(x, z))));
}
@Override public BiomeType getBiomeSynchronous(String world, int x, int 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) {
ensureLoaded(world, x, z, chunk -> {
final World bukkitWorld = getWorld(world);
@ -394,7 +395,8 @@ public class BukkitUtil extends WorldUtil {
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 -> {
final Block block = chunk.getWorld().getBlockAt(getLocation(location));
if (block.getState() instanceof Sign) {
@ -519,7 +521,8 @@ public class BukkitUtil extends WorldUtil {
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 -> {
final World world = getWorld(location.getWorld());
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
@ -554,7 +557,8 @@ public class BukkitUtil extends WorldUtil {
}
@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<>();
switch (category) {
case "animal": {
@ -563,13 +567,16 @@ public class BukkitUtil extends WorldUtil {
allowedInterfaces.add(Animals.class);
allowedInterfaces.add(WaterMob.class);
allowedInterfaces.add(Ambient.class);
} break;
}
break;
case "tameable": {
allowedInterfaces.add(Tameable.class);
} break;
}
break;
case "vehicle": {
allowedInterfaces.add(Vehicle.class);
} break;
}
break;
case "hostile": {
allowedInterfaces.add(Shulker.class);
allowedInterfaces.add(Monster.class);
@ -578,16 +585,20 @@ public class BukkitUtil extends WorldUtil {
allowedInterfaces.add(Ghast.class);
allowedInterfaces.add(Phantom.class);
allowedInterfaces.add(EnderCrystal.class);
} break;
}
break;
case "hanging": {
allowedInterfaces.add(Hanging.class);
} break;
}
break;
case "villager": {
allowedInterfaces.add(NPC.class);
} break;
}
break;
case "projectile": {
allowedInterfaces.add(Projectile.class);
} break;
}
break;
case "other": {
allowedInterfaces.add(ArmorStand.class);
allowedInterfaces.add(FallingBlock.class);
@ -599,16 +610,20 @@ public class BukkitUtil extends WorldUtil {
allowedInterfaces.add(ExperienceOrb.class);
allowedInterfaces.add(EnderSignal.class);
allowedInterfaces.add(Firework.class);
} break;
}
break;
case "player": {
allowedInterfaces.add(Player.class);
} break;
}
break;
default: {
PlotSquared.log(Captions.PREFIX + "Unknown entity category requested: " + category);
} break;
}
break;
}
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();
if (entityClass == null) {
continue;
@ -623,22 +638,23 @@ public class BukkitUtil extends WorldUtil {
return types;
}
private static void ensureLoaded(final String world, final int x, final int z, final Consumer<Chunk> chunkConsumer) {
PaperLib.getChunkAtAsync(getWorld(world), x >> 4, z >> 4, true).thenAccept(chunk ->
ensureMainThread(chunkConsumer, chunk));
private static void ensureLoaded(final String world, final int x, final int z,
final Consumer<Chunk> chunkConsumer) {
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) {
PaperLib.getChunkAtAsync(getLocation(location), true).thenAccept(chunk ->
ensureMainThread(chunkConsumer, chunk));
PaperLib.getChunkAtAsync(getLocation(location), true)
.thenAccept(chunk -> ensureMainThread(chunkConsumer, chunk));
}
private static <T> void ensureMainThread(final Consumer<T> consumer, final T value) {
if (Bukkit.isPrimaryThread()) {
consumer.accept(value);
} else {
Bukkit.getScheduler().runTask(BukkitMain.getPlugin(BukkitMain.class), () ->
consumer.accept(value));
Bukkit.getScheduler()
.runTask(BukkitMain.getPlugin(BukkitMain.class), () -> consumer.accept(value));
}
}

View File

@ -99,7 +99,8 @@ public class OfflinePlayerUtil {
Class<?> minecraftServerClass = getNmsClass("MinecraftServer");
Class<?> dimensionManager = getNmsClass("DimensionManager");
Object overworld = getField(makeField(dimensionManager, "OVERWORLD"), null);
Method getWorldServer = makeMethod(minecraftServerClass, "getWorldServer", dimensionManager);
Method getWorldServer =
makeMethod(minecraftServerClass, "getWorldServer", dimensionManager);
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.core.PlotSquared;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
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.RefConstructor;
import com.plotsquared.core.util.ReflectionUtils.RefField;

View File

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

View File

@ -25,9 +25,9 @@
*/
package com.plotsquared.bukkit.util.uuid;
import com.google.common.base.Charsets;
import com.plotsquared.core.player.OfflinePlotPlayer;
import com.plotsquared.core.player.PlotPlayer;
import com.google.common.base.Charsets;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
@ -37,7 +37,8 @@ import java.util.UUID;
public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
@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) {
@ -47,7 +48,8 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
@Override public UUID getUUID(OfflinePlayer player) {
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) {

View File

@ -25,6 +25,8 @@
*/
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.core.PlotSquared;
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.uuid.UUIDHandler;
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.OfflinePlayer;
import org.bukkit.Server;
@ -60,7 +60,8 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
}
@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) {

View File

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