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

View File

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

View File

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

View File

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

View File

@ -117,8 +117,9 @@ public class BukkitPlotGenerator extends ChunkGenerator
return toAdd; return toAdd;
} }
@Override @NotNull public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, @Override @NotNull
int x, int z, @NotNull BiomeGrid biome) { 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 (this.getPlotGenerator() instanceof SingleWorldGenerator) {

View File

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

View File

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

View File

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

View File

@ -132,11 +132,11 @@ import java.util.UUID;
Player player = event.getPlayer(); Player player = event.getPlayer();
Plot plot = event.getPlot(); Plot plot = event.getPlot();
Optional<IntervalFlag.Interval> feed = plot.getFlag(Flags.FEED); Optional<IntervalFlag.Interval> feed = plot.getFlag(Flags.FEED);
feed.ifPresent( feed.ifPresent(value -> feedRunnable
value -> feedRunnable.put(player.getUniqueId(), new Interval(value.getVal1(), value.getVal2(), 20))); .put(player.getUniqueId(), new Interval(value.getVal1(), value.getVal2(), 20)));
Optional<IntervalFlag.Interval> heal = plot.getFlag(Flags.HEAL); Optional<IntervalFlag.Interval> heal = plot.getFlag(Flags.HEAL);
heal.ifPresent( heal.ifPresent(value -> healRunnable
value -> healRunnable.put(player.getUniqueId(), new Interval(value.getVal1(), value.getVal2(), 20))); .put(player.getUniqueId(), new Interval(value.getVal1(), value.getVal2(), 20)));
} }
@EventHandler public void onPlayerQuit(PlayerQuitEvent event) { @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.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.*;
import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -17,13 +16,8 @@ import org.bukkit.event.Event;
import org.bukkit.event.EventException; import org.bukkit.event.EventException;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; 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.PermissionAttachmentInfo;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.RegisteredListener; import org.bukkit.plugin.RegisteredListener;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.Arrays; import java.util.Arrays;
@ -33,6 +27,7 @@ import java.util.stream.Collectors;
public class BukkitPlayer extends PlotPlayer { public class BukkitPlayer extends PlotPlayer {
private static boolean CHECK_EFFECTIVE = true;
public final Player player; public final Player player;
private boolean offline; private boolean offline;
private UUID uuid; private UUID uuid;
@ -105,8 +100,6 @@ public class BukkitPlayer extends PlotPlayer {
return this.player.hasPermission(permission); return this.player.hasPermission(permission);
} }
private static boolean CHECK_EFFECTIVE = true;
@Override public int hasPermissionRange(String stub, int range) { @Override public int hasPermissionRange(String stub, int range) {
if (hasPermission(Captions.PERMISSION_ADMIN.s())) { if (hasPermission(Captions.PERMISSION_ADMIN.s())) {
return Integer.MAX_VALUE; return Integer.MAX_VALUE;

View File

@ -408,7 +408,8 @@ public class TitleManager_1_11 {
private Method getMethod(Class<?> clazz, String name, Class<?>... args) { private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
for (Method m : clazz.getMethods()) { 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); m.setAccessible(true);
return m; 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, public void unloadChunk(final String world, final ChunkLoc loc, final boolean save,
final boolean safe) { final boolean safe) {
if (!PlotSquared.get().isMainThread(Thread.currentThread())) { if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
TaskManager TaskManager.runTask(() -> BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save));
.runTask(() -> BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save));
} else { } else {
BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save); 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); PlotSquared.get().worlds.createSection(worldPath);
} }
if (steps.length != 0) { if (steps.length != 0) {
ConfigurationSection worldSection = PlotSquared.get().worlds.getConfigurationSection(worldPath); ConfigurationSection worldSection =
PlotSquared.get().worlds.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) { for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue()); worldSection.set(step.getConstant(), step.getValue());
} }
} }
PlotSquared.get().worlds.set("worlds." + world + ".generator.type", object.type); PlotSquared.get().worlds
PlotSquared.get().worlds.set("worlds." + world + ".generator.terrain", object.terrain); .set("worlds." + world + ".generator.type", object.type);
PlotSquared.get().worlds.set("worlds." + world + ".generator.plugin", object.plotManager); PlotSquared.get().worlds
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) { .set("worlds." + world + ".generator.terrain", object.terrain);
PlotSquared.get().worlds.set("worlds." + world + ".generator.init", object.setupGenerator); 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); GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);

View File

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

View File

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

View File

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

View File

@ -15,8 +15,11 @@ import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
import java.util.Set; 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) @CommandDeclaration(command = "area", permission = "plots.area",
public class Area extends SubCommand { 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) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 0) { 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; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@CommandDeclaration(command = "chat", description = "Toggle plot chat on or off", @CommandDeclaration(command = "chat", description = "Toggle plot chat on or off",
usage = "/plot chat [on|off]", permission = "plots.chat", category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER) usage = "/plot chat [on|off]", permission = "plots.chat", category = CommandCategory.CHAT,
public class Chat extends SubCommand { requiredType = RequiredType.PLAYER) public class Chat extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
MainCommand.getInstance().toggle.chat(this, player, new String[0], null, null); MainCommand.getInstance().toggle.chat(this, player, new String[0], null, null);

View File

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

View File

@ -11,31 +11,39 @@ import lombok.RequiredArgsConstructor;
* Claiming CommandConfig. * Claiming CommandConfig.
* Such as: /plot claim * Such as: /plot claim
*/ */
CLAIMING(Captions.COMMAND_CATEGORY_CLAIMING), /** CLAIMING(Captions.COMMAND_CATEGORY_CLAIMING),
/**
* Teleportation CommandConfig. * Teleportation CommandConfig.
* Such as: /plot visit * Such as: /plot visit
*/ */
TELEPORT(Captions.COMMAND_CATEGORY_TELEPPORT), /** TELEPORT(Captions.COMMAND_CATEGORY_TELEPPORT),
/**
* Protection. * Protection.
*/ */
SETTINGS(Captions.COMMAND_CATEGORY_SETTINGS), /** SETTINGS(Captions.COMMAND_CATEGORY_SETTINGS),
/**
* Chat. * Chat.
*/ */
CHAT(Captions.COMMAND_CATEGORY_CHAT), /** CHAT(Captions.COMMAND_CATEGORY_CHAT),
/**
* Web. * Web.
*/ */
SCHEMATIC(Captions.COMMAND_CATEGORY_SCHEMATIC), /** SCHEMATIC(Captions.COMMAND_CATEGORY_SCHEMATIC),
/**
* Cosmetic. * Cosmetic.
*/ */
APPEARANCE(Captions.COMMAND_CATEGORY_APPEARANCE), /** APPEARANCE(Captions.COMMAND_CATEGORY_APPEARANCE),
/**
* Information CommandConfig. * Information CommandConfig.
* Such as: /plot info * Such as: /plot info
*/ */
INFO(Captions.COMMAND_CATEGORY_INFO), /** INFO(Captions.COMMAND_CATEGORY_INFO),
/**
* Debug CommandConfig. * Debug CommandConfig.
* Such as: /plot debug * Such as: /plot debug
*/ */
DEBUG(Captions.COMMAND_CATEGORY_DEBUG), /** DEBUG(Captions.COMMAND_CATEGORY_DEBUG),
/**
* Administration commands. * Administration commands.
*/ */
ADMINISTRATION(Captions.COMMAND_CATEGORY_ADMINISTRATION); 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.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import java.util.*;
import java.util.Set; import java.util.Set;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@CommandDeclaration(command = "condense", permission = "plots.admin", @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.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; 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.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
@ -38,7 +37,8 @@ import java.util.UUID;
PlotId id = new PlotId(0, 0); PlotId id = new PlotId(0, 0);
File container = PlotSquared.imp().getWorldContainer(); File container = PlotSquared.imp().getWorldContainer();
if (container.equals(new File("."))) { 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; return;
} }
for (File folder : container.listFiles()) { 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.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@CommandDeclaration(command = "dislike", permission = "plots.dislike", description = "Dislike the plot", @CommandDeclaration(command = "dislike", permission = "plots.dislike",
usage = "/plot dislike [next|purge]", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER) description = "Dislike the plot", usage = "/plot dislike [next|purge]",
public class Dislike extends SubCommand { category = CommandCategory.INFO, requiredType = RequiredType.PLAYER) public class Dislike
extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
return Like.handleLike(player, args, false); return Like.handleLike(player, args, false);

View File

@ -79,8 +79,7 @@ public class Help extends Command {
for (CommandCategory c : CommandCategory.values()) { for (CommandCategory c : CommandCategory.values()) {
builder.append("\n" + StringMan builder.append("\n" + StringMan
.replaceAll(Captions.HELP_INFO_ITEM.s(), "%category%", .replaceAll(Captions.HELP_INFO_ITEM.s(), "%category%",
c.toString().toLowerCase(), c.toString().toLowerCase(), "%category_desc%", c.toString()));
"%category_desc%", c.toString()));
} }
builder.append("\n").append(Captions.HELP_INFO_ITEM.s().replaceAll("%category%", "all") builder.append("\n").append(Captions.HELP_INFO_ITEM.s().replaceAll("%category%", "all")
.replaceAll("%category_desc%", Captions.HELP_DISPLAY_ALL_COMMANDS.s())); .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; import java.util.UUID;
@CommandDeclaration(command = "info", aliases = "i", description = "Display plot info", @CommandDeclaration(command = "info", aliases = "i", description = "Display plot info",
usage = "/plot info <id> [-f, to force info]", category = CommandCategory.INFO) public class Info usage = "/plot info <id> [-f, to force info]", category = CommandCategory.INFO)
extends SubCommand { public class Info extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
Plot plot; Plot plot;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,17 +23,16 @@ public abstract class SubCommand extends Command {
setRequiredArguments(arguments); 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, @Override public void execute(PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
onCommand(player, args); onCommand(player, args);
} }
public abstract boolean onCommand(PlotPlayer player, String[] 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.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.*;
@CommandDeclaration(command = "unlink", aliases = {"u", @CommandDeclaration(command = "unlink", aliases = {"u", "unmerge"},
"unmerge"}, description = "Unlink a mega-plot", usage = "/plot unlink [createroads]", requiredType = RequiredType.PLAYER, category = CommandCategory.SETTINGS, confirmation = true) description = "Unlink a mega-plot", usage = "/plot unlink [createroads]",
requiredType = RequiredType.PLAYER, category = CommandCategory.SETTINGS, confirmation = true)
public class Unlink extends SubCommand { public class Unlink extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @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.*; import java.util.*;
@CommandDeclaration(command = "visit", permission = "plots.visit", @CommandDeclaration(command = "visit", permission = "plots.visit",
description = "Visit someones plot", usage = "/plot visit [<player>|<alias>|<world>|<id>] [#]", aliases = { description = "Visit someones plot", usage = "/plot visit [<player>|<alias>|<world>|<id>] [#]",
"v", "tp", "teleport", "goto", "home", "h"}, requiredType = RequiredType.PLAYER, aliases = {"v", "tp", "teleport", "goto", "home", "h"}, requiredType = RequiredType.PLAYER,
category = CommandCategory.TELEPORT) public class Visit extends Command { category = CommandCategory.TELEPORT) public class Visit extends Command {
public Visit() { public Visit() {

View File

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

View File

@ -317,8 +317,7 @@ public class Settings extends Config {
public static final class Ratings { public static final class Ratings {
@Comment("Replace the rating system with a like system. Will add /plot like/dislike," @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; + " and remove the rating command") public static boolean USE_LIKES = false;
@Comment("Rating categories") @Comment("Rating categories") public static List<String> CATEGORIES = new ArrayList<>();
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.add(new FileBytes(newDir + "intersection.schem",
Files.readAllBytes(intersection.toPath()))); Files.readAllBytes(intersection.toPath())));
} }
File plot = File plot = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "plot.schem");
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "plot.schem");
if (plot.exists()) { if (plot.exists()) {
files.add( files.add(new FileBytes(newDir + "plot.schem", Files.readAllBytes(plot.toPath())));
new FileBytes(newDir + "plot.schem", Files.readAllBytes(plot.toPath())));
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -34,8 +34,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
public short PATH_WIDTH_LOWER; public short PATH_WIDTH_LOWER;
public short PATH_WIDTH_UPPER; public short PATH_WIDTH_UPPER;
public HashMap<Integer, BaseBlock[]> G_SCH; public HashMap<Integer, BaseBlock[]> G_SCH;
private Location SIGN_LOCATION;
public int SCHEM_Y; public int SCHEM_Y;
private Location SIGN_LOCATION;
public HybridPlotWorld(String worldName, String id, IndependentPlotGenerator generator, public HybridPlotWorld(String worldName, String id, IndependentPlotGenerator generator,
PlotId min, PlotId max) { PlotId min, PlotId max) {
@ -134,13 +134,17 @@ public class HybridPlotWorld extends ClassicPlotWorld {
public void setupSchematics() throws SchematicHandler.UnsupportedFormatException { public void setupSchematics() throws SchematicHandler.UnsupportedFormatException {
this.G_SCH = new HashMap<>(); 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"); 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"); 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"); 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 schematic1 = SchematicHandler.manager.getSchematic(schematic1File);
Schematic schematic2 = SchematicHandler.manager.getSchematic(schematic2File); Schematic schematic2 = SchematicHandler.manager.getSchematic(schematic2File);
Schematic schematic3 = SchematicHandler.manager.getSchematic(schematic3File); Schematic schematic3 = SchematicHandler.manager.getSchematic(schematic3File);
@ -193,7 +197,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
for (short x = 0; x < w3; x++) { for (short x = 0; x < w3; x++) {
for (short z = 0; z < l3; z++) { for (short z = 0; z < l3; z++) {
for (short y = 0; y < h3; y++) { 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()) { if (!id.getBlockType().getMaterial().isAir()) {
addOverlayBlock((short) (x + shift + oddshift + centerShiftX), addOverlayBlock((short) (x + shift + oddshift + centerShiftX),
(short) (y + plotY), (short) (z + shift + oddshift + centerShiftZ), (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 x = 0; x < w1; x++) {
for (short z = 0; z < l1; z++) { for (short z = 0; z < l1; z++) {
for (short y = 0; y < h1; y++) { 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()) { if (!id.getBlockType().getMaterial().isAir()) {
addOverlayBlock((short) (x - shift), (short) (y + roadY), addOverlayBlock((short) (x - shift), (short) (y + roadY),
(short) (z + shift + oddshift), id, false, h1); (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 x = 0; x < w2; x++) {
for (short z = 0; z < l2; z++) { for (short z = 0; z < l2; z++) {
for (short y = 0; y < h2; y++) { 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()) { if (!id.getBlockType().getMaterial().isAir()) {
addOverlayBlock((short) (x - shift), (short) (y + roadY), addOverlayBlock((short) (x - shift), (short) (y + roadY),
(short) (z - shift), id, false, h2); (short) (z - shift), id, false, h2);

View File

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

View File

@ -95,8 +95,7 @@ public class PlotListener {
} else { } else {
MainUtil.sendMessage(player, StringMan MainUtil.sendMessage(player, StringMan
.replaceAll(Captions.GAMEMODE_WAS_BYPASSED.s(), "{plot}", .replaceAll(Captions.GAMEMODE_WAS_BYPASSED.s(), "{plot}",
plot.getId(), plot.getId(), "{gamemode}", gamemodeFlag.get()));
"{gamemode}", gamemodeFlag.get()));
} }
} }
} }
@ -109,8 +108,7 @@ public class PlotListener {
} else { } else {
MainUtil.sendMessage(player, StringMan MainUtil.sendMessage(player, StringMan
.replaceAll(Captions.GAMEMODE_WAS_BYPASSED.s(), "{plot}", .replaceAll(Captions.GAMEMODE_WAS_BYPASSED.s(), "{plot}",
plot.getId(), plot.getId(), "{gamemode}", guestGamemodeFlag.get()));
"{gamemode}", guestGamemodeFlag.get()));
} }
} }
} }
@ -158,8 +156,7 @@ public class PlotListener {
} }
if (titles) { if (titles) {
if (!Captions.TITLE_ENTERED_PLOT.s().isEmpty() || !Captions.TITLE_ENTERED_PLOT_SUB if (!Captions.TITLE_ENTERED_PLOT.s().isEmpty() || !Captions.TITLE_ENTERED_PLOT_SUB
.s() .s().isEmpty()) {
.isEmpty()) {
TaskManager.runTaskLaterAsync(() -> { TaskManager.runTaskLaterAsync(() -> {
Plot lastPlot = player.getMeta(PlotPlayer.META_LAST_PLOT); Plot lastPlot = player.getMeta(PlotPlayer.META_LAST_PLOT);
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) { if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) {
@ -206,8 +203,7 @@ public class PlotListener {
} else { } else {
MainUtil.sendMessage(player, StringMan MainUtil.sendMessage(player, StringMan
.replaceAll(Captions.GAMEMODE_WAS_BYPASSED.s(), "{plot}", .replaceAll(Captions.GAMEMODE_WAS_BYPASSED.s(), "{plot}",
plot.toString(), plot.toString(), "{gamemode}", pw.GAMEMODE.name().toLowerCase()));
"{gamemode}", pw.GAMEMODE.name().toLowerCase()));
} }
} }
} }

View File

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

View File

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

View File

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

View File

@ -58,6 +58,7 @@ public class Plot {
* plot owner * plot owner
* (Merged plots can have multiple owners) * (Merged plots can have multiple owners)
* Direct access is Deprecated: use getOwners() * Direct access is Deprecated: use getOwners()
*
* @deprecated * @deprecated
*/ */
@Deprecated public UUID owner; @Deprecated public UUID owner;
@ -344,6 +345,7 @@ public class Plot {
* plot owner * plot owner
* (Merged plots can have multiple owners) * (Merged plots can have multiple owners)
* Direct access is Deprecated: use getOwners() * Direct access is Deprecated: use getOwners()
*
* @deprecated * @deprecated
*/ */
@Deprecated public UUID getOwner() { @Deprecated public UUID getOwner() {
@ -353,6 +355,32 @@ public class Plot {
return this.owner; 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). * Gets a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots).
* <p> * <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) * 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) { @Nonnull public static PlotId fromString(@Nonnull String string) {
PlotId plot = fromStringOrNull(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; return plot;
} }
@ -101,6 +102,7 @@ public class PlotId {
public PlotId getRelative(Direction direction) { public PlotId getRelative(Direction direction) {
return getRelative(direction.getIndex()); return getRelative(direction.getIndex());
} }
/** /**
* Get the PlotId in a relative direction * Get the PlotId in a relative direction
* 0 = north<br> * 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} * Initialize a new {@link PlotLoc} and set the Y value to {@code -1}
*
* @param x X value * @param x X value
* @param z Y 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. * Determines whether or not the player can fly.
*
* @return {@code true} if the player is allowed to fly * @return {@code true} if the player is allowed to fly
*/ */
public abstract boolean getFlight(); public abstract boolean getFlight();
@ -466,7 +467,8 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
*/ */
public void unregister() { public void unregister() {
Plot plot = getCurrentPlot(); 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(); PlotId id = plot.getId();
int x = id.x; int x = id.x;
int z = id.y; int z = id.y;
@ -581,17 +583,21 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
TaskManager.runTask(() -> { TaskManager.runTask(() -> {
if (getMeta("teleportOnLogin", true)) { if (getMeta("teleportOnLogin", true)) {
teleport(loc); 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())) { } else if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
if (getMeta("teleportOnLogin", true)) { if (getMeta("teleportOnLogin", true)) {
if (plot.teleportPlayer(PlotPlayer.this)) { if (plot.teleportPlayer(PlotPlayer.this)) {
TaskManager.runTask(() -> { TaskManager.runTask(() -> {
if (getMeta("teleportOnLogin",true)) { if (getMeta("teleportOnLogin", true)) {
if (plot.isLoaded()) { if (plot.isLoaded()) {
teleport(loc); 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; package com.github.intellectualsites.plotsquared.plot.object;
/** /**
*
*/ */
public class StringWrapper { public class StringWrapper {

View File

@ -38,8 +38,7 @@ public class FlatRandomCollection<T> extends RandomCollection<T> {
this.values = (T[]) parsed.toArray(); this.values = (T[]) parsed.toArray();
} }
@Override @Override public T next() {
public T next() {
return values[random.nextInt(values.length)]; 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) { public void setRandom(Random random) {
checkNotNull(random); checkNotNull(random);
this.random = random; this.random = random;
} }
public Random getRandom() {
return random;
}
public abstract T next(); public abstract T next();
} }

View File

@ -18,7 +18,8 @@ public class SimpleRandomCollection<E> extends RandomCollection<E> {
} }
public void add(double weight, E result) { public void add(double weight, E result) {
if (weight <= 0) return; if (weight <= 0)
return;
total += weight; total += weight;
map.put(total, result); 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.Configuration;
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode; import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.generator.GridPlotWorld; import com.github.intellectualsites.plotsquared.plot.generator.GridPlotWorld;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.*;
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.util.SetupUtils; import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
@ -66,13 +60,15 @@ public class SinglePlotArea extends GridPlotWorld {
File levelDat = new File(src, "level.dat"); File levelDat = new File(src, "level.dat");
if (levelDat.exists()) { if (levelDat.exists()) {
try { 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"); File data = new File(src, "data");
if (data.exists()) { if (data.exists()) {
File dataDest = new File(dest, "data"); File dataDest = new File(dest, "data");
dataDest.mkdirs(); dataDest.mkdirs();
for (File file : data.listFiles()) { 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) { } catch (IOException ignore) {

View File

@ -96,7 +96,9 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
if (found != null && found.length != 0) { if (found != null && found.length != 0) {
return found; 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() { @Override public PlotArea[] getAllPlotAreas() {

View File

@ -12,9 +12,11 @@ import java.util.concurrent.ConcurrentHashMap;
public abstract class ChunkManager { 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; 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) { public static ChunkLoc getChunkChunk(Location location) {
int x = location.getX() >> 9; 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.listener.PlayerBlockEventType;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea; 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 com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -77,7 +76,8 @@ public abstract class EventUtil {
} }
} }
final Plot plot = player.getCurrentPlot(); 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)); TaskManager.runTask(() -> plot.teleportPlayer(player));
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
Captions.TELEPORTED_TO_ROAD.f() + " (on-login) " + "(" + plot.getId().x + ";" + plot Captions.TELEPORTED_TO_ROAD.f() + " (on-login) " + "(" + plot.getId().x + ";" + plot
@ -154,8 +154,8 @@ public abstract class EventUtil {
if (plot.hasOwner()) { if (plot.hasOwner()) {
return Permissions return Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.s(), false) .hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)
|| !( || !(!notifyPerms || MainUtil
!notifyPerms || MainUtil.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE, .sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
Captions.FLAG_HANGING_BREAK.s())); Captions.FLAG_HANGING_BREAK.s()));
} }
return Permissions return Permissions
@ -173,8 +173,8 @@ public abstract class EventUtil {
if (plot.hasOwner()) { if (plot.hasOwner()) {
return Permissions return Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.s(), false) .hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)
|| !( || !(!notifyPerms || MainUtil
!notifyPerms || MainUtil.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE, .sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
Captions.FLAG_MISC_BREAK.s())); Captions.FLAG_MISC_BREAK.s()));
} }
return Permissions return Permissions
@ -219,9 +219,8 @@ public abstract class EventUtil {
.contains(block.getPlotBlock())) { .contains(block.getPlotBlock())) {
return Permissions return Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.s(), false) .hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)
|| !( || !(!notifyPerms || MainUtil
!notifyPerms || MainUtil.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE, .sendMessage(player, Captions.FLAG_TUTORIAL_USAGE, Captions.FLAG_USE.s()));
Captions.FLAG_USE.s()));
} }
return true; return true;
} }

View File

@ -735,7 +735,8 @@ public class MainUtil {
seen = Captions.NEVER.s(); seen = Captions.NEVER.s();
} }
Optional<String> descriptionFlag = plot.getFlag(Flags.DESCRIPTION); 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()); Flags.DESCRIPTION.valueToString(descriptionFlag.get());
StringBuilder flags = new StringBuilder(); StringBuilder flags = new StringBuilder();
@ -779,10 +780,12 @@ public class MainUtil {
TaskManager.runTaskAsync(() -> { TaskManager.runTaskAsync(() -> {
String info1; String info1;
if (Settings.Ratings.USE_LIKES) { 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 { } else {
int max = 10; int max = 10;
if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) { if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES
.isEmpty()) {
max = 8; max = 8;
} }
if (full && Settings.Ratings.CATEGORIES != null if (full && Settings.Ratings.CATEGORIES != null

View File

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

View File

@ -32,8 +32,7 @@ public class UpdateUtility {
if (jobInfo == null && exception != null) { if (jobInfo == null && exception != null) {
whenDone.accept(null, exception); whenDone.accept(null, exception);
} else if (jobInfo != null) { } else if (jobInfo != null) {
jobInfo.getLastSuccessfulBuild().getBuildInfo() jobInfo.getLastSuccessfulBuild().getBuildInfo().whenComplete(whenDone);
.whenComplete(whenDone);
} else { } else {
whenDone.accept(null, new IllegalStateException( whenDone.accept(null, new IllegalStateException(
String.format("Could not fetch job info for job %s", this.jobName))); String.format("Could not fetch job info for job %s", this.jobName)));
@ -47,7 +46,8 @@ public class UpdateUtility {
whenDone.accept(null, throwable); whenDone.accept(null, throwable);
} else { } else {
final Collection<ArtifactDescription> artifacts = buildInfo.getArtifacts(); final Collection<ArtifactDescription> artifacts = buildInfo.getArtifacts();
final Optional<ArtifactDescription> artifact = artifacts.stream().filter(artifactDescription -> { final Optional<ArtifactDescription> artifact =
artifacts.stream().filter(artifactDescription -> {
final String name = artifactDescription.getFileName(); final String name = artifactDescription.getFileName();
final Matcher matcher = artifactPattern.matcher(name); final Matcher matcher = artifactPattern.matcher(name);
return matcher.matches(); return matcher.matches();
@ -56,8 +56,9 @@ public class UpdateUtility {
final ArtifactDescription artifactDescription = artifact.get(); final ArtifactDescription artifactDescription = artifact.get();
whenDone.accept(artifactDescription, null); whenDone.accept(artifactDescription, null);
} else { } else {
whenDone.accept(null, whenDone.accept(null, new NullPointerException(String
new NullPointerException(String.format("Could not find any matching artifacts in build %d", buildInfo.getId()))); .format("Could not find any matching artifacts in build %d",
buildInfo.getId())));
} }
} }
}); });
@ -67,30 +68,34 @@ public class UpdateUtility {
final BiConsumer<UpdateDescription, Throwable> whenDone) { final BiConsumer<UpdateDescription, Throwable> whenDone) {
this.getMatchingArtifact(((artifactDescription, throwable) -> { this.getMatchingArtifact(((artifactDescription, throwable) -> {
if (throwable != null) { if (throwable != null) {
whenDone.accept(null, new RuntimeException( whenDone.accept(null, new RuntimeException(String
String.format("Failed to read artifact description: %s", throwable.getMessage()), throwable)); .format("Failed to read artifact description: %s", throwable.getMessage()),
throwable));
} else { } else {
try { try {
final String version = this.isNewer(currentVersion, artifactDescription); final String version = this.isNewer(currentVersion, artifactDescription);
if (version != null) { if (version != null) {
whenDone.accept(new UpdateDescription(version, artifactDescription.getUrl()), whenDone
.accept(new UpdateDescription(version, artifactDescription.getUrl()),
null); null);
} else { } else {
whenDone.accept(null, null); whenDone.accept(null, null);
} }
} catch (final Throwable exception) { } catch (final Throwable exception) {
whenDone.accept(null, whenDone.accept(null, new RuntimeException(
new RuntimeException(String.format("Failed to compare versions: %s", String.format("Failed to compare versions: %s", exception.getMessage()),
exception.getMessage()), exception)); 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()); final Matcher matcher = artifactPattern.matcher(artifact.getFileName());
if (!matcher.matches()) { 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"); final String version = matcher.group("version");
if (version == null) { if (version == null) {
@ -101,12 +106,14 @@ public class UpdateUtility {
/** /**
* Compare two given versions in the format $major.$minor * Compare two given versions in the format $major.$minor
*
* @param oldVersion current version * @param oldVersion current version
* @param newVersion other version * @param newVersion other version
* @return -1 if the current version is older, 1 is the versions are the same, * @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 // Versions look this this: major.minor :P
final int[] oldNums = splitVersion(oldVersion); final int[] oldNums = splitVersion(oldVersion);
final int[] newNums = splitVersion(newVersion); final int[] newNums = splitVersion(newVersion);
@ -131,16 +138,18 @@ public class UpdateUtility {
private int[] splitVersion(@NonNull final String versionString) { private int[] splitVersion(@NonNull final String versionString) {
final String[] parts = versionString.split("\\."); final String[] parts = versionString.split("\\.");
switch (parts.length) { switch (parts.length) {
case 0: return new int[] {-1, -1}; case 0:
case 1: return new int[] {-1, Integer.parseInt(parts[0])}; return new int[] {-1, -1};
case 2: return new int[] {Integer.parseInt(parts[0]), Integer.parseInt(parts[1])}; case 1:
default: return null; 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 @Getter @RequiredArgsConstructor public static class UpdateDescription {
@RequiredArgsConstructor
public static class UpdateDescription {
private final String version; private final String version;
private final String url; 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); var uuid = UUIDHandler.getUUID('%s0', null);
if (uuid === null) { if (uuid === null) {
C_INVALID_PLAYER.send(PlotPlayer, '%s0'); 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 + ')'); C_NOT_VALID_NUMBER.send(PlotPlayer, '(0, ' + Settings.MAX_PLOTS + ')');
} } else {
else {
var amount = parseInt('%s1'); var amount = parseInt('%s1');
var pp = IMP.wrapPlayer(UUIDHandler.getUUIDWrapper().getOfflinePlayer(uuid).player); var pp = IMP.wrapPlayer(UUIDHandler.getUUIDWrapper().getOfflinePlayer(uuid).player);
var allowed = pp.getAllowedPlots(); var allowed = pp.getAllowedPlots();

View File

@ -35,14 +35,12 @@ if ("%s0" === "true") {
var plot = plots.get(i); var plot = plots.get(i);
plot.autoMerge(-1, 250000, plot.owner, true); plot.autoMerge(-1, 250000, plot.owner, true);
} }
} } else if ("%s0" === "false") {
else if ("%s0" === "false") {
for (var i = 0; i < plots.size(); i++) { for (var i = 0; i < plots.size(); i++) {
var plot = plots.get(i); var plot = plots.get(i);
plot.autoMerge(-1, 250000, plot.owner, false); plot.autoMerge(-1, 250000, plot.owner, false);
} }
} } else {
else {
C_COMMAND_SYNTAX.send(PlotPlayer, "/plot debugexec automerge.js <removeroads>"); 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"); 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); PS.class.static.log(plot);
} } else {
else {
PlotPlayer.sendMessage("Usage: /plot debugexec runasync furthest.js <plotworld>"); PlotPlayer.sendMessage("Usage: /plot debugexec runasync furthest.js <plotworld>");
} }