Reformat code

This commit is contained in:
dordsor21
2019-04-23 23:48:22 +01:00
parent d352804b5d
commit bef3dbc6f4
63 changed files with 332 additions and 300 deletions

View File

@ -31,8 +31,8 @@ import com.sk89q.worldedit.extension.platform.Capability;
import lombok.Getter;
import lombok.NonNull;
import org.bstats.bukkit.Metrics;
import org.bukkit.*;
import org.bukkit.Location;
import org.bukkit.*;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -48,7 +48,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import javax.annotation.Nullable;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.*;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
@ -60,7 +59,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
static {
try {
Settings.load(new File("plugins/PlotSquared/config/settings.yml"));
} catch (Throwable ignored) {}
} catch (Throwable ignored) {
}
}
private final LegacyMappings legacyMappings = new BukkitLegacyMappings();
@ -110,8 +110,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS);
} catch (final Throwable throwable) {
throw new IllegalStateException(
"Failed to force load WorldEdit. Road schematics will fail to generate",
throwable);
"Failed to force load WorldEdit. Road schematics will fail to generate", throwable);
}
}
@ -145,25 +144,31 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
// Check for updates
if (PlotSquared.get().getUpdateUtility() != null) {
final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility();
updateUtility.checkForUpdate(this.getPluginVersionString(), ((updateDescription, throwable) -> {
Bukkit.getScheduler().runTask(BukkitMain.this, () -> {
getLogger().info("-------- PlotSquared Update Check --------");
if (throwable != null) {
getLogger().severe(String.format("Could not check for update. Reason: %s",
throwable.getMessage()));
} else {
if (updateDescription == null) {
getLogger().info("You appear to be running the latest version of PlotSquared. Congratulations!");
updateUtility
.checkForUpdate(this.getPluginVersionString(), ((updateDescription, throwable) -> {
Bukkit.getScheduler().runTask(BukkitMain.this, () -> {
getLogger().info("-------- PlotSquared Update Check --------");
if (throwable != null) {
getLogger().severe(String
.format("Could not check for update. Reason: %s",
throwable.getMessage()));
} else {
getLogger().info("There appears to be a PlotSquared update available!");
getLogger().info(String.format("You are running version %s,"
+ " the newest available version is %s", getPluginVersionString(), updateDescription.getVersion()));
getLogger().info(String.format("Update URL: %s", updateDescription.getUrl()));
if (updateDescription == null) {
getLogger().info(
"You appear to be running the latest version of PlotSquared. Congratulations!");
} else {
getLogger()
.info("There appears to be a PlotSquared update available!");
getLogger().info(String.format("You are running version %s,"
+ " the newest available version is %s",
getPluginVersionString(), updateDescription.getVersion()));
getLogger().info(
String.format("Update URL: %s", updateDescription.getUrl()));
}
}
}
getLogger().info("-------- PlotSquared Update Check --------");
});
}));
getLogger().info("-------- PlotSquared Update Check --------");
});
}));
} else {
getLogger().warning("Update checking disabled. Skipping.");
}
@ -246,8 +251,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
continue outer;
}
} else {
result = world
.unloadChunk(chunkI.getX(), chunkI.getZ(), true);
result = world.unloadChunk(chunkI.getX(), chunkI.getZ(), true);
}
if (!result) {
continue outer;

View File

@ -6,8 +6,7 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
/**
*
*/
public class PlayerLeavePlotEvent extends PlayerEvent {

View File

@ -7,8 +7,7 @@ import org.bukkit.event.HandlerList;
import java.util.UUID;
/**
*
*/
public class PlayerPlotHelperEvent extends PlotEvent {

View File

@ -7,8 +7,7 @@ import org.bukkit.event.HandlerList;
import java.util.UUID;
/**
*
*/
public class PlayerPlotTrustedEvent extends PlotEvent {

View File

@ -117,10 +117,11 @@ public class BukkitPlotGenerator extends ChunkGenerator
return toAdd;
}
@Override @NotNull public ChunkData generateChunkData(@NotNull World world, @NotNull Random random,
int x, int z, @NotNull BiomeGrid biome) {
@Override @NotNull
public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z,
@NotNull BiomeGrid biome) {
GenChunk result = new GenChunk();
GenChunk result = new GenChunk();
if (this.getPlotGenerator() instanceof SingleWorldGenerator) {
if (result.getCd() != null) {
for (int cx = 0; cx < 16; cx++) {

View File

@ -32,10 +32,8 @@ import java.util.Random;
return this.chunkGenerator.getClass().getName();
}
@Override
public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
return PlotSquared.get().IMP.getDefaultGenerator()
.getNewPlotArea(world, id, min, max);
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
return PlotSquared.get().IMP.getDefaultGenerator().getNewPlotArea(world, id, min, max);
}
@Override public BlockBucket[][] generateBlockBucketChunk(PlotArea settings) {
@ -55,15 +53,14 @@ import java.util.Random;
for (int y = 1; y < hpw.PLOT_HEIGHT; y++) {
blockBuckets[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = hpw.MAIN_BLOCK;
}
blockBuckets[hpw.PLOT_HEIGHT >> 4][((hpw.PLOT_HEIGHT & 0xF) << 8) | (z << 4)
| x] = hpw.MAIN_BLOCK;
blockBuckets[hpw.PLOT_HEIGHT >> 4][((hpw.PLOT_HEIGHT & 0xF) << 8) | (z << 4) | x] =
hpw.MAIN_BLOCK;
}
}
return blockBuckets;
}
@Override
public void generateChunk(final ScopedLocalBlockQueue result, PlotArea settings) {
@Override public void generateChunk(final ScopedLocalBlockQueue result, PlotArea settings) {
World w = BukkitUtil.getWorld(world);
Location min = result.getMin();
int cx = min.getX() >> 4;

View File

@ -269,15 +269,13 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
}
PlotSquared.debug(
Captions.PREFIX.s() + "&a detected unsafe chunk and processed: " + (chunk.getX()
<< 4)
+ "," + (chunk.getX() << 4));
<< 4) + "," + (chunk.getX() << 4));
}
if (tiles.length > Settings.Chunk_Processor.MAX_TILES) {
if (unload) {
PlotSquared.debug(
Captions.PREFIX.s() + "&c detected unsafe chunk: " + (chunk.getX() << 4) + ","
+ (
chunk.getX() << 4));
+ (chunk.getX() << 4));
cleanChunk(chunk);
return true;
}

View File

@ -19,33 +19,34 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.EntityTeleportEvent;
import org.bukkit.event.vehicle.*;
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
import org.bukkit.event.vehicle.VehicleCreateEvent;
import org.bukkit.event.vehicle.VehicleMoveEvent;
import org.bukkit.event.vehicle.VehicleUpdateEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class EntitySpawnListener implements Listener {
private static boolean ignoreTP = false;
private final static String KEY = "P2";
private static boolean ignoreTP = false;
private static boolean hasPlotArea = false;
private static String areaName = null;
public static void testNether(Entity entity) {
@NotNull World world = entity.getWorld();
if (world.getEnvironment() != World.Environment.NETHER && world.getEnvironment() != World.Environment.THE_END) {
if (world.getEnvironment() != World.Environment.NETHER
&& world.getEnvironment() != World.Environment.THE_END) {
return;
}
test(entity);
}
private static boolean hasPlotArea = false;
private static String areaName = null;
public static void testCreate(Entity entity) {
@NotNull World world = entity.getWorld();
if (areaName == world.getName()) {
@ -53,7 +54,8 @@ public class EntitySpawnListener implements Listener {
areaName = world.getName();
hasPlotArea = PlotSquared.get().hasPlotArea(areaName);
}
if (!hasPlotArea) return;
if (!hasPlotArea)
return;
test(entity);
}

View File

@ -132,11 +132,11 @@ import java.util.UUID;
Player player = event.getPlayer();
Plot plot = event.getPlot();
Optional<IntervalFlag.Interval> feed = plot.getFlag(Flags.FEED);
feed.ifPresent(
value -> feedRunnable.put(player.getUniqueId(), new Interval(value.getVal1(), value.getVal2(), 20)));
feed.ifPresent(value -> feedRunnable
.put(player.getUniqueId(), new Interval(value.getVal1(), value.getVal2(), 20)));
Optional<IntervalFlag.Interval> heal = plot.getFlag(Flags.HEAL);
heal.ifPresent(
value -> healRunnable.put(player.getUniqueId(), new Interval(value.getVal1(), value.getVal2(), 20)));
heal.ifPresent(value -> healRunnable
.put(player.getUniqueId(), new Interval(value.getVal1(), value.getVal2(), 20)));
}
@EventHandler public void onPlayerQuit(PlayerQuitEvent event) {

View File

@ -7,7 +7,6 @@ import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.*;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -17,13 +16,8 @@ import org.bukkit.event.Event;
import org.bukkit.event.EventException;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.permissions.Permissible;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.RegisteredListener;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import java.util.Arrays;
@ -33,6 +27,7 @@ import java.util.stream.Collectors;
public class BukkitPlayer extends PlotPlayer {
private static boolean CHECK_EFFECTIVE = true;
public final Player player;
private boolean offline;
private UUID uuid;
@ -105,8 +100,6 @@ public class BukkitPlayer extends PlotPlayer {
return this.player.hasPermission(permission);
}
private static boolean CHECK_EFFECTIVE = true;
@Override public int hasPermissionRange(String stub, int range) {
if (hasPermission(Captions.PERMISSION_ADMIN.s())) {
return Integer.MAX_VALUE;

View File

@ -408,7 +408,8 @@ public class TitleManager_1_11 {
private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
for (Method m : clazz.getMethods()) {
if (m.getName().equals(name) && (args.length == 0 || ClassListEqual(args, m.getParameterTypes()))) {
if (m.getName().equals(name) && (args.length == 0 || ClassListEqual(args,
m.getParameterTypes()))) {
m.setAccessible(true);
return m;
}

View File

@ -394,8 +394,7 @@ public class BukkitChunkManager extends ChunkManager {
public void unloadChunk(final String world, final ChunkLoc loc, final boolean save,
final boolean safe) {
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
TaskManager
.runTask(() -> BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save));
TaskManager.runTask(() -> BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save));
} else {
BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save);
}

View File

@ -128,16 +128,22 @@ public class BukkitSetupUtils extends SetupUtils {
PlotSquared.get().worlds.createSection(worldPath);
}
if (steps.length != 0) {
ConfigurationSection worldSection = PlotSquared.get().worlds.getConfigurationSection(worldPath);
ConfigurationSection worldSection =
PlotSquared.get().worlds.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
}
PlotSquared.get().worlds.set("worlds." + world + ".generator.type", object.type);
PlotSquared.get().worlds.set("worlds." + world + ".generator.terrain", object.terrain);
PlotSquared.get().worlds.set("worlds." + world + ".generator.plugin", object.plotManager);
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
PlotSquared.get().worlds.set("worlds." + world + ".generator.init", object.setupGenerator);
PlotSquared.get().worlds
.set("worlds." + world + ".generator.type", object.type);
PlotSquared.get().worlds
.set("worlds." + world + ".generator.terrain", object.terrain);
PlotSquared.get().worlds
.set("worlds." + world + ".generator.plugin", object.plotManager);
if (object.setupGenerator != null && !object.setupGenerator
.equals(object.plotManager)) {
PlotSquared.get().worlds
.set("worlds." + world + ".generator.init", object.setupGenerator);
}
}
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);

View File

@ -35,10 +35,6 @@ public class GenChunk extends ScopedLocalBlockQueue {
this.biomes = Biome.values();
}
public void setChunk(Chunk chunk) {
this.chunk = chunk;
}
public Chunk getChunk() {
if (chunk == null) {
World worldObj = BukkitUtil.getWorld(world);
@ -49,6 +45,10 @@ public class GenChunk extends ScopedLocalBlockQueue {
return chunk;
}
public void setChunk(Chunk chunk) {
this.chunk = chunk;
}
public void setChunk(ChunkWrapper wrap) {
chunk = null;
world = wrap.world;

View File

@ -72,7 +72,7 @@ permissions:
plots.permpack.basicinbox:
default: op
children:
comments.notifications.enabled : true
comments.notifications.enabled: true
plots.inbox.read.public: true
plots.inbox.modify.public: true
plots.inbox.modify.public: true