Merge branch 'v6' into features/v6/queue-features

# Conflicts:
#	Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java
#	Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotManager.java
#	Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java
This commit is contained in:
dordsor21
2020-10-09 15:23:09 +01:00
43 changed files with 613 additions and 994 deletions

View File

@ -142,8 +142,6 @@ public interface PlotPlatform<P> extends LocaleHolder {
return getInjector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
}
List<Map.Entry<Map.Entry<String, String>, Boolean>> getPluginIds();
/**
* Get the backup manager instance
*
@ -256,6 +254,8 @@ public interface PlotPlatform<P> extends LocaleHolder {
*/
@Nonnull Audience getConsoleAudience();
String getPluginList();
/**
* Load the caption maps
*/

View File

@ -1300,7 +1300,6 @@ public class PlotSquared {
String commitString = br.readLine();
String dateString = br.readLine();
this.version = PlotVersion.tryParse(versionString, commitString, dateString);
System.out.println("Version is " + this.version);
}
} catch (IOException throwable) {
throwable.printStackTrace();

View File

@ -322,7 +322,7 @@ public final class Backup extends Command {
Template.of("reason", error.getMessage())
);
} else {
player.sendMessage(TranslatableCaption.of("backup_load_success"));
player.sendMessage(TranslatableCaption.of("backups.backup_load_success"));
}
}));
}

View File

@ -103,28 +103,21 @@ public class DebugPaste extends SubCommand {
.append("\n");
b.append("online_mode: ").append(!Settings.UUID.OFFLINE).append(';')
.append(!Settings.UUID.OFFLINE).append('\n');
b.append("Plugins:");
for (Map.Entry<Map.Entry<String, String>, Boolean> pluginInfo : PlotSquared
.platform().getPluginIds()) {
Map.Entry<String, String> nameVersion = pluginInfo.getKey();
String name = nameVersion.getKey();
String version = nameVersion.getValue();
boolean enabled = pluginInfo.getValue();
b.append("\n ").append(name).append(":\n ").append("version: '")
.append(version).append('\'').append("\n enabled: ").append(enabled);
}
b.append(PlotSquared.platform().getPluginList());
b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n");
Runtime runtime = Runtime.getRuntime();
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
b.append("Uptime: ").append(
TimeUnit.MINUTES.convert(rb.getUptime(), TimeUnit.MILLISECONDS) + " minutes")
b.append("Uptime: ")
.append(TimeUnit.MINUTES.convert(rb.getUptime(), TimeUnit.MILLISECONDS))
.append(" minutes")
.append('\n');
b.append("JVM Flags: ").append(rb.getInputArguments()).append('\n');
b.append("Free Memory: ").append(runtime.freeMemory() / 1024 / 1024 + " MB")
b.append("Free Memory: ").append(runtime.freeMemory() / 1024 / 1024).append(" MB")
.append('\n');
b.append("Max Memory: ").append(runtime.maxMemory() / 1024 / 1024 + " MB")
b.append("Max Memory: ").append(runtime.maxMemory() / 1024 / 1024).append(" MB")
.append('\n');
b.append("Total Memory: ").append(runtime.totalMemory() / 1024 / 1024).append(" MB")
.append('\n');
b.append("Total Memory: ").append(runtime.totalMemory() / 1024 / 1024 + " MB").append('\n');
b.append("Available Processors: ").append(runtime.availableProcessors()).append('\n');
b.append("Java Name: ").append(rb.getVmName()).append('\n');
b.append("Java Version: '").append(System.getProperty("java.version"))

View File

@ -35,19 +35,21 @@ import com.plotsquared.core.player.PlayerMetaDataKeys;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import java.util.Collection;
import java.util.Locale;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import net.kyori.adventure.text.minimessage.Template;
import com.plotsquared.core.uuid.UUIDMapping;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@CommandDeclaration(command = "grant",
category = CommandCategory.CLAIMING,
@ -86,8 +88,8 @@ public class Grant extends Command {
Template.of("value", String.valueOf(uuids))
);
} else {
final UUID uuid = uuids.toArray(new UUID[0])[0];
PlotPlayer<?> pp = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
final UUIDMapping uuid = uuids.toArray(new UUIDMapping[0])[0];
PlotPlayer<?> pp = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid.getUuid());
if (pp != null) {
try (final MetaDataAccess<Integer> access = pp.accessPersistentMetaData(
PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) {
@ -99,7 +101,7 @@ public class Grant extends Command {
}
}
} else {
DBFunc.getPersistentMeta(uuid, new RunnableVal<Map<String, byte[]>>() {
DBFunc.getPersistentMeta(uuid.getUuid(), new RunnableVal<Map<String, byte[]>>() {
@Override public void run(Map<String, byte[]> value) {
final byte[] array = value.get("grantedPlots");
if (arg0.equals("check")) { // check
@ -123,7 +125,11 @@ public class Grant extends Command {
boolean replace = array != null;
String key = "grantedPlots";
byte[] rawData = Ints.toByteArray(amount);
DBFunc.addPersistentMeta(uuid, key, rawData, replace);
DBFunc.addPersistentMeta(uuid.getUuid(), key, rawData, replace);
player.sendMessage(
TranslatableCaption.of("grants.added"),
Template.of("grants", String.valueOf(amount))
);
}
}
});
@ -135,10 +141,22 @@ public class Grant extends Command {
sendUsage(player);
return CompletableFuture.completedFuture(true);
}
@Override public Collection<Command> tab(final PlotPlayer player, String[] args, boolean space) {
return Stream.of("check", "add")
.filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH)))
.map(value -> new Command(null, false, value, "plots.grant", RequiredType.NONE, null) {
}).collect(Collectors.toList());
@Override public Collection<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) {
if (args.length == 1) {
final List<String> completions = new LinkedList<>();
if (Permissions.hasPermission(player, "plots.grant.add")) {
completions.add("add");
}
if (Permissions.hasPermission(player, "plots.grant.check")) {
completions.add("check");
}
final List<Command> commands = completions.stream().filter(completion -> completion.toLowerCase().startsWith(args[0].toLowerCase()))
.map(completion -> new Command(null, true, completion, "", RequiredType.NONE, CommandCategory.ADMINISTRATION) {
}).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, "plots.grant") && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList()));
}
return commands;
} return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList());
}
}

View File

@ -38,6 +38,7 @@ import com.plotsquared.core.plot.PlotItemStack;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.MusicFlag;
import com.plotsquared.core.util.InventoryUtil;
import com.plotsquared.core.util.Permissions;
import com.sk89q.worldedit.world.item.ItemTypes;
import net.kyori.adventure.text.minimessage.Template;
@ -71,8 +72,11 @@ public class Music extends SubCommand {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
return false;
}
if (!plot.isAdded(player.getUUID())) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
if (!plot.isAdded(player.getUUID()) && !Permissions
.hasPermission(player, "plots.admin.music.other")) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", "plots.admin.music.other"));
return true;
}
PlotInventory inv = new PlotInventory(this.inventoryUtil, player, 2, "Plot Jukebox") {

View File

@ -45,6 +45,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Collections;
import java.util.LinkedList;
import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull;
@ -180,7 +182,7 @@ public class Set extends SubCommand {
if (plot != null) {
newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getId())));
}
player.sendMessage(StaticCaption.of(TranslatableCaption.of("commandconfig.subcommand_set_options_header").getComponent(player) + StringMan
player.sendMessage(StaticCaption.of(TranslatableCaption.of("commandconfig.subcommand_set_options_header_only").getComponent(player) + StringMan
.join(newValues, TranslatableCaption.of("blocklist.block_list_separator").getComponent(player))));
return false;
}
@ -213,15 +215,51 @@ public class Set extends SubCommand {
}
@Override
public Collection<Command> tab(final PlotPlayer player, final String[] args,
final boolean space) {
public Collection<Command> tab(final PlotPlayer<?> player, String[] args, boolean space) {
if (args.length == 1) {
return Stream
.of("biome", "alias", "home", "main", "floor", "air", "all", "border", "wall",
"outline", "middle")
.filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH)))
.map(value -> new Command(null, false, value, "", RequiredType.NONE, null) {
}).collect(Collectors.toList());
final List<String> completions = new LinkedList<>();
if (Permissions.hasPermission(player, "plots.set.biome")) {
completions.add("biome");
}
if (Permissions.hasPermission(player, "plots.set.alias")) {
completions.add("alias");
}
if (Permissions.hasPermission(player, "plots.set.home")) {
completions.add("home");
}
if (Permissions.hasPermission(player, "plots.set.main")) {
completions.add("main");
}
if (Permissions.hasPermission(player, "plots.set.floor")) {
completions.add("floor");
}
if (Permissions.hasPermission(player, "plots.set.air")) {
completions.add("air");
}
if (Permissions.hasPermission(player, "plots.set.all")) {
completions.add("all");
}
if (Permissions.hasPermission(player, "plots.set.border")) {
completions.add("border");
}
if (Permissions.hasPermission(player, "plots.set.wall")) {
completions.add("wall");
}
if (Permissions.hasPermission(player, "plots.set.outline")) {
completions.add("outline");
}
if (Permissions.hasPermission(player, "plots.set.middle")) {
completions.add("middle");
}
final List<Command> commands = completions.stream().filter(completion -> completion.toLowerCase().startsWith(args[0].toLowerCase()))
.map(completion -> new Command(null, true, completion, "", RequiredType.NONE, CommandCategory.APPEARANCE) {
}).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, "plots.set") && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList()));
}
return commands;
} else if (args.length > 1) {
// Additional checks
Plot plot = player.getCurrentPlot();

View File

@ -45,10 +45,15 @@ import com.plotsquared.core.setup.PlotAreaBuilder;
import com.plotsquared.core.setup.SettingsNodesWrapper;
import com.plotsquared.core.util.FileBytes;
import com.plotsquared.core.util.FileUtils;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.TaskManager;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.Nonnull;
import java.io.File;
import java.io.FileInputStream;
@ -266,10 +271,22 @@ public class Template extends SubCommand {
}
return false;
}
@Override public Collection<Command> tab(final PlotPlayer player, String[] args, boolean space) {
return Stream.of("import", "export")
.filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH)))
.map(value -> new Command(null, false, value, "plots.admin", RequiredType.NONE, null) {
}).collect(Collectors.toList());
@Override public Collection<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) {
if (args.length == 1) {
final List<String> completions = new LinkedList<>();
if (Permissions.hasPermission(player, "plots.template.export")) {
completions.add("export");
}
if (Permissions.hasPermission(player, "plots.template.import")) {
completions.add("import");
}
final List<Command> commands = completions.stream().filter(completion -> completion.toLowerCase().startsWith(args[0].toLowerCase()))
.map(completion -> new Command(null, true, completion, "", RequiredType.NONE, CommandCategory.ADMINISTRATION) {
}).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, "plots.template") && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList()));
}
return commands;
} return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList());
}
}

View File

@ -267,8 +267,6 @@ public class Settings extends Config {
public static boolean SERVICE_BUKKIT = true;
@Comment("Whether the EssentialsX service is enabled")
public static boolean SERVICE_ESSENTIALSX = true;
@Comment("Whether the BungeePerms service is enabled")
public static boolean SERVICE_BUNGEE_PERMS = true;
}

View File

@ -47,7 +47,6 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -265,7 +264,7 @@ public class HybridPlotManager extends ClassicPlotManager {
* @param plot The plot
* @return The location where a sign should be
*/
@Override public Location getSignLoc(@Nonnull final @NotNull Plot plot) {
@Override public Location getSignLoc(@Nonnull final Plot plot) {
return hybridPlotWorld.getSignLocation(plot);
}

View File

@ -35,7 +35,6 @@ import com.plotsquared.core.queue.QueueCoordinator;
import com.plotsquared.core.util.HashUtil;
import com.plotsquared.core.util.RegionManager;
import com.sk89q.worldedit.regions.CuboidRegion;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -60,7 +59,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
this.regionManager = regionManager;
}
@Override public boolean clearPlot(final @NotNull Plot plot,
@Override public boolean clearPlot(final @Nonnull Plot plot,
final @Nullable Runnable whenDone,
@Nullable PlotPlayer<?> actor,
@Nullable QueueCoordinator queue) {
@ -85,7 +84,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
return true;
}
@Override public Location getPlotTopLocAbs(@NotNull PlotId plotId) {
@Override public Location getPlotTopLocAbs(@Nonnull PlotId plotId) {
int px = plotId.getX();
int pz = plotId.getY();
int x = (squarePlotWorld.ROAD_OFFSET_X + (px * (squarePlotWorld.ROAD_WIDTH + squarePlotWorld.PLOT_WIDTH))) - (int) Math
@ -246,7 +245,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
/**
* Get the bottom plot loc (some basic math).
*/
@Override public Location getPlotBottomLocAbs(@NotNull PlotId plotId) {
@Override public Location getPlotBottomLocAbs(@Nonnull PlotId plotId) {
int px = plotId.getX();
int pz = plotId.getY();
int x = (squarePlotWorld.ROAD_OFFSET_X + (px * (squarePlotWorld.ROAD_WIDTH + squarePlotWorld.PLOT_WIDTH))) - squarePlotWorld.PLOT_WIDTH

View File

@ -28,12 +28,11 @@ package com.plotsquared.core.inject.factory;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.plotsquared.core.queue.ChunkCoordinatorBuilder;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
public interface ChunkCoordinatorBuilderFactory {
@Inject @Nonnull ChunkCoordinatorBuilder create(@Assisted @NotNull ChunkCoordinatorFactory chunkCoordinatorFactory);
@Inject @Nonnull ChunkCoordinatorBuilder create(@Assisted @Nonnull ChunkCoordinatorFactory chunkCoordinatorFactory);
}

View File

@ -53,6 +53,7 @@ public enum Permission {
PERMISSION_MERGE_OTHER("plots.merge.other"),
PERMISSION_MERGE_KEEP_ROAD("plots.merge.keeproad"),
PERMISSION_ADMIN_CAPS_OTHER("plots.admin.caps.other"),
PERMISSION_ADMIN_MUSIC_OTHER("plots.admin.music.other"),
PERMISSION_ADMIN_DESTROY_UNOWNED("plots.admin.destroy.unowned"),
PERMISSION_ADMIN_DESTROY_GROUNDLEVEL("plots.admin.destroy.groundlevel"),
PERMISSION_ADMIN_DESTROY_OTHER("plots.admin.destroy.other"),

View File

@ -68,7 +68,6 @@ import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.title.Title;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -851,7 +850,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
}
// Redefine from PermissionHolder as it's required from CommandCaller
@Override public boolean hasPermission(@NotNull String permission) {
@Override public boolean hasPermission(@Nonnull String permission) {
return hasPermission(null, permission);
}

View File

@ -36,7 +36,6 @@ import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.Arrays;
@ -57,21 +56,21 @@ public final class BlockBucket implements ConfigurationSerializable {
private BlockState single;
private Pattern pattern;
public BlockBucket(@NotNull final BlockType type) {
public BlockBucket(@Nonnull final BlockType type) {
this(type.getId());
this.single = type.getDefaultState();
this.pattern = new BlockPattern(this.single);
this.compiled = true;
}
public BlockBucket(@NotNull final BlockState state) {
public BlockBucket(@Nonnull final BlockState state) {
this(state.getAsString());
this.single = state;
this.pattern = new BlockPattern(this.single);
this.compiled = true;
}
public BlockBucket(@NotNull final String input) {
public BlockBucket(@Nonnull final String input) {
this.input = new StringBuilder(input);
}

View File

@ -36,7 +36,6 @@ import com.plotsquared.core.queue.QueueCoordinator;
import com.plotsquared.core.util.FileUtils;
import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.worldedit.function.pattern.Pattern;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -57,15 +56,15 @@ public class SinglePlotManager extends PlotManager {
return PlotId.of(0, 0);
}
@Override public Location getPlotBottomLocAbs(@Nonnull final @NotNull PlotId plotId) {
@Override public Location getPlotBottomLocAbs(@Nonnull final PlotId plotId) {
return Location.at(plotId.toCommaSeparatedString(), -30000000, 0, -30000000);
}
@Override public Location getPlotTopLocAbs(@Nonnull final @NotNull PlotId plotId) {
@Override public Location getPlotTopLocAbs(@Nonnull final PlotId plotId) {
return Location.at(plotId.toCommaSeparatedString(), 30000000, 0, 30000000);
}
@Override public boolean clearPlot(@NotNull Plot plot, final Runnable whenDone, @Nullable PlotPlayer<?> actor, @Nullable QueueCoordinator queue) {
@Override public boolean clearPlot(@Nonnull Plot plot, final Runnable whenDone, @Nullable PlotPlayer<?> actor, @Nullable QueueCoordinator queue) {
PlotSquared.platform().getSetupUtils().unload(plot.getWorldName(), false);
final File worldFolder = new File(PlotSquared.platform().getWorldContainer(), plot.getWorldName());
TaskManager.getPlatformImplementation().taskAsync(() -> {
@ -77,71 +76,71 @@ public class SinglePlotManager extends PlotManager {
return true;
}
@Override public boolean claimPlot(@NotNull Plot plot, @Nullable QueueCoordinator queue) {
@Override public boolean claimPlot(@Nonnull Plot plot, @Nullable QueueCoordinator queue) {
// TODO
return true;
}
@Override public boolean unClaimPlot(@NotNull Plot plot, Runnable whenDone, @Nullable QueueCoordinator queue) {
@Override public boolean unClaimPlot(@Nonnull Plot plot, Runnable whenDone, @Nullable QueueCoordinator queue) {
if (whenDone != null) {
whenDone.run();
}
return true;
}
@Override public Location getSignLoc(@NotNull Plot plot) {
@Override public Location getSignLoc(@Nonnull Plot plot) {
return null;
}
@Override public String[] getPlotComponents(@NotNull PlotId plotId) {
@Override public String[] getPlotComponents(@Nonnull PlotId plotId) {
return new String[0];
}
@Override public boolean setComponent(@NotNull PlotId plotId,
@NotNull String component,
@NotNull Pattern blocks,
@Override public boolean setComponent(@Nonnull PlotId plotId,
@Nonnull String component,
@Nonnull Pattern blocks,
@Nullable PlotPlayer<?> actor,
@Nullable QueueCoordinator queue) {
return false;
}
@Override public boolean createRoadEast(@NotNull Plot plot, @Nullable QueueCoordinator queue) {
@Override public boolean createRoadEast(@Nonnull Plot plot, @Nullable QueueCoordinator queue) {
return false;
}
@Override public boolean createRoadSouth(@NotNull Plot plot, @Nullable QueueCoordinator queue) {
@Override public boolean createRoadSouth(@Nonnull Plot plot, @Nullable QueueCoordinator queue) {
return false;
}
@Override public boolean createRoadSouthEast(@NotNull Plot plot, @Nullable QueueCoordinator queue) {
@Override public boolean createRoadSouthEast(@Nonnull Plot plot, @Nullable QueueCoordinator queue) {
return false;
}
@Override public boolean removeRoadEast(@NotNull Plot plot, @Nullable QueueCoordinator queue) {
@Override public boolean removeRoadEast(@Nonnull Plot plot, @Nullable QueueCoordinator queue) {
return false;
}
@Override public boolean removeRoadSouth(@NotNull Plot plot, @Nullable QueueCoordinator queue) {
@Override public boolean removeRoadSouth(@Nonnull Plot plot, @Nullable QueueCoordinator queue) {
return false;
}
@Override public boolean removeRoadSouthEast(@NotNull Plot plot, @Nullable QueueCoordinator queue) {
@Override public boolean removeRoadSouthEast(@Nonnull Plot plot, @Nullable QueueCoordinator queue) {
return false;
}
@Override public boolean startPlotMerge(@NotNull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
@Override public boolean startPlotMerge(@Nonnull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
return false;
}
@Override public boolean startPlotUnlink(@NotNull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
@Override public boolean startPlotUnlink(@Nonnull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
return false;
}
@Override public boolean finishPlotMerge(@NotNull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
@Override public boolean finishPlotMerge(@Nonnull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
return false;
}
@Override public boolean finishPlotUnlink(@NotNull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
@Override public boolean finishPlotUnlink(@Nonnull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
return false;
}

View File

@ -269,7 +269,7 @@ public enum CommonSetupSteps implements SetupStep {
private static boolean isValidWorldName(String s) {
return s.chars().allMatch((i) -> {
return i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 48 && i <= 57 || i == 46;
return i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 65 && i <= 90 || i >= 48 && i <= 57 || i == 46;
});
}

View File

@ -26,6 +26,9 @@
package com.plotsquared.core.util;
import com.google.inject.Inject;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonParseException;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.generator.ClassicPlotWorld;
@ -63,8 +66,6 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import org.json.JSONArray;
import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -109,6 +110,7 @@ import java.util.zip.GZIPOutputStream;
public abstract class SchematicHandler {
private static final Logger logger = LoggerFactory.getLogger("P2/" + SchematicHandler.class.getSimpleName());
private static final Gson GSON = new Gson();
public static SchematicHandler manager;
private final WorldUtil worldUtil;
private boolean exportAll = false;
@ -462,7 +464,7 @@ public abstract class SchematicHandler {
}
public List<String> getSaves(UUID uuid) {
String rawJSON = "";
String rawJSON;
try {
String website = Settings.Web.URL + "list.php?" + uuid.toString();
URL url = new URL(website);
@ -471,14 +473,14 @@ public abstract class SchematicHandler {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
rawJSON = reader.lines().collect(Collectors.joining());
}
JSONArray array = new JSONArray(rawJSON);
JsonArray array = GSON.fromJson(rawJSON, JsonArray.class);
List<String> schematics = new ArrayList<>();
for (int i = 0; i < array.length(); i++) {
String schematic = array.getString(i);
for (int i = 0; i < array.size(); i++) {
String schematic = array.get(i).getAsString();
schematics.add(schematic);
}
return schematics;
} catch (JSONException | IOException e) {
} catch (JsonParseException | IOException e) {
e.printStackTrace();
}
return null;

View File

@ -27,7 +27,8 @@ package com.plotsquared.core.util.placeholders;
import com.google.common.base.Preconditions;
import com.plotsquared.core.player.PlotPlayer;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
/**
* A placeholder is a keyed value that gets replaced by a {@link PlotPlayer player}-specific value at runtime
@ -36,7 +37,7 @@ public abstract class Placeholder {
private final String key;
public Placeholder(@NotNull final String key) {
public Placeholder(@Nonnull final String key) {
this.key = Preconditions.checkNotNull(key, "Key may not be null");
}
@ -46,14 +47,14 @@ public abstract class Placeholder {
* @param player Player
* @return Placeholder value. Return {@code ""} if no placeholder value can be returned
*/
@NotNull public abstract String getValue(@NotNull final PlotPlayer<?> player);
@Nonnull public abstract String getValue(@Nonnull final PlotPlayer<?> player);
/**
* Get the placeholder key
*
* @return Placeholder key
*/
@NotNull public final String getKey() {
@Nonnull public final String getKey() {
return this.key;
}

View File

@ -34,9 +34,9 @@ import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.PlayerManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
import java.util.Locale;
@ -52,7 +52,7 @@ public final class PlaceholderRegistry {
private final Map<String, Placeholder> placeholders;
private final EventDispatcher eventDispatcher;
public PlaceholderRegistry(@NotNull final EventDispatcher eventDispatcher) {
public PlaceholderRegistry(@Nonnull final EventDispatcher eventDispatcher) {
this.placeholders = Maps.newHashMap();
this.eventDispatcher = eventDispatcher;
this.registerDefault();
@ -124,10 +124,10 @@ public final class PlaceholderRegistry {
* @param key Placeholder key
* @param placeholderFunction Placeholder generator. Cannot return null
*/
@SuppressWarnings("ALL") public void createPlaceholder(@NotNull final String key,
@NotNull final Function<PlotPlayer<?>, String> placeholderFunction) {
@SuppressWarnings("ALL") public void createPlaceholder(@Nonnull final String key,
@Nonnull final Function<PlotPlayer<?>, String> placeholderFunction) {
this.registerPlaceholder(new Placeholder(key) {
@Override @NotNull public String getValue(@NotNull final PlotPlayer<?> player) {
@Override @Nonnull public String getValue(@Nonnull final PlotPlayer<?> player) {
return placeholderFunction.apply(player);
}
});
@ -139,10 +139,10 @@ public final class PlaceholderRegistry {
* @param key Placeholder key
* @param placeholderFunction Placeholder generator. Cannot return null
*/
public void createPlaceholder(@NotNull final String key,
@NotNull final BiFunction<PlotPlayer<?>, Plot, String> placeholderFunction) {
public void createPlaceholder(@Nonnull final String key,
@Nonnull final BiFunction<PlotPlayer<?>, Plot, String> placeholderFunction) {
this.registerPlaceholder(new PlotSpecificPlaceholder(key) {
@Override @NotNull public String getValue(@NotNull final PlotPlayer<?> player, @NotNull final Plot plot) {
@Override @Nonnull public String getValue(@Nonnull final PlotPlayer<?> player, @Nonnull final Plot plot) {
return placeholderFunction.apply(player, plot);
}
});
@ -153,7 +153,7 @@ public final class PlaceholderRegistry {
*
* @param placeholder Placeholder instance
*/
public void registerPlaceholder(@NotNull final Placeholder placeholder) {
public void registerPlaceholder(@Nonnull final Placeholder placeholder) {
final Placeholder previous = this.placeholders
.put(placeholder.getKey().toLowerCase(Locale.ENGLISH),
Preconditions.checkNotNull(placeholder, "Placeholder may not be null"));
@ -168,7 +168,7 @@ public final class PlaceholderRegistry {
* @param key Placeholder key
* @return Placeholder value
*/
@Nullable public Placeholder getPlaceholder(@NotNull final String key) {
@Nullable public Placeholder getPlaceholder(@Nonnull final String key) {
return this.placeholders.get(
Preconditions.checkNotNull(key, "Key may not be null").toLowerCase(Locale.ENGLISH));
}
@ -181,8 +181,8 @@ public final class PlaceholderRegistry {
* @param player Player to evaluate for
* @return Replacement value
*/
@NotNull public String getPlaceholderValue(@NotNull final String key,
@NotNull final PlotPlayer<?> player) {
@Nonnull public String getPlaceholderValue(@Nonnull final String key,
@Nonnull final PlotPlayer<?> player) {
final Placeholder placeholder = getPlaceholder(key);
if (placeholder == null) {
return "";
@ -209,7 +209,7 @@ public final class PlaceholderRegistry {
*
* @return Unmodifiable collection of placeholders
*/
@NotNull public Collection<Placeholder> getPlaceholders() {
@Nonnull public Collection<Placeholder> getPlaceholders() {
return Collections.unmodifiableCollection(this.placeholders.values());
}

View File

@ -29,20 +29,21 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.PlotFlag;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
public final class PlotFlagPlaceholder extends PlotSpecificPlaceholder {
private final PlotFlag<?, ?> flag;
private final boolean local;
public PlotFlagPlaceholder(@NotNull final PlotFlag<?, ?> flag, final boolean local) {
public PlotFlagPlaceholder(@Nonnull final PlotFlag<?, ?> flag, final boolean local) {
super(String.format("currentplot_%sflag_%s", local ? "local": "", flag.getName()));
this.flag = flag;
this.local = local;
}
@Override @NotNull public String getValue(@NotNull final PlotPlayer<?> player, @NotNull final Plot plot) {
@Override @Nonnull public String getValue(@Nonnull final PlotPlayer<?> player, @Nonnull final Plot plot) {
return this.getFlagValue(plot, this.flag.getName(), !this.local);
}
@ -57,7 +58,7 @@ public final class PlotFlagPlaceholder extends PlotSpecificPlaceholder {
* @param inherit Define if it returns only the flag set on the current plot or also inherited flags
* @return The value of flag serialized in string
*/
@NotNull private String getFlagValue(@NotNull final Plot plot, @NotNull final String flagName, final boolean inherit) {
@Nonnull private String getFlagValue(@Nonnull final Plot plot, @Nonnull final String flagName, final boolean inherit) {
if (flagName.isEmpty()) {
return "";
}

View File

@ -27,18 +27,19 @@ package com.plotsquared.core.util.placeholders;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
/**
* A {@link Placeholder placeholder} that requires a {@link com.plotsquared.core.plot.Plot plot}
*/
public abstract class PlotSpecificPlaceholder extends Placeholder {
public PlotSpecificPlaceholder(@NotNull final String key) {
public PlotSpecificPlaceholder(@Nonnull final String key) {
super(key);
}
@Override @NotNull public final String getValue(@NotNull final PlotPlayer<?> player) {
@Override @Nonnull public final String getValue(@Nonnull final PlotPlayer<?> player) {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
return "";
@ -53,7 +54,7 @@ public abstract class PlotSpecificPlaceholder extends Placeholder {
* @param plot Plot that the player is in
* @return Placeholder value, or {@code ""} if the placeholder does not apply
*/
@NotNull public abstract String getValue(@NotNull final PlotPlayer<?> player,
@NotNull final Plot plot);
@Nonnull public abstract String getValue(@Nonnull final PlotPlayer<?> player,
@Nonnull final Plot plot);
}

View File

@ -220,6 +220,7 @@
"commandconfig.not_valid_subcommand": "<prefix><gray>That is not a valid subcommand.</gray>",
"commandconfig.did_you_mean": "<prefix><gray>Did you mean: <gold><value></gold></gray>",
"commandconfig.subcommand_set_options_header": "<prefix><gray>Possible Values: <values>",
"commandconfig.subcommand_set_options_header_only": "<prefix><gray>Possible Values: ",
"commandconfig.command_syntax": "<prefix><gold>Usage: </gold><gray><value></gray>",
"commandconfig.command_syntax_extended": "<prefix><gold>Usage: </gold><gray><value1> <value2></gray>",
"commandconfig.flag_tutorial_usage": "<prefix><gold>Have an admin set the flag: </gold><gray><flag></gray>",
@ -472,6 +473,7 @@
"category.command_category_administration": "<gray>Admin</gray>",
"grants.granted_plots": "<prefix><gold>Result: <gray><amount> </gray>grants left.</gold>",
"grants.added": "<prefix><gold><grants></gold> <gray>grant(s) have been added.</gray>",
"events.event_denied": "<prefix><gold><value> </gold><gray>Cancelled by external plugin.</gray>",
@ -671,6 +673,7 @@
"commands.description.comment": "<gray>Comment on a plot.</gray>",
"commands.description.condense": "<gray>Condense a plotworld.</gray>",
"commands.description.confirm": "<gray>Confirm an action.</gray>",
"commands.description.continue": "<gray>Continue a plot that was previously marked as done.</gray>",
"commands.description.copy": "<gray>Copy a plot.</gray>",
"commands.description.createroadschematic": "<gray>Add a road schematic to your world using the roads around your current plot.</gray>",
"commands.description.database": "<gray>Convert/Backup Storage.</gray>",

View File

@ -32,11 +32,15 @@ import com.plotsquared.core.plot.flag.implementations.UseFlag;
import com.sk89q.worldedit.world.item.ItemType;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.assertEquals;
public class FlagTest {
private static final Logger logger = LoggerFactory.getLogger("P2/" + FlagTest.class.getSimpleName());
private ItemType testBlock;
@Before public void setUp() throws Exception {
@ -50,11 +54,11 @@ public class FlagTest {
// //plot.setFlag(use, use.parseValue("33,33:1,6:4")); //TODO fix this so FlagTest will run during compile
// Optional<? extends Collection> flag = plot.getFlag(use);
// if (flag.isPresent()) {
// System.out.println(Flags.USE.valueToString(flag.get()));
// logger.info(Flags.USE.valueToString(flag.get()));
// testBlock = ItemTypes.BONE_BLOCK;
// flag.get().add(testBlock);
// }
// flag.ifPresent(collection -> System.out.println(Flags.USE.valueToString(collection)));
// flag.ifPresent(collection -> logger.info(Flags.USE.valueToString(collection)));
// Optional<Set<BlockType>> flag2 = plot.getFlag(Flags.USE);
// if (flag2.isPresent()) {
// // assertThat(flag2.get(), (Matcher<? super Set<BlockType>>) IsCollectionContaining.hasItem(testBlock));

View File

@ -27,13 +27,17 @@ package com.plotsquared.core.plot;
import com.plotsquared.core.PlotVersion;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PlotVersionTest {
private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotVersionTest.class.getSimpleName());
@Test public void tryParse() {
//These are all random values chosen to form the test class.
PlotVersion version = new PlotVersion("4.340", "f06903f", "19.08.05");
System.out.println(version.versionString);
logger.info(version.versionString);
}
}