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

View File

@ -1156,9 +1156,9 @@ import java.util.zip.ZipInputStream;
+ areaGen);
PlotSquared.log(Captions.PREFIX + "&c | &9plotworld: &7" + pa);
PlotSquared.log(Captions.PREFIX + "&c | &9manager: &7" + pa);
PlotSquared
.log(Captions.PREFIX + "&cNote: &7Area created for cluster:" + name
+ " (invalid or old configuration?)");
PlotSquared.log(
Captions.PREFIX + "&cNote: &7Area created for cluster:" + name
+ " (invalid or old configuration?)");
areaGen.getPlotGenerator().initialize(pa);
areaGen.augment(pa);
toLoad.add(pa);
@ -1613,12 +1613,13 @@ import java.util.zip.ZipInputStream;
Settings.load(configFile);
try {
copyFile("updater.properties", "config");
try (BufferedReader bufferedReader =
new BufferedReader(new InputStreamReader(new FileInputStream(new File(new File(this.IMP.getDirectory(),
"config"), "updater.properties"))))) {
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(
new FileInputStream(new File(new File(this.IMP.getDirectory(), "config"),
"updater.properties"))))) {
final Properties properties = new Properties();
properties.load(bufferedReader);
final boolean enabled = Boolean.valueOf(properties.getOrDefault("enabled", true).toString());
final boolean enabled =
Boolean.valueOf(properties.getOrDefault("enabled", true).toString());
if (enabled) {
this.updateUtility = new UpdateUtility(properties.getProperty("path"),
properties.getProperty("job"), properties.getProperty("artifact"));

View File

@ -15,8 +15,11 @@ import java.util.ArrayList;
import java.util.Objects;
import java.util.Set;
@CommandDeclaration(command = "area", permission = "plots.area", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE, description = "Create a new PlotArea", aliases = "world", usage = "/plot area <create|info|list|tp|regen>", confirmation = true)
public class Area extends SubCommand {
@CommandDeclaration(command = "area", permission = "plots.area",
category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE,
description = "Create a new PlotArea", aliases = "world",
usage = "/plot area <create|info|list|tp|regen>", confirmation = true) public class Area
extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 0) {

View File

@ -4,8 +4,8 @@ import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@CommandDeclaration(command = "chat", description = "Toggle plot chat on or off",
usage = "/plot chat [on|off]", permission = "plots.chat", category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER)
public class Chat extends SubCommand {
usage = "/plot chat [on|off]", permission = "plots.chat", category = CommandCategory.CHAT,
requiredType = RequiredType.PLAYER) public class Chat extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) {
MainCommand.getInstance().toggle.chat(this, player, new String[0], null, null);

View File

@ -141,9 +141,9 @@ import java.util.UUID;
} else {
current = player.getPlayerClusterCount(player.getLocation().getWorld());
}
int allowed =
Permissions.hasPermissionRange(player, Captions.PERMISSION_CLUSTER_SIZE,
Settings.Limit.MAX_PLOTS);
int allowed = Permissions
.hasPermissionRange(player, Captions.PERMISSION_CLUSTER_SIZE,
Settings.Limit.MAX_PLOTS);
if (current + cluster.getArea() > allowed) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_SIZE + "." + (current + cluster.getArea()));

View File

@ -11,31 +11,39 @@ import lombok.RequiredArgsConstructor;
* Claiming CommandConfig.
* Such as: /plot claim
*/
CLAIMING(Captions.COMMAND_CATEGORY_CLAIMING), /**
CLAIMING(Captions.COMMAND_CATEGORY_CLAIMING),
/**
* Teleportation CommandConfig.
* Such as: /plot visit
*/
TELEPORT(Captions.COMMAND_CATEGORY_TELEPPORT), /**
TELEPORT(Captions.COMMAND_CATEGORY_TELEPPORT),
/**
* Protection.
*/
SETTINGS(Captions.COMMAND_CATEGORY_SETTINGS), /**
SETTINGS(Captions.COMMAND_CATEGORY_SETTINGS),
/**
* Chat.
*/
CHAT(Captions.COMMAND_CATEGORY_CHAT), /**
CHAT(Captions.COMMAND_CATEGORY_CHAT),
/**
* Web.
*/
SCHEMATIC(Captions.COMMAND_CATEGORY_SCHEMATIC), /**
SCHEMATIC(Captions.COMMAND_CATEGORY_SCHEMATIC),
/**
* Cosmetic.
*/
APPEARANCE(Captions.COMMAND_CATEGORY_APPEARANCE), /**
APPEARANCE(Captions.COMMAND_CATEGORY_APPEARANCE),
/**
* Information CommandConfig.
* Such as: /plot info
*/
INFO(Captions.COMMAND_CATEGORY_INFO), /**
INFO(Captions.COMMAND_CATEGORY_INFO),
/**
* Debug CommandConfig.
* Such as: /plot debug
*/
DEBUG(Captions.COMMAND_CATEGORY_DEBUG), /**
DEBUG(Captions.COMMAND_CATEGORY_DEBUG),
/**
* Administration commands.
*/
ADMINISTRATION(Captions.COMMAND_CATEGORY_ADMINISTRATION);

View File

@ -11,8 +11,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import java.util.*;
import java.util.Set;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
@CommandDeclaration(command = "condense", permission = "plots.admin",

View File

@ -3,7 +3,6 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
@ -38,7 +37,8 @@ import java.util.UUID;
PlotId id = new PlotId(0, 0);
File container = PlotSquared.imp().getWorldContainer();
if (container.equals(new File("."))) {
player.sendMessage("World container must be configured to be a separate directory to your base files!");
player.sendMessage(
"World container must be configured to be a separate directory to your base files!");
return;
}
for (File folder : container.listFiles()) {

View File

@ -3,9 +3,10 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@CommandDeclaration(command = "dislike", permission = "plots.dislike", description = "Dislike the plot",
usage = "/plot dislike [next|purge]", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
public class Dislike extends SubCommand {
@CommandDeclaration(command = "dislike", permission = "plots.dislike",
description = "Dislike the plot", usage = "/plot dislike [next|purge]",
category = CommandCategory.INFO, requiredType = RequiredType.PLAYER) public class Dislike
extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) {
return Like.handleLike(player, args, false);

View File

@ -79,8 +79,7 @@ public class Help extends Command {
for (CommandCategory c : CommandCategory.values()) {
builder.append("\n" + StringMan
.replaceAll(Captions.HELP_INFO_ITEM.s(), "%category%",
c.toString().toLowerCase(),
"%category_desc%", c.toString()));
c.toString().toLowerCase(), "%category_desc%", c.toString()));
}
builder.append("\n").append(Captions.HELP_INFO_ITEM.s().replaceAll("%category%", "all")
.replaceAll("%category_desc%", Captions.HELP_DISPLAY_ALL_COMMANDS.s()));

View File

@ -12,8 +12,8 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import java.util.UUID;
@CommandDeclaration(command = "info", aliases = "i", description = "Display plot info",
usage = "/plot info <id> [-f, to force info]", category = CommandCategory.INFO) public class Info
extends SubCommand {
usage = "/plot info <id> [-f, to force info]", category = CommandCategory.INFO)
public class Info extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
Plot plot;

View File

@ -17,14 +17,11 @@ import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import java.util.*;
@CommandDeclaration(command = "like", permission = "plots.like", description = "Like the plot",
usage = "/plot like [next|purge]", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
public class Like extends SubCommand {
usage = "/plot like [next|purge]", category = CommandCategory.INFO,
requiredType = RequiredType.PLAYER) public class Like extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) {
return handleLike(player, args, true);
}
protected static boolean handleLike(final PlotPlayer player, String[] args, final boolean like) {
protected static boolean handleLike(final PlotPlayer player, String[] args,
final boolean like) {
final UUID uuid = player.getUUID();
if (args.length == 1) {
switch (args[0].toLowerCase()) {
@ -143,4 +140,8 @@ public class Like extends SubCommand {
return numLikes / (numLikes + numDislikes);
}
@Override public boolean onCommand(PlotPlayer player, String[] args) {
return handleLike(player, args, true);
}
}

View File

@ -363,13 +363,13 @@ public class ListCmd extends SubCommand {
} else {
color = "$1";
}
PlotMessage trusted =
new PlotMessage().text(Captions.color(Captions.PLOT_INFO_TRUSTED.s()
.replaceAll("%trusted%", MainUtil.getPlayerList(plot.getTrusted()))))
PlotMessage trusted = new PlotMessage().text(Captions.color(
Captions.PLOT_INFO_TRUSTED.s()
.replaceAll("%trusted%", MainUtil.getPlayerList(plot.getTrusted()))))
.color("$1");
PlotMessage members =
new PlotMessage().text(Captions.color(Captions.PLOT_INFO_MEMBERS.s()
.replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers()))))
PlotMessage members = new PlotMessage().text(Captions.color(
Captions.PLOT_INFO_MEMBERS.s()
.replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers()))))
.color("$1");
String strFlags = StringMan.join(plot.getFlags().values(), ",");
if (strFlags.isEmpty()) {

View File

@ -198,8 +198,7 @@ public class MainCommand extends Command {
Plot newPlot = Plot.fromString(area, args[0]);
if (newPlot != null && (player instanceof ConsolePlayer || newPlot.getArea()
.equals(area) || Permissions.hasPermission(player, Captions.PERMISSION_ADMIN))
&& !newPlot
.isDenied(player.getUUID())) {
&& !newPlot.isDenied(player.getUUID())) {
Location newLoc = newPlot.getCenter();
if (player.canTeleport(newLoc)) {
// Save meta

View File

@ -11,8 +11,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
@CommandDeclaration(usage = "/plot move <X;Z>", command = "move", description = "Move a plot",
aliases = {"debugmove"}, permission = "plots.move", category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER)
public class Move extends SubCommand {
aliases = {"debugmove"}, permission = "plots.move", category = CommandCategory.CLAIMING,
requiredType = RequiredType.PLAYER) public class Move extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
Location loc = player.getLocation();

View File

@ -9,7 +9,8 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
@CommandDeclaration(command = "near", aliases = "n", description = "Display nearby players", usage = "/plot near", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
@CommandDeclaration(command = "near", aliases = "n", description = "Display nearby players",
usage = "/plot near", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
public class Near extends Command {
public Near() {
super(MainCommand.getInstance(), true);

View File

@ -16,8 +16,8 @@ import java.util.Map.Entry;
import java.util.UUID;
@CommandDeclaration(command = "rate", permission = "plots.rate", description = "Rate the plot",
usage = "/plot rate [#|next|purge]", aliases = "rt", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
public class Rate extends SubCommand {
usage = "/plot rate [#|next|purge]", aliases = "rt", category = CommandCategory.INFO,
requiredType = RequiredType.PLAYER) public class Rate extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 1) {

View File

@ -58,8 +58,8 @@ import java.util.Map.Entry;
object.setup_index--;
ConfigurationNode node = object.step[object.setup_index];
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
node.getDescription(),
node.getType().getType(), String.valueOf(node.getDefaultValue()));
node.getDescription(), node.getType().getType(),
String.valueOf(node.getDefaultValue()));
return false;
} else if (object.current > 0) {
object.current--;
@ -131,8 +131,8 @@ import java.util.Map.Entry;
}
ConfigurationNode step = object.step[object.setup_index];
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
step.getDescription(),
step.getType().getType(), String.valueOf(step.getDefaultValue()));
step.getDescription(), step.getType().getType(),
String.valueOf(step.getDefaultValue()));
} else {
if (gen.isFull()) {
object.plotManager = object.setupGenerator;
@ -234,8 +234,8 @@ import java.util.Map.Entry;
}
ConfigurationNode step = object.step[object.setup_index];
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
step.getDescription(),
step.getType().getType(), String.valueOf(step.getDefaultValue()));
step.getDescription(), step.getType().getType(),
String.valueOf(step.getDefaultValue()));
break;
}
case 6: // world setup
@ -248,8 +248,8 @@ import java.util.Map.Entry;
ConfigurationNode step = object.step[object.setup_index];
if (args.length < 1) {
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
step.getDescription(),
step.getType().getType(), String.valueOf(step.getDefaultValue()));
step.getDescription(), step.getType().getType(),
String.valueOf(step.getDefaultValue()));
return false;
}
@ -269,14 +269,14 @@ import java.util.Map.Entry;
}
step = object.step[object.setup_index];
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
step.getDescription(),
step.getType().getType(), String.valueOf(step.getDefaultValue()));
step.getDescription(), step.getType().getType(),
String.valueOf(step.getDefaultValue()));
return false;
} else {
sendMessage(player, Captions.SETUP_INVALID_ARG, args[0], step.getConstant());
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
step.getDescription(),
step.getType().getType(), String.valueOf(step.getDefaultValue()));
step.getDescription(), step.getType().getType(),
String.valueOf(step.getDefaultValue()));
return false;
}
case 7:

View File

@ -23,17 +23,16 @@ public abstract class SubCommand extends Command {
setRequiredArguments(arguments);
}
public static boolean sendMessage(PlotPlayer player, Captions message, Object... args) {
message.send(player, args);
return true;
}
@Override public void execute(PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) {
onCommand(player, args);
}
public abstract boolean onCommand(PlotPlayer player, String[] args);
public static boolean sendMessage(PlotPlayer player, Captions message, Object... args) {
message.send(player, args);
return true;
}
}

View File

@ -7,8 +7,9 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.*;
@CommandDeclaration(command = "unlink", aliases = {"u",
"unmerge"}, description = "Unlink a mega-plot", usage = "/plot unlink [createroads]", requiredType = RequiredType.PLAYER, category = CommandCategory.SETTINGS, confirmation = true)
@CommandDeclaration(command = "unlink", aliases = {"u", "unmerge"},
description = "Unlink a mega-plot", usage = "/plot unlink [createroads]",
requiredType = RequiredType.PLAYER, category = CommandCategory.SETTINGS, confirmation = true)
public class Unlink extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) {

View File

@ -14,8 +14,8 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import java.util.*;
@CommandDeclaration(command = "visit", permission = "plots.visit",
description = "Visit someones plot", usage = "/plot visit [<player>|<alias>|<world>|<id>] [#]", aliases = {
"v", "tp", "teleport", "goto", "home", "h"}, requiredType = RequiredType.PLAYER,
description = "Visit someones plot", usage = "/plot visit [<player>|<alias>|<world>|<id>] [#]",
aliases = {"v", "tp", "teleport", "goto", "home", "h"}, requiredType = RequiredType.PLAYER,
category = CommandCategory.TELEPORT) public class Visit extends Command {
public Visit() {

View File

@ -378,8 +378,8 @@ public enum Captions {
RATING_ALREADY_EXISTS("$2You have already rated plot $2%s", "Ratings"), RATING_APPLIED(
"$4You successfully rated plot $2%s", "Ratings"),
RATING_DISLIKED("$4You successfully disliked plot $2%s", "Ratings"),
RATING_LIKED("$4You successfully liked plot $2%s", "Ratings"),
RATING_DISLIKED("$4You successfully disliked plot $2%s", "Ratings"), RATING_LIKED(
"$4You successfully liked plot $2%s", "Ratings"),
RATING_NOT_YOUR_OWN("$2You cannot rate your own plot", "Ratings"), RATING_NOT_DONE(
"$2You can only rate finished plots.", "Ratings"),

View File

@ -317,8 +317,7 @@ public class Settings extends Config {
public static final class Ratings {
@Comment("Replace the rating system with a like system. Will add /plot like/dislike,"
+ " and remove the rating command") public static boolean USE_LIKES = false;
@Comment("Rating categories")
public static List<String> CATEGORIES = new ArrayList<>();
@Comment("Rating categories") public static List<String> CATEGORIES = new ArrayList<>();
}

View File

@ -42,11 +42,9 @@ public class HybridPlotManager extends ClassicPlotManager {
files.add(new FileBytes(newDir + "intersection.schem",
Files.readAllBytes(intersection.toPath())));
}
File plot =
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "plot.schem");
File plot = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "plot.schem");
if (plot.exists()) {
files.add(
new FileBytes(newDir + "plot.schem", Files.readAllBytes(plot.toPath())));
files.add(new FileBytes(newDir + "plot.schem", Files.readAllBytes(plot.toPath())));
}
} catch (IOException e) {
e.printStackTrace();

View File

@ -34,8 +34,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
public short PATH_WIDTH_LOWER;
public short PATH_WIDTH_UPPER;
public HashMap<Integer, BaseBlock[]> G_SCH;
private Location SIGN_LOCATION;
public int SCHEM_Y;
private Location SIGN_LOCATION;
public HybridPlotWorld(String worldName, String id, IndependentPlotGenerator generator,
PlotId min, PlotId max) {
@ -134,13 +134,17 @@ public class HybridPlotWorld extends ClassicPlotWorld {
public void setupSchematics() throws SchematicHandler.UnsupportedFormatException {
this.G_SCH = new HashMap<>();
File root = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname);
File root = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(),
"schematics/GEN_ROAD_SCHEMATIC/" + this.worldname);
File schematic1File = new File(root, "sideroad.schem");
if (!schematic1File.exists()) schematic1File = new File(root, "sideroad.schematic");
if (!schematic1File.exists())
schematic1File = new File(root, "sideroad.schematic");
File schematic2File = new File(root, "intersection.schem");
if (!schematic2File.exists()) schematic2File = new File(root, "intersection.schematic");
if (!schematic2File.exists())
schematic2File = new File(root, "intersection.schematic");
File schematic3File = new File(root, "plot.schem");
if (!schematic3File.exists()) schematic3File = new File(root, "plot.schematic");
if (!schematic3File.exists())
schematic3File = new File(root, "plot.schematic");
Schematic schematic1 = SchematicHandler.manager.getSchematic(schematic1File);
Schematic schematic2 = SchematicHandler.manager.getSchematic(schematic2File);
Schematic schematic3 = SchematicHandler.manager.getSchematic(schematic3File);
@ -193,7 +197,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
for (short x = 0; x < w3; x++) {
for (short z = 0; z < l3; z++) {
for (short y = 0; y < h3; y++) {
BaseBlock id = blockArrayClipboard3.getFullBlock(BlockVector3.at(x + min.getBlockX(), y + min.getBlockY(), z + min.getBlockZ()));
BaseBlock id = blockArrayClipboard3.getFullBlock(BlockVector3
.at(x + min.getBlockX(), y + min.getBlockY(), z + min.getBlockZ()));
if (!id.getBlockType().getMaterial().isAir()) {
addOverlayBlock((short) (x + shift + oddshift + centerShiftX),
(short) (y + plotY), (short) (z + shift + oddshift + centerShiftZ),
@ -253,7 +258,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
for (short x = 0; x < w1; x++) {
for (short z = 0; z < l1; z++) {
for (short y = 0; y < h1; y++) {
BaseBlock id = blockArrayClipboard1.getFullBlock(BlockVector3.at(x + min.getBlockX(), y + min.getBlockY(), z + min.getBlockZ()));
BaseBlock id = blockArrayClipboard1.getFullBlock(BlockVector3
.at(x + min.getBlockX(), y + min.getBlockY(), z + min.getBlockZ()));
if (!id.getBlockType().getMaterial().isAir()) {
addOverlayBlock((short) (x - shift), (short) (y + roadY),
(short) (z + shift + oddshift), id, false, h1);
@ -273,7 +279,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
for (short x = 0; x < w2; x++) {
for (short z = 0; z < l2; z++) {
for (short y = 0; y < h2; y++) {
BaseBlock id = blockArrayClipboard2.getFullBlock(BlockVector3.at(x + min.getBlockX(), y + min.getBlockY(), z + min.getBlockZ()));
BaseBlock id = blockArrayClipboard2.getFullBlock(BlockVector3
.at(x + min.getBlockX(), y + min.getBlockY(), z + min.getBlockZ()));
if (!id.getBlockType().getMaterial().isAir()) {
addOverlayBlock((short) (x - shift), (short) (y + roadY),
(short) (z - shift), id, false, h2);

View File

@ -345,7 +345,8 @@ public abstract class HybridUtils {
if (condition) {
BaseBlock[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ));
int minY = plotWorld.SCHEM_Y;
if (!Settings.Schematics.PASTE_ON_TOP) minY = 1;
if (!Settings.Schematics.PASTE_ON_TOP)
minY = 1;
int maxY = Math.max(extend, blocks.length);
if (blocks != null) {
for (int y = 0; y < maxY; y++) {

View File

@ -95,8 +95,7 @@ public class PlotListener {
} else {
MainUtil.sendMessage(player, StringMan
.replaceAll(Captions.GAMEMODE_WAS_BYPASSED.s(), "{plot}",
plot.getId(),
"{gamemode}", gamemodeFlag.get()));
plot.getId(), "{gamemode}", gamemodeFlag.get()));
}
}
}
@ -109,8 +108,7 @@ public class PlotListener {
} else {
MainUtil.sendMessage(player, StringMan
.replaceAll(Captions.GAMEMODE_WAS_BYPASSED.s(), "{plot}",
plot.getId(),
"{gamemode}", guestGamemodeFlag.get()));
plot.getId(), "{gamemode}", guestGamemodeFlag.get()));
}
}
}
@ -158,8 +156,7 @@ public class PlotListener {
}
if (titles) {
if (!Captions.TITLE_ENTERED_PLOT.s().isEmpty() || !Captions.TITLE_ENTERED_PLOT_SUB
.s()
.isEmpty()) {
.s().isEmpty()) {
TaskManager.runTaskLaterAsync(() -> {
Plot lastPlot = player.getMeta(PlotPlayer.META_LAST_PLOT);
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) {
@ -206,8 +203,7 @@ public class PlotListener {
} else {
MainUtil.sendMessage(player, StringMan
.replaceAll(Captions.GAMEMODE_WAS_BYPASSED.s(), "{plot}",
plot.toString(),
"{gamemode}", pw.GAMEMODE.name().toLowerCase()));
plot.toString(), "{gamemode}", pw.GAMEMODE.name().toLowerCase()));
}
}
}
@ -215,10 +211,10 @@ public class PlotListener {
farewell.ifPresent(s -> MainUtil
.format(Captions.PREFIX_FAREWELL.s() + s, plot, player, false,
new RunnableVal<String>() {
@Override public void run(String value) {
MainUtil.sendMessage(player, value);
}
}));
@Override public void run(String value) {
MainUtil.sendMessage(player, value);
}
}));
Optional<Boolean> leave = plot.getFlag(Flags.NOTIFY_LEAVE);
if (leave.isPresent() && leave.get()) {
if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) {

View File

@ -163,8 +163,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
this.Eblocked = true;
PlotSquared.debug(
Captions.PREFIX + "&cdetected unsafe WorldEdit: " + location.getBlockX() + ","
+ location
.getBlockZ());
+ location.getBlockZ());
}
if (WEManager.maskContains(this.mask, location.getBlockX(), location.getBlockY(),
location.getBlockZ())) {

View File

@ -1,7 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.object;
import com.github.intellectualsites.plotsquared.configuration.serialization.ConfigurationSerializable;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
import com.github.intellectualsites.plotsquared.plot.object.collection.RandomCollection;
import com.google.common.collect.ImmutableMap;
@ -56,7 +55,8 @@ import java.util.Map.Entry;
}
private void addBlock(@NonNull final PlotBlock block, double chance) {
if (chance == -1) chance = 1;
if (chance == -1)
chance = 1;
this.blocks.put(block, chance);
this.compiled = false;
if (head == null) {

View File

@ -3,7 +3,8 @@ package com.github.intellectualsites.plotsquared.plot.object;
public enum Direction {
NORTH(0, "north"), EAST(1, "east"), SOUTH(2, "south"), WEST(3, "west"), NORTHEAST(4,
"northeast"), SOUTHEAST(5, "southeast"), SOUTHWEST(6, "southwest"), NORTHWEST(7,
"northwest"),;
"northwest"),
;
private int index;

View File

@ -58,6 +58,7 @@ public class Plot {
* plot owner
* (Merged plots can have multiple owners)
* Direct access is Deprecated: use getOwners()
*
* @deprecated
*/
@Deprecated public UUID owner;
@ -344,6 +345,7 @@ public class Plot {
* plot owner
* (Merged plots can have multiple owners)
* Direct access is Deprecated: use getOwners()
*
* @deprecated
*/
@Deprecated public UUID getOwner() {
@ -353,6 +355,32 @@ public class Plot {
return this.owner;
}
/**
* Sets the plot owner (and update the database)
*
* @param owner uuid to set as owner
*/
public void setOwner(UUID owner) {
if (!hasOwner()) {
this.owner = owner;
create();
return;
}
if (!isMerged()) {
if (!this.owner.equals(owner)) {
this.owner = owner;
DBFunc.setOwner(this, owner);
}
return;
}
for (Plot current : getConnectedPlots()) {
if (!owner.equals(current.owner)) {
current.owner = owner;
DBFunc.setOwner(current, owner);
}
}
}
/**
* Gets a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots).
* <p>
@ -748,32 +776,6 @@ public class Plot {
}
}
/**
* Sets the plot owner (and update the database)
*
* @param owner uuid to set as owner
*/
public void setOwner(UUID owner) {
if (!hasOwner()) {
this.owner = owner;
create();
return;
}
if (!isMerged()) {
if (!this.owner.equals(owner)) {
this.owner = owner;
DBFunc.setOwner(this, owner);
}
return;
}
for (Plot current : getConnectedPlots()) {
if (!owner.equals(current.owner)) {
current.owner = owner;
DBFunc.setOwner(current, owner);
}
}
}
/**
* Sets the plot owner (and update the database)
*

View File

@ -34,7 +34,8 @@ public class PlotId {
*/
@Nonnull public static PlotId fromString(@Nonnull String string) {
PlotId plot = fromStringOrNull(string);
if (plot == null) throw new IllegalArgumentException("Cannot create PlotID. String invalid.");
if (plot == null)
throw new IllegalArgumentException("Cannot create PlotID. String invalid.");
return plot;
}
@ -101,6 +102,7 @@ public class PlotId {
public PlotId getRelative(Direction direction) {
return getRelative(direction.getIndex());
}
/**
* Get the PlotId in a relative direction
* 0 = north<br>

View File

@ -33,6 +33,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Initialize a new {@link PlotLoc} and set the Y value to {@code -1}
*
* @param x X value
* @param z Y value
*/

View File

@ -428,6 +428,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
/**
* Determines whether or not the player can fly.
*
* @return {@code true} if the player is allowed to fly
*/
public abstract boolean getFlight();
@ -466,7 +467,8 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
*/
public void unregister() {
Plot plot = getCurrentPlot();
if (plot != null && Settings.Enabled_Components.PERSISTENT_META && plot.getArea() instanceof SinglePlotArea) {
if (plot != null && Settings.Enabled_Components.PERSISTENT_META && plot
.getArea() instanceof SinglePlotArea) {
PlotId id = plot.getId();
int x = id.x;
int z = id.y;
@ -581,17 +583,21 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
TaskManager.runTask(() -> {
if (getMeta("teleportOnLogin", true)) {
teleport(loc);
sendMessage(Captions.TELEPORTED_TO_PLOT.f() + " (quitLoc) (" + plotX + "," + plotZ + ")");
sendMessage(
Captions.TELEPORTED_TO_PLOT.f() + " (quitLoc) (" + plotX
+ "," + plotZ + ")");
}
});
} else if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
if (getMeta("teleportOnLogin", true)) {
if (plot.teleportPlayer(PlotPlayer.this)) {
TaskManager.runTask(() -> {
if (getMeta("teleportOnLogin",true)) {
if (getMeta("teleportOnLogin", true)) {
if (plot.isLoaded()) {
teleport(loc);
sendMessage(Captions.TELEPORTED_TO_PLOT.f() + " (quitLoc-unloaded) (" + plotX + "," + plotZ + ")");
sendMessage(Captions.TELEPORTED_TO_PLOT.f()
+ " (quitLoc-unloaded) (" + plotX + "," + plotZ
+ ")");
}
}
});

View File

@ -1,7 +1,7 @@
package com.github.intellectualsites.plotsquared.plot.object;
/**
*
*/
public class StringWrapper {

View File

@ -38,8 +38,7 @@ public class FlatRandomCollection<T> extends RandomCollection<T> {
this.values = (T[]) parsed.toArray();
}
@Override
public T next() {
@Override public T next() {
return values[random.nextInt(values.length)];
}
}

View File

@ -20,14 +20,14 @@ public abstract class RandomCollection<T> {
}
}
public Random getRandom() {
return random;
}
public void setRandom(Random random) {
checkNotNull(random);
this.random = random;
}
public Random getRandom() {
return random;
}
public abstract T next();
}

View File

@ -18,7 +18,8 @@ public class SimpleRandomCollection<E> extends RandomCollection<E> {
}
public void add(double weight, E result) {
if (weight <= 0) return;
if (weight <= 0)
return;
total += weight;
map.put(total, result);
}

View File

@ -5,13 +5,7 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.generator.GridPlotWorld;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotLoc;
import com.github.intellectualsites.plotsquared.plot.object.PlotSettings;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
@ -66,13 +60,15 @@ public class SinglePlotArea extends GridPlotWorld {
File levelDat = new File(src, "level.dat");
if (levelDat.exists()) {
try {
Files.copy(levelDat.toPath(), new File(dest, levelDat.getName()).toPath());
Files.copy(levelDat.toPath(),
new File(dest, levelDat.getName()).toPath());
File data = new File(src, "data");
if (data.exists()) {
File dataDest = new File(dest, "data");
dataDest.mkdirs();
for (File file : data.listFiles()) {
Files.copy(file.toPath(), new File(dataDest, file.getName()).toPath());
Files.copy(file.toPath(),
new File(dataDest, file.getName()).toPath());
}
}
} catch (IOException ignore) {

View File

@ -96,7 +96,9 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
if (found != null && found.length != 0) {
return found;
}
return isWorld(world) || world.equals("*") ? array : all.length == 0 ? noPlotAreas : super.getPlotAreas(world, region);
return isWorld(world) || world.equals("*") ?
array :
all.length == 0 ? noPlotAreas : super.getPlotAreas(world, region);
}
@Override public PlotArea[] getAllPlotAreas() {

View File

@ -12,9 +12,11 @@ import java.util.concurrent.ConcurrentHashMap;
public abstract class ChunkManager {
private static final Map<ChunkLoc, RunnableVal<ScopedLocalBlockQueue>> forceChunks =
new ConcurrentHashMap<>();
private static final Map<ChunkLoc, RunnableVal<ScopedLocalBlockQueue>> addChunks =
new ConcurrentHashMap<>();
public static ChunkManager manager = null;
private static final Map<ChunkLoc, RunnableVal<ScopedLocalBlockQueue>> forceChunks = new ConcurrentHashMap<>();
private static final Map<ChunkLoc, RunnableVal<ScopedLocalBlockQueue>> addChunks = new ConcurrentHashMap<>();
public static ChunkLoc getChunkChunk(Location location) {
int x = location.getX() >> 9;

View File

@ -8,7 +8,6 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import javax.annotation.Nullable;
@ -77,7 +76,8 @@ public abstract class EventUtil {
}
}
final Plot plot = player.getCurrentPlot();
if (Settings.Teleport.ON_LOGIN && plot != null && !(plot.getArea() instanceof SinglePlotArea)) {
if (Settings.Teleport.ON_LOGIN && plot != null && !(plot
.getArea() instanceof SinglePlotArea)) {
TaskManager.runTask(() -> plot.teleportPlayer(player));
MainUtil.sendMessage(player,
Captions.TELEPORTED_TO_ROAD.f() + " (on-login) " + "(" + plot.getId().x + ";" + plot
@ -154,8 +154,8 @@ public abstract class EventUtil {
if (plot.hasOwner()) {
return Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)
|| !(
!notifyPerms || MainUtil.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
|| !(!notifyPerms || MainUtil
.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
Captions.FLAG_HANGING_BREAK.s()));
}
return Permissions
@ -173,8 +173,8 @@ public abstract class EventUtil {
if (plot.hasOwner()) {
return Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)
|| !(
!notifyPerms || MainUtil.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
|| !(!notifyPerms || MainUtil
.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
Captions.FLAG_MISC_BREAK.s()));
}
return Permissions
@ -219,9 +219,8 @@ public abstract class EventUtil {
.contains(block.getPlotBlock())) {
return Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)
|| !(
!notifyPerms || MainUtil.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
Captions.FLAG_USE.s()));
|| !(!notifyPerms || MainUtil
.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE, Captions.FLAG_USE.s()));
}
return true;
}

View File

@ -115,10 +115,10 @@ import java.util.Map;
if (worldSection.contains(entry.getKey())) {
if (entry.getValue() == ConfigurationType.BLOCK) {
this.convertBlock(worldSection, entry.getKey(),
worldSection.getString(entry.getKey()));
worldSection.getString(entry.getKey()));
} else {
this.convertBlockList(worldSection, entry.getKey(),
worldSection.getStringList(entry.getKey()));
worldSection.getStringList(entry.getKey()));
}
}
}

View File

@ -735,7 +735,8 @@ public class MainUtil {
seen = Captions.NEVER.s();
}
Optional<String> descriptionFlag = plot.getFlag(Flags.DESCRIPTION);
String description = !descriptionFlag.isPresent() ? Captions.NONE.s() :
String description = !descriptionFlag.isPresent() ?
Captions.NONE.s() :
Flags.DESCRIPTION.valueToString(descriptionFlag.get());
StringBuilder flags = new StringBuilder();
@ -779,10 +780,12 @@ public class MainUtil {
TaskManager.runTaskAsync(() -> {
String info1;
if (Settings.Ratings.USE_LIKES) {
info1 = newInfo.replaceAll("%rating%", String.format("%.0f%%", Like.getLikesPercentage(plot) * 100D));
info1 = newInfo.replaceAll("%rating%",
String.format("%.0f%%", Like.getLikesPercentage(plot) * 100D));
} else {
int max = 10;
if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) {
if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES
.isEmpty()) {
max = 8;
}
if (full && Settings.Ratings.CATEGORIES != null

View File

@ -253,9 +253,11 @@ public abstract class SchematicHandler {
if (!name.endsWith(".schem") && !name.endsWith(".schematic")) {
name = name + ".schem";
}
File file = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), Settings.Paths.SCHEMATICS + File.separator + name);
File file = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(),
Settings.Paths.SCHEMATICS + File.separator + name);
if (!file.exists()) {
file = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), Settings.Paths.SCHEMATICS + File.separator + name + "atic");
file = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(),
Settings.Paths.SCHEMATICS + File.separator + name + "atic");
}
return getSchematic(file);
}
@ -270,7 +272,8 @@ public abstract class SchematicHandler {
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), Settings.Paths.SCHEMATICS);
final List<String> names = new ArrayList<>();
if (parent.exists()) {
final String[] rawNames = parent.list((dir, name) -> name.endsWith(".schematic") || name.endsWith(".schem"));
final String[] rawNames =
parent.list((dir, name) -> name.endsWith(".schematic") || name.endsWith(".schem"));
if (rawNames != null) {
final List<String> transformed = Arrays.stream(rawNames)
.map(rawName -> rawName.substring(0, rawName.length() - 10))

View File

@ -29,15 +29,14 @@ public class UpdateUtility {
private void fetchLatestBuildInfo(final BiConsumer<BuildInfo, Throwable> whenDone) {
this.jenkins.getJobInfo(jobName).whenCompleteAsync((jobInfo, exception) -> {
if (jobInfo == null && exception != null) {
whenDone.accept(null, exception);
} else if (jobInfo != null) {
jobInfo.getLastSuccessfulBuild().getBuildInfo()
.whenComplete(whenDone);
} else {
whenDone.accept(null, new IllegalStateException(
String.format("Could not fetch job info for job %s", this.jobName)));
}
if (jobInfo == null && exception != null) {
whenDone.accept(null, exception);
} else if (jobInfo != null) {
jobInfo.getLastSuccessfulBuild().getBuildInfo().whenComplete(whenDone);
} else {
whenDone.accept(null, new IllegalStateException(
String.format("Could not fetch job info for job %s", this.jobName)));
}
});
}
@ -47,17 +46,19 @@ public class UpdateUtility {
whenDone.accept(null, throwable);
} else {
final Collection<ArtifactDescription> artifacts = buildInfo.getArtifacts();
final Optional<ArtifactDescription> artifact = artifacts.stream().filter(artifactDescription -> {
final String name = artifactDescription.getFileName();
final Matcher matcher = artifactPattern.matcher(name);
return matcher.matches();
}).findAny();
final Optional<ArtifactDescription> artifact =
artifacts.stream().filter(artifactDescription -> {
final String name = artifactDescription.getFileName();
final Matcher matcher = artifactPattern.matcher(name);
return matcher.matches();
}).findAny();
if (artifact.isPresent()) {
final ArtifactDescription artifactDescription = artifact.get();
whenDone.accept(artifactDescription, null);
} else {
whenDone.accept(null,
new NullPointerException(String.format("Could not find any matching artifacts in build %d", buildInfo.getId())));
whenDone.accept(null, new NullPointerException(String
.format("Could not find any matching artifacts in build %d",
buildInfo.getId())));
}
}
});
@ -67,30 +68,34 @@ public class UpdateUtility {
final BiConsumer<UpdateDescription, Throwable> whenDone) {
this.getMatchingArtifact(((artifactDescription, throwable) -> {
if (throwable != null) {
whenDone.accept(null, new RuntimeException(
String.format("Failed to read artifact description: %s", throwable.getMessage()), throwable));
whenDone.accept(null, new RuntimeException(String
.format("Failed to read artifact description: %s", throwable.getMessage()),
throwable));
} else {
try {
final String version = this.isNewer(currentVersion, artifactDescription);
if (version != null) {
whenDone.accept(new UpdateDescription(version, artifactDescription.getUrl()),
null);
whenDone
.accept(new UpdateDescription(version, artifactDescription.getUrl()),
null);
} else {
whenDone.accept(null, null);
}
} catch (final Throwable exception) {
whenDone.accept(null,
new RuntimeException(String.format("Failed to compare versions: %s",
exception.getMessage()), exception));
whenDone.accept(null, new RuntimeException(
String.format("Failed to compare versions: %s", exception.getMessage()),
exception));
}
}
}));
}
private String isNewer(@NonNull final String currentVersion, @NonNull final ArtifactDescription artifact) {
private String isNewer(@NonNull final String currentVersion,
@NonNull final ArtifactDescription artifact) {
final Matcher matcher = artifactPattern.matcher(artifact.getFileName());
if (!matcher.matches()) {
throw new IllegalArgumentException("Artifact file name does not match artifact pattern");
throw new IllegalArgumentException(
"Artifact file name does not match artifact pattern");
}
final String version = matcher.group("version");
if (version == null) {
@ -101,12 +106,14 @@ public class UpdateUtility {
/**
* Compare two given versions in the format $major.$minor
*
* @param oldVersion current version
* @param newVersion other version
* @return -1 if the current version is older, 1 is the versions are the same,
* and 1 if the current version is newer
* and 1 if the current version is newer
*/
private int compareVersions(@NonNull final String oldVersion, @NonNull final String newVersion) {
private int compareVersions(@NonNull final String oldVersion,
@NonNull final String newVersion) {
// Versions look this this: major.minor :P
final int[] oldNums = splitVersion(oldVersion);
final int[] newNums = splitVersion(newVersion);
@ -131,16 +138,18 @@ public class UpdateUtility {
private int[] splitVersion(@NonNull final String versionString) {
final String[] parts = versionString.split("\\.");
switch (parts.length) {
case 0: return new int[] {-1, -1};
case 1: return new int[] {-1, Integer.parseInt(parts[0])};
case 2: return new int[] {Integer.parseInt(parts[0]), Integer.parseInt(parts[1])};
default: return null;
case 0:
return new int[] {-1, -1};
case 1:
return new int[] {-1, Integer.parseInt(parts[0])};
case 2:
return new int[] {Integer.parseInt(parts[0]), Integer.parseInt(parts[1])};
default:
return null;
}
}
@Getter
@RequiredArgsConstructor
public static class UpdateDescription {
@Getter @RequiredArgsConstructor public static class UpdateDescription {
private final String version;
private final String url;
}

View File

@ -5,11 +5,9 @@ This will increase a player's allowed plots by the provided value
var uuid = UUIDHandler.getUUID('%s0', null);
if (uuid === null) {
C_INVALID_PLAYER.send(PlotPlayer, '%s0');
}
else if (!MathMan.class.static.isInteger('%s1')) {
} else if (!MathMan.class.static.isInteger('%s1')) {
C_NOT_VALID_NUMBER.send(PlotPlayer, '(0, ' + Settings.MAX_PLOTS + ')');
}
else {
} else {
var amount = parseInt('%s1');
var pp = IMP.wrapPlayer(UUIDHandler.getUUIDWrapper().getOfflinePlayer(uuid).player);
var allowed = pp.getAllowedPlots();

View File

@ -35,14 +35,12 @@ if ("%s0" === "true") {
var plot = plots.get(i);
plot.autoMerge(-1, 250000, plot.owner, true);
}
}
else if ("%s0" === "false") {
} else if ("%s0" === "false") {
for (var i = 0; i < plots.size(); i++) {
var plot = plots.get(i);
plot.autoMerge(-1, 250000, plot.owner, false);
}
}
else {
} else {
C_COMMAND_SYNTAX.send(PlotPlayer, "/plot debugexec automerge.js <removeroads>");
MainUtil.class.static.sendMessage(PlotPlayer, "$1<removeroads> is true or false if you want to remove roads when auto merging");
}

View File

@ -27,7 +27,6 @@ if (PS.hasPlotArea("%s0")) {
}
}
PS.class.static.log(plot);
}
else {
} else {
PlotPlayer.sendMessage("Usage: /plot debugexec runasync furthest.js <plotworld>");
}