mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Major code reformatting
This commit is contained in:
@ -21,221 +21,225 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public interface IPlotMain {
|
||||
|
||||
|
||||
/**
|
||||
* Log a message to console
|
||||
* Log a message to console.
|
||||
* @param message
|
||||
*/
|
||||
void log(final String message);
|
||||
|
||||
void log(String message);
|
||||
|
||||
/**
|
||||
* Get the `PlotSquared` directory (e.g. /plugins/PlotSquared or /mods/PlotSquared)
|
||||
* Get the `PlotSquared` directory.
|
||||
* @return
|
||||
*/
|
||||
File getDirectory();
|
||||
|
||||
|
||||
/**
|
||||
* Get the directory containing all the worlds
|
||||
* Get the directory containing all the worlds.
|
||||
* @return
|
||||
*/
|
||||
File getWorldContainer();
|
||||
|
||||
|
||||
/**
|
||||
* Wrap a player into a PlotPlayer object
|
||||
* @param obj
|
||||
* Wrap a player into a PlotPlayer object.
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
PlotPlayer wrapPlayer(final Object obj);
|
||||
|
||||
PlotPlayer wrapPlayer(Object player);
|
||||
|
||||
/**
|
||||
* Disable the implementation
|
||||
* - If a full disable isn't feasibly, just disable what it can
|
||||
* Disable the implementation.
|
||||
*
|
||||
* <ul>
|
||||
* <li>If a full disable isn't feasibly, just disable what it can.</li>
|
||||
* </ul>
|
||||
*/
|
||||
void disable();
|
||||
|
||||
|
||||
/**
|
||||
* Get the version of the PlotSquared being used
|
||||
* Get the version of the PlotSquared being used.
|
||||
* @return
|
||||
*/
|
||||
int[] getPluginVersion();
|
||||
|
||||
|
||||
/**
|
||||
* Get the version of Minecraft that is running
|
||||
* (used to check what protocols and such are supported)
|
||||
* Get the version of Minecraft that is running.
|
||||
* @return
|
||||
*/
|
||||
int[] getServerVersion();
|
||||
|
||||
|
||||
/**
|
||||
* Get the nms package prefix
|
||||
* Get the nms package prefix.
|
||||
* @return
|
||||
*/
|
||||
String getNMSPackage();
|
||||
|
||||
|
||||
/**
|
||||
* Get the schematic handler
|
||||
* Get the schematic handler.
|
||||
* @return
|
||||
*/
|
||||
SchematicHandler initSchematicHandler();
|
||||
|
||||
|
||||
/**
|
||||
* Get the schematic handler
|
||||
* Get the schematic handler.
|
||||
* @return
|
||||
*/
|
||||
ChatManager initChatManager();
|
||||
|
||||
|
||||
/**
|
||||
* The task manager will run and manage minecraft tasks
|
||||
* The task manager will run and manage Minecraft tasks.
|
||||
* @return
|
||||
*/
|
||||
TaskManager getTaskManager();
|
||||
|
||||
|
||||
/**
|
||||
* Run the task that will kill road mobs
|
||||
* Run the task that will kill road mobs.
|
||||
*/
|
||||
void runEntityTask();
|
||||
|
||||
|
||||
/**
|
||||
* Register the implementation specific commands
|
||||
* Register the implementation specific commands.
|
||||
*/
|
||||
void registerCommands();
|
||||
|
||||
|
||||
/**
|
||||
* Register the protection system (used to protect blocks and such)
|
||||
* Register the protection system.
|
||||
*/
|
||||
void registerPlayerEvents();
|
||||
|
||||
|
||||
/**
|
||||
* Register inventory related events (used for inventory guis)
|
||||
* Register inventory related events.
|
||||
*/
|
||||
void registerInventoryEvents();
|
||||
|
||||
|
||||
/**
|
||||
* Register plot plus related events (whatever these are?)
|
||||
* Register plot plus related events.
|
||||
*/
|
||||
void registerPlotPlusEvents();
|
||||
|
||||
|
||||
/**
|
||||
* Register force field events (why is this a thing?)
|
||||
* Register force field events.
|
||||
*/
|
||||
void registerForceFieldEvents();
|
||||
|
||||
|
||||
/**
|
||||
* Register the WorldEdit hook
|
||||
* Register the WorldEdit hook.
|
||||
*/
|
||||
boolean initWorldEdit();
|
||||
|
||||
|
||||
/**
|
||||
* Get the economy provider
|
||||
* Get the economy provider.
|
||||
* @return
|
||||
*/
|
||||
EconHandler getEconomyHandler();
|
||||
|
||||
|
||||
/**
|
||||
* Get the Plot Queue class
|
||||
* Get the {@link PlotQueue} class.
|
||||
* @return
|
||||
*/
|
||||
PlotQueue initPlotQueue();
|
||||
|
||||
|
||||
/**
|
||||
* Get the World Util class
|
||||
* Get the {@link WorldUtil} class.
|
||||
* @return
|
||||
*/
|
||||
WorldUtil initWorldUtil();
|
||||
|
||||
|
||||
/**
|
||||
* Get the EventUtil class
|
||||
* Get the EventUtil class.
|
||||
* @return
|
||||
*/
|
||||
EventUtil initEventUtil();
|
||||
|
||||
|
||||
/**
|
||||
* Get the chunk manager
|
||||
* Get the chunk manager.
|
||||
* @return
|
||||
*/
|
||||
ChunkManager initChunkManager();
|
||||
|
||||
|
||||
/**
|
||||
* Get the setuputils class (used for world creation)
|
||||
* Get the {@link SetupUtils} class.
|
||||
* @return
|
||||
*/
|
||||
SetupUtils initSetupUtils();
|
||||
|
||||
|
||||
/**
|
||||
* Get HybridUtils class (common functions useful for hybrid world generation)
|
||||
* Get {@link HybridUtils} class.
|
||||
* @return
|
||||
*/
|
||||
HybridUtils initHybridUtils();
|
||||
|
||||
|
||||
/**
|
||||
* Start the metrics task
|
||||
* Start Metrics.
|
||||
*/
|
||||
void startMetrics();
|
||||
|
||||
|
||||
/**
|
||||
* If a world is already loaded, set the generator (use NMS if required)
|
||||
* If a world is already loaded, set the generator (use NMS if required).
|
||||
* @param world
|
||||
*/
|
||||
void setGenerator(final String world);
|
||||
|
||||
void setGenerator(String world);
|
||||
|
||||
/**
|
||||
* Get the UUIDHandlerImplementation which will cache and provide UUIDs
|
||||
* Get the {@link UUIDHandlerImplementation} which will cache and provide UUIDs.
|
||||
* @return
|
||||
*/
|
||||
UUIDHandlerImplementation initUUIDHandler();
|
||||
|
||||
|
||||
/**
|
||||
* Get the InventoryUtil class (used for implementation specific inventory guis)
|
||||
* Get the {@link InventoryUtil} class (used for implementation specific inventory guis).
|
||||
* @return
|
||||
*/
|
||||
InventoryUtil initInventoryUtil();
|
||||
|
||||
|
||||
/**
|
||||
* Run the converter for the implementation (not necessarily PlotMe, just any plugin that we can convert from)
|
||||
* Run the converter for the implementation (not necessarily PlotMe, just any plugin that we can convert from).
|
||||
* @return
|
||||
*/
|
||||
boolean initPlotMeConverter();
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a PlotPlayer from cache e.g. if they have logged off
|
||||
* Unregister a PlotPlayer from cache e.g. if they have logged off.
|
||||
* @param player
|
||||
*/
|
||||
void unregister(final PlotPlayer player);
|
||||
|
||||
void unregister(PlotPlayer player);
|
||||
|
||||
/**
|
||||
* Get the generator wrapper for a world (world) and generator (name)
|
||||
* Get the generator wrapper for a world (world) and generator (name).
|
||||
* @param world
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
GeneratorWrapper<?> getGenerator(final String world, final String name);
|
||||
|
||||
GeneratorWrapper<?> getGenerator(String world, String name);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param generator
|
||||
* @return
|
||||
*/
|
||||
GeneratorWrapper<?> wrapPlotGenerator(IndependentPlotGenerator generator);
|
||||
|
||||
|
||||
/**
|
||||
* Register the chunk processor which will clean out chunks that have too many blockstates or entities
|
||||
* Register the chunk processor which will clean out chunks that have too many blockstates or entities.
|
||||
*/
|
||||
void registerChunkProcessor();
|
||||
|
||||
|
||||
/**
|
||||
* Register the world initialization events (used to keep track of worlds being generated)
|
||||
* Register the world initialization events (used to keep track of worlds being generated).
|
||||
*/
|
||||
void registerWorldEvents();
|
||||
|
||||
|
||||
/**
|
||||
* Get the name of the server
|
||||
* Get the name of the server.
|
||||
* @return
|
||||
*/
|
||||
String getServerName();
|
||||
|
||||
|
||||
/**
|
||||
* Get the class that will manage player titles
|
||||
* Get the class that will manage player titles.
|
||||
* @return
|
||||
*/
|
||||
AbstractTitle initTitleManager();
|
||||
|
||||
|
||||
List<String> getPluginIds();
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,17 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import static com.intellectualcrafters.plot.PS.log;
|
||||
|
||||
import com.intellectualcrafters.json.JSONArray;
|
||||
import com.intellectualcrafters.json.JSONObject;
|
||||
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import static com.intellectualcrafters.plot.PS.log;
|
||||
|
||||
public class Updater {
|
||||
|
||||
private static String readUrl(String urlString) {
|
||||
@ -53,7 +53,12 @@ public class Updater {
|
||||
if (downloadURL.equals(name)) {
|
||||
try {
|
||||
String[] split = release.getString("name").split("\\.");
|
||||
int[] version = new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
|
||||
int[] version;
|
||||
if (split.length == 3) {
|
||||
version = new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
|
||||
} else {
|
||||
version = new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), 0};
|
||||
}
|
||||
URL url = new URL(asset.getString("browser_download_url"));
|
||||
// If current version >= update
|
||||
if (PS.get().checkVersion(PS.get().getVersion(), version)) {
|
||||
|
@ -20,8 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -34,24 +32,26 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "add",
|
||||
aliases = { "a" },
|
||||
description = "Allow a user to build while you are online",
|
||||
usage = "/plot add <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
permission = "plots.add",
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "add",
|
||||
aliases = {"a"},
|
||||
description = "Allow a user to build while you are online",
|
||||
usage = "/plot add <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
permission = "plots.add",
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Add extends SubCommand {
|
||||
|
||||
|
||||
public Add() {
|
||||
requiredArguments = new Argument[] { Argument.PlayerName };
|
||||
this.requiredArguments = new Argument[]{Argument.PlayerName};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class Add extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.ALREADY_OWNER);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (plot.getMembers().contains(uuid)) {
|
||||
MainUtil.sendMessage(plr, C.ALREADY_ADDED);
|
||||
return false;
|
||||
|
@ -31,17 +31,17 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "setalias",
|
||||
permission = "plots.set.alias",
|
||||
description = "Set the plot name",
|
||||
usage = "/plot alias <alias>",
|
||||
aliases = { "alias", "sa", "name", "rename", "setname", "seta" },
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "setalias",
|
||||
permission = "plots.set.alias",
|
||||
description = "Set the plot name",
|
||||
usage = "/plot alias <alias>",
|
||||
aliases = {"alias", "sa", "name", "rename", "setname", "seta"},
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Alias extends SetCommand {
|
||||
|
||||
@Override
|
||||
public boolean set(final PlotPlayer plr, final Plot plot, final String alias) {
|
||||
public boolean set(PlotPlayer plr, Plot plot, String alias) {
|
||||
if (alias.isEmpty()) {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
return false;
|
||||
@ -54,7 +54,7 @@ public class Alias extends SetCommand {
|
||||
C.NOT_VALID_VALUE.send(plr);
|
||||
return false;
|
||||
}
|
||||
for (final Plot p : PS.get().getPlots(plot.getArea())) {
|
||||
for (Plot p : PS.get().getPlots(plot.getArea())) {
|
||||
if (p.getAlias().equalsIgnoreCase(alias)) {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
|
@ -26,18 +26,19 @@ import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@CommandDeclaration(command = "area",
|
||||
permission = "plots.area",
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Create a new PlotArea",
|
||||
aliases = "world",
|
||||
usage = "/plot area <create|info|list|tp|regen>")
|
||||
permission = "plots.area",
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Create a new PlotArea",
|
||||
aliases = "world",
|
||||
usage = "/plot area <create|info|list|tp|regen>")
|
||||
public class Area extends SubCommand {
|
||||
|
||||
@Override
|
||||
@ -71,7 +72,7 @@ public class Area extends SubCommand {
|
||||
plr.setMeta("area_pos1", loc);
|
||||
C.SET_ATTRIBUTE.send(plr, "area_pos1", loc.getX() + "," + loc.getZ());
|
||||
MainUtil.sendMessage(plr, "You will now set pos2: /plot area create pos2"
|
||||
+ "\nNote: The chosen plot size may result in the created area not exactly matching your second position.");
|
||||
+ "\nNote: The chosen plot size may result in the created area not exactly matching your second position.");
|
||||
return true;
|
||||
}
|
||||
case "pos2": { // Set position 2 and finish creation for type=2 (partial)
|
||||
@ -86,8 +87,8 @@ public class Area extends SubCommand {
|
||||
int dz = Math.abs(pos1.getZ() - pos2.getZ());
|
||||
int numx = Math.max(1, (dx + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
||||
int numz = Math.max(1, (dz + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
||||
final int ddx = dx - (numx * area.SIZE - area.ROAD_WIDTH);
|
||||
final int ddz = dz - (numz * area.SIZE - area.ROAD_WIDTH);
|
||||
int ddx = dx - (numx * area.SIZE - area.ROAD_WIDTH);
|
||||
int ddz = dz - (numz * area.SIZE - area.ROAD_WIDTH);
|
||||
int bx = Math.min(pos1.getX(), pos2.getX()) + ddx;
|
||||
int bz = Math.min(pos1.getZ(), pos2.getZ()) + ddz;
|
||||
int tx = Math.max(pos1.getX(), pos2.getX()) - ddx;
|
||||
@ -129,7 +130,7 @@ public class Area extends SubCommand {
|
||||
if (area.TERRAIN != 3) {
|
||||
ChunkManager.largeRegionTask(world, region, new RunnableVal<ChunkLoc>() {
|
||||
@Override
|
||||
public void run(final ChunkLoc value) {
|
||||
public void run(ChunkLoc value) {
|
||||
AugmentedUtils.generate(world, value.x, value.z, null);
|
||||
}
|
||||
}, null);
|
||||
@ -326,13 +327,13 @@ public class Area extends SubCommand {
|
||||
region = "N/A";
|
||||
}
|
||||
String value = "&r$1NAME: " + name
|
||||
+ "\n$1Type: $2" + area.TYPE
|
||||
+ "\n$1Terrain: $2" + area.TERRAIN
|
||||
+ "\n$1Usage: $2" + String.format("%.2f", percent) + "%"
|
||||
+ "\n$1Claimed: $2" + claimed
|
||||
+ "\n$1Clusters: $2" + clusters
|
||||
+ "\n$1Region: $2" + region
|
||||
+ "\n$1Generator: $2" + generator;
|
||||
+ "\n$1Type: $2" + area.TYPE
|
||||
+ "\n$1Terrain: $2" + area.TERRAIN
|
||||
+ "\n$1Usage: $2" + String.format("%.2f", percent) + "%"
|
||||
+ "\n$1Claimed: $2" + claimed
|
||||
+ "\n$1Clusters: $2" + clusters
|
||||
+ "\n$1Region: $2" + region
|
||||
+ "\n$1Generator: $2" + generator;
|
||||
MainUtil.sendMessage(plr, C.PLOT_INFO_HEADER.s() + '\n' + value + '\n' + C.PLOT_INFO_FOOTER.s(), false);
|
||||
return true;
|
||||
}
|
||||
@ -379,19 +380,19 @@ public class Area extends SubCommand {
|
||||
region = "N/A";
|
||||
}
|
||||
PlotMessage tooltip = new PlotMessage()
|
||||
.text("Claimed=").color("$1").text("" + claimed).color("$2")
|
||||
.text("\nUsage=").color("$1").text(String.format("%.2f", percent) + "%").color("$2")
|
||||
.text("\nClusters=").color("$1").text("" + clusters).color("$2")
|
||||
.text("\nRegion=").color("$1").text(region).color("$2")
|
||||
.text("\nGenerator=").color("$1").text(generator).color("$2");
|
||||
.text("Claimed=").color("$1").text("" + claimed).color("$2")
|
||||
.text("\nUsage=").color("$1").text(String.format("%.2f", percent) + "%").color("$2")
|
||||
.text("\nClusters=").color("$1").text("" + clusters).color("$2")
|
||||
.text("\nRegion=").color("$1").text(region).color("$2")
|
||||
.text("\nGenerator=").color("$1").text(generator).color("$2");
|
||||
|
||||
// type / terrain
|
||||
String visit = "/plot area tp " + area.toString();
|
||||
message.text("[").color("$3")
|
||||
.text(i + "").command(visit).tooltip(visit).color("$1")
|
||||
.text("]").color("$3")
|
||||
.text(" " + name).tooltip(tooltip).command("/plot area info " + area).color("$1").text(" - ").color("$2")
|
||||
.text(area.TYPE + ":" + area.TERRAIN).color("$3");
|
||||
.text(i + "").command(visit).tooltip(visit).color("$1")
|
||||
.text("]").color("$3")
|
||||
.text(" " + name).tooltip(tooltip).command("/plot area info " + area).color("$1").text(" - ").color("$2")
|
||||
.text(area.TYPE + ":" + area.TERRAIN).color("$3");
|
||||
}
|
||||
}, "/plot area list", C.AREA_LIST_HEADER_PAGED.s());
|
||||
return true;
|
||||
@ -442,7 +443,8 @@ public class Area extends SubCommand {
|
||||
center = WorldUtil.IMP.getSpawn(area.worldname);
|
||||
} else {
|
||||
RegionWrapper region = area.getRegion();
|
||||
center = new Location(area.worldname, region.minX + (region.maxX - region.minX) / 2, 0, region.minZ + (region.maxZ - region.minZ) / 2);
|
||||
center = new Location(area.worldname, region.minX + (region.maxX - region.minX) / 2, 0,
|
||||
region.minZ + (region.maxZ - region.minZ) / 2);
|
||||
center.setY(WorldUtil.IMP.getHighestBlock(area.worldname, center.getX(), center.getZ()));
|
||||
}
|
||||
plr.teleport(center);
|
||||
@ -451,10 +453,10 @@ public class Area extends SubCommand {
|
||||
case "delete":
|
||||
case "remove": {
|
||||
MainUtil.sendMessage(plr, "$1World creation settings may be stored in multiple locations:"
|
||||
+ "\n$3 - $2Bukkit bukkit.yml"
|
||||
+ "\n$3 - $2PlotSquared settings.yml"
|
||||
+ "\n$3 - $2Multiverse worlds.yml (or any world management plugin)"
|
||||
+ "\n$1Stop the server and delete it from these locations.");
|
||||
+ "\n$3 - $2Bukkit bukkit.yml"
|
||||
+ "\n$3 - $2PlotSquared settings.yml"
|
||||
+ "\n$3 - $2Multiverse worlds.yml (or any world management plugin)"
|
||||
+ "\n$1Stop the server and delete it from these locations.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -33,17 +33,17 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "auto",
|
||||
permission = "plots.auto",
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Claim the nearest plot",
|
||||
aliases = "a",
|
||||
usage = "/plot auto [length,width]")
|
||||
permission = "plots.auto",
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Claim the nearest plot",
|
||||
aliases = "a",
|
||||
usage = "/plot auto [length,width]")
|
||||
public class Auto extends SubCommand {
|
||||
|
||||
public static PlotId getNextPlotId(final PlotId id, final int step) {
|
||||
final int absX = Math.abs(id.x);
|
||||
final int absY = Math.abs(id.y);
|
||||
public static PlotId getNextPlotId(PlotId id, int step) {
|
||||
int absX = Math.abs(id.x);
|
||||
int absY = Math.abs(id.y);
|
||||
if (absX > absY) {
|
||||
if (id.x > 0) {
|
||||
return new PlotId(id.x, id.y + 1);
|
||||
@ -71,7 +71,7 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
PlotArea plotarea = plr.getApplicablePlotArea();
|
||||
if (plotarea == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
@ -83,7 +83,7 @@ public class Auto extends SubCommand {
|
||||
if (args.length > 0) {
|
||||
if (Permissions.hasPermission(plr, "plots.auto.mega")) {
|
||||
try {
|
||||
final String[] split = args[0].split(",|;");
|
||||
String[] split = args[0].split(",|;");
|
||||
size_x = Integer.parseInt(split[0]);
|
||||
size_z = Integer.parseInt(split[1]);
|
||||
if (size_x < 1 || size_z < 1) {
|
||||
@ -110,8 +110,8 @@ public class Auto extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + "");
|
||||
return false;
|
||||
}
|
||||
final int currentPlots = Settings.GLOBAL_LIMIT ? plr.getPlotCount() : plr.getPlotCount(plotarea.worldname);
|
||||
final int diff = currentPlots - plr.getAllowedPlots();
|
||||
int currentPlots = Settings.GLOBAL_LIMIT ? plr.getPlotCount() : plr.getPlotCount(plotarea.worldname);
|
||||
int diff = currentPlots - plr.getAllowedPlots();
|
||||
if (diff + size_x * size_z > 0) {
|
||||
if (diff < 0) {
|
||||
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
|
||||
@ -159,15 +159,15 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
// TODO handle type 2 the same as normal worlds!
|
||||
if (plotarea.TYPE == 2) {
|
||||
final PlotId bot = plotarea.getMin();
|
||||
final PlotId top = plotarea.getMax();
|
||||
final PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
|
||||
PlotId bot = plotarea.getMin();
|
||||
PlotId top = plotarea.getMax();
|
||||
PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
|
||||
PlotId id = new PlotId(0, 0);
|
||||
final int width = Math.max(top.x - bot.x + 1, top.y - bot.y + 1);
|
||||
final int max = width * width;
|
||||
int width = Math.max(top.x - bot.x + 1, top.y - bot.y + 1);
|
||||
int max = width * width;
|
||||
//
|
||||
for (int i = 0; i <= max; i++) {
|
||||
final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
|
||||
PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
|
||||
Plot current = plotarea.getPlotAbs(currentId);
|
||||
if (current.canClaim(plr)) {
|
||||
current.claim(plr, true, null);
|
||||
@ -182,14 +182,14 @@ public class Auto extends SubCommand {
|
||||
plotarea.setMeta("lastPlot", new PlotId(0, 0));
|
||||
boolean br = false;
|
||||
while (true) {
|
||||
final PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
|
||||
final PlotId end = new PlotId(start.x + size_x - 1, start.y + size_z - 1);
|
||||
PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
|
||||
PlotId end = new PlotId(start.x + size_x - 1, start.y + size_z - 1);
|
||||
plotarea.setMeta("lastPlot", start);
|
||||
if (plotarea.canClaim(plr, start, end)) {
|
||||
for (int i = start.x; i <= end.x; i++) {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
|
||||
final boolean teleport = i == end.x && j == end.y;
|
||||
boolean teleport = i == end.x && j == end.y;
|
||||
plot.claim(plr, teleport, null);
|
||||
}
|
||||
}
|
||||
@ -205,7 +205,7 @@ public class Auto extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
public PlotId getLastPlotId(final PlotArea area) {
|
||||
public PlotId getLastPlotId(PlotArea area) {
|
||||
PlotId value = (PlotId) area.getMeta("lastPlot");
|
||||
if (value == null) {
|
||||
value = new PlotId(0, 0);
|
||||
|
@ -30,26 +30,26 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "bo3",
|
||||
aliases = { "bo2" },
|
||||
description = "Mark a plot as done",
|
||||
permission = "plots.bo3",
|
||||
category = CommandCategory.SCHEMATIC,
|
||||
requiredType = RequiredType.NONE)
|
||||
aliases = {"bo2"},
|
||||
description = "Mark a plot as done",
|
||||
permission = "plots.bo3",
|
||||
category = CommandCategory.SCHEMATIC,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class BO3 extends SubCommand {
|
||||
|
||||
public void noArgs(final PlotPlayer plr) {
|
||||
public void noArgs(PlotPlayer plr) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 export [category] [alias] [-r]");
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 import <file>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.bo3")) {
|
||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.bo3")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -29,18 +29,18 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "setbiome",
|
||||
permission = "plots.set.biome",
|
||||
description = "Set the plot biome",
|
||||
usage = "/plot biome [biome]",
|
||||
aliases = { "biome", "sb", "setb", "b" },
|
||||
category = CommandCategory.APPEARANCE,
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "setbiome",
|
||||
permission = "plots.set.biome",
|
||||
description = "Set the plot biome",
|
||||
usage = "/plot biome [biome]",
|
||||
aliases = {"biome", "sb", "setb", "b"},
|
||||
category = CommandCategory.APPEARANCE,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Biome extends SetCommand {
|
||||
|
||||
@Override
|
||||
public boolean set(final PlotPlayer plr, final Plot plot, final String value) {
|
||||
final int biome = WorldUtil.IMP.getBiomeFromString(value);
|
||||
int biome = WorldUtil.IMP.getBiomeFromString(value);
|
||||
if (biome == -1) {
|
||||
String biomes = StringMan.join(WorldUtil.IMP.getBiomeList(), C.BLOCK_LIST_SEPARATER.s());
|
||||
C.NEED_BIOME.send(plr);
|
||||
|
@ -35,22 +35,22 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import java.util.Set;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "buy",
|
||||
aliases = { "b" },
|
||||
description = "Buy the plot you are standing on",
|
||||
usage = "/plot buy",
|
||||
permission = "plots.buy",
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "buy",
|
||||
aliases = {"b"},
|
||||
description = "Buy the plot you are standing on",
|
||||
usage = "/plot buy",
|
||||
permission = "plots.buy",
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Buy extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
public boolean onCommand(PlotPlayer plr, String... args) {
|
||||
if (EconHandler.manager == null) {
|
||||
return sendMessage(plr, C.ECON_DISABLED);
|
||||
}
|
||||
final Location loc = plr.getLocation();
|
||||
final String world = loc.getWorld();
|
||||
Location loc = plr.getLocation();
|
||||
String world = loc.getWorld();
|
||||
if (!PS.get().hasPlotArea(world)) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
@ -63,7 +63,7 @@ public class Buy extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
plots = plot.getConnectedPlots();
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
return sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
}
|
||||
} else {
|
||||
@ -76,11 +76,11 @@ public class Buy extends SubCommand {
|
||||
if (!plot.hasOwner()) {
|
||||
return sendMessage(plr, C.PLOT_UNOWNED);
|
||||
}
|
||||
final int currentPlots = plr.getPlotCount() + plots.size();
|
||||
int currentPlots = plr.getPlotCount() + plots.size();
|
||||
if (currentPlots > plr.getAllowedPlots()) {
|
||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "price");
|
||||
Flag flag = FlagManager.getPlotFlagRaw(plot, "price");
|
||||
if (flag == null) {
|
||||
return sendMessage(plr, C.NOT_FOR_SALE);
|
||||
}
|
||||
@ -95,13 +95,13 @@ public class Buy extends SubCommand {
|
||||
EconHandler.manager.withdrawMoney(plr, price);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
||||
EconHandler.manager.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), price);
|
||||
final PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
|
||||
PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
|
||||
if (owner != null) {
|
||||
sendMessage(plr, C.PLOT_SOLD, plot.getId() + "", plr.getName(), price + "");
|
||||
}
|
||||
FlagManager.removePlotFlag(plot, "price");
|
||||
}
|
||||
for (final Plot current : plots) {
|
||||
for (Plot current : plots) {
|
||||
plot.setOwner(plr.getUUID());
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.CLAIMED);
|
||||
|
@ -4,16 +4,16 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "chat",
|
||||
description = "Toggle plot chat on or off",
|
||||
usage = "/plot chat [on|off]",
|
||||
permission = "plots.chat",
|
||||
category = CommandCategory.CHAT,
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "chat",
|
||||
description = "Toggle plot chat on or off",
|
||||
usage = "/plot chat [on|off]",
|
||||
permission = "plots.chat",
|
||||
category = CommandCategory.CHAT,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Chat extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String... args) {
|
||||
public boolean onCommand(PlotPlayer player, String... args) {
|
||||
return MainCommand.onCommand(player, "plot", "toggle", "chat");
|
||||
}
|
||||
}
|
||||
|
@ -32,24 +32,25 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "claim",
|
||||
aliases = "c",
|
||||
description = "Claim the current plot you're standing on",
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.claim", usage = "/plot claim")
|
||||
aliases = "c",
|
||||
description = "Claim the current plot you're standing on",
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.claim", usage = "/plot claim")
|
||||
public class Claim extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
public boolean onCommand(PlotPlayer plr, String... args) {
|
||||
String schematic = "";
|
||||
if (args.length >= 1) {
|
||||
schematic = args[0];
|
||||
}
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final int currentPlots = Settings.GLOBAL_LIMIT ? plr.getPlotCount() : plr.getPlotCount(loc.getWorld());
|
||||
int currentPlots = Settings.GLOBAL_LIMIT ? plr.getPlotCount() : plr.getPlotCount(loc.getWorld());
|
||||
int grants = 0;
|
||||
if (currentPlots >= plr.getAllowedPlots()) {
|
||||
if (plr.hasPersistentMeta("grantedPlots")) {
|
||||
@ -65,9 +66,9 @@ public class Claim extends SubCommand {
|
||||
if (!plot.canClaim(plr)) {
|
||||
return sendMessage(plr, C.PLOT_IS_CLAIMED);
|
||||
}
|
||||
final PlotArea world = plot.getArea();
|
||||
PlotArea world = plot.getArea();
|
||||
if ((EconHandler.manager != null) && world.USE_ECONOMY) {
|
||||
final double cost = world.PRICES.get("claim");
|
||||
double cost = world.PRICES.get("claim");
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
|
@ -32,19 +32,20 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@CommandDeclaration(command = "clear",
|
||||
description = "Clear a plot",
|
||||
permission = "plots.clear",
|
||||
category = CommandCategory.APPEARANCE,
|
||||
usage = "/plot clear [id]",
|
||||
aliases = "reset")
|
||||
description = "Clear a plot",
|
||||
permission = "plots.clear",
|
||||
category = CommandCategory.APPEARANCE,
|
||||
usage = "/plot clear [id]",
|
||||
aliases = "reset")
|
||||
public class Clear extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
final Location loc = plr.getLocation();
|
||||
public boolean onCommand(final PlotPlayer plr, String... args) {
|
||||
Location loc = plr.getLocation();
|
||||
final Plot plot;
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("mine")) {
|
||||
@ -81,15 +82,16 @@ public class Clear extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if ((FlagManager.getPlotFlagRaw(plot, "done") != null)
|
||||
&& (!Permissions.hasPermission(plr, "plots.continue") || (Settings.DONE_COUNTS_TOWARDS_LIMIT && (plr.getAllowedPlots() >= plr.getPlotCount())))) {
|
||||
&& (!Permissions.hasPermission(plr, "plots.continue") || (Settings.DONE_COUNTS_TOWARDS_LIMIT && (plr.getAllowedPlots() >= plr
|
||||
.getPlotCount())))) {
|
||||
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
|
||||
return false;
|
||||
}
|
||||
final Runnable runnable = new Runnable() {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final long start = System.currentTimeMillis();
|
||||
final boolean result = plot.clear(true, false, new Runnable() {
|
||||
boolean result = plot.clear(true, false, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plot.unlink();
|
||||
@ -111,13 +113,12 @@ public class Clear extends SubCommand {
|
||||
});
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
plot.addRunning();
|
||||
}
|
||||
}
|
||||
};
|
||||
if (Settings.CONFIRM_CLEAR && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) {
|
||||
if (Settings.CONFIRM_CLEAR && !Permissions.hasPermission(plr, "plots.confirm.bypass")) {
|
||||
CmdConfirm.addPending(plr, "/plot clear " + plot.getId(), runnable);
|
||||
} else {
|
||||
TaskManager.runTask(runnable);
|
||||
|
@ -35,21 +35,22 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "cluster",
|
||||
aliases = "clusters",
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.cluster",
|
||||
description = "Manage a plot cluster")
|
||||
aliases = "clusters",
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.cluster",
|
||||
description = "Manage a plot cluster")
|
||||
public class Cluster extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
public boolean onCommand(PlotPlayer plr, String... args) {
|
||||
|
||||
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
|
||||
if (args.length == 0) {
|
||||
@ -57,7 +58,7 @@ public class Cluster extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS);
|
||||
return false;
|
||||
}
|
||||
final String sub = args[0].toLowerCase();
|
||||
String sub = args[0].toLowerCase();
|
||||
switch (sub) {
|
||||
case "l":
|
||||
case "list": {
|
||||
@ -70,11 +71,11 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
final Set<PlotCluster> clusters = area.getClusters();
|
||||
Set<PlotCluster> clusters = area.getClusters();
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + "");
|
||||
for (final PlotCluster cluster : clusters) {
|
||||
for (PlotCluster cluster : clusters) {
|
||||
// Ignore unmanaged clusters
|
||||
final String name = "'" + cluster.getName() + "' : " + cluster.toString();
|
||||
String name = "'" + cluster.getName() + "' : " + cluster.toString();
|
||||
if (plr.getUUID().equals(cluster.owner)) {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + name);
|
||||
} else if (cluster.helpers.contains(plr.getUUID())) {
|
||||
@ -110,7 +111,7 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
// check if name is taken
|
||||
final String name = args[1];
|
||||
String name = args[1];
|
||||
if (area.getCluster(name) != null) {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
@ -127,11 +128,11 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
// Check if it occupies existing plots
|
||||
final Set<Plot> plots = area.getPlotSelectionOwned(pos1, pos2);
|
||||
Set<Plot> plots = area.getPlotSelectionOwned(pos1, pos2);
|
||||
if (!plots.isEmpty()) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.create.other")) {
|
||||
final UUID uuid = plr.getUUID();
|
||||
for (final Plot plot : plots) {
|
||||
UUID uuid = plr.getUUID();
|
||||
for (Plot plot : plots) {
|
||||
if (!plot.isOwner(uuid)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.create.other");
|
||||
return false;
|
||||
@ -147,7 +148,7 @@ public class Cluster extends SubCommand {
|
||||
} else {
|
||||
current = plr.getPlayerClusterCount(plr.getLocation().getWorld());
|
||||
}
|
||||
final int allowed = Permissions.hasPermissionRange(plr, "plots.cluster", Settings.MAX_PLOTS);
|
||||
int allowed = Permissions.hasPermissionRange(plr, "plots.cluster", Settings.MAX_PLOTS);
|
||||
if (current + cluster.getArea() > allowed) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
|
||||
return false;
|
||||
@ -157,7 +158,7 @@ public class Cluster extends SubCommand {
|
||||
area.addCluster(cluster);
|
||||
DBFunc.createCluster(cluster);
|
||||
// Add any existing plots to the current cluster
|
||||
for (final Plot plot : plots) {
|
||||
for (Plot plot : plots) {
|
||||
if (plot.hasOwner()) {
|
||||
if (!cluster.isAdded(plot.owner)) {
|
||||
cluster.invited.add(plot.owner);
|
||||
@ -235,7 +236,7 @@ public class Cluster extends SubCommand {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
return false;
|
||||
}
|
||||
final PlotCluster cluster = area.getCluster(plr.getLocation());
|
||||
PlotCluster cluster = area.getCluster(plr.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
@ -252,9 +253,9 @@ public class Cluster extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_INTERSECTION, intersect.getName());
|
||||
return false;
|
||||
}
|
||||
final HashSet<Plot> existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2());
|
||||
final HashSet<Plot> newplots = area.getPlotSelectionOwned(pos1, pos2);
|
||||
final HashSet<Plot> removed = (HashSet<Plot>) existing.clone();
|
||||
HashSet<Plot> existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2());
|
||||
HashSet<Plot> newplots = area.getPlotSelectionOwned(pos1, pos2);
|
||||
HashSet<Plot> removed = (HashSet<Plot>) existing.clone();
|
||||
removed.removeAll(newplots);
|
||||
// Check expand / shrink
|
||||
if (!removed.isEmpty()) {
|
||||
@ -278,7 +279,7 @@ public class Cluster extends SubCommand {
|
||||
current = plr.getPlayerClusterCount(plr.getLocation().getWorld());
|
||||
}
|
||||
current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
|
||||
final int allowed = Permissions.hasPermissionRange(plr, "plots.cluster", Settings.MAX_PLOTS);
|
||||
int allowed = Permissions.hasPermissionRange(plr, "plots.cluster", Settings.MAX_PLOTS);
|
||||
if (current + cluster.getArea() > allowed) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
|
||||
return false;
|
||||
@ -304,7 +305,7 @@ public class Cluster extends SubCommand {
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
}
|
||||
final PlotCluster cluster = area.getCluster(plr.getLocation());
|
||||
PlotCluster cluster = area.getCluster(plr.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
@ -316,7 +317,7 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
}
|
||||
// check uuid
|
||||
final UUID uuid = UUIDHandler.getUUID(args[1], null);
|
||||
UUID uuid = UUIDHandler.getUUID(args[1], null);
|
||||
if (uuid == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[2]);
|
||||
return false;
|
||||
@ -325,7 +326,7 @@ public class Cluster extends SubCommand {
|
||||
// add the user if not added
|
||||
cluster.invited.add(uuid);
|
||||
DBFunc.setInvited(cluster, uuid);
|
||||
final PlotPlayer player = UUIDHandler.getPlayer(uuid);
|
||||
PlotPlayer player = UUIDHandler.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_INVITED, cluster.getName());
|
||||
}
|
||||
@ -348,7 +349,7 @@ public class Cluster extends SubCommand {
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
}
|
||||
final PlotCluster cluster = area.getCluster(plr.getLocation());
|
||||
PlotCluster cluster = area.getCluster(plr.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
@ -360,7 +361,7 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
}
|
||||
// check uuid
|
||||
final UUID uuid = UUIDHandler.getUUID(args[1], null);
|
||||
UUID uuid = UUIDHandler.getUUID(args[1], null);
|
||||
if (uuid == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]);
|
||||
return false;
|
||||
@ -376,12 +377,12 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
cluster.invited.remove(uuid);
|
||||
DBFunc.removeInvited(cluster, uuid);
|
||||
final PlotPlayer player = UUIDHandler.getPlayer(uuid);
|
||||
PlotPlayer player = UUIDHandler.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName());
|
||||
}
|
||||
for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
|
||||
final PlotCluster current = plot.getCluster();
|
||||
for (Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
|
||||
PlotCluster current = plot.getCluster();
|
||||
if (current != null && current.equals(cluster)) {
|
||||
plot.unclaim();
|
||||
}
|
||||
@ -417,7 +418,7 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final UUID uuid = plr.getUUID();
|
||||
UUID uuid = plr.getUUID();
|
||||
if (!cluster.isAdded(uuid)) {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_NOT_ADDED);
|
||||
return false;
|
||||
@ -433,8 +434,8 @@ public class Cluster extends SubCommand {
|
||||
cluster.invited.remove(uuid);
|
||||
DBFunc.removeInvited(cluster, uuid);
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName());
|
||||
for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
|
||||
final PlotCluster current = plot.getCluster();
|
||||
for (Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
|
||||
PlotCluster current = plot.getCluster();
|
||||
if (current != null && current.equals(cluster)) {
|
||||
plr.getLocation().getWorld();
|
||||
plot.unclaim();
|
||||
@ -457,12 +458,12 @@ public class Cluster extends SubCommand {
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
}
|
||||
final PlotCluster cluster = area.getCluster(plr.getLocation());
|
||||
PlotCluster cluster = area.getCluster(plr.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
final UUID uuid = UUIDHandler.getUUID(args[2], null);
|
||||
UUID uuid = UUIDHandler.getUUID(args[2], null);
|
||||
if (uuid == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[2]);
|
||||
return false;
|
||||
@ -495,12 +496,12 @@ public class Cluster extends SubCommand {
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
}
|
||||
final PlotCluster cluster = area.getCluster(args[1]);
|
||||
PlotCluster cluster = area.getCluster(args[1]);
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
||||
return false;
|
||||
}
|
||||
final UUID uuid = plr.getUUID();
|
||||
UUID uuid = plr.getUUID();
|
||||
if (!cluster.isAdded(uuid)) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.tp.other")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other");
|
||||
@ -540,14 +541,14 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final String id = cluster.toString();
|
||||
String id = cluster.toString();
|
||||
String owner = UUIDHandler.getName(cluster.owner);
|
||||
if (owner == null) {
|
||||
owner = "unknown";
|
||||
}
|
||||
final String name = cluster.getName();
|
||||
final String size = (cluster.getP2().x - cluster.getP1().x + 1) + "x" + (cluster.getP2().y - cluster.getP1().y + 1);
|
||||
final String rights = cluster.isAdded(plr.getUUID()) + "";
|
||||
String name = cluster.getName();
|
||||
String size = (cluster.getP2().x - cluster.getP1().x + 1) + "x" + (cluster.getP2().y - cluster.getP1().y + 1);
|
||||
String rights = cluster.isAdded(plr.getUUID()) + "";
|
||||
String message = C.CLUSTER_INFO.s();
|
||||
message = message.replaceAll("%id%", id);
|
||||
message = message.replaceAll("%owner%", owner);
|
||||
@ -572,7 +573,7 @@ public class Cluster extends SubCommand {
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
}
|
||||
final PlotCluster cluster = area.getCluster(plr.getLocation());
|
||||
PlotCluster cluster = area.getCluster(plr.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
@ -583,9 +584,9 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final Location base = cluster.getClusterBottom();
|
||||
final Location relative = plr.getLocation().subtract(base.getX(), 0, base.getZ());
|
||||
final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ());
|
||||
Location base = cluster.getClusterBottom();
|
||||
Location relative = plr.getLocation().subtract(base.getX(), 0, base.getZ());
|
||||
BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ());
|
||||
cluster.settings.setPosition(blockloc);
|
||||
DBFunc.setPosition(cluster, relative.getX() + "," + relative.getY() + "," + relative.getZ());
|
||||
return MainUtil.sendMessage(plr, C.POSITION_SET);
|
||||
|
@ -2,7 +2,9 @@ package com.intellectualcrafters.plot.commands;
|
||||
|
||||
/**
|
||||
* CommandCategory
|
||||
*
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public enum CommandCategory {
|
||||
/**
|
||||
@ -54,18 +56,18 @@ public enum CommandCategory {
|
||||
* The category name (Readable)
|
||||
*/
|
||||
private final String name;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param name readable name
|
||||
*/
|
||||
* @param name readable name
|
||||
CommandCategory(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
this.name = name;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@Override
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
@ -25,27 +25,29 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-03.
|
||||
*
|
||||
*
|
||||
|
||||
*/
|
||||
public class CommandPermission {
|
||||
|
||||
/**
|
||||
* Permission Node
|
||||
*/
|
||||
public final String permission;
|
||||
public final String permission;
|
||||
|
||||
/**
|
||||
* @param permission Command Permission
|
||||
*/
|
||||
*/
|
||||
public CommandPermission(String permission) {
|
||||
this.permission = permission.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player Does the player have the permission?
|
||||
*
|
||||
* @return true of player has the required permission node
|
||||
*/
|
||||
*/
|
||||
public boolean hasPermission(final PlotPlayer player) {
|
||||
public boolean hasPermission(PlotPlayer player) {
|
||||
return Permissions.hasPermission(player, this.permission);
|
||||
}
|
||||
}
|
||||
|
@ -32,30 +32,31 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@CommandDeclaration(command = "comment",
|
||||
aliases = { "msg" },
|
||||
description = "Comment on a plot",
|
||||
category = CommandCategory.CHAT,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.comment")
|
||||
aliases = {"msg"},
|
||||
description = "Comment on a plot",
|
||||
category = CommandCategory.CHAT,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.comment")
|
||||
public class Comment extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
sendMessage(player, C.COMMENT_SYNTAX, StringMan.join(CommentManager.inboxes.keySet(), "|"));
|
||||
return false;
|
||||
}
|
||||
final CommentInbox inbox = CommentManager.inboxes.get(args[0].toLowerCase());
|
||||
CommentInbox inbox = CommentManager.inboxes.get(args[0].toLowerCase());
|
||||
if (inbox == null) {
|
||||
sendMessage(player, C.COMMENT_SYNTAX, StringMan.join(CommentManager.inboxes.keySet(), "|"));
|
||||
return false;
|
||||
}
|
||||
final Location loc = player.getLocation();
|
||||
final PlotId id = PlotId.fromString(args[1]);
|
||||
Location loc = player.getLocation();
|
||||
PlotId id = PlotId.fromString(args[1]);
|
||||
Plot plot = MainUtil.getPlotFromString(player, args[1], false);
|
||||
int index;
|
||||
if (plot == null) {
|
||||
@ -72,9 +73,9 @@ public class Comment extends SubCommand {
|
||||
sendMessage(player, C.NO_PERM_INBOX, "");
|
||||
return false;
|
||||
}
|
||||
final String message = StringMan.join(Arrays.copyOfRange(args, index, args.length), " ");
|
||||
final PlotComment comment = new PlotComment(loc.getWorld(), id, message, player.getName(), inbox.toString(), System.currentTimeMillis());
|
||||
final boolean result = inbox.addComment(plot, comment);
|
||||
String message = StringMan.join(Arrays.copyOfRange(args, index, args.length), " ");
|
||||
PlotComment comment = new PlotComment(loc.getWorld(), id, message, player.getName(), inbox.toString(), System.currentTimeMillis());
|
||||
boolean result = inbox.addComment(plot, comment);
|
||||
if (!result) {
|
||||
sendMessage(player, C.NO_PLOT_INBOX, "");
|
||||
sendMessage(player, C.COMMENT_SYNTAX, StringMan.join(CommentManager.inboxes.keySet(), "|"));
|
||||
|
@ -30,6 +30,7 @@ import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@ -39,16 +40,16 @@ import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@CommandDeclaration(command = "condense",
|
||||
permission = "plots.admin",
|
||||
description = "Condense a plotworld",
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.CONSOLE)
|
||||
permission = "plots.admin",
|
||||
description = "Condense a plotworld",
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.CONSOLE)
|
||||
public class Condense extends SubCommand {
|
||||
|
||||
public static boolean TASK = false;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
public boolean onCommand(final PlotPlayer plr, String... args) {
|
||||
if ((args.length != 2) && (args.length != 3)) {
|
||||
MainUtil.sendMessage(plr, "/plot condense <area> <start|stop|info> [radius]");
|
||||
return false;
|
||||
@ -72,7 +73,7 @@ public class Condense extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "INVALID RADIUS");
|
||||
return false;
|
||||
}
|
||||
final int radius = Integer.parseInt(args[2]);
|
||||
int radius = Integer.parseInt(args[2]);
|
||||
ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlots(area));
|
||||
// remove non base plots
|
||||
Iterator<Plot> iter = plots.iterator();
|
||||
@ -109,23 +110,23 @@ public class Condense extends SubCommand {
|
||||
allPlots.addAll(array);
|
||||
}
|
||||
}
|
||||
final int size = allPlots.size();
|
||||
final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
||||
if (radius < minimum_radius) {
|
||||
int size = allPlots.size();
|
||||
int minimumRadius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
||||
if (radius < minimumRadius) {
|
||||
MainUtil.sendMessage(plr, "RADIUS TOO SMALL");
|
||||
return false;
|
||||
}
|
||||
final List<PlotId> to_move = new ArrayList<>(getPlots(allPlots, radius));
|
||||
List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius));
|
||||
final List<PlotId> free = new ArrayList<>();
|
||||
PlotId start = new PlotId(0, 0);
|
||||
while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) {
|
||||
while ((start.x <= minimumRadius) && (start.y <= minimumRadius)) {
|
||||
Plot plot = area.getPlotAbs(start);
|
||||
if (plot != null && !plot.hasOwner()) {
|
||||
free.add(plot.getId());
|
||||
}
|
||||
start = Auto.getNextPlotId(start, 1);
|
||||
}
|
||||
if ((free.isEmpty()) || (to_move.isEmpty())) {
|
||||
if (free.isEmpty() || toMove.isEmpty()) {
|
||||
MainUtil.sendMessage(plr, "NO FREE PLOTS FOUND");
|
||||
return false;
|
||||
}
|
||||
@ -197,22 +198,22 @@ public class Condense extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "INVALID RADIUS");
|
||||
return false;
|
||||
}
|
||||
final int radius = Integer.parseInt(args[2]);
|
||||
final Collection<Plot> plots = area.getPlots();
|
||||
final int size = plots.size();
|
||||
final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
||||
if (radius < minimum_radius) {
|
||||
int radius = Integer.parseInt(args[2]);
|
||||
Collection<Plot> plots = area.getPlots();
|
||||
int size = plots.size();
|
||||
int minimumRadius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
||||
if (radius < minimumRadius) {
|
||||
MainUtil.sendMessage(plr, "RADIUS TOO SMALL");
|
||||
return false;
|
||||
}
|
||||
final int max_move = getPlots(plots, minimum_radius).size();
|
||||
final int user_move = getPlots(plots, radius).size();
|
||||
int maxMove = getPlots(plots, minimumRadius).size();
|
||||
int userMove = getPlots(plots, radius).size();
|
||||
MainUtil.sendMessage(plr, "=== DEFAULT EVAL ===");
|
||||
MainUtil.sendMessage(plr, "MINIMUM RADIUS: " + minimum_radius);
|
||||
MainUtil.sendMessage(plr, "MAXIMUM MOVES: " + max_move);
|
||||
MainUtil.sendMessage(plr, "MINIMUM RADIUS: " + minimumRadius);
|
||||
MainUtil.sendMessage(plr, "MAXIMUM MOVES: " + maxMove);
|
||||
MainUtil.sendMessage(plr, "=== INPUT EVAL ===");
|
||||
MainUtil.sendMessage(plr, "INPUT RADIUS: " + radius);
|
||||
MainUtil.sendMessage(plr, "ESTIMATED MOVES: " + user_move);
|
||||
MainUtil.sendMessage(plr, "ESTIMATED MOVES: " + userMove);
|
||||
MainUtil.sendMessage(plr, "ESTIMATED TIME: " + "No idea, times will drastically change based on the system performance and load");
|
||||
MainUtil.sendMessage(plr, "&e - Radius is measured in plot width");
|
||||
return true;
|
||||
@ -222,9 +223,9 @@ public class Condense extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Set<PlotId> getPlots(final Collection<Plot> plots, final int radius) {
|
||||
final HashSet<PlotId> outside = new HashSet<>();
|
||||
for (final Plot plot : plots) {
|
||||
public Set<PlotId> getPlots(Collection<Plot> plots, int radius) {
|
||||
HashSet<PlotId> outside = new HashSet<>();
|
||||
for (Plot plot : plots) {
|
||||
if ((plot.getId().x > radius) || (plot.getId().x < -radius) || (plot.getId().y > radius) || (plot.getId().y < -radius)) {
|
||||
outside.add(plot.getId());
|
||||
}
|
||||
|
@ -29,14 +29,14 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "confirm",
|
||||
permission = "plots.use",
|
||||
description = "Confirm an action",
|
||||
category = CommandCategory.INFO)
|
||||
permission = "plots.use",
|
||||
description = "Confirm an action",
|
||||
category = CommandCategory.INFO)
|
||||
public class Confirm extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
final CmdInstance command = CmdConfirm.getPending(plr);
|
||||
public boolean onCommand(PlotPlayer plr, String... args) {
|
||||
CmdInstance command = CmdConfirm.getPending(plr);
|
||||
if (command == null) {
|
||||
MainUtil.sendMessage(plr, C.FAILED_CONFIRM);
|
||||
return false;
|
||||
|
@ -30,16 +30,16 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "continue",
|
||||
description = "Continue a plot that was previously marked as done",
|
||||
permission = "plots.continue",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "continue",
|
||||
description = "Continue a plot that was previously marked as done",
|
||||
permission = "plots.continue",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Continue extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Plot plot = plr.getCurrentPlot();
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Plot plot = plr.getCurrentPlot();
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -29,19 +29,19 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "copy",
|
||||
permission = "plots.copy",
|
||||
aliases = { "copypaste" },
|
||||
category = CommandCategory.CLAIMING,
|
||||
description = "Copy a plot",
|
||||
usage = "/plot copy <X;Z>",
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "copy",
|
||||
permission = "plots.copy",
|
||||
aliases = {"copypaste"},
|
||||
category = CommandCategory.CLAIMING,
|
||||
description = "Copy a plot",
|
||||
usage = "/plot copy <X;Z>",
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Copy extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot1 = loc.getPlotAbs();
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot1 = loc.getPlotAbs();
|
||||
if (plot1 == null) {
|
||||
return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -53,8 +53,8 @@ public class Copy extends SubCommand {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
return false;
|
||||
}
|
||||
final Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
if ((plot2 == null)) {
|
||||
Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
if (plot2 == null) {
|
||||
return false;
|
||||
}
|
||||
if (plot1.equals(plot2)) {
|
||||
|
@ -30,19 +30,19 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "createroadschematic",
|
||||
aliases = { "crs" },
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.createroadschematic",
|
||||
description = "Add a road schematic to your world using the roads around your current plot",
|
||||
usage = "/plot createroadschematic")
|
||||
command = "createroadschematic",
|
||||
aliases = {"crs"},
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.createroadschematic",
|
||||
description = "Add a road schematic to your world using the roads around your current plot",
|
||||
usage = "/plot createroadschematic")
|
||||
public class CreateRoadSchematic extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String... args) {
|
||||
final Location loc = player.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
public boolean onCommand(PlotPlayer player, String... args) {
|
||||
Location loc = player.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@ -20,13 +21,13 @@ import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "database",
|
||||
aliases = { "convert" },
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
permission = "plots.database",
|
||||
description = "Convert/Backup Storage",
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
usage = "/plots database [area] <sqlite|mysql|import>")
|
||||
command = "database",
|
||||
aliases = {"convert"},
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
permission = "plots.database",
|
||||
description = "Convert/Backup Storage",
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
usage = "/plots database [area] <sqlite|mysql|import>")
|
||||
public class Database extends SubCommand {
|
||||
|
||||
public static void insertPlots(final SQLManager manager, final ArrayList<Plot> plots, final PlotPlayer player) {
|
||||
@ -34,8 +35,8 @@ public class Database extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final ArrayList<Plot> ps = new ArrayList<>();
|
||||
for (final Plot p : plots) {
|
||||
ArrayList<Plot> ps = new ArrayList<>();
|
||||
for (Plot p : plots) {
|
||||
ps.add(p);
|
||||
}
|
||||
MainUtil.sendMessage(player, "&6Starting...");
|
||||
@ -46,7 +47,7 @@ public class Database extends SubCommand {
|
||||
manager.close();
|
||||
}
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
MainUtil.sendMessage(player, "Failed to insert plot objects, see stacktrace for info");
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -89,15 +90,15 @@ public class Database extends SubCommand {
|
||||
}
|
||||
MainUtil.sendMessage(player, "&6Starting...");
|
||||
implementation = new SQLite(file.getPath());
|
||||
final SQLManager manager = new SQLManager(implementation, (args.length == 3) ? args[2] : "", true);
|
||||
final HashMap<String, HashMap<PlotId, Plot>> map = manager.getPlots();
|
||||
SQLManager manager = new SQLManager(implementation, (args.length == 3) ? args[2] : "", true);
|
||||
HashMap<String, HashMap<PlotId, Plot>> map = manager.getPlots();
|
||||
plots = new ArrayList<>();
|
||||
for (final Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
||||
String areaname = entry.getKey();
|
||||
PlotArea pa = PS.get().getPlotAreaByString(areaname);
|
||||
if (pa != null) {
|
||||
for (final Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
final Plot plot = entry2.getValue();
|
||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
Plot plot = entry2.getValue();
|
||||
if (pa.getOwnedPlotAbs(plot.getId()) != null) {
|
||||
MainUtil.sendMessage(player, "Skipping duplicate plot: " + plot + " | id=" + plot.temp);
|
||||
continue;
|
||||
@ -126,11 +127,11 @@ public class Database extends SubCommand {
|
||||
if (args.length < 6) {
|
||||
return MainUtil.sendMessage(player, "/plot database mysql [host] [port] [username] [password] [database] {prefix}");
|
||||
}
|
||||
final String host = args[1];
|
||||
final String port = args[2];
|
||||
final String username = args[3];
|
||||
final String password = args[4];
|
||||
final String database = args[5];
|
||||
String host = args[1];
|
||||
String port = args[2];
|
||||
String username = args[3];
|
||||
String password = args[4];
|
||||
String database = args[5];
|
||||
if (args.length > 6) {
|
||||
prefix = args[6];
|
||||
}
|
||||
@ -146,7 +147,7 @@ public class Database extends SubCommand {
|
||||
return MainUtil.sendMessage(player, "/plot database [sqlite/mysql]");
|
||||
}
|
||||
try {
|
||||
final SQLManager manager = new SQLManager(implementation, prefix, true);
|
||||
SQLManager manager = new SQLManager(implementation, prefix, true);
|
||||
insertPlots(manager, plots, player);
|
||||
return true;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
|
@ -29,17 +29,17 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "debug",
|
||||
category = CommandCategory.DEBUG,
|
||||
description = "Show debug information",
|
||||
usage = "/plot debug [msg]",
|
||||
permission = "plots.admin")
|
||||
category = CommandCategory.DEBUG,
|
||||
description = "Show debug information",
|
||||
usage = "/plot debug [msg]",
|
||||
permission = "plots.admin")
|
||||
public class Debug extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
|
||||
final StringBuilder msg = new StringBuilder();
|
||||
for (final C c : C.values()) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for (C c : C.values()) {
|
||||
msg.append(c.s()).append("\n");
|
||||
}
|
||||
MainUtil.sendMessage(plr, msg.toString());
|
||||
@ -75,11 +75,11 @@ public class Debug extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getSection(final String line, final String val) {
|
||||
private String getSection(String line, String val) {
|
||||
return line.replaceAll("%val%", val) + "\n";
|
||||
}
|
||||
|
||||
private String getLine(final String line, final String var, final Object val) {
|
||||
private String getLine(String line, String var, Object val) {
|
||||
return line.replaceAll("%var%", var).replaceAll("%val%", "" + val) + "\n";
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,27 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugallowunsafe",
|
||||
description = "Allow unsafe actions until toggled off",
|
||||
usage = "/plot debugallowunsafe",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.debugallowunsafe")
|
||||
command = "debugallowunsafe",
|
||||
description = "Allow unsafe actions until toggled off",
|
||||
usage = "/plot debugallowunsafe",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.debugallowunsafe")
|
||||
public class DebugAllowUnsafe extends SubCommand {
|
||||
|
||||
|
||||
public static final List<UUID> unsafeAllowed = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
|
||||
public boolean onCommand(PlotPlayer plr, String... args) {
|
||||
|
||||
if (unsafeAllowed.contains(plr.getUUID())) {
|
||||
unsafeAllowed.remove(plr.getUUID());
|
||||
sendMessage(plr, C.DEBUGALLOWUNSAFE_OFF);
|
||||
@ -31,5 +31,5 @@ public class DebugAllowUnsafe extends SubCommand {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,14 @@ import com.google.common.collect.BiMap;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
@ -36,20 +43,22 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugclaimtest",
|
||||
description = "If you accidentally delete your database, this command will attempt to restore all plots based on the data from plot signs. Execution time may vary",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
permission = "plots.debugclaimtest")
|
||||
command = "debugclaimtest",
|
||||
description = "If you accidentally delete your database, this command will attempt to restore all plots based on the data from plot signs. "
|
||||
+ "Execution time may vary",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
permission = "plots.debugclaimtest")
|
||||
public class DebugClaimTest extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
if (args.length < 3) {
|
||||
return !MainUtil
|
||||
.sendMessage(
|
||||
null,
|
||||
"If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}");
|
||||
.sendMessage(
|
||||
null,
|
||||
"If you accidentally delete your database, this command will attempt to restore all plots based on the data from the "
|
||||
+ "plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}");
|
||||
}
|
||||
PlotArea area = PS.get().getPlotAreaByString(args[0]);
|
||||
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) {
|
||||
@ -62,35 +71,36 @@ public class DebugClaimTest extends SubCommand {
|
||||
args[2].split(";");
|
||||
min = PlotId.fromString(args[1]);
|
||||
max = PlotId.fromString(args[2]);
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
return !MainUtil.sendMessage(plr,
|
||||
"&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X;Y are the plot coords\nThe conversion will only check the plots in the selected area.");
|
||||
"&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X;Y are the plot coords\nThe conversion "
|
||||
+ "will only check the plots in the selected area.");
|
||||
}
|
||||
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
|
||||
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
|
||||
final PlotManager manager = area.getPlotManager();
|
||||
final ArrayList<Plot> plots = new ArrayList<>();
|
||||
for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
|
||||
final Plot plot = area.getPlotAbs(id);
|
||||
PlotManager manager = area.getPlotManager();
|
||||
ArrayList<Plot> plots = new ArrayList<>();
|
||||
for (PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
|
||||
Plot plot = area.getPlotAbs(id);
|
||||
if (plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, " - &cDB Already contains: " + plot.getId());
|
||||
continue;
|
||||
}
|
||||
final Location loc = manager.getSignLoc(area, plot);
|
||||
final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
||||
final boolean result = ChunkManager.manager.loadChunk(area.worldname, chunk, false);
|
||||
Location loc = manager.getSignLoc(area, plot);
|
||||
ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
||||
boolean result = ChunkManager.manager.loadChunk(area.worldname, chunk, false);
|
||||
if (!result) {
|
||||
continue;
|
||||
}
|
||||
final String[] lines = WorldUtil.IMP.getSign(loc);
|
||||
String[] lines = WorldUtil.IMP.getSign(loc);
|
||||
if (lines != null) {
|
||||
String line = lines[2];
|
||||
if (line != null && line.length() > 2) {
|
||||
line = line.substring(2);
|
||||
final BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
|
||||
BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
|
||||
UUID uuid = map.get(new StringWrapper(line));
|
||||
if (uuid == null) {
|
||||
for (final Map.Entry<StringWrapper, UUID> stringWrapperUUIDEntry : map.entrySet()) {
|
||||
for (Map.Entry<StringWrapper, UUID> stringWrapperUUIDEntry : map.entrySet()) {
|
||||
if (stringWrapperUUIDEntry.getKey().value.toLowerCase().startsWith(line.toLowerCase())) {
|
||||
uuid = stringWrapperUUIDEntry.getValue();
|
||||
break;
|
||||
@ -118,7 +128,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "&6Database update finished!");
|
||||
}
|
||||
});
|
||||
for (final Plot plot : plots) {
|
||||
for (Plot plot : plots) {
|
||||
plot.create();
|
||||
}
|
||||
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
|
||||
|
@ -54,6 +54,7 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import com.plotsquared.listener.WEManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -62,6 +63,7 @@ import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import javax.script.ScriptContext;
|
||||
import javax.script.ScriptEngine;
|
||||
@ -70,111 +72,114 @@ import javax.script.ScriptException;
|
||||
import javax.script.SimpleScriptContext;
|
||||
|
||||
@CommandDeclaration(command = "debugexec",
|
||||
permission = "plots.admin",
|
||||
description = "Mutli-purpose debug command",
|
||||
aliases = "exec",
|
||||
category = CommandCategory.DEBUG)
|
||||
permission = "plots.admin",
|
||||
description = "Mutli-purpose debug command",
|
||||
aliases = "exec",
|
||||
category = CommandCategory.DEBUG)
|
||||
public class DebugExec extends SubCommand {
|
||||
|
||||
private ScriptEngine engine;
|
||||
private Bindings scope;
|
||||
|
||||
public DebugExec() {
|
||||
try {
|
||||
if (PS.get() != null) {
|
||||
final File file = new File(PS.get().IMP.getDirectory(), "scripts" + File.separator + "start.js");
|
||||
File file = new File(PS.get().IMP.getDirectory(), "scripts" + File.separator + "start.js");
|
||||
if (file.exists()) {
|
||||
init();
|
||||
final String script = StringMan.join(Files
|
||||
String script = StringMan.join(Files
|
||||
.readLines(new File(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), "start.js"),
|
||||
StandardCharsets.UTF_8),
|
||||
System.getProperty("line.separator"));
|
||||
scope.put("THIS", this);
|
||||
scope.put("PlotPlayer", ConsolePlayer.getConsole());
|
||||
engine.eval(script, scope);
|
||||
this.scope.put("THIS", this);
|
||||
this.scope.put("PlotPlayer", ConsolePlayer.getConsole());
|
||||
this.engine.eval(script, this.scope);
|
||||
}
|
||||
}
|
||||
} catch (IOException | ScriptException e) {}
|
||||
} catch (IOException | ScriptException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public ScriptEngine getEngine() {
|
||||
return engine;
|
||||
return this.engine;
|
||||
}
|
||||
|
||||
public Bindings getScope() {
|
||||
return scope;
|
||||
return this.scope;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
if (engine != null) {
|
||||
if (this.engine != null) {
|
||||
return;
|
||||
}
|
||||
engine = new ScriptEngineManager(null).getEngineByName("nashorn");
|
||||
if (engine == null) {
|
||||
engine = new ScriptEngineManager(null).getEngineByName("JavaScript");
|
||||
this.engine = new ScriptEngineManager(null).getEngineByName("nashorn");
|
||||
if (this.engine == null) {
|
||||
this.engine = new ScriptEngineManager(null).getEngineByName("JavaScript");
|
||||
}
|
||||
final ScriptContext context = new SimpleScriptContext();
|
||||
scope = context.getBindings(ScriptContext.ENGINE_SCOPE);
|
||||
ScriptContext context = new SimpleScriptContext();
|
||||
this.scope = context.getBindings(ScriptContext.ENGINE_SCOPE);
|
||||
|
||||
// stuff
|
||||
scope.put("MainUtil", new MainUtil());
|
||||
scope.put("Settings", new Settings());
|
||||
scope.put("StringMan", new StringMan());
|
||||
scope.put("MathMan", new MathMan());
|
||||
scope.put("FlagManager", new FlagManager());
|
||||
this.scope.put("MainUtil", new MainUtil());
|
||||
this.scope.put("Settings", new Settings());
|
||||
this.scope.put("StringMan", new StringMan());
|
||||
this.scope.put("MathMan", new MathMan());
|
||||
this.scope.put("FlagManager", new FlagManager());
|
||||
|
||||
// Classes
|
||||
scope.put("Location", Location.class);
|
||||
scope.put("PlotBlock", PlotBlock.class);
|
||||
scope.put("Plot", Plot.class);
|
||||
scope.put("PlotId", PlotId.class);
|
||||
scope.put("Runnable", Runnable.class);
|
||||
scope.put("RunnableVal", RunnableVal.class);
|
||||
this.scope.put("Location", Location.class);
|
||||
this.scope.put("PlotBlock", PlotBlock.class);
|
||||
this.scope.put("Plot", Plot.class);
|
||||
this.scope.put("PlotId", PlotId.class);
|
||||
this.scope.put("Runnable", Runnable.class);
|
||||
this.scope.put("RunnableVal", RunnableVal.class);
|
||||
|
||||
// Instances
|
||||
scope.put("PS", PS.get());
|
||||
scope.put("SetQueue", SetQueue.IMP);
|
||||
scope.put("ExpireManager", ExpireManager.IMP);
|
||||
this.scope.put("PS", PS.get());
|
||||
this.scope.put("SetQueue", SetQueue.IMP);
|
||||
this.scope.put("ExpireManager", ExpireManager.IMP);
|
||||
if (PS.get().worldedit != null) {
|
||||
scope.put("WEManager", new WEManager());
|
||||
this.scope.put("WEManager", new WEManager());
|
||||
}
|
||||
scope.put("TaskManager", PS.get().TASK);
|
||||
scope.put("TitleManager", AbstractTitle.TITLE_CLASS);
|
||||
scope.put("ConsolePlayer", ConsolePlayer.getConsole());
|
||||
scope.put("SchematicHandler", SchematicHandler.manager);
|
||||
scope.put("ChunkManager", ChunkManager.manager);
|
||||
scope.put("BlockManager", WorldUtil.IMP);
|
||||
scope.put("SetupUtils", SetupUtils.manager);
|
||||
scope.put("EventUtil", EventUtil.manager);
|
||||
scope.put("EconHandler", EconHandler.manager);
|
||||
scope.put("UUIDHandler", UUIDHandler.implementation);
|
||||
scope.put("DBFunc", DBFunc.dbManager);
|
||||
scope.put("HybridUtils", HybridUtils.manager);
|
||||
scope.put("IMP", PS.get().IMP);
|
||||
scope.put("MainCommand", MainCommand.getInstance());
|
||||
this.scope.put("TaskManager", PS.get().TASK);
|
||||
this.scope.put("TitleManager", AbstractTitle.TITLE_CLASS);
|
||||
this.scope.put("ConsolePlayer", ConsolePlayer.getConsole());
|
||||
this.scope.put("SchematicHandler", SchematicHandler.manager);
|
||||
this.scope.put("ChunkManager", ChunkManager.manager);
|
||||
this.scope.put("BlockManager", WorldUtil.IMP);
|
||||
this.scope.put("SetupUtils", SetupUtils.manager);
|
||||
this.scope.put("EventUtil", EventUtil.manager);
|
||||
this.scope.put("EconHandler", EconHandler.manager);
|
||||
this.scope.put("UUIDHandler", UUIDHandler.implementation);
|
||||
this.scope.put("DBFunc", DBFunc.dbManager);
|
||||
this.scope.put("HybridUtils", HybridUtils.manager);
|
||||
this.scope.put("IMP", PS.get().IMP);
|
||||
this.scope.put("MainCommand", MainCommand.getInstance());
|
||||
|
||||
// enums
|
||||
for (final Enum<?> value : C.values()) {
|
||||
scope.put("C_" + value.name(), value);
|
||||
for (Enum<?> value : C.values()) {
|
||||
this.scope.put("C_" + value.name(), value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String... args) {
|
||||
final java.util.List<String> allowed_params = Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen");
|
||||
public boolean onCommand(final PlotPlayer player, String... args) {
|
||||
java.util.List<String> allowed_params =
|
||||
Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen");
|
||||
if (args.length > 0) {
|
||||
final String arg = args[0].toLowerCase();
|
||||
String arg = args[0].toLowerCase();
|
||||
String script;
|
||||
boolean async = false;
|
||||
switch (arg) {
|
||||
case "analyze": {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
final PlotAnalysis analysis = plot.getComplexity();
|
||||
PlotAnalysis analysis = plot.getComplexity();
|
||||
if (analysis != null) {
|
||||
final int complexity = analysis.getComplexity();
|
||||
int complexity = analysis.getComplexity();
|
||||
MainUtil.sendMessage(player, "Changes/column: " + analysis.changes / 1.0);
|
||||
MainUtil.sendMessage(player, "Complexity: " + complexity);
|
||||
return true;
|
||||
@ -191,13 +196,15 @@ public class DebugExec extends SubCommand {
|
||||
case "calibrate-analysis":
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot debugexec analyze <threshold>");
|
||||
MainUtil.sendMessage(player, "$1<threshold> $2= $1The percentage of plots you want to clear (100 clears 100% of plots so no point calibrating it)");
|
||||
MainUtil.sendMessage(player,
|
||||
"$1<threshold> $2= $1The percentage of plots you want to clear (100 clears 100% of plots so no point calibrating "
|
||||
+ "it)");
|
||||
return false;
|
||||
}
|
||||
double threshold;
|
||||
try {
|
||||
threshold = Integer.parseInt(args[1]) / 100d;
|
||||
} catch (final NumberFormatException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
MainUtil.sendMessage(player, "$2Invalid threshold: " + args[1]);
|
||||
MainUtil.sendMessage(player, "$1<threshold> $2= $1The percentage of plots you want to clear as a number between 0 - 100");
|
||||
return false;
|
||||
@ -219,8 +226,8 @@ public class DebugExec extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot debugexec remove-flag <flag>");
|
||||
return false;
|
||||
}
|
||||
final String flag = args[1];
|
||||
for (final Plot plot : PS.get().getBasePlots()) {
|
||||
String flag = args[1];
|
||||
for (Plot plot : PS.get().getBasePlots()) {
|
||||
if (FlagManager.getPlotFlagRaw(plot, flag) != null) {
|
||||
FlagManager.removePlotFlag(plot, flag);
|
||||
}
|
||||
@ -275,16 +282,16 @@ public class DebugExec extends SubCommand {
|
||||
if (args.length != 2) {
|
||||
return MainUtil.sendMessage(player, "Use /plot debugexec seen <player>");
|
||||
}
|
||||
final UUID uuid = UUIDHandler.getUUID(args[1], null);
|
||||
UUID uuid = UUIDHandler.getUUID(args[1], null);
|
||||
if (uuid == null) {
|
||||
return MainUtil.sendMessage(player, "Player not found: " + args[1]);
|
||||
}
|
||||
final OfflinePlotPlayer op = UUIDHandler.getUUIDWrapper().getOfflinePlayer(uuid);
|
||||
OfflinePlotPlayer op = UUIDHandler.getUUIDWrapper().getOfflinePlayer(uuid);
|
||||
if (op == null || op.getLastPlayed() == 0) {
|
||||
return MainUtil.sendMessage(player, "Player hasn't connected before: " + args[1]);
|
||||
}
|
||||
final Timestamp stamp = new Timestamp(op.getLastPlayed());
|
||||
final Date date = new Date(stamp.getTime());
|
||||
Timestamp stamp = new Timestamp(op.getLastPlayed());
|
||||
Date date = new Date(stamp.getTime());
|
||||
MainUtil.sendMessage(player, "PLAYER: " + args[1]);
|
||||
MainUtil.sendMessage(player, "UUID: " + uuid);
|
||||
MainUtil.sendMessage(player, "Object: " + date.toGMTString());
|
||||
@ -300,17 +307,18 @@ public class DebugExec extends SubCommand {
|
||||
case "addcmd":
|
||||
try {
|
||||
final String cmd = StringMan.join(Files
|
||||
.readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]), StandardCharsets.UTF_8),
|
||||
.readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]),
|
||||
StandardCharsets.UTF_8),
|
||||
System.getProperty("line.separator"));
|
||||
final Command<PlotPlayer> subcommand = new Command<PlotPlayer>(args[1].split("\\.")[0]) {
|
||||
Command<PlotPlayer> subcommand = new Command<PlotPlayer>(args[1].split("\\.")[0]) {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
try {
|
||||
scope.put("PlotPlayer", plr);
|
||||
scope.put("args", args);
|
||||
engine.eval(cmd, scope);
|
||||
DebugExec.this.scope.put("PlotPlayer", plr);
|
||||
DebugExec.this.scope.put("args", args);
|
||||
DebugExec.this.engine.eval(cmd, DebugExec.this.scope);
|
||||
return true;
|
||||
} catch (final ScriptException e) {
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(player, C.COMMAND_WENT_WRONG);
|
||||
return false;
|
||||
@ -328,16 +336,18 @@ public class DebugExec extends SubCommand {
|
||||
async = true;
|
||||
case "run":
|
||||
try {
|
||||
script = StringMan.join(Files.readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]), StandardCharsets.UTF_8),
|
||||
System.getProperty("line.separator"));
|
||||
script = StringMan.join(Files
|
||||
.readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]),
|
||||
StandardCharsets.UTF_8),
|
||||
System.getProperty("line.separator"));
|
||||
if (args.length > 2) {
|
||||
final HashMap<String, String> replacements = new HashMap<>();
|
||||
HashMap<String, String> replacements = new HashMap<>();
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
replacements.put("%s" + (i - 2), args[i]);
|
||||
}
|
||||
script = StringMan.replaceFromMap(script, replacements);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
@ -372,9 +382,11 @@ public class DebugExec extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
init();
|
||||
scope.put("_2", params);
|
||||
scope.put("_3", cmd);
|
||||
script = "_1=PS.getBasePlots().iterator();while(_1.hasNext()){plot=_1.next();if(" + args[1] + "){PlotPlayer.setMeta(\"location\",plot.getBottomAbs());PlotPlayer.setMeta(\"lastplot\",plot);_3.onCommand(PlotPlayer,_2)}}";
|
||||
this.scope.put("_2", params);
|
||||
this.scope.put("_3", cmd);
|
||||
script = "_1=PS.getBasePlots().iterator();while(_1.hasNext()){plot=_1.next();if(" + args[1]
|
||||
+ "){PlotPlayer.setMeta(\"location\",plot.getBottomAbs());PlotPlayer.setMeta(\"lastplot\",plot);_3.onCommand"
|
||||
+ "(PlotPlayer,_2)}}";
|
||||
|
||||
break;
|
||||
case "all":
|
||||
@ -395,7 +407,7 @@ public class DebugExec extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
init();
|
||||
scope.put("PlotPlayer", player);
|
||||
this.scope.put("PlotPlayer", player);
|
||||
PS.debug("> " + script);
|
||||
try {
|
||||
if (async) {
|
||||
@ -403,23 +415,23 @@ public class DebugExec extends SubCommand {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final long start = System.currentTimeMillis();
|
||||
long start = System.currentTimeMillis();
|
||||
Object result = null;
|
||||
try {
|
||||
result = engine.eval(toExec, scope);
|
||||
} catch (final ScriptException e) {
|
||||
result = DebugExec.this.engine.eval(toExec, DebugExec.this.scope);
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ConsolePlayer.getConsole().sendMessage("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
final long start = System.currentTimeMillis();
|
||||
Object result = engine.eval(script, scope);
|
||||
long start = System.currentTimeMillis();
|
||||
Object result = this.engine.eval(script, this.scope);
|
||||
ConsolePlayer.getConsole().sendMessage("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
|
||||
}
|
||||
return true;
|
||||
} catch (final ScriptException e) {
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
@ -20,10 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
@ -37,30 +33,34 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugfixflags",
|
||||
usage = "/plot debugfixflags <world>",
|
||||
permission = "plots.debugfixflags",
|
||||
description = "Attempt to fix all flags for a world",
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
category = CommandCategory.DEBUG)
|
||||
command = "debugfixflags",
|
||||
usage = "/plot debugfixflags <world>",
|
||||
permission = "plots.debugfixflags",
|
||||
description = "Attempt to fix all flags for a world",
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
category = CommandCategory.DEBUG)
|
||||
public class DebugFixFlags extends SubCommand {
|
||||
|
||||
|
||||
public DebugFixFlags() {
|
||||
requiredArguments = new Argument[] { Argument.String };
|
||||
this.requiredArguments = new Argument[]{Argument.String};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
PlotArea area = PS.get().getPlotAreaByString(args[0]);
|
||||
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---");
|
||||
for (final Plot plot : area.getPlots()) {
|
||||
final HashMap<String, Flag> flags = plot.getFlags();
|
||||
final Iterator<Entry<String, Flag>> i = flags.entrySet().iterator();
|
||||
for (Plot plot : area.getPlots()) {
|
||||
HashMap<String, Flag> flags = plot.getFlags();
|
||||
Iterator<Entry<String, Flag>> i = flags.entrySet().iterator();
|
||||
boolean changed = false;
|
||||
while (i.hasNext()) {
|
||||
if (FlagManager.getFlag(i.next().getKey()) == null) {
|
||||
|
@ -20,29 +20,29 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugloadtest",
|
||||
permission = "plots.debugloadtest",
|
||||
description = "This debug command will force the reload of all plots in the DB",
|
||||
usage = "/plot debugloadtest",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = RequiredType.CONSOLE)
|
||||
command = "debugloadtest",
|
||||
permission = "plots.debugloadtest",
|
||||
description = "This debug command will force the reload of all plots in the DB",
|
||||
usage = "/plot debugloadtest",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = RequiredType.CONSOLE)
|
||||
public class DebugLoadTest extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
try {
|
||||
final Field fPlots = PS.class.getDeclaredField("plots");
|
||||
Field fPlots = PS.class.getDeclaredField("plots");
|
||||
fPlots.setAccessible(true);
|
||||
fPlots.set(null, DBFunc.getPlots());
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
PS.debug("&3===FAILED&3===");
|
||||
e.printStackTrace();
|
||||
PS.debug("&3===END OF STACKTRACE===");
|
||||
|
@ -9,23 +9,24 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@CommandDeclaration(command = "debugpaste",
|
||||
aliases = "dp", usage = "/plot debugpaste",
|
||||
description = "Upload settings.yml & latest.log to HasteBin",
|
||||
permission = "plots.debugpaste",
|
||||
category = CommandCategory.DEBUG)
|
||||
aliases = "dp", usage = "/plot debugpaste",
|
||||
description = "Upload settings.yml & latest.log to HasteBin",
|
||||
permission = "plots.debugpaste",
|
||||
category = CommandCategory.DEBUG)
|
||||
public class DebugPaste extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final String settingsYML = HastebinUtility.upload(PS.get().configFile);
|
||||
String settingsYML = HastebinUtility.upload(PS.get().configFile);
|
||||
String latestLOG;
|
||||
try {
|
||||
latestLOG = HastebinUtility.upload(new File(PS.get().IMP.getDirectory(), "../../logs/latest.log"));
|
||||
@ -33,8 +34,10 @@ public class DebugPaste extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "&clatest.log is too big to be pasted, will ignore");
|
||||
latestLOG = "too big :(";
|
||||
}
|
||||
final StringBuilder b = new StringBuilder();
|
||||
b.append("# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your problem\n\n# We will start with some informational files\n");
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(
|
||||
"# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your "
|
||||
+ "problem\n\n# We will start with some informational files\n");
|
||||
b.append("links.settings_yml: ").append(settingsYML).append("\n");
|
||||
b.append("links.latest_log: ").append(latestLOG).append("\n");
|
||||
b.append("\n# Server Information\n");
|
||||
@ -48,10 +51,11 @@ public class DebugPaste extends SubCommand {
|
||||
String enabled = split.length == 2 ? split[1] : "unknown";
|
||||
String name = split2[0];
|
||||
String version = split2.length == 2 ? split2[1] : "unknown";
|
||||
b.append("\n ").append(name).append(":\n ").append("version: '").append(version).append("'").append("\n enabled: ").append(enabled);
|
||||
b.append("\n ").append(name).append(":\n ").append("version: '").append(version).append("'").append("\n enabled: ")
|
||||
.append(enabled);
|
||||
}
|
||||
b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n");
|
||||
final Runtime runtime = Runtime.getRuntime();
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
b.append("memory.free: ").append(runtime.freeMemory()).append("\n");
|
||||
b.append("memory.max: ").append(runtime.maxMemory()).append("\n");
|
||||
b.append("java.specification.version: '").append(System.getProperty("java.specification.version")).append("'\n");
|
||||
@ -63,9 +67,9 @@ public class DebugPaste extends SubCommand {
|
||||
b.append("# Okay :D Great. You are now ready to create your bug report!");
|
||||
b.append("\n# You can do so at https://github.com/IntellectualSites/PlotSquared/issues");
|
||||
|
||||
final String link = HastebinUtility.upload(b.toString());
|
||||
String link = HastebinUtility.upload(b.toString());
|
||||
plr.sendMessage(C.DEBUG_REPORT_CREATED.s().replace("%url%", link));
|
||||
} catch (final IOException e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -34,40 +34,41 @@ import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugroadregen",
|
||||
usage = "/plot debugroadregen",
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Regenerate all roads based on the road schematic",
|
||||
category = CommandCategory.DEBUG,
|
||||
permission = "plots.debugroadregen")
|
||||
command = "debugroadregen",
|
||||
usage = "/plot debugroadregen",
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Regenerate all roads based on the road schematic",
|
||||
category = CommandCategory.DEBUG,
|
||||
permission = "plots.debugroadregen")
|
||||
public class DebugRoadRegen extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String... args) {
|
||||
final Location loc = player.getLocation();
|
||||
final PlotArea plotworld = loc.getPlotArea();
|
||||
public boolean onCommand(PlotPlayer player, String... args) {
|
||||
Location loc = player.getLocation();
|
||||
PlotArea plotworld = loc.getPlotArea();
|
||||
if (!(plotworld instanceof HybridPlotWorld)) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
||||
ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
||||
int extend = 0;
|
||||
if (args.length == 1) {
|
||||
if (MathMan.isInteger(args[0])) {
|
||||
try {
|
||||
extend = Integer.parseInt(args[0]);
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
C.NOT_VALID_NUMBER.send(player, "(0, <EXTEND HEIGHT>)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
final boolean result = HybridUtils.manager.regenerateRoad(plotworld, chunk, extend);
|
||||
MainUtil.sendMessage(player, "&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result ? "&aSuccess" : "&cFailed"));
|
||||
boolean result = HybridUtils.manager.regenerateRoad(plotworld, chunk, extend);
|
||||
MainUtil.sendMessage(player,
|
||||
"&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result ? "&aSuccess" : "&cFailed"));
|
||||
MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads");
|
||||
} else {
|
||||
final HybridPlotManager manager = (HybridPlotManager) plotworld.getPlotManager();
|
||||
HybridPlotManager manager = (HybridPlotManager) plotworld.getPlotManager();
|
||||
manager.createRoadEast(plotworld, plot);
|
||||
manager.createRoadSouth(plotworld, plot);
|
||||
manager.createRoadSouthEast(plotworld, plot);
|
||||
|
@ -20,8 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -29,18 +27,20 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugsavetest",
|
||||
permission = "plots.debugsavetest",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
usage = "/plot debugsavetest",
|
||||
description = "This command will force the recreation of all plots in the DB")
|
||||
command = "debugsavetest",
|
||||
permission = "plots.debugsavetest",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
usage = "/plot debugsavetest",
|
||||
description = "This command will force the recreation of all plots in the DB")
|
||||
public class DebugSaveTest extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final ArrayList<Plot> plots = new ArrayList<Plot>();
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
ArrayList<Plot> plots = new ArrayList<Plot>();
|
||||
plots.addAll(PS.get().getPlots());
|
||||
MainUtil.sendMessage(plr, "&6Starting `DEBUGSAVETEST`");
|
||||
DBFunc.createPlotsAndData(plots, new Runnable() {
|
||||
|
@ -36,19 +36,19 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import java.util.HashSet;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "delete",
|
||||
permission = "plots.delete",
|
||||
description = "Delete a plot",
|
||||
usage = "/plot delete",
|
||||
aliases = { "dispose", "del" },
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "delete",
|
||||
permission = "plots.delete",
|
||||
description = "Delete a plot",
|
||||
usage = "/plot delete",
|
||||
aliases = {"dispose", "del"},
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Delete extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
|
||||
Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
@ -61,7 +61,7 @@ public class Delete extends SubCommand {
|
||||
}
|
||||
final PlotArea plotworld = plot.getArea();
|
||||
final HashSet<Plot> plots = plot.getConnectedPlots();
|
||||
final Runnable run = new Runnable() {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (plot.getRunning() > 0) {
|
||||
@ -74,7 +74,7 @@ public class Delete extends SubCommand {
|
||||
public void run() {
|
||||
plot.removeRunning();
|
||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY) {
|
||||
final double value = plotworld.PRICES.get("sell") * plots.size();
|
||||
double value = plotworld.PRICES.get("sell") * plots.size();
|
||||
if (value > 0d) {
|
||||
EconHandler.manager.depositMoney(plr, value);
|
||||
sendMessage(plr, C.ADDED_BALANCE, value + "");
|
||||
|
@ -28,30 +28,31 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||
import com.intellectualcrafters.plot.util.PlotGameMode;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "deny",
|
||||
aliases = { "d", "ban" },
|
||||
description = "Deny a user from a plot",
|
||||
usage = "/plot deny <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
aliases = {"d", "ban"},
|
||||
description = "Deny a user from a plot",
|
||||
usage = "/plot deny <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Deny extends SubCommand {
|
||||
|
||||
public Deny() {
|
||||
requiredArguments = new Argument[] { Argument.PlayerName };
|
||||
this.requiredArguments = new Argument[]{Argument.PlayerName};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -97,7 +98,7 @@ public class Deny extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void handleKick(final PlotPlayer pp, final Plot plot) {
|
||||
private void handleKick(PlotPlayer pp, Plot plot) {
|
||||
if (pp == null) {
|
||||
return;
|
||||
}
|
||||
@ -107,7 +108,7 @@ public class Deny extends SubCommand {
|
||||
if (pp.hasPermission("plots.admin.entry.denied")) {
|
||||
return;
|
||||
}
|
||||
if (pp.getGamemode() == PlotGamemode.SPECTATOR) {
|
||||
if (pp.getGameMode() == PlotGameMode.SPECTATOR) {
|
||||
pp.stopSpectating();
|
||||
}
|
||||
pp.teleport(WorldUtil.IMP.getSpawn(pp.getLocation().getWorld()));
|
||||
|
@ -29,13 +29,13 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "setdescription",
|
||||
permission = "plots.set.desc",
|
||||
description = "Set the plot description",
|
||||
usage = "/plot desc <description>",
|
||||
aliases = { "desc", "setdesc", "setd", "description" },
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "setdescription",
|
||||
permission = "plots.set.desc",
|
||||
description = "Set the plot description",
|
||||
usage = "/plot desc <description>",
|
||||
aliases = {"desc", "setdesc", "setd", "description"},
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Desc extends SetCommand {
|
||||
|
||||
@Override
|
||||
@ -45,8 +45,8 @@ public class Desc extends SetCommand {
|
||||
MainUtil.sendMessage(plr, C.DESC_UNSET);
|
||||
return true;
|
||||
}
|
||||
final Flag flag = new Flag(FlagManager.getFlag("description"), desc);
|
||||
final boolean result = FlagManager.addPlotFlag(plot, flag);
|
||||
Flag flag = new Flag(FlagManager.getFlag("description"), desc);
|
||||
boolean result = FlagManager.addPlotFlag(plot, flag);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, C.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
|
@ -35,21 +35,21 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "done",
|
||||
aliases = { "submit" },
|
||||
description = "Mark a plot as done",
|
||||
permission = "plots.done",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
aliases = {"submit"},
|
||||
description = "Mark a plot as done",
|
||||
permission = "plots.done",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Done extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.done")) {
|
||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.done")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
@ -68,7 +68,7 @@ public class Done extends SubCommand {
|
||||
public void run(PlotAnalysis value) {
|
||||
plot.removeRunning();
|
||||
if ((value == null) || (value.getComplexity() >= Settings.CLEAR_THRESHOLD)) {
|
||||
final Flag flag = new Flag(FlagManager.getFlag("done"), (System.currentTimeMillis() / 1000));
|
||||
Flag flag = new Flag(FlagManager.getFlag("done"), System.currentTimeMillis() / 1000);
|
||||
FlagManager.addPlotFlag(plot, flag);
|
||||
MainUtil.sendMessage(plr, C.DONE_SUCCESS);
|
||||
} else {
|
||||
|
@ -15,20 +15,21 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
@CommandDeclaration(usage = "/plot download [schematic|bo3|world]",
|
||||
command = "download",
|
||||
aliases = { "dl" },
|
||||
category = CommandCategory.SCHEMATIC,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Download your plot",
|
||||
permission = "plots.download")
|
||||
command = "download",
|
||||
aliases = {"dl"},
|
||||
category = CommandCategory.SCHEMATIC,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Download your plot",
|
||||
permission = "plots.download")
|
||||
public class Download extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final String world = plr.getLocation().getWorld();
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
String world = plr.getLocation().getWorld();
|
||||
if (!PS.get().hasPlotArea(world)) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
@ -40,7 +41,8 @@ public class Download extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if ((!plot.isOwner(plr.getUUID()) || (Settings.DOWNLOAD_REQUIRES_DONE && (FlagManager.getPlotFlagRaw(plot, "done") != null))) && !Permissions.hasPermission(plr, "plots.admin.command.download")) {
|
||||
if ((!plot.isOwner(plr.getUUID()) || (Settings.DOWNLOAD_REQUIRES_DONE && (FlagManager.getPlotFlagRaw(plot, "done") != null))) && !Permissions
|
||||
.hasPermission(plr, "plots.admin.command.download")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
@ -52,7 +54,7 @@ public class Download extends SubCommand {
|
||||
plot.addRunning();
|
||||
SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run(final CompoundTag value) {
|
||||
public void run(CompoundTag value) {
|
||||
plot.removeRunning();
|
||||
SchematicHandler.manager.upload(value, null, null, new RunnableVal<URL>() {
|
||||
@Override
|
||||
@ -99,8 +101,7 @@ public class Download extends SubCommand {
|
||||
MainUtil.sendMessage(plr, url.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
return false;
|
||||
}
|
||||
|
@ -40,22 +40,22 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "setflag",
|
||||
aliases = { "f", "flag", "setf", "setflag" },
|
||||
usage = "/plot flag <set|remove|add|list|info> <flag> <value>",
|
||||
description = "Set plot flags",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.flag")
|
||||
command = "setflag",
|
||||
aliases = {"f", "flag", "setf", "setflag"},
|
||||
usage = "/plot flag <set|remove|add|list|info> <flag> <value>",
|
||||
description = "Set plot flags",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.flag")
|
||||
public class FlagCmd extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return super.getUsage().replaceAll("<flag>", StringMan.join(FlagManager.getFlags(), "|"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String... args) {
|
||||
public boolean onCommand(PlotPlayer player, String... args) {
|
||||
|
||||
/*
|
||||
* plot flag set fly true
|
||||
@ -68,8 +68,8 @@ public class FlagCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag <set|remove|add|list|info>");
|
||||
return false;
|
||||
}
|
||||
final Location loc = player.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
Location loc = player.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
@ -96,7 +96,7 @@ public class FlagCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
||||
return false;
|
||||
}
|
||||
final AbstractFlag af = FlagManager.getFlag(args[1]);
|
||||
AbstractFlag af = FlagManager.getFlag(args[1]);
|
||||
if (af == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
||||
@ -119,23 +119,23 @@ public class FlagCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag set <flag> <value>");
|
||||
return false;
|
||||
}
|
||||
final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
|
||||
AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
|
||||
if (af == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||
return false;
|
||||
}
|
||||
final String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + value.toLowerCase())) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + value.toLowerCase());
|
||||
return false;
|
||||
}
|
||||
final Object parsed = af.parseValueRaw(value);
|
||||
Object parsed = af.parseValueRaw(value);
|
||||
if (parsed == null) {
|
||||
MainUtil.sendMessage(player, "&c" + af.getValueDesc());
|
||||
return false;
|
||||
}
|
||||
final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed);
|
||||
final boolean result = FlagManager.addPlotFlag(plot, flag);
|
||||
Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed);
|
||||
boolean result = FlagManager.addPlotFlag(plot, flag);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
@ -152,18 +152,18 @@ public class FlagCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove <flag> [values]");
|
||||
return false;
|
||||
}
|
||||
final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
|
||||
AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
|
||||
if (af == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||
return false;
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase());
|
||||
Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase());
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
||||
return false;
|
||||
}
|
||||
for (final String entry : args[2].split(",")) {
|
||||
for (String entry : args[2].split(",")) {
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + entry);
|
||||
return false;
|
||||
@ -175,11 +175,11 @@ public class FlagCmd extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if (args.length == 3 && flag.getAbstractFlag().isList()) {
|
||||
final String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
((FlagValue.ListValue) flag.getAbstractFlag().value).remove(flag.getValue(), value);
|
||||
DBFunc.setFlags(plot, plot.getFlags().values());
|
||||
} else {
|
||||
final boolean result = FlagManager.removePlotFlag(plot, flag.getKey());
|
||||
boolean result = FlagManager.removePlotFlag(plot, flag.getKey());
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_REMOVED);
|
||||
return false;
|
||||
@ -197,19 +197,19 @@ public class FlagCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag add <flag> <values>");
|
||||
return false;
|
||||
}
|
||||
final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
|
||||
AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
|
||||
if (af == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||
return false;
|
||||
}
|
||||
for (final String entry : args[2].split(",")) {
|
||||
for (String entry : args[2].split(",")) {
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + entry);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
final Object parsed = af.parseValueRaw(value);
|
||||
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
Object parsed = af.parseValueRaw(value);
|
||||
if (parsed == null) {
|
||||
MainUtil.sendMessage(player, "&c" + af.getValueDesc());
|
||||
return false;
|
||||
@ -220,7 +220,7 @@ public class FlagCmd extends SubCommand {
|
||||
} else {
|
||||
((FlagValue.ListValue) flag.getAbstractFlag().value).add(flag.getValue(), value);
|
||||
}
|
||||
final boolean result = FlagManager.addPlotFlag(plot, flag);
|
||||
boolean result = FlagManager.addPlotFlag(plot, flag);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
@ -238,9 +238,9 @@ public class FlagCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag list");
|
||||
return false;
|
||||
}
|
||||
final HashMap<String, ArrayList<String>> flags = new HashMap<>();
|
||||
for (final AbstractFlag af : FlagManager.getFlags()) {
|
||||
final String type = af.value.getClass().getSimpleName().replaceAll("Value", "");
|
||||
HashMap<String, ArrayList<String>> flags = new HashMap<>();
|
||||
for (AbstractFlag af : FlagManager.getFlags()) {
|
||||
String type = af.value.getClass().getSimpleName().replaceAll("Value", "");
|
||||
if (!flags.containsKey(type)) {
|
||||
flags.put(type, new ArrayList<String>());
|
||||
}
|
||||
@ -248,7 +248,7 @@ public class FlagCmd extends SubCommand {
|
||||
}
|
||||
String message = "";
|
||||
String prefix = "";
|
||||
for (final Map.Entry<String, ArrayList<String>> stringArrayListEntry : flags.entrySet()) {
|
||||
for (Map.Entry<String, ArrayList<String>> stringArrayListEntry : flags.entrySet()) {
|
||||
message += prefix + "&6" + stringArrayListEntry.getKey() + ": &7" + StringMan.join(stringArrayListEntry.getValue(), ", ");
|
||||
prefix = "\n";
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
@ -20,40 +21,43 @@ public class GenerateDocs {
|
||||
public static void main(String[] args) {
|
||||
MainCommand.getInstance().addCommand(new WE_Anywhere());
|
||||
MainCommand.getInstance().addCommand(new Cluster());
|
||||
final ArrayList<Command<PlotPlayer>> commands = MainCommand.getInstance().getCommands();
|
||||
ArrayList<Command<PlotPlayer>> commands = MainCommand.getInstance().getCommands();
|
||||
log("### Want to document some commands?");
|
||||
log(" - This page is automatically generated");
|
||||
log(" - Fork the project and add a javadoc comment to one of the command classes");
|
||||
log(" - Then do a pull request and it will be added to this page");
|
||||
log("");
|
||||
log("# Contents");
|
||||
for (final CommandCategory category : CommandCategory.values()) {
|
||||
for (CommandCategory category : CommandCategory.values()) {
|
||||
log("###### " + category.name());
|
||||
for (final Command<PlotPlayer> command : MainCommand.getCommands(category, null)) {
|
||||
log(" - [/plot " + command.getCommand() + "](https://github.com/IntellectualSites/PlotSquared/wiki/Commands#" + command.getCommand() + ") ");
|
||||
for (Command<PlotPlayer> command : MainCommand.getCommands(category, null)) {
|
||||
log(" - [/plot " + command.getCommand() + "](https://github.com/IntellectualSites/PlotSquared/wiki/Commands#" + command.getCommand()
|
||||
+ ") ");
|
||||
}
|
||||
log("");
|
||||
}
|
||||
log("# Commands");
|
||||
for (final Command<PlotPlayer> command : commands) {
|
||||
for (Command<PlotPlayer> command : commands) {
|
||||
printCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
public static void printCommand(Command<PlotPlayer> command) {
|
||||
try {
|
||||
final String clazz = command.getClass().getSimpleName();
|
||||
final String name = command.getCommand();
|
||||
String clazz = command.getClass().getSimpleName();
|
||||
String name = command.getCommand();
|
||||
|
||||
// Header
|
||||
final String source = "https://github.com/IntellectualSites/PlotSquared/tree/master/Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz + ".java";
|
||||
String source =
|
||||
"https://github.com/IntellectualSites/PlotSquared/tree/master/Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz
|
||||
+ ".java";
|
||||
log("## [" + name.toUpperCase() + "](" + source + ") ");
|
||||
|
||||
final File file = new File("Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz + ".java");
|
||||
final List<String> lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
|
||||
final List<String> perms = getPerms(name, lines);
|
||||
final List<String> usages = getUsage(name, lines);
|
||||
final String comment = getComments(lines);
|
||||
File file = new File("Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz + ".java");
|
||||
List<String> lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
|
||||
List<String> perms = getPerms(name, lines);
|
||||
List<String> usages = getUsage(name, lines);
|
||||
String comment = getComments(lines);
|
||||
|
||||
log("#### Description");
|
||||
log("`" + command.getDescription() + "`");
|
||||
@ -84,7 +88,7 @@ public class GenerateDocs {
|
||||
log("`" + command.getRequiredType().name() + "`");
|
||||
}
|
||||
|
||||
final Set<String> aliases = command.getAliases();
|
||||
Set<String> aliases = command.getAliases();
|
||||
if (!aliases.isEmpty()) {
|
||||
log("#### Aliases");
|
||||
log("`" + StringMan.getString(command.getAliases()) + "`");
|
||||
@ -103,17 +107,17 @@ public class GenerateDocs {
|
||||
}
|
||||
log("***");
|
||||
log("");
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getUsage(String cmd, List<String> lines) {
|
||||
final Pattern p = Pattern.compile("\"([^\"]*)\"");
|
||||
Pattern p = Pattern.compile("\"([^\"]*)\"");
|
||||
HashSet<String> usages = new HashSet<String>();
|
||||
for (final String line : lines) {
|
||||
for (String line : lines) {
|
||||
if (line.contains("COMMAND_SYNTAX") && !line.contains("getUsage()")) {
|
||||
final Matcher m = p.matcher(line);
|
||||
Matcher m = p.matcher(line);
|
||||
String prefix = "";
|
||||
StringBuilder usage = new StringBuilder();
|
||||
while (m.find()) {
|
||||
@ -130,11 +134,11 @@ public class GenerateDocs {
|
||||
}
|
||||
|
||||
public static List<String> getPerms(String cmd, List<String> lines) {
|
||||
final HashSet<String> perms = new HashSet<>();
|
||||
final Pattern p = Pattern.compile("\"([^\"]*)\"");
|
||||
final Pattern p2 = Pattern.compile("C.PERMISSION_\\s*(\\w+)");
|
||||
HashSet<String> perms = new HashSet<>();
|
||||
Pattern p = Pattern.compile("\"([^\"]*)\"");
|
||||
Pattern p2 = Pattern.compile("C.PERMISSION_\\s*(\\w+)");
|
||||
String last = null;
|
||||
for (final String line : lines) {
|
||||
for (String line : lines) {
|
||||
|
||||
Matcher m2 = p2.matcher(line);
|
||||
while (m2.find()) {
|
||||
@ -148,17 +152,15 @@ public class GenerateDocs {
|
||||
if (!perm.equalsIgnoreCase(perm)) {
|
||||
if (perm.startsWith("C.")) {
|
||||
perm = C.valueOf(perm.split("\\.")[1]).s();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
perm = perm.substring(1, perm.length() - 1);
|
||||
}
|
||||
perms.add(perm);
|
||||
}
|
||||
final Matcher m = p.matcher(line);
|
||||
Matcher m = p.matcher(line);
|
||||
while (m.find()) {
|
||||
String perm = m.group(1);
|
||||
if (perm.endsWith(".")) {
|
||||
@ -172,8 +174,7 @@ public class GenerateDocs {
|
||||
perms.add(perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (line.contains("Permissions.hasPermissionRange")) {
|
||||
} else if (line.contains("Permissions.hasPermissionRange")) {
|
||||
String[] split = line.split("Permissions.hasPermissionRange");
|
||||
split = Arrays.copyOfRange(split, 1, split.length);
|
||||
for (String method : split) {
|
||||
@ -181,12 +182,10 @@ public class GenerateDocs {
|
||||
if (!perm.equalsIgnoreCase(perm)) {
|
||||
if (perm.startsWith("C.")) {
|
||||
perm = C.valueOf(perm.split("\\.")[1]).s();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
perm = perm.substring(1, perm.length() - 1);
|
||||
}
|
||||
perms.add(perm + ".<#>");
|
||||
@ -204,7 +203,7 @@ public class GenerateDocs {
|
||||
}
|
||||
|
||||
public static String getComments(List<String> lines) {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (String line : lines) {
|
||||
line = line.trim();
|
||||
if (line.startsWith("/** ") || line.startsWith("*/ ") || line.startsWith("* ")) {
|
||||
@ -215,7 +214,7 @@ public class GenerateDocs {
|
||||
return result.toString().trim();
|
||||
}
|
||||
|
||||
public static void log(final String s) {
|
||||
public static void log(String s) {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
|
@ -9,17 +9,19 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "grant",
|
||||
category = CommandCategory.CLAIMING,
|
||||
usage = "/plot grant <check|add> [player]",
|
||||
permission = "plots.grant",
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "grant",
|
||||
category = CommandCategory.CLAIMING,
|
||||
usage = "/plot grant <check|add> [player]",
|
||||
permission = "plots.grant",
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Grant extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
final String arg0 = args[0].toLowerCase();
|
||||
switch (arg0) {
|
||||
case "add":
|
||||
|
@ -4,13 +4,13 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "help",
|
||||
description = "Get this help menu",
|
||||
aliases = { "he" },
|
||||
category = CommandCategory.INFO)
|
||||
description = "Get this help menu",
|
||||
aliases = {"he"},
|
||||
category = CommandCategory.INFO)
|
||||
public class Help extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -24,15 +24,15 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "home",
|
||||
aliases = { "h" },
|
||||
description = "Go to your plot",
|
||||
usage = "/plot home [id|alias]",
|
||||
category = CommandCategory.TELEPORT,
|
||||
requiredType = RequiredType.NONE)
|
||||
aliases = {"h"},
|
||||
description = "Go to your plot",
|
||||
usage = "/plot home [id|alias]",
|
||||
category = CommandCategory.TELEPORT,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Home extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
return MainCommand.getInstance().getCommand("visit").onCommand(plr, args);
|
||||
}
|
||||
}
|
||||
|
@ -35,26 +35,26 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "inbox",
|
||||
description = "Review the comments for a plot",
|
||||
usage = "/plot inbox [inbox] [delete <index>|clear|page]",
|
||||
permission = "plots.inbox",
|
||||
category = CommandCategory.CHAT,
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "inbox",
|
||||
description = "Review the comments for a plot",
|
||||
usage = "/plot inbox [inbox] [delete <index>|clear|page]",
|
||||
permission = "plots.inbox",
|
||||
category = CommandCategory.CHAT,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Inbox extends SubCommand {
|
||||
|
||||
public void displayComments(final PlotPlayer player, final List<PlotComment> oldComments, int page) {
|
||||
|
||||
public void displayComments(PlotPlayer player, List<PlotComment> oldComments, int page) {
|
||||
if ((oldComments == null) || oldComments.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.INBOX_EMPTY);
|
||||
return;
|
||||
}
|
||||
final PlotComment[] comments = oldComments.toArray(new PlotComment[oldComments.size()]);
|
||||
PlotComment[] comments = oldComments.toArray(new PlotComment[oldComments.size()]);
|
||||
if (page < 0) {
|
||||
page = 0;
|
||||
}
|
||||
// Get the total pages
|
||||
// int totalPages = ((int) Math.ceil(12 *
|
||||
final int totalPages = (int) Math.ceil(comments.length / 12);
|
||||
int totalPages = (int) Math.ceil(comments.length / 12);
|
||||
if (page > totalPages) {
|
||||
page = totalPages;
|
||||
}
|
||||
@ -63,8 +63,10 @@ public class Inbox extends SubCommand {
|
||||
if (max > comments.length) {
|
||||
max = comments.length;
|
||||
}
|
||||
final StringBuilder string = new StringBuilder();
|
||||
string.append(StringMan.replaceAll(C.COMMENT_LIST_HEADER_PAGED.s(), "%amount%", comments.length, "%cur", page + 1, "%max", totalPages + 1, "%word", "all") + "\n");
|
||||
StringBuilder string = new StringBuilder();
|
||||
string.append(StringMan
|
||||
.replaceAll(C.COMMENT_LIST_HEADER_PAGED.s(), "%amount%", comments.length, "%cur", page + 1, "%max", totalPages + 1, "%word", "all")
|
||||
+ "\n");
|
||||
|
||||
// This might work xD
|
||||
for (int x = page * 12; x < max; x++) {
|
||||
@ -79,10 +81,10 @@ public class Inbox extends SubCommand {
|
||||
}
|
||||
MainUtil.sendMessage(player, string.toString());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (args.length == 0) {
|
||||
sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete <index>|clear|page]");
|
||||
@ -94,7 +96,7 @@ public class Inbox extends SubCommand {
|
||||
if (value != null) {
|
||||
int total = 0;
|
||||
int unread = 0;
|
||||
for (final PlotComment comment : value) {
|
||||
for (PlotComment comment : value) {
|
||||
total++;
|
||||
if (comment.timestamp > CommentManager.getTimestamp(player, inbox.toString())) {
|
||||
unread++;
|
||||
@ -144,11 +146,11 @@ public class Inbox extends SubCommand {
|
||||
sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + "");
|
||||
return false;
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox " + inbox.toString() + " delete <index>");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!inbox.getComments(plot, new RunnableVal<List<PlotComment>>() {
|
||||
@Override
|
||||
public void run(List<PlotComment> value) {
|
||||
@ -156,7 +158,7 @@ public class Inbox extends SubCommand {
|
||||
sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + "");
|
||||
return;
|
||||
}
|
||||
final PlotComment comment = value.get(index - 1);
|
||||
PlotComment comment = value.get(index - 1);
|
||||
inbox.removeComment(plot, comment);
|
||||
plot.getSettings().removeComment(comment);
|
||||
MainUtil.sendMessage(player, C.COMMENT_REMOVED, comment.comment);
|
||||
@ -172,7 +174,7 @@ public class Inbox extends SubCommand {
|
||||
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
||||
}
|
||||
inbox.clearInbox(plot);
|
||||
final ArrayList<PlotComment> comments = plot.getSettings().getComments(inbox.toString());
|
||||
ArrayList<PlotComment> comments = plot.getSettings().getComments(inbox.toString());
|
||||
if (comments != null) {
|
||||
plot.getSettings().removeComments(comments);
|
||||
}
|
||||
@ -182,7 +184,7 @@ public class Inbox extends SubCommand {
|
||||
default: {
|
||||
try {
|
||||
page = Integer.parseInt(args[1]);
|
||||
} catch (final NumberFormatException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete <index>|clear|page]");
|
||||
return false;
|
||||
}
|
||||
|
@ -29,13 +29,14 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "info",
|
||||
aliases = "i",
|
||||
description = "Display plot info",
|
||||
usage = "/plot info <id>",
|
||||
category = CommandCategory.INFO)
|
||||
aliases = "i",
|
||||
description = "Display plot info",
|
||||
usage = "/plot info <id>",
|
||||
category = CommandCategory.INFO)
|
||||
public class Info extends SubCommand {
|
||||
|
||||
@Override
|
||||
@ -82,20 +83,20 @@ public class Info extends SubCommand {
|
||||
if (args.length == 1) {
|
||||
args = new String[0];
|
||||
} else {
|
||||
args = new String[] { args[1] };
|
||||
args = new String[]{args[1]};
|
||||
}
|
||||
}
|
||||
if ((args.length == 1) && args[0].equalsIgnoreCase("inv")) {
|
||||
final PlotInventory inv = new PlotInventory(player) {
|
||||
PlotInventory inv = new PlotInventory(player) {
|
||||
@Override
|
||||
public boolean onClick(final int index) {
|
||||
public boolean onClick(int index) {
|
||||
// TODO InfoInventory not implemented yet!!!!!!!!
|
||||
// See plot rating or musicsubcommand on examples
|
||||
return false;
|
||||
}
|
||||
};
|
||||
final UUID uuid = player.getUUID();
|
||||
final String name = MainUtil.getName(plot.owner);
|
||||
UUID uuid = player.getUUID();
|
||||
String name = MainUtil.getName(plot.owner);
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info", "&cID: &6" + plot.getId().toString(),
|
||||
"&cOwner: &6" + name,
|
||||
"&cAlias: &6" + plot.getAlias(),
|
||||
@ -113,7 +114,7 @@ public class Info extends SubCommand {
|
||||
inv.openInventory();
|
||||
return true;
|
||||
}
|
||||
final boolean hasOwner = plot.hasOwner();
|
||||
boolean hasOwner = plot.hasOwner();
|
||||
boolean containsEveryone;
|
||||
boolean trustedEveryone;
|
||||
// Wildcard player {added}
|
||||
@ -123,7 +124,7 @@ public class Info extends SubCommand {
|
||||
}
|
||||
// Unclaimed?
|
||||
if (!hasOwner && !containsEveryone && !trustedEveryone) {
|
||||
MainUtil.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.getId().x + ";" + plot.getId().y));
|
||||
MainUtil.sendMessage(player, C.PLOT_INFO_UNCLAIMED, plot.getId().x + ";" + plot.getId().y);
|
||||
return true;
|
||||
}
|
||||
String info = C.PLOT_INFO.s();
|
||||
@ -131,7 +132,9 @@ public class Info extends SubCommand {
|
||||
if (arg != null) {
|
||||
info = getCaption(arg);
|
||||
if (info == null) {
|
||||
MainUtil.sendMessage(player, "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating");
|
||||
MainUtil.sendMessage(player,
|
||||
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, "
|
||||
+ "&arating");
|
||||
return false;
|
||||
}
|
||||
full = true;
|
||||
@ -147,7 +150,7 @@ public class Info extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getCaption(final String string) {
|
||||
private String getCaption(String string) {
|
||||
switch (string) {
|
||||
case "trusted":
|
||||
return C.PLOT_INFO_TRUSTED.s();
|
||||
|
@ -31,21 +31,21 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "kick",
|
||||
aliases = { "k" },
|
||||
description = "Kick a player from your plot",
|
||||
permission = "plots.kick",
|
||||
category = CommandCategory.TELEPORT,
|
||||
requiredType = RequiredType.NONE)
|
||||
aliases = {"k"},
|
||||
description = "Kick a player from your plot",
|
||||
permission = "plots.kick",
|
||||
category = CommandCategory.TELEPORT,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Kick extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlot();
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlot();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (((!plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.kick"))) {
|
||||
if ((!plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
@ -53,12 +53,12 @@ public class Kick extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "&c/plot kick <player>");
|
||||
return false;
|
||||
}
|
||||
final PlotPlayer player = UUIDHandler.getPlayer(args[0]);
|
||||
PlotPlayer player = UUIDHandler.getPlayer(args[0]);
|
||||
if (player == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
final Location otherLoc = player.getLocation();
|
||||
Location otherLoc = player.getLocation();
|
||||
if (!plr.getLocation().getWorld().equals(otherLoc.getWorld()) || !plot.equals(otherLoc.getPlot())) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
|
@ -19,23 +19,24 @@ import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "load",
|
||||
aliases = { "restore" },
|
||||
category = CommandCategory.SCHEMATIC,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Load your plot",
|
||||
permission = "plots.load",
|
||||
usage = "/plot restore")
|
||||
command = "load",
|
||||
aliases = {"restore"},
|
||||
category = CommandCategory.SCHEMATIC,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Load your plot",
|
||||
permission = "plots.load",
|
||||
usage = "/plot restore")
|
||||
public class Load extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
|
||||
if (!Settings.METRICS) {
|
||||
MainUtil.sendMessage(plr, "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
|
||||
MainUtil.sendMessage(plr,
|
||||
"&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
|
||||
return false;
|
||||
}
|
||||
final String world = plr.getLocation().getWorld();
|
||||
String world = plr.getLocation().getWorld();
|
||||
if (!PS.get().hasPlotArea(world)) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
@ -55,10 +56,10 @@ public class Load extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (args.length != 0) {
|
||||
if (args.length == 1) {
|
||||
final List<String> schematics = plr.getMeta("plot_schematics");
|
||||
List<String> schematics = plr.getMeta("plot_schematics");
|
||||
if (schematics == null) {
|
||||
// No schematics found:
|
||||
MainUtil.sendMessage(plr, C.LOAD_NULL);
|
||||
@ -67,7 +68,7 @@ public class Load extends SubCommand {
|
||||
String schem;
|
||||
try {
|
||||
schem = schematics.get(Integer.parseInt(args[0]) - 1);
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
// use /plot load <index>
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(1, " + schematics.size() + ")");
|
||||
return false;
|
||||
@ -75,7 +76,7 @@ public class Load extends SubCommand {
|
||||
final URL url;
|
||||
try {
|
||||
url = new URL(Settings.WEB_URL + "saves/" + plr.getUUID() + "/" + schem + ".schematic");
|
||||
} catch (final MalformedURLException e) {
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(plr, C.LOAD_FAILED);
|
||||
return false;
|
||||
@ -85,7 +86,7 @@ public class Load extends SubCommand {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Schematic schematic = SchematicHandler.manager.getSchematic(url);
|
||||
Schematic schematic = SchematicHandler.manager.getSchematic(url);
|
||||
if (schematic == null) {
|
||||
plot.removeRunning();
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent or not in gzip format");
|
||||
@ -110,18 +111,18 @@ public class Load extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot load <index>");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// list schematics
|
||||
|
||||
final List<String> schematics = plr.getMeta("plot_schematics");
|
||||
|
||||
List<String> schematics = plr.getMeta("plot_schematics");
|
||||
if (schematics == null) {
|
||||
plot.addRunning();
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final List<String> schematics = SchematicHandler.manager.getSaves(plr.getUUID());
|
||||
List<String> schematics = SchematicHandler.manager.getSaves(plr.getUUID());
|
||||
plot.removeRunning();
|
||||
if ((schematics == null) || (schematics.isEmpty())) {
|
||||
if ((schematics == null) || schematics.isEmpty()) {
|
||||
MainUtil.sendMessage(plr, C.LOAD_FAILED);
|
||||
return;
|
||||
}
|
||||
@ -134,37 +135,38 @@ public class Load extends SubCommand {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void displaySaves(final PlotPlayer player, final int page) {
|
||||
final List<String> schematics = player.getMeta("plot_schematics");
|
||||
|
||||
public void displaySaves(PlotPlayer player, int page) {
|
||||
List<String> schematics = player.getMeta("plot_schematics");
|
||||
for (int i = 0; i < Math.min(schematics.size(), 32); i++) {
|
||||
try {
|
||||
final String schem = schematics.get(i);
|
||||
final String[] split = schem.split("_");
|
||||
String schem = schematics.get(i);
|
||||
String[] split = schem.split("_");
|
||||
if (split.length != 6) {
|
||||
continue;
|
||||
}
|
||||
final String time = secToTime((System.currentTimeMillis() / 1000) - (Long.parseLong(split[0])));
|
||||
final String world = split[1];
|
||||
final PlotId id = PlotId.fromString(split[2] + ";" + split[3]);
|
||||
final String size = split[4];
|
||||
final String server = split[5].replaceAll(".schematic", "");
|
||||
String time = secToTime((System.currentTimeMillis() / 1000) - Long.parseLong(split[0]));
|
||||
String world = split[1];
|
||||
PlotId id = PlotId.fromString(split[2] + ";" + split[3]);
|
||||
String size = split[4];
|
||||
String server = split[5].replaceAll(".schematic", "");
|
||||
String color;
|
||||
if (PS.get().IMP.getServerName().replaceAll("[^A-Za-z0-9]", "").equals(server)) {
|
||||
color = "$4";
|
||||
} else {
|
||||
color = "$1";
|
||||
}
|
||||
MainUtil.sendMessage(player, "$3[$2" + (i + 1) + "$3] " + color + time + "$3 | " + color + world + ";" + id + "$3 | " + color + size + "x" + size);
|
||||
} catch (final Exception e) {
|
||||
MainUtil.sendMessage(player,
|
||||
"$3[$2" + (i + 1) + "$3] " + color + time + "$3 | " + color + world + ";" + id + "$3 | " + color + size + "x" + size);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(player, C.LOAD_LIST);
|
||||
}
|
||||
|
||||
|
||||
public String secToTime(long time) {
|
||||
final StringBuilder toreturn = new StringBuilder();
|
||||
StringBuilder toreturn = new StringBuilder();
|
||||
if (time >= 33868800) {
|
||||
int years = (int) (time / 33868800);
|
||||
time -= years * 33868800;
|
||||
@ -191,7 +193,7 @@ public class Load extends SubCommand {
|
||||
toreturn.append(minutes + "m ");
|
||||
}
|
||||
if (toreturn.equals("") || (time > 0)) {
|
||||
toreturn.append((time) + "s ");
|
||||
toreturn.append(time + "s ");
|
||||
}
|
||||
return toreturn.toString().trim();
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandHandlingOutput;
|
||||
import com.plotsquared.general.commands.CommandManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -44,11 +45,10 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PlotSquared command class
|
||||
*
|
||||
|
||||
* PlotSquared command class.
|
||||
*/
|
||||
public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
|
||||
private static MainCommand instance;
|
||||
|
||||
private MainCommand() {
|
||||
@ -137,14 +137,14 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static boolean no_permission(final PlotPlayer player, final String permission) {
|
||||
public static boolean no_permission(PlotPlayer player, String permission) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, permission);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<Command<PlotPlayer>> getCommandAndAliases(final CommandCategory category, final PlotPlayer player) {
|
||||
final List<Command<PlotPlayer>> commands = new ArrayList<>();
|
||||
for (final Command<PlotPlayer> command : getInstance().getCommands()) {
|
||||
public static List<Command<PlotPlayer>> getCommandAndAliases(CommandCategory category, PlotPlayer player) {
|
||||
List<Command<PlotPlayer>> commands = new ArrayList<>();
|
||||
for (Command<PlotPlayer> command : getInstance().getCommands()) {
|
||||
if ((category != null) && !command.getCategory().equals(category)) {
|
||||
continue;
|
||||
}
|
||||
@ -156,9 +156,9 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public static List<Command<PlotPlayer>> getCommands(final CommandCategory category, final PlotPlayer player) {
|
||||
final List<Command<PlotPlayer>> commands = new ArrayList<>();
|
||||
for (final Command<PlotPlayer> command : new HashSet<>(getInstance().getCommands())) {
|
||||
public static List<Command<PlotPlayer>> getCommands(CommandCategory category, PlotPlayer player) {
|
||||
List<Command<PlotPlayer>> commands = new ArrayList<>();
|
||||
for (Command<PlotPlayer> command : new HashSet<>(getInstance().getCommands())) {
|
||||
if ((category != null) && !command.getCategory().equals(category)) {
|
||||
continue;
|
||||
}
|
||||
@ -170,13 +170,13 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public static void displayHelp(final PlotPlayer player, String cat, int page, final String label) {
|
||||
public static void displayHelp(PlotPlayer player, String cat, int page, String label) {
|
||||
CommandCategory catEnum = null;
|
||||
if (cat != null) {
|
||||
if (StringMan.isEqualIgnoreCase(cat, "all")) {
|
||||
catEnum = null;
|
||||
} else {
|
||||
for (final CommandCategory c : CommandCategory.values()) {
|
||||
for (CommandCategory c : CommandCategory.values()) {
|
||||
if (StringMan.isEqualIgnoreCaseToAny(cat, c.name(), c.toString())) {
|
||||
catEnum = c;
|
||||
cat = c.name();
|
||||
@ -188,11 +188,12 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((cat == null) && (page == 0)) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
if (cat == null && page == 0) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.HELP_HEADER.s());
|
||||
for (final CommandCategory c : CommandCategory.values()) {
|
||||
builder.append("\n" + StringMan.replaceAll(C.HELP_INFO_ITEM.s(), "%category%", c.toString().toLowerCase(), "%category_desc%", c.toString()));
|
||||
for (CommandCategory c : CommandCategory.values()) {
|
||||
builder.append(
|
||||
"\n" + StringMan.replaceAll(C.HELP_INFO_ITEM.s(), "%category%", c.toString().toLowerCase(), "%category_desc%", c.toString()));
|
||||
}
|
||||
builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", "all").replaceAll("%category_desc%", "Display all commands"));
|
||||
builder.append("\n" + C.HELP_FOOTER.s());
|
||||
@ -203,7 +204,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
new HelpMenu(player).setCategory(catEnum).getCommands().generateMaxPages().generatePage(page, label).render();
|
||||
}
|
||||
|
||||
public static boolean onCommand(final PlotPlayer player, final String cmd, String... args) {
|
||||
public static boolean onCommand(PlotPlayer player, String cmd, String... args) {
|
||||
// Clear perm caching //
|
||||
player.deleteMeta("perm");
|
||||
////////////////////////
|
||||
@ -221,7 +222,8 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
if (MathMan.isInteger(args[0])) {
|
||||
try {
|
||||
help_index = Integer.parseInt(args[args.length - 1]);
|
||||
} catch (final NumberFormatException e) {}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -240,7 +242,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
category = null;
|
||||
try {
|
||||
help_index = Integer.parseInt(args[1]);
|
||||
} catch (final NumberFormatException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
help_index = 1;
|
||||
}
|
||||
} else {
|
||||
@ -254,7 +256,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
if (MathMan.isInteger(args[2])) {
|
||||
try {
|
||||
help_index = Integer.parseInt(args[2]);
|
||||
} catch (final NumberFormatException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
help_index = 1;
|
||||
}
|
||||
}
|
||||
@ -274,7 +276,8 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
if (newPlot == null) {
|
||||
break;
|
||||
}
|
||||
if (!ConsolePlayer.isConsole(player) && (!newPlot.getArea().equals(area) || newPlot.isDenied(player.getUUID())) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN)) {
|
||||
if (!ConsolePlayer.isConsole(player) && (!newPlot.getArea().equals(area) || newPlot.isDenied(player.getUUID()))
|
||||
&& !Permissions.hasPermission(player, C.PERMISSION_ADMIN)) {
|
||||
break;
|
||||
}
|
||||
// Save meta
|
||||
@ -332,7 +335,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
}
|
||||
}
|
||||
String[] usage = cmd.getUsage().split(" ");
|
||||
for (int i = 0; i < Math.min(4 , usage.length); i++) {
|
||||
for (int i = 0; i < Math.min(4, usage.length); i++) {
|
||||
int require;
|
||||
if (usage[i].startsWith("<")) {
|
||||
require = 1;
|
||||
@ -353,8 +356,8 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int handle(final PlotPlayer plr, final String input) {
|
||||
final String[] parts = input.split(" ");
|
||||
public int handle(PlotPlayer plr, String input) {
|
||||
String[] parts = input.split(" ");
|
||||
String[] args;
|
||||
String label;
|
||||
if (parts.length == 1) {
|
||||
@ -387,18 +390,18 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
if (cmd == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_SUBCOMMAND);
|
||||
{
|
||||
final List<Command<PlotPlayer>> cmds = getCommands(null, plr);
|
||||
if ((label == null) || (cmds.isEmpty())) {
|
||||
List<Command<PlotPlayer>> cmds = getCommands(null, plr);
|
||||
if ((label == null) || cmds.isEmpty()) {
|
||||
MainUtil.sendMessage(plr, C.DID_YOU_MEAN, "/plot help");
|
||||
} else {
|
||||
final HashSet<String> setargs = new HashSet<>(args.length + 1);
|
||||
for (final String arg : args) {
|
||||
HashSet<String> setargs = new HashSet<>(args.length + 1);
|
||||
for (String arg : args) {
|
||||
setargs.add(arg.toLowerCase());
|
||||
}
|
||||
setargs.add(label);
|
||||
final String[] allargs = setargs.toArray(new String[setargs.size()]);
|
||||
String[] allargs = setargs.toArray(new String[setargs.size()]);
|
||||
int best = 0;
|
||||
for (final Command<PlotPlayer> current : cmds) {
|
||||
for (Command<PlotPlayer> current : cmds) {
|
||||
int match = getMatch(allargs, current);
|
||||
if (match > best) {
|
||||
cmd = current;
|
||||
@ -424,7 +427,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, cmd.getPermission());
|
||||
return CommandHandlingOutput.NOT_PERMITTED;
|
||||
}
|
||||
final Argument<?>[] requiredArguments = cmd.getRequiredArguments();
|
||||
Argument<?>[] requiredArguments = cmd.getRequiredArguments();
|
||||
if ((requiredArguments != null) && (requiredArguments.length > 0)) {
|
||||
boolean success = true;
|
||||
if (args.length < requiredArguments.length) {
|
||||
@ -443,12 +446,12 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
}
|
||||
}
|
||||
try {
|
||||
final boolean result = cmd.onCommand(plr, args);
|
||||
boolean result = cmd.onCommand(plr, args);
|
||||
if (!result) {
|
||||
cmd.getUsage();
|
||||
return CommandHandlingOutput.WRONG_USAGE;
|
||||
}
|
||||
} catch (final Throwable t) {
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return CommandHandlingOutput.ERROR;
|
||||
}
|
||||
|
@ -33,22 +33,24 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "merge",
|
||||
aliases = "m",
|
||||
description = "Merge the plot you are standing on, with another plot",
|
||||
permission = "plots.merge", usage = "/plot merge <all|n|e|s|w> [removeroads]",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
aliases = "m",
|
||||
description = "Merge the plot you are standing on, with another plot",
|
||||
permission = "plots.merge", usage = "/plot merge <all|n|e|s|w> [removeroads]",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Merge extends SubCommand {
|
||||
public final static String[] values = new String[] { "north", "east", "south", "west", "auto" };
|
||||
public final static String[] aliases = new String[] { "n", "e", "s", "w", "all" };
|
||||
|
||||
public final static String[] values = new String[]{"north", "east", "south", "west", "auto"};
|
||||
public final static String[] aliases = new String[]{"n", "e", "s", "w", "all"};
|
||||
|
||||
public static String direction(float yaw) {
|
||||
yaw = yaw / 90;
|
||||
final int i = Math.round(yaw);
|
||||
int i = Math.round(yaw);
|
||||
switch (i) {
|
||||
case -4:
|
||||
case 0:
|
||||
@ -69,8 +71,8 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocationFull();
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocationFull();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
@ -84,8 +86,7 @@ public class Merge extends SubCommand {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command.merge")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
uuid = plot.owner;
|
||||
}
|
||||
}
|
||||
@ -97,26 +98,26 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
final int size = plot.getConnectedPlots().size();
|
||||
final int maxSize = Permissions.hasPermissionRange(plr, "plots.merge", Settings.MAX_PLOTS);
|
||||
if (size - 1> maxSize) {
|
||||
if (size - 1 > maxSize) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.merge." + (size + 1));
|
||||
return false;
|
||||
}
|
||||
int direction = -1;
|
||||
if (args.length == 0) {
|
||||
// switch (direction(plr.getLocationFull().getYaw())) {
|
||||
// case "NORTH":
|
||||
// direction = 0;
|
||||
// break;
|
||||
// case "EAST":
|
||||
// direction = 1;
|
||||
// break;
|
||||
// case "SOUTH":
|
||||
// direction = 2;
|
||||
// break;
|
||||
// case "WEST":
|
||||
// direction = 3;
|
||||
// break;
|
||||
// }
|
||||
// switch (direction(plr.getLocationFull().getYaw())) {
|
||||
// case "NORTH":
|
||||
// direction = 0;
|
||||
// break;
|
||||
// case "EAST":
|
||||
// direction = 1;
|
||||
// break;
|
||||
// case "SOUTH":
|
||||
// direction = 2;
|
||||
// break;
|
||||
// case "WEST":
|
||||
// direction = 3;
|
||||
// break;
|
||||
// }
|
||||
} else {
|
||||
if ("all".equalsIgnoreCase(args[0]) || "auto".equalsIgnoreCase(args[0])) {
|
||||
boolean terrain = Settings.MERGE_REMOVES_ROADS;
|
||||
@ -184,7 +185,7 @@ public class Merge extends SubCommand {
|
||||
public void run() {
|
||||
MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
|
||||
plot.autoMerge(dir, maxSize - size, owner, terrain);
|
||||
final PlotPlayer pp = UUIDHandler.getPlayer(plr.getUUID());
|
||||
PlotPlayer pp = UUIDHandler.getPlayer(plr.getUUID());
|
||||
if (pp == null) {
|
||||
sendMessage(accepter, C.MERGE_NOT_VALID);
|
||||
return;
|
||||
|
@ -12,18 +12,18 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
* @author manuelgu, altered by Citymonstret
|
||||
*/
|
||||
@CommandDeclaration(
|
||||
command = "middle",
|
||||
aliases = { "center" },
|
||||
description = "Teleports you to the center of the current plot",
|
||||
usage = "/plot middle",
|
||||
category = CommandCategory.TELEPORT,
|
||||
requiredType = RequiredType.PLAYER)
|
||||
command = "middle",
|
||||
aliases = {"center"},
|
||||
description = "Teleports you to the center of the current plot",
|
||||
usage = "/plot middle",
|
||||
category = CommandCategory.TELEPORT,
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Middle extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] arguments) {
|
||||
final Location location = player.getLocation();
|
||||
final Plot plot = location.getPlot();
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlot();
|
||||
if (plot == null) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -29,19 +29,19 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
usage = "/plot move <X;Z>",
|
||||
command = "move",
|
||||
description = "Move a plot",
|
||||
aliases = { "debugmove" },
|
||||
permission = "plots.move",
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
usage = "/plot move <X;Z>",
|
||||
command = "move",
|
||||
description = "Move a plot",
|
||||
aliases = {"debugmove"},
|
||||
permission = "plots.move",
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Move extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot1 = loc.getPlotAbs();
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot1 = loc.getPlotAbs();
|
||||
if (plot1 == null) {
|
||||
return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -53,8 +53,8 @@ public class Move extends SubCommand {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
return false;
|
||||
}
|
||||
final Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
if ((plot2 == null)) {
|
||||
Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
if (plot2 == null) {
|
||||
return false;
|
||||
}
|
||||
if (plot1.equals(plot2)) {
|
||||
@ -78,5 +78,5 @@ public class Move extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -33,17 +33,17 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "music",
|
||||
permission = "plots.music",
|
||||
description = "Player music in a plot",
|
||||
usage = "/plot music",
|
||||
category = CommandCategory.APPEARANCE,
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "music",
|
||||
permission = "plots.music",
|
||||
description = "Player music in a plot",
|
||||
usage = "/plot music",
|
||||
category = CommandCategory.APPEARANCE,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Music extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
final Location loc = player.getLocation();
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
Location loc = player.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
@ -52,14 +52,14 @@ public class Music extends SubCommand {
|
||||
sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return true;
|
||||
}
|
||||
final PlotInventory inv = new PlotInventory(player, 2, "Plot Jukebox") {
|
||||
PlotInventory inv = new PlotInventory(player, 2, "Plot Jukebox") {
|
||||
@Override
|
||||
public boolean onClick(final int index) {
|
||||
final PlotItemStack item = getItem(index);
|
||||
public boolean onClick(int index) {
|
||||
PlotItemStack item = getItem(index);
|
||||
if (item == null) {
|
||||
return true;
|
||||
}
|
||||
final int id = item.id == 7 ? 0 : item.id;
|
||||
int id = item.id == 7 ? 0 : item.id;
|
||||
if (id == 0) {
|
||||
FlagManager.removePlotFlag(plot, "music");
|
||||
} else {
|
||||
@ -70,15 +70,15 @@ public class Music extends SubCommand {
|
||||
};
|
||||
int index = 0;
|
||||
for (int i = 2256; i < 2268; i++) {
|
||||
final String name = "&r&6" + WorldUtil.IMP.getClosestMatchingName(new PlotBlock((short) i, (byte) 0));
|
||||
final String[] lore = { "&r&aClick to play!" };
|
||||
final PlotItemStack item = new PlotItemStack(i, (byte) 0, 1, name, lore);
|
||||
String name = "&r&6" + WorldUtil.IMP.getClosestMatchingName(new PlotBlock((short) i, (byte) 0));
|
||||
String[] lore = {"&r&aClick to play!"};
|
||||
PlotItemStack item = new PlotItemStack(i, (byte) 0, 1, name, lore);
|
||||
inv.setItem(index, item);
|
||||
index++;
|
||||
}
|
||||
if (player.getMeta("music") != null) {
|
||||
final String name = "&r&6Cancel music";
|
||||
final String[] lore = { "&r&cClick to cancel!" };
|
||||
String name = "&r&6Cancel music";
|
||||
String[] lore = {"&r&cClick to cancel!"};
|
||||
inv.setItem(index, new PlotItemStack(7, (short) 0, 1, name, lore));
|
||||
}
|
||||
inv.openInventory();
|
||||
|
@ -24,22 +24,26 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.CmdConfirm;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "setowner",
|
||||
permission = "plots.set.owner",
|
||||
description = "Set the plot owner",
|
||||
usage = "/plot setowner <player>",
|
||||
aliases = { "owner", "so", "seto" },
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "setowner",
|
||||
permission = "plots.set.owner",
|
||||
description = "Set the plot owner",
|
||||
usage = "/plot setowner <player>",
|
||||
aliases = {"owner", "so", "seto"},
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Owner extends SetCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean set(final PlotPlayer plr, final Plot plot, String value) {
|
||||
HashSet<Plot> plots = plot.getConnectedPlots();
|
||||
@ -49,7 +53,8 @@ public class Owner extends SetCommand {
|
||||
try {
|
||||
uuid = UUID.fromString(value);
|
||||
name = MainUtil.getName(uuid);
|
||||
} catch (Exception e) {}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} else {
|
||||
uuid = UUIDHandler.getUUID(value, null);
|
||||
name = UUIDHandler.getName(uuid);
|
||||
@ -79,8 +84,8 @@ public class Owner extends SetCommand {
|
||||
C.INVALID_PLAYER_OFFLINE.send(plr, value);
|
||||
return false;
|
||||
}
|
||||
final int size = plots.size();
|
||||
final int currentPlots = (Settings.GLOBAL_LIMIT ? other.getPlotCount() : other.getPlotCount(plot.getArea().worldname)) + size;
|
||||
int size = plots.size();
|
||||
int currentPlots = (Settings.GLOBAL_LIMIT ? other.getPlotCount() : other.getPlotCount(plot.getArea().worldname)) + size;
|
||||
if (currentPlots > other.getAllowedPlots()) {
|
||||
sendMessage(plr, C.CANT_TRANSFER_MORE_PLOTS);
|
||||
return false;
|
||||
@ -99,7 +104,7 @@ public class Owner extends SetCommand {
|
||||
}
|
||||
}
|
||||
};
|
||||
if (Settings.CONFIRM_SETOWNER && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) {
|
||||
if (Settings.CONFIRM_SETOWNER && !Permissions.hasPermission(plr, "plots.confirm.bypass")) {
|
||||
CmdConfirm.addPending(plr, "/plot set owner " + value, run);
|
||||
} else {
|
||||
TaskManager.runTask(run);
|
||||
|
@ -38,15 +38,16 @@ import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
usage = "/plot purge world:<world> area:<area> id:<id> owner:<owner> shared:<shared> unknown:[true|false]",
|
||||
command = "purge",
|
||||
permission = "plots.admin",
|
||||
description = "Purge all plots for a world",
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.CONSOLE)
|
||||
usage = "/plot purge world:<world> area:<area> id:<id> owner:<owner> shared:<shared> unknown:[true|false]",
|
||||
command = "purge",
|
||||
permission = "plots.admin",
|
||||
description = "Purge all plots for a world",
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.CONSOLE)
|
||||
public class Purge extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
}
|
||||
@ -178,7 +179,7 @@ public class Purge extends SubCommand {
|
||||
}
|
||||
}
|
||||
DBFunc.purgeIds(ids);
|
||||
C.PURGE_SUCCESS.send(plr, ids.size() + "/" + (toDelete.size()));
|
||||
C.PURGE_SUCCESS.send(plr, ids.size() + "/" + toDelete.size());
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -36,6 +36,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@ -44,31 +45,31 @@ import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "rate",
|
||||
permission = "plots.rate",
|
||||
description = "Rate the plot",
|
||||
usage = "/plot rate [#|next]",
|
||||
aliases = "rt",
|
||||
category = CommandCategory.INFO,
|
||||
requiredType = RequiredType.NONE)
|
||||
permission = "plots.rate",
|
||||
description = "Rate the plot",
|
||||
usage = "/plot rate [#|next]",
|
||||
aliases = "rt",
|
||||
category = CommandCategory.INFO,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Rate extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("next")) {
|
||||
final ArrayList<Plot> plots = new ArrayList<>(PS.get().getBasePlots());
|
||||
ArrayList<Plot> plots = new ArrayList<>(PS.get().getBasePlots());
|
||||
Collections.sort(plots, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(final Plot p1, final Plot p2) {
|
||||
public int compare(Plot p1, Plot p2) {
|
||||
double v1 = 0;
|
||||
if (!p1.getRatings().isEmpty()) {
|
||||
for (final Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
|
||||
for (Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
|
||||
v1 -= 11 - entry.getValue().getAverageRating();
|
||||
}
|
||||
}
|
||||
double v2 = 0;
|
||||
if (!p2.getRatings().isEmpty()) {
|
||||
for (final Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
|
||||
for (Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
|
||||
v2 -= 11 - entry.getValue().getAverageRating();
|
||||
}
|
||||
}
|
||||
@ -78,8 +79,8 @@ public class Rate extends SubCommand {
|
||||
return v2 > v1 ? 1 : -1;
|
||||
}
|
||||
});
|
||||
final UUID uuid = player.getUUID();
|
||||
for (final Plot p : plots) {
|
||||
UUID uuid = player.getUUID();
|
||||
for (Plot p : plots) {
|
||||
if ((!Settings.REQUIRE_DONE || p.getFlags().containsKey("done")) && p.isBasePlot() && (p.hasRatings() || !p.getRatings()
|
||||
.containsKey(uuid)) && !p.isAdded(uuid)) {
|
||||
p.teleportPlayer(player);
|
||||
@ -107,7 +108,7 @@ public class Rate extends SubCommand {
|
||||
sendMessage(player, C.RATING_NOT_DONE);
|
||||
return false;
|
||||
}
|
||||
if ((Settings.RATING_CATEGORIES != null) && (!Settings.RATING_CATEGORIES.isEmpty())) {
|
||||
if ((Settings.RATING_CATEGORIES != null) && !Settings.RATING_CATEGORIES.isEmpty()) {
|
||||
final Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -117,25 +118,25 @@ public class Rate extends SubCommand {
|
||||
}
|
||||
final MutableInt index = new MutableInt(0);
|
||||
final MutableInt rating = new MutableInt(0);
|
||||
final String title = Settings.RATING_CATEGORIES.get(0);
|
||||
final PlotInventory inventory = new PlotInventory(player, 1, title) {
|
||||
String title = Settings.RATING_CATEGORIES.get(0);
|
||||
PlotInventory inventory = new PlotInventory(player, 1, title) {
|
||||
@Override
|
||||
public boolean onClick(final int i) {
|
||||
public boolean onClick(int i) {
|
||||
rating.add((i + 1) * Math.pow(10, index.getValue()));
|
||||
index.increment();
|
||||
if (index.getValue() >= Settings.RATING_CATEGORIES.size()) {
|
||||
close();
|
||||
final int rV = rating.getValue();
|
||||
final Rating result = EventUtil.manager.callRating(player, plot, new Rating(rV));
|
||||
plot.addRating(player.getUUID(), result);
|
||||
sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
|
||||
int rV = rating.getValue();
|
||||
Rating result = EventUtil.manager.callRating(this.player, plot, new Rating(rV));
|
||||
plot.addRating(this.player.getUUID(), result);
|
||||
sendMessage(this.player, C.RATING_APPLIED, plot.getId().toString());
|
||||
return false;
|
||||
}
|
||||
setTitle(Settings.RATING_CATEGORIES.get(index.getValue()));
|
||||
if (Permissions.hasPermission(player, "plots.comment")) {
|
||||
final Command<PlotPlayer> command = MainCommand.getInstance().getCommand("comment");
|
||||
if (Permissions.hasPermission(this.player, "plots.comment")) {
|
||||
Command<PlotPlayer> command = MainCommand.getInstance().getCommand("comment");
|
||||
if (command != null) {
|
||||
MainUtil.sendMessage(player, C.COMMENT_THIS, command.getUsage().replaceAll("{label}", "plot"));
|
||||
MainUtil.sendMessage(this.player, C.COMMENT_THIS, command.getUsage().replaceAll("{label}", "plot"));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -173,9 +174,9 @@ public class Rate extends SubCommand {
|
||||
sendMessage(player, C.RATING_NOT_VALID);
|
||||
return true;
|
||||
}
|
||||
final String arg = args[0];
|
||||
String arg = args[0];
|
||||
final int rating;
|
||||
if (MathMan.isInteger(arg) && (arg.length() < 3) && (!arg.isEmpty())) {
|
||||
if (MathMan.isInteger(arg) && (arg.length() < 3) && !arg.isEmpty()) {
|
||||
rating = Integer.parseInt(arg);
|
||||
if (rating > 10 || rating < 1) {
|
||||
sendMessage(player, C.RATING_NOT_VALID);
|
||||
@ -193,8 +194,8 @@ public class Rate extends SubCommand {
|
||||
sendMessage(player, C.RATING_ALREADY_EXISTS, plot.getId().toString());
|
||||
return;
|
||||
}
|
||||
final Rating result = EventUtil.manager.callRating(player, plot, new Rating(rating));
|
||||
plot.addRating(uuid,result);
|
||||
Rating result = EventUtil.manager.callRating(player, plot, new Rating(rating));
|
||||
plot.addRating(uuid, result);
|
||||
sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
|
||||
}
|
||||
};
|
||||
@ -220,19 +221,19 @@ public class Rate extends SubCommand {
|
||||
private int value;
|
||||
|
||||
MutableInt(int i) {
|
||||
value = i;
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
void increment() {
|
||||
value++;
|
||||
this.value++;
|
||||
}
|
||||
|
||||
void decrement() {
|
||||
value--;
|
||||
this.value--;
|
||||
}
|
||||
|
||||
int getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
void add(Number v) {
|
||||
|
@ -20,8 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotManager;
|
||||
@ -35,23 +33,25 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "regenallroads",
|
||||
description = "Regenerate all roads in the map using the set road schematic",
|
||||
aliases = { "rgar" },
|
||||
usage = "/plot regenallroads <world> [height]",
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
permission = "plots.regenallroads")
|
||||
command = "regenallroads",
|
||||
description = "Regenerate all roads in the map using the set road schematic",
|
||||
aliases = {"rgar"},
|
||||
usage = "/plot regenallroads <world> [height]",
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
permission = "plots.regenallroads")
|
||||
public class RegenAllRoads extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
int height = 0;
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
height = Integer.parseInt(args[1]);
|
||||
} catch (final NumberFormatException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(0, 256)");
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
|
||||
return false;
|
||||
@ -65,18 +65,18 @@ public class RegenAllRoads extends SubCommand {
|
||||
C.NOT_VALID_PLOT_WORLD.send(plr, args[0]);
|
||||
return false;
|
||||
}
|
||||
final String name = args[0];
|
||||
final PlotManager manager = area.getPlotManager();
|
||||
String name = args[0];
|
||||
PlotManager manager = area.getPlotManager();
|
||||
if ((manager == null) || !(manager instanceof HybridPlotManager)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
final Set<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name);
|
||||
Set<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name);
|
||||
MainUtil.sendMessage(plr, "&cIf no schematic is set, the following will not do anything");
|
||||
MainUtil.sendMessage(plr, "&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
|
||||
MainUtil.sendMessage(plr, "&6Potential chunks to update: &7" + (chunks.size() * 1024));
|
||||
MainUtil.sendMessage(plr, "&6Estimated time: &7" + (chunks.size()) + " seconds");
|
||||
final boolean result = HybridUtils.manager.scheduleRoadUpdate(area, height);
|
||||
MainUtil.sendMessage(plr, "&6Estimated time: &7" + chunks.size() + " seconds");
|
||||
boolean result = HybridUtils.manager.scheduleRoadUpdate(area, height);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, "&cCannot schedule mass schematic update! (Is one already in progress?)");
|
||||
return false;
|
||||
|
@ -30,17 +30,18 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@CommandDeclaration(command = "reload",
|
||||
permission = "plots.admin.command.reload",
|
||||
description = "Reload configurations",
|
||||
usage = "/plot reload",
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
permission = "plots.admin.command.reload",
|
||||
description = "Reload configurations",
|
||||
usage = "/plot reload",
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Reload extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
try {
|
||||
// The following won't affect world generation, as that has to be
|
||||
// loaded during startup unfortunately.
|
||||
@ -51,12 +52,13 @@ public class Reload extends SubCommand {
|
||||
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
||||
@Override
|
||||
public void run(PlotArea area) {
|
||||
final ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds." + area.worldname);
|
||||
ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds." + area.worldname);
|
||||
if (area.TYPE != 2 || !worldSection.contains("areas")) {
|
||||
area.saveConfiguration(worldSection);
|
||||
area.loadDefaultConfiguration(worldSection);
|
||||
} else {
|
||||
ConfigurationSection areaSection = worldSection.getConfigurationSection("areas." + area.id + "-" + area.getMin() + "-" + area.getMax());
|
||||
ConfigurationSection areaSection =
|
||||
worldSection.getConfigurationSection("areas." + area.id + "-" + area.getMin() + "-" + area.getMax());
|
||||
YamlConfiguration clone = new YamlConfiguration();
|
||||
for (String key : areaSection.getKeys(true)) {
|
||||
if (areaSection.get(key) instanceof MemorySection) {
|
||||
@ -95,7 +97,7 @@ public class Reload extends SubCommand {
|
||||
});
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
MainUtil.sendMessage(plr, C.RELOADED_CONFIGS);
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(plr, C.RELOAD_FAILED);
|
||||
}
|
||||
|
@ -35,27 +35,27 @@ import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "remove",
|
||||
aliases = { "r" },
|
||||
description = "Remove a player from a plot",
|
||||
usage = "/plot remove <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.remove")
|
||||
command = "remove",
|
||||
aliases = {"r"},
|
||||
description = "Remove a player from a plot",
|
||||
usage = "/plot remove <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.remove")
|
||||
public class Remove extends SubCommand {
|
||||
|
||||
|
||||
public Remove() {
|
||||
requiredArguments = new Argument[] { Argument.PlayerName };
|
||||
this.requiredArguments = new Argument[]{Argument.PlayerName};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
if (args.length != 1) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot remove <player>");
|
||||
return true;
|
||||
}
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -70,18 +70,18 @@ public class Remove extends SubCommand {
|
||||
int count = 0;
|
||||
switch (args[0]) {
|
||||
case "unknown": {
|
||||
final ArrayList<UUID> toRemove = new ArrayList<>();
|
||||
final HashSet<UUID> all = new HashSet<>();
|
||||
ArrayList<UUID> toRemove = new ArrayList<>();
|
||||
HashSet<UUID> all = new HashSet<>();
|
||||
all.addAll(plot.getMembers());
|
||||
all.addAll(plot.getTrusted());
|
||||
all.addAll(plot.getDenied());
|
||||
for (final UUID uuid : all) {
|
||||
for (UUID uuid : all) {
|
||||
if (UUIDHandler.getName(uuid) == null) {
|
||||
toRemove.add(uuid);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
for (final UUID uuid : toRemove) {
|
||||
for (UUID uuid : toRemove) {
|
||||
plot.removeDenied(uuid);
|
||||
plot.removeTrusted(uuid);
|
||||
plot.removeMember(uuid);
|
||||
@ -89,16 +89,16 @@ public class Remove extends SubCommand {
|
||||
break;
|
||||
}
|
||||
case "*": {
|
||||
final ArrayList<UUID> toRemove = new ArrayList<>();
|
||||
final HashSet<UUID> all = new HashSet<>();
|
||||
ArrayList<UUID> toRemove = new ArrayList<>();
|
||||
HashSet<UUID> all = new HashSet<>();
|
||||
all.addAll(plot.getMembers());
|
||||
all.addAll(plot.getTrusted());
|
||||
all.addAll(plot.getDenied());
|
||||
for (final UUID uuid : all) {
|
||||
for (UUID uuid : all) {
|
||||
toRemove.add(uuid);
|
||||
count++;
|
||||
}
|
||||
for (final UUID uuid : toRemove) {
|
||||
for (UUID uuid : toRemove) {
|
||||
plot.removeDenied(uuid);
|
||||
plot.removeTrusted(uuid);
|
||||
plot.removeMember(uuid);
|
||||
@ -106,7 +106,7 @@ public class Remove extends SubCommand {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
final UUID uuid = UUIDHandler.getUUID(args[0], null);
|
||||
UUID uuid = UUIDHandler.getUUID(args[0], null);
|
||||
if (uuid != null) {
|
||||
if (plot.getTrusted().contains(uuid)) {
|
||||
if (plot.removeTrusted(uuid)) {
|
||||
|
@ -4,8 +4,8 @@ import com.plotsquared.general.commands.CommandCaller;
|
||||
|
||||
public enum RequiredType {
|
||||
CONSOLE, PLAYER, NONE;
|
||||
|
||||
public boolean allows(final CommandCaller player) {
|
||||
|
||||
public boolean allows(CommandCaller player) {
|
||||
switch (this) {
|
||||
case NONE:
|
||||
return true;
|
||||
|
@ -14,26 +14,28 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "save",
|
||||
aliases = { "backup" },
|
||||
description = "Save your plot",
|
||||
category = CommandCategory.SCHEMATIC,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.save")
|
||||
aliases = {"backup"},
|
||||
description = "Save your plot",
|
||||
category = CommandCategory.SCHEMATIC,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.save")
|
||||
public class Save extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
|
||||
if (!Settings.METRICS) {
|
||||
MainUtil.sendMessage(plr, "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
|
||||
MainUtil.sendMessage(plr,
|
||||
"&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
|
||||
return false;
|
||||
}
|
||||
final String world = plr.getLocation().getWorld();
|
||||
String world = plr.getLocation().getWorld();
|
||||
if (!PS.get().hasPlotArea(world)) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
@ -60,14 +62,14 @@ public class Save extends SubCommand {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String time = (System.currentTimeMillis() / 1000) + "";
|
||||
final String name = PS.get().IMP.getServerName().replaceAll("[^A-Za-z0-9]", "");
|
||||
String time = (System.currentTimeMillis() / 1000) + "";
|
||||
String name = PS.get().IMP.getServerName().replaceAll("[^A-Za-z0-9]", "");
|
||||
Location[] corners = plot.getCorners();
|
||||
final int size = (corners[1].getX() - corners[0].getX()) + 1;
|
||||
final PlotId id = plot.getId();
|
||||
final String world = plot.getArea().toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", "");
|
||||
int size = (corners[1].getX() - corners[0].getX()) + 1;
|
||||
PlotId id = plot.getId();
|
||||
String world = plot.getArea().toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", "");
|
||||
final String file = time + "_" + world + "_" + id.x + "_" + id.y + "_" + size + "_" + name;
|
||||
final UUID uuid = plr.getUUID();
|
||||
UUID uuid = plr.getUUID();
|
||||
SchematicHandler.manager.upload(value, uuid, file, new RunnableVal<URL>() {
|
||||
@Override
|
||||
public void run(URL url) {
|
||||
@ -77,7 +79,7 @@ public class Save extends SubCommand {
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SAVE_SUCCESS);
|
||||
final List<String> schematics = plr.getMeta("plot_schematics");
|
||||
List<String> schematics = plr.getMeta("plot_schematics");
|
||||
if (schematics != null) {
|
||||
schematics.add(file);
|
||||
}
|
||||
|
@ -35,28 +35,30 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "schematic",
|
||||
permission = "plots.schematic",
|
||||
description = "Schematic command",
|
||||
aliases = { "sch" },
|
||||
category = CommandCategory.SCHEMATIC,
|
||||
usage = "/plot schematic <arg...>")
|
||||
command = "schematic",
|
||||
permission = "plots.schematic",
|
||||
description = "Schematic command",
|
||||
aliases = {"sch"},
|
||||
category = CommandCategory.SCHEMATIC,
|
||||
usage = "/plot schematic <arg...>")
|
||||
public class SchematicCmd extends SubCommand {
|
||||
|
||||
private boolean running = false;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
public boolean onCommand(final PlotPlayer plr, String... args) {
|
||||
if (args.length < 1) {
|
||||
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
return true;
|
||||
}
|
||||
final String arg = args[0].toLowerCase();
|
||||
String arg = args[0].toLowerCase();
|
||||
switch (arg) {
|
||||
case "paste": {
|
||||
if (!Permissions.hasPermission(plr, "plots.schematic.paste")) {
|
||||
@ -67,7 +69,7 @@ public class SchematicCmd extends SubCommand {
|
||||
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
break;
|
||||
}
|
||||
final Location loc = plr.getLocation();
|
||||
Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
@ -80,40 +82,40 @@ public class SchematicCmd extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (running) {
|
||||
if (this.running) {
|
||||
MainUtil.sendMessage(plr, "&cTask is already running.");
|
||||
return false;
|
||||
}
|
||||
final String location = args[1];
|
||||
running = true;
|
||||
this.running = true;
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Schematic schematic;
|
||||
if (location.startsWith("url:")) {
|
||||
try {
|
||||
final UUID uuid = UUID.fromString(location.substring(4));
|
||||
final URL base = new URL(Settings.WEB_URL);
|
||||
final URL url = new URL(base, "uploads/" + uuid + ".schematic");
|
||||
UUID uuid = UUID.fromString(location.substring(4));
|
||||
URL base = new URL(Settings.WEB_URL);
|
||||
URL url = new URL(base, "uploads/" + uuid + ".schematic");
|
||||
schematic = SchematicHandler.manager.getSchematic(url);
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent url: " + location);
|
||||
running = false;
|
||||
SchematicCmd.this.running = false;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
schematic = SchematicHandler.manager.getSchematic(location);
|
||||
}
|
||||
if (schematic == null) {
|
||||
running = false;
|
||||
SchematicCmd.this.running = false;
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent or not in gzip format");
|
||||
return;
|
||||
}
|
||||
SchematicHandler.manager.paste(schematic, plot, 0, 0, 0, true, new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
running = false;
|
||||
SchematicCmd.this.running = false;
|
||||
if (value) {
|
||||
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
} else {
|
||||
@ -125,38 +127,38 @@ public class SchematicCmd extends SubCommand {
|
||||
});
|
||||
break;
|
||||
}
|
||||
// TODO test
|
||||
// case "test": {
|
||||
// if (!Permissions.hasPermission(plr, "plots.schematic.test")) {
|
||||
// MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test");
|
||||
// return false;
|
||||
// }
|
||||
// if (args.length < 2) {
|
||||
// sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
// return false;
|
||||
// }
|
||||
// final Location loc = plr.getLocation();
|
||||
// final Plot plot = MainUtil.getPlot(loc);
|
||||
// if (plot == null) {
|
||||
// sendMessage(plr, C.NOT_IN_PLOT);
|
||||
// return false;
|
||||
// }
|
||||
// file = args[1];
|
||||
// schematic = SchematicHandler.manager.getSchematic(file);
|
||||
// if (schematic == null) {
|
||||
// sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
||||
// return false;
|
||||
// }
|
||||
// final int l1 = schematic.getSchematicDimension().getX();
|
||||
// final int l2 = schematic.getSchematicDimension().getZ();
|
||||
// TODO test
|
||||
// case "test": {
|
||||
// if (!Permissions.hasPermission(plr, "plots.schematic.test")) {
|
||||
// MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test");
|
||||
// return false;
|
||||
// }
|
||||
// if (args.length < 2) {
|
||||
// sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
// return false;
|
||||
// }
|
||||
// final Location loc = plr.getLocation();
|
||||
// final Plot plot = MainUtil.getPlot(loc);
|
||||
// if (plot == null) {
|
||||
// sendMessage(plr, C.NOT_IN_PLOT);
|
||||
// return false;
|
||||
// }
|
||||
// file = args[1];
|
||||
// schematic = SchematicHandler.manager.getSchematic(file);
|
||||
// if (schematic == null) {
|
||||
// sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
||||
// return false;
|
||||
// }
|
||||
// final int l1 = schematic.getSchematicDimension().getX();
|
||||
// final int l2 = schematic.getSchematicDimension().getZ();
|
||||
// final int length = MainUtil.getPlotWidth(loc.getWorld(), plot.id);
|
||||
// if ((l1 < length) || (l2 < length)) {
|
||||
// sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
|
||||
// break;
|
||||
// }
|
||||
// sendMessage(plr, C.SCHEMATIC_VALID);
|
||||
// break;
|
||||
// }
|
||||
// if ((l1 < length) || (l2 < length)) {
|
||||
// sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
|
||||
// break;
|
||||
// }
|
||||
// sendMessage(plr, C.SCHEMATIC_VALID);
|
||||
// break;
|
||||
// }
|
||||
case "saveall":
|
||||
case "exportall": {
|
||||
if (!ConsolePlayer.isConsole(plr)) {
|
||||
@ -172,12 +174,12 @@ public class SchematicCmd extends SubCommand {
|
||||
C.NOT_VALID_PLOT_WORLD.send(plr, args[1]);
|
||||
return false;
|
||||
}
|
||||
final Collection<Plot> plots = area.getPlots();
|
||||
if ((plots.isEmpty())) {
|
||||
Collection<Plot> plots = area.getPlots();
|
||||
if (plots.isEmpty()) {
|
||||
MainUtil.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall <area>");
|
||||
return false;
|
||||
}
|
||||
final boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
||||
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, "&aFinished mass export");
|
||||
@ -198,13 +200,13 @@ public class SchematicCmd extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save");
|
||||
return false;
|
||||
}
|
||||
if (running) {
|
||||
if (this.running) {
|
||||
MainUtil.sendMessage(plr, "&cTask is already running.");
|
||||
return false;
|
||||
}
|
||||
final Plot p2;
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
Plot p2;
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -218,13 +220,13 @@ public class SchematicCmd extends SubCommand {
|
||||
}
|
||||
p2 = plot;
|
||||
loc.getWorld();
|
||||
final Collection<Plot> plots = new ArrayList<Plot>();
|
||||
Collection<Plot> plots = new ArrayList<Plot>();
|
||||
plots.add(p2);
|
||||
final boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
||||
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, "&aFinished export");
|
||||
running = false;
|
||||
SchematicCmd.this.running = false;
|
||||
}
|
||||
});
|
||||
if (!result) {
|
||||
|
@ -20,10 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||
@ -42,23 +38,28 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "set",
|
||||
description = "Set a plot value",
|
||||
aliases = { "s" },
|
||||
usage = "/plot set <biome|alias|home|flag> <value...>",
|
||||
permission = "plots.set",
|
||||
category = CommandCategory.APPEARANCE,
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "set",
|
||||
description = "Set a plot value",
|
||||
aliases = {"s"},
|
||||
usage = "/plot set <biome|alias|home|flag> <value...>",
|
||||
permission = "plots.set",
|
||||
category = CommandCategory.APPEARANCE,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Set extends SubCommand {
|
||||
public final static String[] values = new String[] { "biome", "alias", "home", "flag" };
|
||||
public final static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "fl" };
|
||||
|
||||
|
||||
public final static String[] values = new String[]{"biome", "alias", "home", "flag"};
|
||||
public final static String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"};
|
||||
|
||||
private final SetCommand component;
|
||||
|
||||
public Set() {
|
||||
component = new SetCommand() {
|
||||
|
||||
this.component = new SetCommand() {
|
||||
|
||||
@Override
|
||||
public String getCommand() {
|
||||
return "set.component";
|
||||
@ -66,15 +67,15 @@ public class Set extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean set(PlotPlayer plr, final Plot plot, String value) {
|
||||
final PlotArea plotworld = plr.getLocation().getPlotArea();
|
||||
final PlotManager manager = plr.getLocation().getPlotManager();
|
||||
final String[] components = manager.getPlotComponents(plotworld, plot.getId());
|
||||
final boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(plr.getUUID());
|
||||
|
||||
PlotArea plotworld = plr.getLocation().getPlotArea();
|
||||
PlotManager manager = plr.getLocation().getPlotManager();
|
||||
String[] components = manager.getPlotComponents(plotworld, plot.getId());
|
||||
boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(plr.getUUID());
|
||||
|
||||
String[] args = value.split(" ");
|
||||
String material = StringMan.join(Arrays.copyOfRange(args, 1, args.length), ",").trim();
|
||||
|
||||
for (final String component : components) {
|
||||
for (String component : components) {
|
||||
if (component.equalsIgnoreCase(args[0])) {
|
||||
if (!Permissions.hasPermission(plr, "plots.set." + component)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set." + component);
|
||||
@ -86,10 +87,10 @@ public class Set extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NEED_BLOCK);
|
||||
return true;
|
||||
}
|
||||
final String[] split = material.split(",");
|
||||
String[] split = material.split(",");
|
||||
blocks = Configuration.BLOCKLIST.parseString(material);
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
final PlotBlock block = blocks[i];
|
||||
PlotBlock block = blocks[i];
|
||||
if (block == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, split[i]);
|
||||
String name;
|
||||
@ -98,7 +99,7 @@ public class Set extends SubCommand {
|
||||
} else {
|
||||
name = split[i];
|
||||
}
|
||||
final StringComparison<PlotBlock>.ComparisonResult match = WorldUtil.IMP.getClosestBlock(name);
|
||||
StringComparison<PlotBlock>.ComparisonResult match = WorldUtil.IMP.getClosestBlock(name);
|
||||
if (match != null) {
|
||||
name = WorldUtil.IMP.getClosestMatchingName(match.best);
|
||||
if (name != null) {
|
||||
@ -112,14 +113,14 @@ public class Set extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (!allowUnsafe) {
|
||||
for (final PlotBlock block : blocks) {
|
||||
for (PlotBlock block : blocks) {
|
||||
if (!WorldUtil.IMP.isBlockSolid(block)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_ALLOWED_BLOCK, block.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception e2) {
|
||||
} catch (Exception e2) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, material);
|
||||
return false;
|
||||
}
|
||||
@ -147,7 +148,7 @@ public class Set extends SubCommand {
|
||||
}
|
||||
|
||||
public boolean noArgs(PlotPlayer plr) {
|
||||
final ArrayList<String> newValues = new ArrayList<>();
|
||||
ArrayList<String> newValues = new ArrayList<>();
|
||||
newValues.addAll(Arrays.asList("biome", "alias", "home", "flag"));
|
||||
Plot plot = plr.getCurrentPlot();
|
||||
if (plot != null) {
|
||||
@ -158,7 +159,7 @@ public class Set extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
public boolean onCommand(PlotPlayer plr, String... args) {
|
||||
if (args.length == 0) {
|
||||
return noArgs(plr);
|
||||
}
|
||||
@ -175,18 +176,18 @@ public class Set extends SubCommand {
|
||||
// components
|
||||
HashSet<String> components = new HashSet<>(Arrays.asList(plot.getManager().getPlotComponents(plot.getArea(), plot.getId())));
|
||||
if (components.contains(args[0].toLowerCase())) {
|
||||
return component.onCommand(plr, Arrays.copyOfRange(args, 0, args.length));
|
||||
return this.component.onCommand(plr, Arrays.copyOfRange(args, 0, args.length));
|
||||
}
|
||||
// flag
|
||||
{
|
||||
AbstractFlag af;
|
||||
try {
|
||||
af = new AbstractFlag(args[0].toLowerCase());
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
af = new AbstractFlag("");
|
||||
}
|
||||
if (FlagManager.getFlags().contains(af)) {
|
||||
final StringBuilder a = new StringBuilder();
|
||||
StringBuilder a = new StringBuilder();
|
||||
if (args.length > 1) {
|
||||
for (int x = 1; x < args.length; x++) {
|
||||
a.append(" ").append(args[x]);
|
||||
|
@ -9,11 +9,11 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
public abstract class SetCommand extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -36,7 +36,7 @@ public abstract class SetCommand extends SubCommand {
|
||||
}
|
||||
return set(plr, plot, StringMan.join(args, " "));
|
||||
}
|
||||
|
||||
|
||||
public abstract boolean set(PlotPlayer plr, Plot plot, String value);
|
||||
|
||||
}
|
||||
|
@ -29,17 +29,17 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "sethome",
|
||||
permission = "plots.set.home",
|
||||
description = "Set the plot home",
|
||||
usage = "/plot sethome [none]",
|
||||
aliases = { "sh", "seth" },
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "sethome",
|
||||
permission = "plots.set.home",
|
||||
description = "Set the plot home",
|
||||
usage = "/plot sethome [none]",
|
||||
aliases = {"sh", "seth"},
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class SetHome extends SetCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean set(final PlotPlayer plr, final Plot plot, final String value) {
|
||||
public boolean set(PlotPlayer plr, Plot plot, String value) {
|
||||
switch (value.toLowerCase()) {
|
||||
case "unset":
|
||||
case "remove":
|
||||
|
@ -40,18 +40,18 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "setup",
|
||||
permission = "plots.admin.command.setup",
|
||||
description = "Setup wizard for plot worlds",
|
||||
usage = "/plot setup",
|
||||
aliases = { "create" },
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
command = "setup",
|
||||
permission = "plots.admin.command.setup",
|
||||
description = "Setup wizard for plot worlds",
|
||||
usage = "/plot setup",
|
||||
aliases = {"create"},
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Setup extends SubCommand {
|
||||
|
||||
public void displayGenerators(final PlotPlayer plr) {
|
||||
final StringBuilder message = new StringBuilder();
|
||||
|
||||
public void displayGenerators(PlotPlayer plr) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append("&6What generator do you want?");
|
||||
for (final Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
|
||||
for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
|
||||
if (entry.getKey().equals("PlotSquared")) {
|
||||
message.append("\n&8 - &2").append(entry.getKey()).append(" (Default Generator)");
|
||||
} else if (entry.getValue().isFull()) {
|
||||
@ -62,9 +62,9 @@ public class Setup extends SubCommand {
|
||||
}
|
||||
MainUtil.sendMessage(plr, message.toString());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
// going through setup
|
||||
SetupObject object = plr.getMeta("setup");
|
||||
if (object == null) {
|
||||
@ -84,34 +84,37 @@ public class Setup extends SubCommand {
|
||||
if (args[0].equalsIgnoreCase("back")) {
|
||||
if (object.setup_index > 0) {
|
||||
object.setup_index--;
|
||||
final ConfigurationNode node = object.step[object.setup_index];
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", node.getDescription(), node.getType().getType(), node.getDefaultValue() + "");
|
||||
ConfigurationNode node = object.step[object.setup_index];
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", node.getDescription(), node.getType().getType(),
|
||||
node.getDefaultValue() + "");
|
||||
return false;
|
||||
} else if (object.current > 0) {
|
||||
object.current--;
|
||||
}
|
||||
}
|
||||
}
|
||||
final int index = object.current;
|
||||
int index = object.current;
|
||||
switch (index) {
|
||||
case 0: { // choose generator
|
||||
if ((args.length != 1) || !SetupUtils.generators.containsKey(args[0])) {
|
||||
final String prefix = "\n&8 - &7";
|
||||
MainUtil.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringMan.join(SetupUtils.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
|
||||
String prefix = "\n&8 - &7";
|
||||
MainUtil.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringMan.join(SetupUtils.generators.keySet(), prefix)
|
||||
.replaceAll("PlotSquared", "&2PlotSquared"));
|
||||
sendMessage(plr, C.SETUP_INIT);
|
||||
return false;
|
||||
}
|
||||
object.setupGenerator = args[0];
|
||||
object.current++;
|
||||
final String partial = "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots";
|
||||
MainUtil.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial);
|
||||
String partial = "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots";
|
||||
MainUtil.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation"
|
||||
+ "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial);
|
||||
break;
|
||||
}
|
||||
case 1: { // choose world type
|
||||
final List<String> allTypes = Arrays.asList("default", "augmented", "partial");
|
||||
final List<String> allDesc = Arrays.asList("Standard plot generation", "Plot generation with vanilla terrain",
|
||||
List<String> allTypes = Arrays.asList("default", "augmented", "partial");
|
||||
List<String> allDesc = Arrays.asList("Standard plot generation", "Plot generation with vanilla terrain",
|
||||
"Vanilla with clusters of plots");
|
||||
final ArrayList<String> types = new ArrayList<>();
|
||||
ArrayList<String> types = new ArrayList<>();
|
||||
if (SetupUtils.generators.get(object.setupGenerator).isFull()) {
|
||||
types.add("default");
|
||||
}
|
||||
@ -119,8 +122,8 @@ public class Setup extends SubCommand {
|
||||
types.add("partial");
|
||||
if ((args.length != 1) || !types.contains(args[0].toLowerCase())) {
|
||||
MainUtil.sendMessage(plr, "&cYou must choose a world type!");
|
||||
for (final String type : types) {
|
||||
final int i = allTypes.indexOf(type);
|
||||
for (String type : types) {
|
||||
int i = allTypes.indexOf(type);
|
||||
if (type.equals("default")) {
|
||||
MainUtil.sendMessage(plr, "&8 - &2" + type + " &8-&7 " + allDesc.get(i));
|
||||
} else {
|
||||
@ -130,12 +133,13 @@ public class Setup extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
object.type = allTypes.indexOf(args[0].toLowerCase());
|
||||
final GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||
if (object.type == 0) {
|
||||
object.current = 6;
|
||||
if (object.step == null) {
|
||||
object.plotManager = object.setupGenerator;
|
||||
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator().getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
||||
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
||||
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
||||
SetupUtils.generators.get(object.plotManager).getPlotGenerator().processSetup(object);
|
||||
}
|
||||
if (object.step.length == 0) {
|
||||
@ -143,29 +147,32 @@ public class Setup extends SubCommand {
|
||||
object.setup_index = 0;
|
||||
return true;
|
||||
}
|
||||
final ConfigurationNode step = object.step[object.setup_index];
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||
ConfigurationNode step = object.step[object.setup_index];
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
||||
step.getDefaultValue() + "");
|
||||
} else {
|
||||
if (gen.isFull()) {
|
||||
object.plotManager = object.setupGenerator;
|
||||
object.setupGenerator = null;
|
||||
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator().getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
||||
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
||||
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
||||
SetupUtils.generators.get(object.plotManager).getPlotGenerator().processSetup(object);
|
||||
} else {
|
||||
object.plotManager = "PlotSquared";
|
||||
MainUtil.sendMessage(plr, "&c[WARNING] The specified generator does not identify as BukkitPlotGenerator");
|
||||
MainUtil.sendMessage(plr, "&7 - You may need to manually configure the other plugin");
|
||||
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator().getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
||||
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
||||
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
||||
}
|
||||
if (object.type == 2) {
|
||||
MainUtil.sendMessage(plr, "What would you like this area called?");
|
||||
object.current++;
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, "&6What terrain would you like in plots?"
|
||||
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
||||
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
|
||||
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
|
||||
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
||||
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
|
||||
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
|
||||
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||
object.current = 5;
|
||||
}
|
||||
}
|
||||
@ -211,29 +218,31 @@ public class Setup extends SubCommand {
|
||||
object.max = id;
|
||||
object.current++;
|
||||
MainUtil.sendMessage(plr, "&6What terrain would you like in plots?"
|
||||
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
||||
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
|
||||
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
|
||||
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
||||
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
|
||||
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
|
||||
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||
break;
|
||||
}
|
||||
case 5: { // Choose terrain
|
||||
final List<String> terrain = Arrays.asList("none", "ore", "road", "all");
|
||||
List<String> terrain = Arrays.asList("none", "ore", "road", "all");
|
||||
if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) {
|
||||
MainUtil.sendMessage(plr, "&cYou must choose the terrain!"
|
||||
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
||||
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
|
||||
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
|
||||
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
||||
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
|
||||
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
|
||||
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||
return false;
|
||||
}
|
||||
object.terrain = terrain.indexOf(args[0].toLowerCase());
|
||||
object.current++;
|
||||
if (object.step == null) {
|
||||
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator().getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
||||
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
||||
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
||||
}
|
||||
final ConfigurationNode step = object.step[object.setup_index];
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||
ConfigurationNode step = object.step[object.setup_index];
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
||||
step.getDefaultValue() + "");
|
||||
break;
|
||||
}
|
||||
case 6: { // world setup
|
||||
@ -245,10 +254,11 @@ public class Setup extends SubCommand {
|
||||
}
|
||||
ConfigurationNode step = object.step[object.setup_index];
|
||||
if (args.length < 1) {
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
||||
step.getDefaultValue() + "");
|
||||
return false;
|
||||
}
|
||||
final boolean valid = step.isValid(args[0]);
|
||||
boolean valid = step.isValid(args[0]);
|
||||
if (valid) {
|
||||
sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(), args[0]);
|
||||
step.setValue(args[0]);
|
||||
@ -258,11 +268,13 @@ public class Setup extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
step = object.step[object.setup_index];
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
||||
step.getDefaultValue() + "");
|
||||
return false;
|
||||
} else {
|
||||
sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant());
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
||||
step.getDefaultValue() + "");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -277,11 +289,12 @@ public class Setup extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr,
|
||||
"&cThe world you specified already exists. After restarting, new terrain will use PlotSquared, however you may need to reset the world for it to generate correctly!");
|
||||
"&cThe world you specified already exists. After restarting, new terrain will use PlotSquared, however you may need to "
|
||||
+ "reset the world for it to generate correctly!");
|
||||
}
|
||||
object.world = args[0];
|
||||
plr.deleteMeta("setup");
|
||||
final String world;
|
||||
String world;
|
||||
if (object.setupManager == null) {
|
||||
world = SetupUtils.manager.setupWorld(object);
|
||||
} else {
|
||||
@ -289,7 +302,7 @@ public class Setup extends SubCommand {
|
||||
}
|
||||
try {
|
||||
plr.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
plr.sendMessage("&cAn error occurred. See console for more information");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -34,12 +34,12 @@ import java.util.List;
|
||||
|
||||
*/
|
||||
public abstract class SubCommand extends com.plotsquared.general.commands.Command<PlotPlayer> {
|
||||
|
||||
|
||||
/**
|
||||
* The category
|
||||
*/
|
||||
public CommandCategory category;
|
||||
|
||||
|
||||
/**
|
||||
* Send a message
|
||||
*
|
||||
@ -49,17 +49,18 @@ public abstract class SubCommand extends com.plotsquared.general.commands.Comman
|
||||
*
|
||||
* @see MainUtil#sendMessage(PlotPlayer, C, String...)
|
||||
*/
|
||||
public boolean sendMessage(final PlotPlayer plr, final C c, final String... args) {
|
||||
public boolean sendMessage(PlotPlayer plr, C c, String... args) {
|
||||
c.send(plr, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
public <T> void paginate(PlotPlayer player, List<T> c, int size, int page, RunnableVal3<Integer, T, PlotMessage> add, String baseCommand, String header) {
|
||||
|
||||
public <T> void paginate(PlotPlayer player, List<T> c, int size, int page, RunnableVal3<Integer, T, PlotMessage> add, String baseCommand,
|
||||
String header) {
|
||||
// Calculate pages & index
|
||||
if (page < 0) {
|
||||
page = 0;
|
||||
}
|
||||
final int totalPages = (int) Math.ceil(c.size() / size);
|
||||
int totalPages = (int) Math.ceil(c.size() / size);
|
||||
if (page > totalPages) {
|
||||
page = totalPages;
|
||||
}
|
||||
@ -68,12 +69,13 @@ public abstract class SubCommand extends com.plotsquared.general.commands.Comman
|
||||
max = c.size();
|
||||
}
|
||||
// Send the header
|
||||
header = header.replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%amount%", c.size() + "").replaceAll("%word%", "all");
|
||||
header = header.replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%amount%", c.size() + "")
|
||||
.replaceAll("%word%", "all");
|
||||
MainUtil.sendMessage(player, header);
|
||||
// Send the page content
|
||||
final List<T> subList = c.subList(page * size, max);
|
||||
List<T> subList = c.subList(page * size, max);
|
||||
int i = page * size;
|
||||
for (final T obj : subList) {
|
||||
for (T obj : subList) {
|
||||
i++;
|
||||
PlotMessage msg = new PlotMessage();
|
||||
add.run(i, obj, msg);
|
||||
@ -83,11 +85,12 @@ public abstract class SubCommand extends com.plotsquared.general.commands.Comman
|
||||
if (page < totalPages && page > 0) { // Back | Next
|
||||
new PlotMessage().text("<-").color("$1").command(baseCommand + " " + page).text(" | ").color("$3").text("->").color("$1")
|
||||
.command(baseCommand + " " + (page + 2))
|
||||
.text(C.CLICKABLE.s()).color("$2").send(player);
|
||||
.text(C.CLICKABLE.s()).color("$2").send(player);
|
||||
return;
|
||||
}
|
||||
if (page == 0 && totalPages != 0) { // Next
|
||||
new PlotMessage().text("<-").color("$3").text(" | ").color("$3").text("->").color("$1").command(baseCommand + " " + (page + 2)).text(C.CLICKABLE.s()).color("$2").send(player);
|
||||
new PlotMessage().text("<-").color("$3").text(" | ").color("$3").text("->").color("$1").command(baseCommand + " " + (page + 2))
|
||||
.text(C.CLICKABLE.s()).color("$2").send(player);
|
||||
return;
|
||||
}
|
||||
if (page == totalPages && totalPages != 0) { // Back
|
||||
|
@ -29,17 +29,17 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(usage = "/plot swap <X;Z>",
|
||||
command = "swap",
|
||||
description = "Swap two plots",
|
||||
aliases = { "switch" },
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
command = "swap",
|
||||
description = "Swap two plots",
|
||||
aliases = {"switch"},
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Swap extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot1 = loc.getPlotAbs();
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot1 = loc.getPlotAbs();
|
||||
if (plot1 == null) {
|
||||
return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -51,8 +51,8 @@ public class Swap extends SubCommand {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
return false;
|
||||
}
|
||||
final Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
if ((plot2 == null)) {
|
||||
Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
if (plot2 == null) {
|
||||
return false;
|
||||
}
|
||||
if (plot1.equals(plot2)) {
|
||||
|
@ -30,17 +30,17 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "target",
|
||||
usage = "/plot target <<plot>|nearest>",
|
||||
description = "Target a plot with your compass",
|
||||
permission = "plots.target",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.INFO)
|
||||
command = "target",
|
||||
usage = "/plot target <<plot>|nearest>",
|
||||
description = "Target a plot with your compass",
|
||||
permission = "plots.target",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.INFO)
|
||||
public class Target extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location ploc = plr.getLocation();
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Location ploc = plr.getLocation();
|
||||
if (!ploc.isPlotArea()) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
@ -48,8 +48,8 @@ public class Target extends SubCommand {
|
||||
Plot target = null;
|
||||
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
||||
int distance = Integer.MAX_VALUE;
|
||||
for (final Plot plot : PS.get().getPlots(ploc.getWorld())) {
|
||||
final double current = plot.getCenter().getEuclideanDistanceSquared(ploc);
|
||||
for (Plot plot : PS.get().getPlots(ploc.getWorld())) {
|
||||
double current = plot.getCenter().getEuclideanDistanceSquared(ploc);
|
||||
if (current < distance) {
|
||||
distance = (int) current;
|
||||
target = plot;
|
||||
|
@ -48,30 +48,30 @@ import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "template",
|
||||
permission = "plots.admin",
|
||||
description = "Create or use a world template",
|
||||
usage = "/plot template [import|export] <world> <template>",
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
command = "template",
|
||||
permission = "plots.admin",
|
||||
description = "Create or use a world template",
|
||||
usage = "/plot template [import|export] <world> <template>",
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Template extends SubCommand {
|
||||
|
||||
public static boolean extractAllFiles(final String world, final String template) {
|
||||
|
||||
public static boolean extractAllFiles(String world, String template) {
|
||||
try {
|
||||
final File folder = new File(PS.get().IMP.getDirectory() + File.separator + "templates");
|
||||
File folder = new File(PS.get().IMP.getDirectory() + File.separator + "templates");
|
||||
if (!folder.exists()) {
|
||||
return false;
|
||||
}
|
||||
final File input = new File(folder + File.separator + template + ".template");
|
||||
final File output = PS.get().IMP.getDirectory();
|
||||
File input = new File(folder + File.separator + template + ".template");
|
||||
File output = PS.get().IMP.getDirectory();
|
||||
if (!output.exists()) {
|
||||
output.mkdirs();
|
||||
}
|
||||
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(input))) {
|
||||
ZipEntry ze = zis.getNextEntry();
|
||||
final byte[] buffer = new byte[2048];
|
||||
byte[] buffer = new byte[2048];
|
||||
while (ze != null) {
|
||||
final String name = ze.getName().replace('\\', File.separatorChar).replace('/', File.separatorChar);
|
||||
final File newFile = new File((output + File.separator + name).replaceAll("__TEMP_DIR__", world));
|
||||
String name = ze.getName().replace('\\', File.separatorChar).replace('/', File.separatorChar);
|
||||
File newFile = new File((output + File.separator + name).replaceAll("__TEMP_DIR__", world));
|
||||
new File(newFile.getParent()).mkdirs();
|
||||
try (FileOutputStream fos = new FileOutputStream(newFile)) {
|
||||
int len;
|
||||
@ -92,37 +92,37 @@ public class Template extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] getBytes(final PlotArea plotworld) {
|
||||
final ConfigurationSection section = PS.get().config.getConfigurationSection("worlds." + plotworld.worldname);
|
||||
final YamlConfiguration config = new YamlConfiguration();
|
||||
final String generator = SetupUtils.manager.getGenerator(plotworld);
|
||||
|
||||
public static byte[] getBytes(PlotArea plotworld) {
|
||||
ConfigurationSection section = PS.get().config.getConfigurationSection("worlds." + plotworld.worldname);
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
String generator = SetupUtils.manager.getGenerator(plotworld);
|
||||
if (generator != null) {
|
||||
config.set("generator.plugin", generator);
|
||||
}
|
||||
for (final String key : section.getKeys(true)) {
|
||||
for (String key : section.getKeys(true)) {
|
||||
config.set(key, section.get(key));
|
||||
}
|
||||
return config.saveToString().getBytes();
|
||||
}
|
||||
|
||||
public static void zipAll(final String world, final Set<FileBytes> files) throws IOException {
|
||||
final File output = new File(PS.get().IMP.getDirectory() + File.separator + "templates");
|
||||
|
||||
public static void zipAll(String world, Set<FileBytes> files) throws IOException {
|
||||
File output = new File(PS.get().IMP.getDirectory() + File.separator + "templates");
|
||||
output.mkdirs();
|
||||
try (FileOutputStream fos = new FileOutputStream(output + File.separator + world + ".template");
|
||||
ZipOutputStream zos = new ZipOutputStream(fos)) {
|
||||
|
||||
for (final FileBytes file : files) {
|
||||
final ZipEntry ze = new ZipEntry(file.path);
|
||||
for (FileBytes file : files) {
|
||||
ZipEntry ze = new ZipEntry(file.path);
|
||||
zos.putNextEntry(ze);
|
||||
zos.write(file.data);
|
||||
}
|
||||
zos.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("export")) {
|
||||
@ -147,18 +147,18 @@ public class Template extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
|
||||
return false;
|
||||
}
|
||||
final boolean result = extractAllFiles(world, args[2]);
|
||||
boolean result = extractAllFiles(world, args[2]);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, "&cInvalid template file: " + args[2] + ".template");
|
||||
return false;
|
||||
}
|
||||
final File worldFile = new File(PS.get().IMP.getDirectory() + File.separator + "templates" + File.separator + "tmp-data.yml");
|
||||
final YamlConfiguration worldConfig = YamlConfiguration.loadConfiguration(worldFile);
|
||||
File worldFile = new File(PS.get().IMP.getDirectory() + File.separator + "templates" + File.separator + "tmp-data.yml");
|
||||
YamlConfiguration worldConfig = YamlConfiguration.loadConfiguration(worldFile);
|
||||
PS.get().config.set("worlds." + world, worldConfig.get(""));
|
||||
try {
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
PS.get().config.load(PS.get().configFile);
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String manager = worldConfig.getString("generator.plugin", "PlotSquared");
|
||||
|
@ -35,35 +35,36 @@ import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "toggle",
|
||||
aliases = { "attribute" },
|
||||
permission = "plots.use",
|
||||
description = "Toggle per user settings",
|
||||
usage = "/plot toggle <setting>",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.SETTINGS)
|
||||
command = "toggle",
|
||||
aliases = {"attribute"},
|
||||
permission = "plots.use",
|
||||
description = "Toggle per user settings",
|
||||
usage = "/plot toggle <setting>",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.SETTINGS)
|
||||
public class Toggle extends SubCommand {
|
||||
|
||||
private HashMap<String, Command<PlotPlayer>> toggles;
|
||||
|
||||
|
||||
private final HashMap<String, Command<PlotPlayer>> toggles;
|
||||
|
||||
public Toggle() {
|
||||
toggles = new HashMap<>();
|
||||
toggles.put("titles", new Command<PlotPlayer>("titles", "/plot toggle titles", "Toggle titles for yourself", C.PERMISSION_PLOT_TOGGLE_TITLES.s()) {
|
||||
this.toggles = new HashMap<>();
|
||||
this.toggles.put("titles",
|
||||
new Command<PlotPlayer>("titles", "/plot toggle titles", "Toggle titles for yourself", C.PERMISSION_PLOT_TOGGLE_TITLES.s()) {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (toggle(player, "disabletitles")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, getCommand());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, getCommand());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
this.toggles.put("chatspy", new Command<PlotPlayer>("chatspy", "/plot toggle chatspy", "Toggle chat spying", C.PERMISSION_COMMANDS_CHAT.s()) {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
if (toggle(player, "disabletitles")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, getCommand());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, getCommand());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
toggles.put("chatspy", new Command<PlotPlayer>("chatspy", "/plot toggle chatspy", "Toggle chat spying", C.PERMISSION_COMMANDS_CHAT.s()) {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (toggle(player, "chatspy")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, getCommand());
|
||||
} else {
|
||||
@ -72,10 +73,11 @@ public class Toggle extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
toggles.put("chat", new Command<PlotPlayer>("chat", "/plot toggle chat", "Toggle plot chat for yourself", C.PERMISSION_PLOT_TOGGLE_CHAT.s()) {
|
||||
this.toggles.put("chat",
|
||||
new Command<PlotPlayer>("chat", "/plot toggle chat", "Toggle plot chat for yourself", C.PERMISSION_PLOT_TOGGLE_CHAT.s()) {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (toggle(player, "chat")) {
|
||||
MainUtil.sendMessage(player, C.PLOT_CHAT_OFF);
|
||||
} else {
|
||||
@ -85,26 +87,27 @@ public class Toggle extends SubCommand {
|
||||
}
|
||||
});
|
||||
if (PS.get() != null && PS.get().worldedit != null) {
|
||||
toggles.put("worldedit", new Command<PlotPlayer>("worldedit", "/plot toggle worldedit", "Toggle worldedit bypass", C.PERMISSION_WORLDEDIT_BYPASS.s()) {
|
||||
this.toggles.put("worldedit",
|
||||
new Command<PlotPlayer>("worldedit", "/plot toggle worldedit", "Toggle worldedit bypass", C.PERMISSION_WORLDEDIT_BYPASS.s()) {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
if (toggle(player, "worldedit")) {
|
||||
MainUtil.sendMessage(player, C.WORLDEDIT_RESTRICTED);
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.WORLDEDIT_UNMASKED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (toggle(player, "worldedit")) {
|
||||
MainUtil.sendMessage(player, C.WORLDEDIT_RESTRICTED);
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.WORLDEDIT_UNMASKED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void noArgs(final PlotPlayer plr) {
|
||||
public void noArgs(PlotPlayer plr) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot toggle <setting>");
|
||||
final ArrayList<String> options = new ArrayList<>();
|
||||
for (final Entry<String, Command<PlotPlayer>> entry : toggles.entrySet()) {
|
||||
ArrayList<String> options = new ArrayList<>();
|
||||
for (Entry<String, Command<PlotPlayer>> entry : this.toggles.entrySet()) {
|
||||
if (Permissions.hasPermission(plr, entry.getValue().getPermission())) {
|
||||
options.add(entry.getKey());
|
||||
}
|
||||
@ -113,14 +116,14 @@ public class Toggle extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringMan.join(options, ","));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
noArgs(player);
|
||||
return false;
|
||||
}
|
||||
final Command<PlotPlayer> cmd = toggles.get(args[0].toLowerCase());
|
||||
Command<PlotPlayer> cmd = this.toggles.get(args[0].toLowerCase());
|
||||
if (cmd == null) {
|
||||
noArgs(player);
|
||||
return false;
|
||||
@ -131,8 +134,8 @@ public class Toggle extends SubCommand {
|
||||
}
|
||||
return cmd.onCommand(player, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
|
||||
public boolean toggle(final PlotPlayer player, final String key) {
|
||||
|
||||
public boolean toggle(PlotPlayer player, String key) {
|
||||
if (player.getAttribute(key)) {
|
||||
player.removeAttribute(key);
|
||||
return true;
|
||||
|
@ -47,16 +47,17 @@ import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "trim",
|
||||
permission = "plots.admin",
|
||||
description = "Delete unmodified portions of your plotworld",
|
||||
usage = "/plot trim <world> [regenerate]",
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
command = "trim",
|
||||
permission = "plots.admin",
|
||||
description = "Delete unmodified portions of your plotworld",
|
||||
usage = "/plot trim <world> [regenerate]",
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Trim extends SubCommand {
|
||||
|
||||
|
||||
public static ArrayList<Plot> expired = null;
|
||||
|
||||
private static volatile boolean TASK = false;
|
||||
|
||||
public static boolean getBulkRegions(final ArrayList<ChunkLoc> empty, final String world, final Runnable whenDone) {
|
||||
if (Trim.TASK) {
|
||||
return false;
|
||||
@ -64,37 +65,37 @@ public class Trim extends SubCommand {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String directory = world + File.separator + "region";
|
||||
final File folder = new File(PS.get().IMP.getWorldContainer(), directory);
|
||||
final File[] regionFiles = folder.listFiles();
|
||||
for (final File file : regionFiles) {
|
||||
final String name = file.getName();
|
||||
String directory = world + File.separator + "region";
|
||||
File folder = new File(PS.get().IMP.getWorldContainer(), directory);
|
||||
File[] regionFiles = folder.listFiles();
|
||||
for (File file : regionFiles) {
|
||||
String name = file.getName();
|
||||
if (name.endsWith("mca")) {
|
||||
if (file.getTotalSpace() <= 8192) {
|
||||
try {
|
||||
final String[] split = name.split("\\.");
|
||||
final int x = Integer.parseInt(split[1]);
|
||||
final int z = Integer.parseInt(split[2]);
|
||||
final ChunkLoc loc = new ChunkLoc(x, z);
|
||||
String[] split = name.split("\\.");
|
||||
int x = Integer.parseInt(split[1]);
|
||||
int z = Integer.parseInt(split[2]);
|
||||
ChunkLoc loc = new ChunkLoc(x, z);
|
||||
empty.add(loc);
|
||||
} catch (NumberFormatException e) {
|
||||
PS.debug("INVALID MCA: " + name);
|
||||
}
|
||||
} else {
|
||||
final Path path = Paths.get(file.getPath());
|
||||
Path path = Paths.get(file.getPath());
|
||||
try {
|
||||
final BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
|
||||
final long creation = attr.creationTime().toMillis();
|
||||
final long modification = file.lastModified();
|
||||
final long diff = Math.abs(creation - modification);
|
||||
BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
|
||||
long creation = attr.creationTime().toMillis();
|
||||
long modification = file.lastModified();
|
||||
long diff = Math.abs(creation - modification);
|
||||
if (diff < 10000) {
|
||||
try {
|
||||
final String[] split = name.split("\\.");
|
||||
final int x = Integer.parseInt(split[1]);
|
||||
final int z = Integer.parseInt(split[2]);
|
||||
final ChunkLoc loc = new ChunkLoc(x, z);
|
||||
String[] split = name.split("\\.");
|
||||
int x = Integer.parseInt(split[1]);
|
||||
int z = Integer.parseInt(split[2]);
|
||||
ChunkLoc loc = new ChunkLoc(x, z);
|
||||
empty.add(loc);
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
PS.debug("INVALID MCA: " + name);
|
||||
}
|
||||
}
|
||||
@ -110,19 +111,19 @@ public class Trim extends SubCommand {
|
||||
Trim.TASK = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs the result task with the parameters (viable, nonViable).<br>
|
||||
* @param world
|
||||
* @param result (viable = .mcr to trim, nonViable = .mcr keep)
|
||||
* @return
|
||||
*/
|
||||
public static boolean getTrimRegions(final String world, final RunnableVal2<Set<ChunkLoc>, Set<ChunkLoc>> result) {
|
||||
public static boolean getTrimRegions(String world, final RunnableVal2<Set<ChunkLoc>, Set<ChunkLoc>> result) {
|
||||
if (result == null) {
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(null, "Collecting region data...");
|
||||
final ArrayList<Plot> plots = new ArrayList<>();
|
||||
ArrayList<Plot> plots = new ArrayList<>();
|
||||
plots.addAll(PS.get().getPlots(world));
|
||||
result.value1 = new HashSet<>(ChunkManager.manager.getChunkChunks(world));
|
||||
result.value2 = new HashSet<>();
|
||||
@ -132,12 +133,12 @@ public class Trim extends SubCommand {
|
||||
TaskManager.objectTask(plots, new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(Plot plot) {
|
||||
final Location pos1 = plot.getBottom();
|
||||
final Location pos2 = plot.getTop();
|
||||
final int ccx1 = (pos1.getX() >> 9);
|
||||
final int ccz1 = (pos1.getZ() >> 9);
|
||||
final int ccx2 = (pos2.getX() >> 9);
|
||||
final int ccz2 = (pos2.getZ() >> 9);
|
||||
Location pos1 = plot.getBottom();
|
||||
Location pos2 = plot.getTop();
|
||||
int ccx1 = pos1.getX() >> 9;
|
||||
int ccz1 = pos1.getZ() >> 9;
|
||||
int ccx2 = pos2.getX() >> 9;
|
||||
int ccz2 = pos2.getZ() >> 9;
|
||||
for (int x = ccx1; x <= ccx2; x++) {
|
||||
for (int z = ccz1; z <= ccz2; z++) {
|
||||
ChunkLoc loc = new ChunkLoc(x, z);
|
||||
@ -150,17 +151,15 @@ public class Trim extends SubCommand {
|
||||
}, result);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static volatile boolean TASK = false;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
if (args.length == 0) {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
return false;
|
||||
}
|
||||
final String world = args[0];
|
||||
if (!WorldUtil.IMP.isWorld(world) || (!PS.get().hasPlotArea(world))) {
|
||||
if (!WorldUtil.IMP.isWorld(world) || !PS.get().hasPlotArea(world)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_WORLD);
|
||||
return false;
|
||||
}
|
||||
@ -172,7 +171,7 @@ public class Trim extends SubCommand {
|
||||
final boolean regen = args.length == 2 && Boolean.parseBoolean(args[1]);
|
||||
getTrimRegions(world, new RunnableVal2<Set<ChunkLoc>, Set<ChunkLoc>>() {
|
||||
@Override
|
||||
public void run(final Set<ChunkLoc> viable, final Set<ChunkLoc> nonViable) {
|
||||
public void run(Set<ChunkLoc> viable, final Set<ChunkLoc> nonViable) {
|
||||
Runnable regenTask;
|
||||
if (regen) {
|
||||
regenTask = new Runnable() {
|
||||
@ -221,8 +220,7 @@ public class Trim extends SubCommand {
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
regenTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -35,23 +35,23 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "trust",
|
||||
aliases = { "t" },
|
||||
requiredType = RequiredType.NONE,
|
||||
usage = "/plot trust <player>",
|
||||
description = "Allow a player to build in a plot",
|
||||
category = CommandCategory.SETTINGS)
|
||||
command = "trust",
|
||||
aliases = {"t"},
|
||||
requiredType = RequiredType.NONE,
|
||||
usage = "/plot trust <player>",
|
||||
description = "Allow a player to build in a plot",
|
||||
category = CommandCategory.SETTINGS)
|
||||
public class Trust extends SubCommand {
|
||||
|
||||
|
||||
public Trust() {
|
||||
requiredArguments = new Argument[] { Argument.PlayerName };
|
||||
this.requiredArguments = new Argument[]{Argument.PlayerName};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -20,9 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -33,24 +30,27 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "undeny",
|
||||
aliases = { "ud" },
|
||||
description = "Remove a denied user from a plot",
|
||||
usage = "/plot undeny <player>",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.SETTINGS)
|
||||
command = "undeny",
|
||||
aliases = {"ud"},
|
||||
description = "Remove a denied user from a plot",
|
||||
usage = "/plot undeny <player>",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.SETTINGS)
|
||||
public class Undeny extends SubCommand {
|
||||
|
||||
|
||||
public Undeny() {
|
||||
requiredArguments = new Argument[] { Argument.PlayerName };
|
||||
this.requiredArguments = new Argument[]{Argument.PlayerName};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
public boolean onCommand(PlotPlayer plr, String... args) {
|
||||
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -65,25 +65,25 @@ public class Undeny extends SubCommand {
|
||||
int count = 0;
|
||||
switch (args[0]) {
|
||||
case "unknown":
|
||||
final ArrayList<UUID> toRemove = new ArrayList<>();
|
||||
for (final UUID uuid : plot.getDenied()) {
|
||||
ArrayList<UUID> toRemove = new ArrayList<>();
|
||||
for (UUID uuid : plot.getDenied()) {
|
||||
if (UUIDHandler.getName(uuid) == null) {
|
||||
toRemove.add(uuid);
|
||||
}
|
||||
}
|
||||
for (final UUID uuid : toRemove) {
|
||||
for (UUID uuid : toRemove) {
|
||||
plot.removeDenied(uuid);
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case "*":
|
||||
for (final UUID uuid : new ArrayList<>(plot.getDenied())) {
|
||||
for (UUID uuid : new ArrayList<>(plot.getDenied())) {
|
||||
plot.removeDenied(uuid);
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
final UUID uuid = UUIDHandler.getUUID(args[0], null);
|
||||
UUID uuid = UUIDHandler.getUUID(args[0], null);
|
||||
if (uuid != null) {
|
||||
if (plot.removeDenied(uuid)) {
|
||||
count++;
|
||||
@ -99,5 +99,5 @@ public class Undeny extends SubCommand {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -33,17 +33,17 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "unlink",
|
||||
aliases = { "u", "unmerge" },
|
||||
description = "Unlink a mega-plot",
|
||||
usage = "/plot unlink",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.SETTINGS)
|
||||
aliases = {"u", "unmerge"},
|
||||
description = "Unlink a mega-plot",
|
||||
usage = "/plot unlink",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.SETTINGS)
|
||||
public class Unlink extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
@ -67,7 +67,7 @@ public class Unlink extends SubCommand {
|
||||
} else {
|
||||
createRoad = true;
|
||||
}
|
||||
final Runnable runnable = new Runnable() {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!plot.unlinkPlot(createRoad, createRoad)) {
|
||||
@ -77,7 +77,7 @@ public class Unlink extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.UNLINK_SUCCESS);
|
||||
}
|
||||
};
|
||||
if (Settings.CONFIRM_UNLINK && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) {
|
||||
if (Settings.CONFIRM_UNLINK && !Permissions.hasPermission(plr, "plots.confirm.bypass")) {
|
||||
CmdConfirm.addPending(plr, "/plot unlink " + plot.getId(), runnable);
|
||||
} else {
|
||||
TaskManager.runTask(runnable);
|
||||
|
@ -20,9 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -33,26 +30,29 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
// UNTRUST("untrust", "ut"),
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "untrust",
|
||||
aliases = { "ut" },
|
||||
permission = "plots.untrust",
|
||||
description = "Remove a trusted user from a plot",
|
||||
usage = "/plot untrust <player>",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.SETTINGS)
|
||||
command = "untrust",
|
||||
aliases = {"ut"},
|
||||
permission = "plots.untrust",
|
||||
description = "Remove a trusted user from a plot",
|
||||
usage = "/plot untrust <player>",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.SETTINGS)
|
||||
public class Untrust extends SubCommand {
|
||||
|
||||
|
||||
public Untrust() {
|
||||
requiredArguments = new Argument[] { Argument.PlayerName };
|
||||
this.requiredArguments = new Argument[]{Argument.PlayerName};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -67,25 +67,25 @@ public class Untrust extends SubCommand {
|
||||
int count = 0;
|
||||
switch (args[0]) {
|
||||
case "unknown":
|
||||
final ArrayList<UUID> toRemove = new ArrayList<>();
|
||||
for (final UUID uuid : plot.getTrusted()) {
|
||||
ArrayList<UUID> toRemove = new ArrayList<>();
|
||||
for (UUID uuid : plot.getTrusted()) {
|
||||
if (UUIDHandler.getName(uuid) == null) {
|
||||
toRemove.add(uuid);
|
||||
}
|
||||
}
|
||||
for (final UUID uuid : toRemove) {
|
||||
for (UUID uuid : toRemove) {
|
||||
plot.removeTrusted(uuid);
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case "*":
|
||||
for (final UUID uuid : new ArrayList<>(plot.getTrusted())) {
|
||||
for (UUID uuid : new ArrayList<>(plot.getTrusted())) {
|
||||
plot.removeTrusted(uuid);
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
final UUID uuid = UUIDHandler.getUUID(args[0], null);
|
||||
UUID uuid = UUIDHandler.getUUID(args[0], null);
|
||||
if (uuid != null) {
|
||||
if (plot.removeTrusted(uuid)) {
|
||||
count++;
|
||||
|
@ -25,28 +25,29 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "update",
|
||||
permission = "plots.admin.command.update",
|
||||
description = "Update PlotSquared",
|
||||
usage = "/plot update",
|
||||
requiredType = RequiredType.NONE,
|
||||
aliases = { "updateplugin" },
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
command = "update",
|
||||
permission = "plots.admin.command.update",
|
||||
description = "Update PlotSquared",
|
||||
usage = "/plot update",
|
||||
requiredType = RequiredType.NONE,
|
||||
aliases = {"updateplugin"},
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Update extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
URL url;
|
||||
if (args.length == 0) {
|
||||
url = PS.get().update;
|
||||
} else if (args.length == 1) {
|
||||
try {
|
||||
url = new URL(args[0]);
|
||||
} catch (final MalformedURLException e) {
|
||||
} catch (MalformedURLException e) {
|
||||
MainUtil.sendMessage(plr, "&cInvalid URL: " + args[0]);
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot update [url]");
|
||||
return false;
|
||||
|
@ -30,6 +30,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -38,31 +39,31 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "visit",
|
||||
permission = "plots.visit",
|
||||
description = "Visit someones plot",
|
||||
usage = "/plot visit [player|alias|world|id] [#]",
|
||||
aliases = { "v", "tp", "teleport", "goto" },
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.TELEPORT)
|
||||
command = "visit",
|
||||
permission = "plots.visit",
|
||||
description = "Visit someones plot",
|
||||
usage = "/plot visit [player|alias|world|id] [#]",
|
||||
aliases = {"v", "tp", "teleport", "goto"},
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.TELEPORT)
|
||||
public class Visit extends SubCommand {
|
||||
|
||||
|
||||
public Visit() {
|
||||
requiredArguments = new Argument[] { Argument.String };
|
||||
this.requiredArguments = new Argument[]{Argument.String};
|
||||
}
|
||||
|
||||
public List<Plot> getPlots(final UUID uuid) {
|
||||
final List<Plot> plots = new ArrayList<>();
|
||||
for (final Plot p : PS.get().getPlots()) {
|
||||
|
||||
public List<Plot> getPlots(UUID uuid) {
|
||||
List<Plot> plots = new ArrayList<>();
|
||||
for (Plot p : PS.get().getPlots()) {
|
||||
if (p.hasOwner() && p.isOwner(uuid)) {
|
||||
plots.add(p);
|
||||
}
|
||||
}
|
||||
return plots;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
int page = Integer.MIN_VALUE;
|
||||
Collection<Plot> unsorted = null;
|
||||
if (args.length == 1 && args[0].contains(":")) {
|
||||
@ -78,7 +79,7 @@ public class Visit extends SubCommand {
|
||||
page = Integer.parseInt(args[1]);
|
||||
}
|
||||
case 1: {
|
||||
final UUID user = UUIDHandler.getCachedUUID(args[0], null);
|
||||
UUID user = UUIDHandler.getCachedUUID(args[0], null);
|
||||
if (page == Integer.MIN_VALUE && user == null && MathMan.isInteger(args[0])) {
|
||||
page = Integer.parseInt(args[0]);
|
||||
unsorted = PS.get().getBasePlots(player);
|
||||
@ -87,7 +88,7 @@ public class Visit extends SubCommand {
|
||||
if (user != null) {
|
||||
unsorted = PS.get().getBasePlots(user);
|
||||
} else {
|
||||
final Plot plot = MainUtil.getPlotFromString(player, args[0], true);
|
||||
Plot plot = MainUtil.getPlotFromString(player, args[0], true);
|
||||
if (plot != null) {
|
||||
unsorted = Collections.singletonList(plot.getBasePlot(false));
|
||||
}
|
||||
@ -100,7 +101,7 @@ public class Visit extends SubCommand {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (page == Integer.MIN_VALUE) {
|
||||
@ -110,7 +111,7 @@ public class Visit extends SubCommand {
|
||||
sendMessage(player, C.FOUND_NO_PLOTS);
|
||||
return false;
|
||||
}
|
||||
final Iterator<Plot> iter = unsorted.iterator();
|
||||
Iterator<Plot> iter = unsorted.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (!iter.next().isBasePlot()) {
|
||||
iter.remove();
|
||||
@ -121,7 +122,7 @@ public class Visit extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
ArrayList<Plot> plots = PS.get().sortPlotsByTemp(unsorted);
|
||||
final Plot plot = plots.get(page - 1);
|
||||
Plot plot = plots.get(page - 1);
|
||||
if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(player, "plots.visit.unowned")) {
|
||||
sendMessage(player, C.NO_PERMISSION, "plots.visit.unowned");
|
||||
@ -146,5 +147,5 @@ public class Visit extends SubCommand {
|
||||
plot.teleportPlayer(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,19 +24,19 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "weanywhere",
|
||||
permission = "plots.worldedit.bypass",
|
||||
description = "Force bypass of WorldEdit",
|
||||
aliases = { "wea" },
|
||||
usage = "/plot weanywhere",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
command = "weanywhere",
|
||||
permission = "plots.worldedit.bypass",
|
||||
description = "Force bypass of WorldEdit",
|
||||
aliases = {"wea"},
|
||||
usage = "/plot weanywhere",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
@Deprecated
|
||||
public class WE_Anywhere extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String[] arguments) {
|
||||
public boolean onCommand(PlotPlayer player, String[] arguments) {
|
||||
return MainCommand.onCommand(player, "plot", "toggle", "worldedit");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -49,16 +50,16 @@ import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "list",
|
||||
aliases = { "l", "find", "search" },
|
||||
description = "List plots",
|
||||
permission = "plots.list",
|
||||
category = CommandCategory.INFO,
|
||||
usage = "/plot list <forsale|mine|shared|world|top|all|unowned|unknown|player|world|done|fuzzy <search...>> [#]")
|
||||
command = "list",
|
||||
aliases = {"l", "find", "search"},
|
||||
description = "List plots",
|
||||
permission = "plots.list",
|
||||
category = CommandCategory.INFO,
|
||||
usage = "/plot list <forsale|mine|shared|world|top|all|unowned|unknown|player|world|done|fuzzy <search...>> [#]")
|
||||
public class List extends SubCommand {
|
||||
|
||||
private String[] getArgumentList(final PlotPlayer player) {
|
||||
final java.util.List<String> args = new ArrayList<>();
|
||||
private String[] getArgumentList(PlotPlayer player) {
|
||||
java.util.List<String> args = new ArrayList<>();
|
||||
if ((EconHandler.manager != null) && Permissions.hasPermission(player, "plots.list.forsale")) {
|
||||
args.add("forsale");
|
||||
}
|
||||
@ -101,12 +102,12 @@ public class List extends SubCommand {
|
||||
return args.toArray(new String[args.size()]);
|
||||
}
|
||||
|
||||
public void noArgs(final PlotPlayer plr) {
|
||||
public void noArgs(PlotPlayer plr) {
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + Arrays.toString(getArgumentList(plr)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
if (args.length < 1) {
|
||||
noArgs(plr);
|
||||
return false;
|
||||
@ -119,16 +120,16 @@ public class List extends SubCommand {
|
||||
if (page < 0) {
|
||||
page = 0;
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
page = -1;
|
||||
}
|
||||
}
|
||||
|
||||
java.util.List<Plot> plots = null;
|
||||
|
||||
final String world = plr.getLocation().getWorld();
|
||||
final PlotArea area = plr.getApplicablePlotArea();
|
||||
final String arg = args[0].toLowerCase();
|
||||
String world = plr.getLocation().getWorld();
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
String arg = args[0].toLowerCase();
|
||||
boolean sort = true;
|
||||
switch (arg) {
|
||||
case "mine": {
|
||||
@ -146,7 +147,7 @@ public class List extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (final Plot plot : PS.get().getPlots()) {
|
||||
for (Plot plot : PS.get().getPlots()) {
|
||||
if (plot.getTrusted().contains(plr.getUUID()) || plot.getMembers().contains(plr.getUUID())) {
|
||||
plots.add(plot);
|
||||
}
|
||||
@ -199,8 +200,8 @@ public class List extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (final Plot plot : PS.get().getPlots()) {
|
||||
final Flag flag = plot.getFlags().get("done");
|
||||
for (Plot plot : PS.get().getPlots()) {
|
||||
Flag flag = plot.getFlags().get("done");
|
||||
if (flag == null) {
|
||||
continue;
|
||||
}
|
||||
@ -208,9 +209,9 @@ public class List extends SubCommand {
|
||||
}
|
||||
Collections.sort(plots, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(final Plot a, final Plot b) {
|
||||
final String va = a.getFlags().get("done").getValueString();
|
||||
final String vb = b.getFlags().get("done").getValueString();
|
||||
public int compare(Plot a, Plot b) {
|
||||
String va = a.getFlags().get("done").getValueString();
|
||||
String vb = b.getFlags().get("done").getValueString();
|
||||
if (MathMan.isInteger(va)) {
|
||||
if (MathMan.isInteger(vb)) {
|
||||
return Integer.parseInt(vb) - Integer.parseInt(va);
|
||||
@ -231,13 +232,13 @@ public class List extends SubCommand {
|
||||
plots = new ArrayList<>(PS.get().getPlots());
|
||||
Collections.sort(plots, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(final Plot p1, final Plot p2) {
|
||||
public int compare(Plot p1, Plot p2) {
|
||||
double v1 = 0;
|
||||
final int p1s = p1.getSettings().getRatings().size();
|
||||
final int p2s = p2.getRatings().size();
|
||||
int p1s = p1.getSettings().getRatings().size();
|
||||
int p2s = p2.getRatings().size();
|
||||
if (!p1.getSettings().getRatings().isEmpty()) {
|
||||
for (final Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
|
||||
final double av = entry.getValue().getAverageRating();
|
||||
for (Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
|
||||
double av = entry.getValue().getAverageRating();
|
||||
v1 += av * av;
|
||||
}
|
||||
v1 /= p1s;
|
||||
@ -245,8 +246,8 @@ public class List extends SubCommand {
|
||||
}
|
||||
double v2 = 0;
|
||||
if (!p2.getSettings().getRatings().isEmpty()) {
|
||||
for (final Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
|
||||
final double av = entry.getValue().getAverageRating();
|
||||
for (Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
|
||||
double av = entry.getValue().getAverageRating();
|
||||
v2 += av * av;
|
||||
}
|
||||
v2 /= p2s;
|
||||
@ -270,8 +271,8 @@ public class List extends SubCommand {
|
||||
break;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (final Plot plot : PS.get().getPlots()) {
|
||||
final Flag price = FlagManager.getPlotFlagRaw(plot, "price");
|
||||
for (Plot plot : PS.get().getPlots()) {
|
||||
Flag price = FlagManager.getPlotFlagRaw(plot, "price");
|
||||
if (price != null) {
|
||||
plots.add(plot);
|
||||
}
|
||||
@ -284,7 +285,7 @@ public class List extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (final Plot plot : PS.get().getPlots()) {
|
||||
for (Plot plot : PS.get().getPlots()) {
|
||||
if (plot.owner == null) {
|
||||
plots.add(plot);
|
||||
}
|
||||
@ -297,7 +298,7 @@ public class List extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (final Plot plot : PS.get().getPlots()) {
|
||||
for (Plot plot : PS.get().getPlots()) {
|
||||
if (plot.owner == null) {
|
||||
continue;
|
||||
}
|
||||
@ -338,7 +339,8 @@ public class List extends SubCommand {
|
||||
if (uuid == null) {
|
||||
try {
|
||||
uuid = UUID.fromString(args[0]);
|
||||
} catch (final Exception e) {}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
if (uuid != null) {
|
||||
if (!Permissions.hasPermission(plr, "plots.list.player")) {
|
||||
@ -365,7 +367,8 @@ public class List extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void displayPlots(final PlotPlayer player, java.util.List<Plot> plots, final int pageSize, int page, final PlotArea area, final String[] args, final boolean sort) {
|
||||
public void displayPlots(final PlotPlayer player, java.util.List<Plot> plots, int pageSize, int page, PlotArea area,
|
||||
String[] args, boolean sort) {
|
||||
// Header
|
||||
Iterator<Plot> iter = plots.iterator();
|
||||
while (iter.hasNext()) {
|
||||
@ -391,23 +394,29 @@ public class List extends SubCommand {
|
||||
} else {
|
||||
color = "$1";
|
||||
}
|
||||
final PlotMessage trusted = new PlotMessage().text(C.color(C.PLOT_INFO_TRUSTED.s().replaceAll("%trusted%", MainUtil.getPlayerList(plot.getTrusted())))).color("$1");
|
||||
final PlotMessage members = new PlotMessage().text(C.color(C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers())))).color("$1");
|
||||
PlotMessage trusted =
|
||||
new PlotMessage().text(C.color(C.PLOT_INFO_TRUSTED.s().replaceAll("%trusted%", MainUtil.getPlayerList(plot.getTrusted()))))
|
||||
.color("$1");
|
||||
PlotMessage members =
|
||||
new PlotMessage().text(C.color(C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers()))))
|
||||
.color("$1");
|
||||
String strFlags = StringMan.join(plot.getFlags().values(), ",");
|
||||
if (strFlags.isEmpty()) {
|
||||
strFlags = C.NONE.s();
|
||||
}
|
||||
final PlotMessage flags = new PlotMessage().text(C.color(C.PLOT_INFO_FLAGS.s().replaceAll("%flags%", strFlags))).color("$1");
|
||||
message.text("[").color("$3").text(i + "").command("/plot visit " + plot.getArea() + ";" + plot.getId()).tooltip("/plot visit " + plot.getArea() + ";" + plot.getId()).color("$1")
|
||||
.text("]")
|
||||
.color("$3").text(" " + plot.toString()).tooltip(trusted, members, flags).command("/plot info " + plot.getArea() + ";" + plot.getId()).color(color).text(" - ").color("$2");
|
||||
PlotMessage flags = new PlotMessage().text(C.color(C.PLOT_INFO_FLAGS.s().replaceAll("%flags%", strFlags))).color("$1");
|
||||
message.text("[").color("$3").text(i + "").command("/plot visit " + plot.getArea() + ";" + plot.getId())
|
||||
.tooltip("/plot visit " + plot.getArea() + ";" + plot.getId()).color("$1")
|
||||
.text("]")
|
||||
.color("$3").text(" " + plot.toString()).tooltip(trusted, members, flags)
|
||||
.command("/plot info " + plot.getArea() + ";" + plot.getId()).color(color).text(" - ").color("$2");
|
||||
String prefix = "";
|
||||
for (final UUID uuid : plot.getOwners()) {
|
||||
final String name = UUIDHandler.getName(uuid);
|
||||
for (UUID uuid : plot.getOwners()) {
|
||||
String name = UUIDHandler.getName(uuid);
|
||||
if (name == null) {
|
||||
message = message.text(prefix).color("$4").text("unknown").color("$2").tooltip(uuid.toString()).suggest(uuid.toString());
|
||||
} else {
|
||||
final PlotPlayer pp = UUIDHandler.getPlayer(uuid);
|
||||
PlotPlayer pp = UUIDHandler.getPlayer(uuid);
|
||||
if (pp != null) {
|
||||
message = message.text(prefix).color("$4").text(name).color("$1").tooltip(new PlotMessage("Online").color("$4"));
|
||||
} else {
|
||||
|
@ -26,14 +26,14 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "plugin",
|
||||
permission = "plots.use",
|
||||
description = "Show plugin information",
|
||||
aliases = "version",
|
||||
category = CommandCategory.INFO)
|
||||
permission = "plots.use",
|
||||
description = "Show plugin information",
|
||||
aliases = "version",
|
||||
category = CommandCategory.INFO)
|
||||
public class Plugin extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", PS.get().IMP.getPluginVersion()));
|
||||
MainUtil.sendMessage(plr, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92");
|
||||
MainUtil.sendMessage(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki");
|
||||
|
@ -41,7 +41,7 @@ import java.util.Set;
|
||||
|
||||
*/
|
||||
public enum C {
|
||||
|
||||
|
||||
/*
|
||||
* Static flags
|
||||
*/
|
||||
@ -94,9 +94,10 @@ public enum C {
|
||||
/*
|
||||
* Static console
|
||||
*/
|
||||
CONSOLE_JAVA_OUTDATED_1_7("&cYour java version is outdated. Please update to at least 1.7.\n&cURL: &6https://java.com/en/download/index.jsp","static.console"),
|
||||
CONSOLE_JAVA_OUTDATED_1_8("&cIt's really recommended to run Java 1.8, as it increases performance","static.console"),
|
||||
CONSOLE_PLEASE_ENABLE_METRICS("&dUsing metrics will allow us to improve the plugin, please consider it :)","static.console"),
|
||||
CONSOLE_JAVA_OUTDATED_1_7("&cYour java version is outdated. Please update to at least 1.7.\n&cURL: &6https://java.com/en/download/index.jsp",
|
||||
"static.console"),
|
||||
CONSOLE_JAVA_OUTDATED_1_8("&cIt's really recommended to run Java 1.8, as it increases performance", "static.console"),
|
||||
CONSOLE_PLEASE_ENABLE_METRICS("&dUsing metrics will allow us to improve the plugin, please consider it :)", "static.console"),
|
||||
/*
|
||||
* Confirm
|
||||
*/
|
||||
@ -130,8 +131,9 @@ public enum C {
|
||||
* Cluster
|
||||
*/
|
||||
CLUSTER_AVAILABLE_ARGS(
|
||||
"$1The following sub commands are available: $4list$2, $4create$2, $4delete$2, $4resize$2, $4invite$2, $4kick$2, $4leave$2, $4members$2, $4info$2, $4tp$2, $4sethome",
|
||||
"Cluster"),
|
||||
"$1The following sub commands are available: $4list$2, $4create$2, $4delete$2, $4resize$2, $4invite$2, $4kick$2, $4leave$2, "
|
||||
+ "$4members$2, $4info$2, $4tp$2, $4sethome",
|
||||
"Cluster"),
|
||||
CLUSTER_LIST_HEADING("$2There are $1%s$2 clusters in this world", "Cluster"),
|
||||
CLUSTER_LIST_ELEMENT("$2 - $1%s&-", "Cluster"),
|
||||
CLUSTER_INTERSECTION("$2The proposed area overlaps with: %s0", "Cluster"),
|
||||
@ -173,8 +175,8 @@ public enum C {
|
||||
WORLDEDIT_BYPASSED("$2Currently bypassing WorldEdit restriction.", "WorldEdit Masks"),
|
||||
WORLDEDIT_UNMASKED("$1Your WorldEdit is now unrestricted.", "WorldEdit Masks"),
|
||||
WORLDEDIT_RESTRICTED("$1Your WorldEdit is now restricted.", "WorldEdit Masks"),
|
||||
|
||||
GAMEMODE_WAS_BYPASSED("$1You bypassed the gamemode ($2{gamemode}$1) $1set for $2{plot}", "Gamemode"),
|
||||
|
||||
GAMEMODE_WAS_BYPASSED("$1You bypassed the GameMode ($2{gamemode}$1) $1set for $2{plot}", "GameMode"),
|
||||
HEIGHT_LIMIT("$1This plot area has a height limit of $2{limit}", "Height Limit"),
|
||||
/*
|
||||
* Records
|
||||
@ -210,14 +212,14 @@ public enum C {
|
||||
*/
|
||||
NOT_CONSOLE("$2For safety reasons, this command can only be executed by console.", "Console"),
|
||||
IS_CONSOLE("$2This command can only be executed by a player.", "Console"),
|
||||
|
||||
|
||||
/*
|
||||
Inventory
|
||||
*/
|
||||
INVENTORY_USAGE("&cUsage: &6{usage}", "Inventory"),
|
||||
INVENTORY_DESC("&cDescription: &6{desc}", "Inventory"),
|
||||
INVENTORY_CATEGORY("&cCategory: &6{category}", "Inventory"),
|
||||
|
||||
|
||||
/*
|
||||
* Clipboard
|
||||
*/
|
||||
@ -231,7 +233,7 @@ public enum C {
|
||||
*/
|
||||
TOGGLE_ENABLED("$2Enabled setting: %s", "Toggle"),
|
||||
TOGGLE_DISABLED("$2Disabled setting: %s", "Toggle"),
|
||||
|
||||
|
||||
COMMAND_BLOCKED("$2That command is not allowed in this plot", "Blocked Command"),
|
||||
/*
|
||||
* Done
|
||||
@ -275,15 +277,18 @@ public enum C {
|
||||
SETUP_INVALID_ARG("$2%s0 is not a valid argument for step %s1. To cancel setup use: $1/plot setup cancel", "Setup"),
|
||||
SETUP_VALID_ARG("$2Value $1%s0 $2set to %s1", "Setup"),
|
||||
SETUP_FINISHED(
|
||||
"$4You should have been teleported to the created world. Otherwise you will need to set the generator manually using the bukkit.yml or your chosen world management plugin.",
|
||||
"Setup"),
|
||||
"$4You should have been teleported to the created world. Otherwise you will need to set the generator manually using the bukkit.yml or "
|
||||
+ "your chosen world management plugin.",
|
||||
"Setup"),
|
||||
SETUP_WORLD_TAKEN("$2%s is already a registered plotworld", "Setup"),
|
||||
SETUP_MISSING_WORLD(
|
||||
"$2You need to specify a world name ($1/plot setup &l<world>$1 <generator>$2)&-$1Additional commands:&-$2 - $1/plot setup <value>&-$2 - $1/plot setup back&-$2 - $1/plot setup cancel",
|
||||
"Setup"),
|
||||
"$2You need to specify a world name ($1/plot setup &l<world>$1 <generator>$2)&-$1Additional commands:&-$2 - $1/plot setup <value>&-$2 -"
|
||||
+ " $1/plot setup back&-$2 - $1/plot setup cancel",
|
||||
"Setup"),
|
||||
SETUP_MISSING_GENERATOR(
|
||||
"$2You need to specify a generator ($1/plot setup <world> &l<generator>&r$2)&-$1Additional commands:&-$2 - $1/plot setup <value>&-$2 - $1/plot setup back&-$2 - $1/plot setup cancel",
|
||||
"Setup"),
|
||||
"$2You need to specify a generator ($1/plot setup <world> &l<generator>&r$2)&-$1Additional commands:&-$2 - $1/plot setup <value>&-$2 - "
|
||||
+ "$1/plot setup back&-$2 - $1/plot setup cancel",
|
||||
"Setup"),
|
||||
SETUP_INVALID_GENERATOR("$2Invalid generator. Possible options: %s", "Setup"),
|
||||
/*
|
||||
* Schematic Stuff
|
||||
@ -315,11 +320,11 @@ public enum C {
|
||||
/*
|
||||
* BarAPI
|
||||
*/
|
||||
|
||||
|
||||
DESC_SET("$2Plot description set", "Desc"),
|
||||
DESC_UNSET("$2Plot description unset", "Desc"),
|
||||
MISSING_DESC("$2You need to specify a description", "Desc"),
|
||||
|
||||
|
||||
/*
|
||||
* Alias
|
||||
*/
|
||||
@ -350,7 +355,7 @@ public enum C {
|
||||
CANT_TRANSFER_MORE_PLOTS("$2You can't send more plots to that user", "Permission"),
|
||||
CANT_CLAIM_MORE_PLOTS_NUM("$2You can't claim more than $1%s $2plots at once", "Permission"),
|
||||
YOU_BE_DENIED("$2You are not allowed to enter this plot", "Permission"),
|
||||
|
||||
|
||||
/*
|
||||
* Merge
|
||||
*/
|
||||
@ -360,7 +365,8 @@ public enum C {
|
||||
MERGE_REQUESTED("$2Successfully sent a merge request", "Merge"),
|
||||
MERGE_REQUEST_CONFIRM("merge request from %s", "Permission"),
|
||||
NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%", "Merge"),
|
||||
NO_AVAILABLE_AUTOMERGE("$2You do not own any adjacent plots in the specified direction or are not allowed to merge to the required size.", "Merge"),
|
||||
NO_AVAILABLE_AUTOMERGE("$2You do not own any adjacent plots in the specified direction or are not allowed to merge to the required size.",
|
||||
"Merge"),
|
||||
UNLINK_REQUIRED("$2An unlink is required to do this.", "Merge"),
|
||||
UNLINK_IMPOSSIBLE("$2You can only unlink a mega-plot", "Merge"),
|
||||
UNLINK_SUCCESS("$2Successfully unlinked plots.", "Merge"),
|
||||
@ -426,7 +432,7 @@ public enum C {
|
||||
* Set Block
|
||||
*/
|
||||
SET_BLOCK_ACTION_FINISHED("$1The last setblock action is now finished.", "Set Block"),
|
||||
|
||||
|
||||
/*
|
||||
AllowUnsafe
|
||||
*/
|
||||
@ -474,15 +480,15 @@ public enum C {
|
||||
PLOT_INFO_UNCLAIMED("$2Plot $1%s$2 is not yet claimed", "Info"),
|
||||
PLOT_INFO_HEADER("$3&m---------&r $1INFO $3&m---------", false, "Info"),
|
||||
PLOT_INFO("$1ID: $2%id%$1&-"
|
||||
+ "$1Alias: $2%alias%$1&-"
|
||||
+ "$1Owner: $2%owner%$1&-"
|
||||
+ "$1Biome: $2%biome%$1&-"
|
||||
+ "$1Can Build: $2%build%$1&-"
|
||||
+ "$1Rating: $2%rating%&-"
|
||||
+ "$1Trusted: $2%trusted%$1&-"
|
||||
+ "$1Members: $2%members%$1&-"
|
||||
+ "$1Denied: $2%denied%$1&-"
|
||||
+ "$1Flags: $2%flags%", "Info"),
|
||||
+ "$1Alias: $2%alias%$1&-"
|
||||
+ "$1Owner: $2%owner%$1&-"
|
||||
+ "$1Biome: $2%biome%$1&-"
|
||||
+ "$1Can Build: $2%build%$1&-"
|
||||
+ "$1Rating: $2%rating%&-"
|
||||
+ "$1Trusted: $2%trusted%$1&-"
|
||||
+ "$1Members: $2%members%$1&-"
|
||||
+ "$1Denied: $2%denied%$1&-"
|
||||
+ "$1Flags: $2%flags%", "Info"),
|
||||
PLOT_INFO_FOOTER("$3&m---------&r $1INFO $3&m---------", false, "Info"),
|
||||
PLOT_INFO_TRUSTED("$1Trusted:$2 %trusted%", "Info"),
|
||||
PLOT_INFO_MEMBERS("$1Members:$2 %members%", "Info"),
|
||||
@ -529,7 +535,9 @@ public enum C {
|
||||
/*
|
||||
* PlotMe
|
||||
*/
|
||||
NOT_USING_PLOTME("$2This server uses the far superior $1PlotSquared $2plot management system. Please use the $1/ps $2or $1/p2 $2or $1/plots $2instead", "Errors"),
|
||||
NOT_USING_PLOTME(
|
||||
"$2This server uses the far superior $1PlotSquared $2plot management system. Please use the $1/ps $2or $1/p2 $2or $1/plots $2instead",
|
||||
"Errors"),
|
||||
/*
|
||||
* Wait
|
||||
*/
|
||||
@ -603,7 +611,7 @@ public enum C {
|
||||
HELP_HEADER("$3&m---------&r $1Plot\u00B2 Help $3&m---------", "Help"),
|
||||
HELP_PAGE_HEADER("$1Category: $2%category%$2,$1 Page: $2%current%$3/$2%max%$2", "Help"),
|
||||
HELP_FOOTER("$3&m---------&r $1Plot\u00B2 Help $3&m---------", "Help"),
|
||||
|
||||
|
||||
HELP_INFO_ITEM("$1/plots help %category% $3- $2%category_desc%", "Help"),
|
||||
HELP_ITEM("$1%usage% [%alias%]&- $3- $2%desc%&-", "Help"),
|
||||
/*
|
||||
@ -622,22 +630,22 @@ public enum C {
|
||||
CUSTOM_STRING("-", "-");
|
||||
public static final HashMap<String, String> replacements = new HashMap<>();
|
||||
/**
|
||||
* Translated
|
||||
* Translated.
|
||||
*/
|
||||
private String s;
|
||||
/**
|
||||
* Default
|
||||
* Default.
|
||||
*/
|
||||
private String d;
|
||||
/**
|
||||
* What locale category should this translation fall under
|
||||
* What locale category should this translation fall under.
|
||||
*/
|
||||
private String cat;
|
||||
/**
|
||||
* Should the string be prefixed?
|
||||
* Should the string be prefixed.
|
||||
*/
|
||||
private boolean prefix;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for custom strings.
|
||||
*/
|
||||
@ -646,34 +654,34 @@ public enum C {
|
||||
* use setCustomString();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*
|
||||
* @param d default
|
||||
* @param prefix use prefix
|
||||
*/
|
||||
C(final String d, final boolean prefix, final String cat) {
|
||||
C(String d, boolean prefix, String cat) {
|
||||
this.d = d;
|
||||
this.s = d;
|
||||
this.prefix = prefix;
|
||||
this.cat = cat.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*
|
||||
* @param d default
|
||||
*/
|
||||
C(final String d, final String cat) {
|
||||
C(String d, String cat) {
|
||||
this(d, true, cat.toLowerCase());
|
||||
}
|
||||
|
||||
public static String format(String m, final Object... args) {
|
||||
|
||||
public static String format(String m, Object... args) {
|
||||
if (args.length == 0) {
|
||||
return m;
|
||||
}
|
||||
final Map<String, String> map = new LinkedHashMap<String, String>();
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
if (args.length > 0) {
|
||||
for (int i = args.length - 1; i >= 0; i--) {
|
||||
String arg = args[i].toString();
|
||||
@ -691,48 +699,52 @@ public enum C {
|
||||
m = StringMan.replaceFromMap(m, map);
|
||||
return m;
|
||||
}
|
||||
|
||||
public static String format(final C c, final Object... args) {
|
||||
return (c.usePrefix() ? C.PREFIX.s() : "") + format(c.s, args);
|
||||
|
||||
public static String format(C c, Object... args) {
|
||||
if (c.usePrefix()) {
|
||||
return C.PREFIX.s() + format(c.s, args);
|
||||
} else {
|
||||
return format(c.s, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static String color(final String string) {
|
||||
|
||||
public static String color(String string) {
|
||||
return StringMan.replaceFromMap(string, replacements);
|
||||
}
|
||||
|
||||
public static void load(final File file) {
|
||||
|
||||
public static void load(File file) {
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
}
|
||||
final YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
|
||||
final Set<String> keys = yml.getKeys(true);
|
||||
final EnumSet<C> all = EnumSet.allOf(C.class);
|
||||
final HashSet<String> allNames = new HashSet<>();
|
||||
final HashSet<String> allCats = new HashSet<>();
|
||||
final HashSet<String> toRemove = new HashSet<>();
|
||||
for (final C c : all) {
|
||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
|
||||
Set<String> keys = yml.getKeys(true);
|
||||
EnumSet<C> all = EnumSet.allOf(C.class);
|
||||
HashSet<String> allNames = new HashSet<>();
|
||||
HashSet<String> allCats = new HashSet<>();
|
||||
HashSet<String> toRemove = new HashSet<>();
|
||||
for (C c : all) {
|
||||
allNames.add(c.name());
|
||||
allCats.add(c.cat.toLowerCase());
|
||||
}
|
||||
final HashSet<C> captions = new HashSet<>();
|
||||
HashSet<C> captions = new HashSet<>();
|
||||
boolean changed = false;
|
||||
for (final String key : keys) {
|
||||
for (String key : keys) {
|
||||
if (!yml.isString(key)) {
|
||||
if (!allCats.contains(key)) {
|
||||
toRemove.add(key);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
final String[] split = key.split("\\.");
|
||||
final String node = split[split.length - 1].toUpperCase();
|
||||
final C caption = allNames.contains(node) ? valueOf(node) : null;
|
||||
String[] split = key.split("\\.");
|
||||
String node = split[split.length - 1].toUpperCase();
|
||||
C caption = allNames.contains(node) ? valueOf(node) : null;
|
||||
if (caption != null) {
|
||||
if (caption.cat.startsWith("static")) {
|
||||
continue;
|
||||
}
|
||||
final String value = yml.getString(key);
|
||||
String value = yml.getString(key);
|
||||
if (!split[0].equalsIgnoreCase(caption.cat)) {
|
||||
changed = true;
|
||||
yml.set(key, null);
|
||||
@ -744,24 +756,24 @@ public enum C {
|
||||
toRemove.add(key);
|
||||
}
|
||||
}
|
||||
for (final String remove : toRemove) {
|
||||
for (String remove : toRemove) {
|
||||
changed = true;
|
||||
yml.set(remove, null);
|
||||
}
|
||||
final ConfigurationSection config = PS.get().style.getConfigurationSection("color");
|
||||
final Set<String> styles = config.getKeys(false);
|
||||
ConfigurationSection config = PS.get().style.getConfigurationSection("color");
|
||||
Set<String> styles = config.getKeys(false);
|
||||
// HashMap<String, String> replacements = new HashMap<>();
|
||||
replacements.clear();
|
||||
for (final String style : styles) {
|
||||
for (String style : styles) {
|
||||
replacements.put("$" + style, "\u00a7" + config.getString(style));
|
||||
}
|
||||
for (final char letter : "1234567890abcdefklmnor".toCharArray()) {
|
||||
for (char letter : "1234567890abcdefklmnor".toCharArray()) {
|
||||
replacements.put("&" + letter, "\u00a7" + letter);
|
||||
}
|
||||
replacements.put("\\\\n", "\n");
|
||||
replacements.put("\\n", "\n");
|
||||
replacements.put("&-", "\n");
|
||||
for (final C caption : all) {
|
||||
for (C caption : all) {
|
||||
if (!captions.contains(caption)) {
|
||||
if (caption.cat.startsWith("static")) {
|
||||
continue;
|
||||
@ -774,37 +786,37 @@ public enum C {
|
||||
if (changed) {
|
||||
yml.save(file);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return s;
|
||||
return this.s;
|
||||
}
|
||||
|
||||
|
||||
public String s() {
|
||||
return s;
|
||||
return this.s;
|
||||
}
|
||||
|
||||
|
||||
public boolean usePrefix() {
|
||||
return prefix;
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
|
||||
public String formatted() {
|
||||
return StringMan.replaceFromMap(s(), replacements);
|
||||
}
|
||||
|
||||
|
||||
public String getCat() {
|
||||
return cat;
|
||||
return this.cat;
|
||||
}
|
||||
|
||||
public void send(final CommandCaller plr, final String... args) {
|
||||
|
||||
public void send(CommandCaller plr, String... args) {
|
||||
send(plr, (Object[]) args);
|
||||
}
|
||||
|
||||
public void send(final CommandCaller plr, final Object... args) {
|
||||
|
||||
public void send(CommandCaller plr, Object... args) {
|
||||
String msg = format(this, args);
|
||||
if (plr == null) {
|
||||
ConsolePlayer.getConsole().sendMessage(msg);
|
||||
|
@ -28,7 +28,6 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@ -37,52 +36,49 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
||||
|
||||
*/
|
||||
public interface AbstractDB {
|
||||
|
||||
/**
|
||||
* The UUID that will count as everyone
|
||||
* The UUID that will count as everyone.
|
||||
*/
|
||||
UUID everyone = UUID.fromString("1-1-3-3-7");
|
||||
|
||||
/**
|
||||
* Set Plot owner
|
||||
* Set Plot owner.
|
||||
*
|
||||
* @param plot Plot in which the owner should be set
|
||||
* @param uuid The uuid of the new owner
|
||||
*/
|
||||
void setOwner(final Plot plot, final UUID uuid);
|
||||
void setOwner(Plot plot, UUID uuid);
|
||||
|
||||
/**
|
||||
* Create all settings, and create default helpers, trusted + denied lists
|
||||
* Create all settings, and create default helpers, trusted + denied lists.
|
||||
*
|
||||
* @param plots Plots for which the default table entries should be created
|
||||
* @param whenDone
|
||||
*/
|
||||
void createPlotsAndData(final ArrayList<Plot> plots, final Runnable whenDone);
|
||||
void createPlotsAndData(ArrayList<Plot> plots, Runnable whenDone);
|
||||
|
||||
/**
|
||||
* Create a plot
|
||||
*
|
||||
* @param plot That should be created
|
||||
*/
|
||||
void createPlot(final Plot plot);
|
||||
void createPlot(Plot plot);
|
||||
|
||||
/**
|
||||
* Create tables
|
||||
* Create tables.
|
||||
*
|
||||
* @throws SQLException If the database manager is unable to create the tables
|
||||
* @throws Exception If the database manager is unable to create the tables
|
||||
*/
|
||||
void createTables() throws Exception;
|
||||
|
||||
/**
|
||||
* Delete a plot
|
||||
* Delete a plot.
|
||||
*
|
||||
* @param plot Plot that should be deleted
|
||||
* @param plot The plot to delete.
|
||||
*/
|
||||
void delete(final Plot plot);
|
||||
void delete(Plot plot);
|
||||
|
||||
void deleteSettings(Plot plot);
|
||||
|
||||
@ -96,7 +92,7 @@ public interface AbstractDB {
|
||||
|
||||
void deleteRatings(Plot plot);
|
||||
|
||||
void delete(final PlotCluster cluster);
|
||||
void delete(PlotCluster cluster);
|
||||
|
||||
void addPersistentMeta(UUID uuid, String key, byte[] meta, boolean delete);
|
||||
|
||||
@ -105,248 +101,254 @@ public interface AbstractDB {
|
||||
void getPersistentMeta(UUID uuid, RunnableVal<Map<String, byte[]>> result);
|
||||
|
||||
/**
|
||||
* Create plot settings
|
||||
* Create plot settings.
|
||||
*
|
||||
* @param id Plot Entry ID
|
||||
* @param plot Plot Object
|
||||
*/
|
||||
void createPlotSettings(final int id, final Plot plot);
|
||||
void createPlotSettings(int id, Plot plot);
|
||||
|
||||
/**
|
||||
* Get the table entry ID
|
||||
* Get the table entry ID.
|
||||
*
|
||||
* @param plot Plot Object
|
||||
*
|
||||
* @return Integer = Plot Entry Id
|
||||
*/
|
||||
int getId(final Plot plot);
|
||||
int getId(Plot plot);
|
||||
|
||||
/**
|
||||
* Get the id of a given plot cluster
|
||||
* Get the id of a given plot cluster.
|
||||
*
|
||||
* @param cluster PlotCluster Object
|
||||
*
|
||||
* @return Integer = Cluster Entry Id
|
||||
*/
|
||||
int getClusterId(final PlotCluster cluster);
|
||||
int getClusterId(PlotCluster cluster);
|
||||
|
||||
/**
|
||||
* @return A linked hashmap containing all plots
|
||||
* @return A linked HashMap containing all plots
|
||||
*/
|
||||
HashMap<String, HashMap<PlotId, Plot>> getPlots();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param toValidate
|
||||
*/
|
||||
void validateAllPlots(final Set<Plot> toValidate);
|
||||
void validateAllPlots(Set<Plot> toValidate);
|
||||
|
||||
/**
|
||||
* @return A hashmap containing all plot clusters
|
||||
* @return A HashMap containing all plot clusters
|
||||
*/
|
||||
HashMap<String, Set<PlotCluster>> getClusters();
|
||||
|
||||
/**
|
||||
* Set the merged status for a plot
|
||||
* Set the merged status for a plot.
|
||||
*
|
||||
* @param plot Plot Object
|
||||
* @param plot The plot to set the merged status of
|
||||
* @param merged boolean[]
|
||||
*/
|
||||
void setMerged(final Plot plot, final boolean[] merged);
|
||||
void setMerged(Plot plot, boolean[] merged);
|
||||
|
||||
/**
|
||||
* Swap the settings, helpers etc. of two plots
|
||||
* @param p1 Plot1
|
||||
* @param p2 Plot2
|
||||
* Swap the settings, helpers etc. of two plots.
|
||||
* @param plot1 Plot1
|
||||
* @param plot2 Plot2
|
||||
*/
|
||||
void swapPlots(final Plot p1, final Plot p2);
|
||||
void swapPlots(Plot plot1, Plot plot2);
|
||||
|
||||
/**
|
||||
* Set plot flags
|
||||
* Set plot flags.
|
||||
*
|
||||
* @param plot Plot Object
|
||||
* @param flags flags to set (flag[])
|
||||
*/
|
||||
void setFlags(final Plot plot, final Collection<Flag> flags);
|
||||
void setFlags(Plot plot, Collection<Flag> flags);
|
||||
|
||||
/**
|
||||
* Set cluster flags
|
||||
* Set cluster flags.
|
||||
*
|
||||
* @param cluster PlotCluster Object
|
||||
* @param flags flags to set (flag[])
|
||||
*/
|
||||
void setFlags(final PlotCluster cluster, final Collection<Flag> flags);
|
||||
void setFlags(PlotCluster cluster, Collection<Flag> flags);
|
||||
|
||||
/**
|
||||
* Rename a cluster
|
||||
* Rename a cluster.
|
||||
*/
|
||||
void setClusterName(final PlotCluster cluster, final String name);
|
||||
void setClusterName(PlotCluster cluster, String name);
|
||||
|
||||
/**
|
||||
* Set the plot alias
|
||||
* Set the plot alias.
|
||||
*
|
||||
* @param plot Plot for which the alias should be set
|
||||
* @param alias Plot Alias
|
||||
*/
|
||||
void setAlias(final Plot plot, final String alias);
|
||||
void setAlias(Plot plot, String alias);
|
||||
|
||||
/**
|
||||
* Purge a plot
|
||||
* Purge a plot.
|
||||
*
|
||||
* @param uniqueIds list of plot id (db) to be purged
|
||||
*/
|
||||
void purgeIds(final Set<Integer> uniqueIds);
|
||||
void purgeIds(Set<Integer> uniqueIds);
|
||||
|
||||
/**
|
||||
* Purge a whole world
|
||||
* Purge a whole world.
|
||||
*
|
||||
* @param area World in which the plots should be purged
|
||||
* @param plotIds
|
||||
*/
|
||||
void purge(final PlotArea area, final Set<PlotId> plotIds);
|
||||
void purge(PlotArea area, Set<PlotId> plotIds);
|
||||
|
||||
/**
|
||||
* Set Plot Home Position
|
||||
* Set Plot Home Position.
|
||||
*
|
||||
* @param plot Plot Object
|
||||
* @param position Plot Home Position
|
||||
*/
|
||||
void setPosition(final Plot plot, final String position);
|
||||
void setPosition(Plot plot, String position);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cluster
|
||||
* @param position
|
||||
*/
|
||||
void setPosition(final PlotCluster cluster, final String position);
|
||||
void setPosition(PlotCluster cluster, String position);
|
||||
|
||||
/**
|
||||
* @param plot Plot Object
|
||||
* @param uuid Player that should be removed
|
||||
*/
|
||||
void removeTrusted(final Plot plot, final UUID uuid);
|
||||
void removeTrusted(Plot plot, UUID uuid);
|
||||
|
||||
/**
|
||||
* @param cluster PlotCluster Object
|
||||
* @param uuid Player that should be removed
|
||||
*/
|
||||
void removeHelper(final PlotCluster cluster, final UUID uuid);
|
||||
void removeHelper(PlotCluster cluster, UUID uuid);
|
||||
|
||||
/**
|
||||
* @param plot Plot Object
|
||||
* @param uuid Player that should be removed
|
||||
*/
|
||||
void removeMember(final Plot plot, final UUID uuid);
|
||||
|
||||
void removeMember(Plot plot, UUID uuid);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cluster
|
||||
* @param uuid
|
||||
*/
|
||||
void removeInvited(final PlotCluster cluster, final UUID uuid);
|
||||
void removeInvited(PlotCluster cluster, UUID uuid);
|
||||
|
||||
/**
|
||||
* @param plot Plot Object
|
||||
* @param uuid Player that should be removed
|
||||
*/
|
||||
void setTrusted(final Plot plot, final UUID uuid);
|
||||
void setTrusted(Plot plot, UUID uuid);
|
||||
|
||||
/**
|
||||
* @param cluster PlotCluster Object
|
||||
* @param uuid Player that should be removed
|
||||
*/
|
||||
void setHelper(final PlotCluster cluster, final UUID uuid);
|
||||
void setHelper(PlotCluster cluster, UUID uuid);
|
||||
|
||||
/**
|
||||
* @param plot Plot Object
|
||||
* @param uuid Player that should be added
|
||||
*/
|
||||
void setMember(final Plot plot, final UUID uuid);
|
||||
void setMember(Plot plot, UUID uuid);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cluster
|
||||
* @param uuid
|
||||
*/
|
||||
void setInvited(final PlotCluster cluster, final UUID uuid);
|
||||
void setInvited(PlotCluster cluster, UUID uuid);
|
||||
|
||||
/**
|
||||
* @param plot Plot Object
|
||||
* @param uuid Player uuid
|
||||
*/
|
||||
void removeDenied(final Plot plot, final UUID uuid);
|
||||
void removeDenied(Plot plot, UUID uuid);
|
||||
|
||||
/**
|
||||
* @param plot Plot Object
|
||||
* @param uuid Player uuid that should be added
|
||||
*/
|
||||
void setDenied(final Plot plot, final UUID uuid);
|
||||
void setDenied(Plot plot, UUID uuid);
|
||||
|
||||
/**
|
||||
* Get Plots ratings
|
||||
* Get Plots ratings.
|
||||
*
|
||||
* @param plot Plot Object
|
||||
*
|
||||
* @return Plot Ratings (pre-calculated)
|
||||
*/
|
||||
HashMap<UUID, Integer> getRatings(final Plot plot);
|
||||
HashMap<UUID, Integer> getRatings(Plot plot);
|
||||
|
||||
/**
|
||||
* Set a rating for a plot
|
||||
* Set a rating for a plot.
|
||||
* @param plot
|
||||
* @param rater
|
||||
* @param value
|
||||
*/
|
||||
void setRating(final Plot plot, final UUID rater, final int value);
|
||||
void setRating(Plot plot, UUID rater, int value);
|
||||
|
||||
/**
|
||||
* Remove a plot comment
|
||||
* Remove a plot comment.
|
||||
*
|
||||
* @param plot Plot Object
|
||||
* @param comment Comment to remove
|
||||
*/
|
||||
void removeComment(final Plot plot, final PlotComment comment);
|
||||
void removeComment(Plot plot, PlotComment comment);
|
||||
|
||||
/**
|
||||
* Clear an inbox
|
||||
* Clear an inbox.
|
||||
*
|
||||
* @param plot
|
||||
* @param inbox
|
||||
*/
|
||||
void clearInbox(final Plot plot, final String inbox);
|
||||
void clearInbox(Plot plot, String inbox);
|
||||
|
||||
/**
|
||||
* Set a plot comment
|
||||
* Set a plot comment.
|
||||
*
|
||||
* @param plot Plot Object
|
||||
* @param comment Comment to add
|
||||
*/
|
||||
void setComment(final Plot plot, final PlotComment comment);
|
||||
void setComment(Plot plot, PlotComment comment);
|
||||
|
||||
/**
|
||||
* Get Plot Comments
|
||||
* Get Plot Comments.
|
||||
*
|
||||
* @param plot Plot Object
|
||||
* @return Plot Comments within the specified tier
|
||||
* @param plot The Plot to get comments from
|
||||
*/
|
||||
void getComments(final Plot plot, final String inbox, final RunnableVal<List<PlotComment>> whenDone);
|
||||
|
||||
void createPlotAndSettings(final Plot plot, final Runnable whenDone);
|
||||
|
||||
void createCluster(final PlotCluster cluster);
|
||||
|
||||
void resizeCluster(final PlotCluster current, PlotId min, PlotId max);
|
||||
|
||||
void movePlot(final Plot originalPlot, final Plot newPlot);
|
||||
void getComments(Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone);
|
||||
|
||||
void createPlotAndSettings(Plot plot, Runnable whenDone);
|
||||
|
||||
void createCluster(PlotCluster cluster);
|
||||
|
||||
void resizeCluster(PlotCluster current, PlotId min, PlotId max);
|
||||
|
||||
void movePlot(Plot originalPlot, Plot newPlot);
|
||||
|
||||
/**
|
||||
* Replace a old uuid with a new one in the database<br>
|
||||
* - Useful for replacing a few uuids (not the entire database)<br>
|
||||
* - For entire conversion, the uuidconvert command scales better
|
||||
* Replace a old uuid with a new one in the database.
|
||||
*
|
||||
* <ul>
|
||||
* <li> Useful for replacing a few uuids (not the entire database).</li>
|
||||
* <li>or entire conversion, the uuidconvert command scales better.</li>
|
||||
* </ul>
|
||||
* @param old
|
||||
* @param now
|
||||
*/
|
||||
void replaceUUID(final UUID old, final UUID now);
|
||||
void replaceUUID(UUID old, UUID now);
|
||||
|
||||
/**
|
||||
* Don't fuck with this one, unless you enjoy it rough
|
||||
* Don't use this method unless you want to ruin someone's server.
|
||||
* @return true if the tables were deleted, false when an error is encountered
|
||||
*/
|
||||
boolean deleteTables();
|
||||
|
||||
|
@ -51,35 +51,35 @@ public class DBFunc {
|
||||
* Abstract Database Manager
|
||||
*/
|
||||
public static AbstractDB dbManager;
|
||||
|
||||
public static void movePlot(final Plot originalPlot, final Plot newPlot) {
|
||||
|
||||
public static void movePlot(Plot originalPlot, Plot newPlot) {
|
||||
if ((originalPlot.temp == -1) || (newPlot.temp == -1)) {
|
||||
return;
|
||||
}
|
||||
dbManager.movePlot(originalPlot, newPlot);
|
||||
}
|
||||
|
||||
public static void validatePlots(final Set<Plot> plots) {
|
||||
|
||||
public static void validatePlots(Set<Plot> plots) {
|
||||
dbManager.validateAllPlots(plots);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a resultset contains a column
|
||||
* @param r
|
||||
* Check if a {@link ResultSet} contains a column
|
||||
* @param resultSet
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasColumn(final ResultSet r, final String name) {
|
||||
public static boolean hasColumn(ResultSet resultSet, String name) {
|
||||
try {
|
||||
final ResultSetMetaData meta = r.getMetaData();
|
||||
final int count = meta.getColumnCount();
|
||||
ResultSetMetaData meta = resultSet.getMetaData();
|
||||
int count = meta.getColumnCount();
|
||||
for (int x = 1; x <= count; x++) {
|
||||
if (name.equals(meta.getColumnName(x))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (final SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -90,7 +90,7 @@ public class DBFunc {
|
||||
* @param plot Plot Object
|
||||
* @param uuid New Owner
|
||||
*/
|
||||
public static void setOwner(final Plot plot, final UUID uuid) {
|
||||
public static void setOwner(Plot plot, UUID uuid) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -102,7 +102,7 @@ public class DBFunc {
|
||||
*
|
||||
* @param plots List containing all plot objects
|
||||
*/
|
||||
public static void createPlotsAndData(final ArrayList<Plot> plots, final Runnable whenDone) {
|
||||
public static void createPlotsAndData(ArrayList<Plot> plots, Runnable whenDone) {
|
||||
dbManager.createPlotsAndData(plots, whenDone);
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ public class DBFunc {
|
||||
*
|
||||
* @param plot Plot to create
|
||||
*/
|
||||
public static void createPlot(final Plot plot) {
|
||||
public static void createPlot(Plot plot) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -123,7 +123,7 @@ public class DBFunc {
|
||||
*
|
||||
* @param plot Plot to create
|
||||
*/
|
||||
public static void createPlotAndSettings(final Plot plot, final Runnable whenDone) {
|
||||
public static void createPlotAndSettings(Plot plot, Runnable whenDone) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -135,7 +135,7 @@ public class DBFunc {
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void createTables(final String database) throws Exception {
|
||||
public static void createTables(String database) throws Exception {
|
||||
dbManager.createTables();
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ public class DBFunc {
|
||||
*
|
||||
* @param plot Plot to delete
|
||||
*/
|
||||
public static void delete(final Plot plot) {
|
||||
public static void delete(Plot plot) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -156,7 +156,7 @@ public class DBFunc {
|
||||
* Delete the ratings for a plot
|
||||
* @param plot
|
||||
*/
|
||||
public static void deleteRatings(final Plot plot) {
|
||||
public static void deleteRatings(Plot plot) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -167,7 +167,7 @@ public class DBFunc {
|
||||
* Delete the trusted list for a plot
|
||||
* @param plot
|
||||
*/
|
||||
public static void deleteTrusted(final Plot plot) {
|
||||
public static void deleteTrusted(Plot plot) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -178,7 +178,7 @@ public class DBFunc {
|
||||
* Delete the members list for a plot
|
||||
* @param plot
|
||||
*/
|
||||
public static void deleteMembers(final Plot plot) {
|
||||
public static void deleteMembers(Plot plot) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -189,7 +189,7 @@ public class DBFunc {
|
||||
* Delete the denied list for a plot
|
||||
* @param plot
|
||||
*/
|
||||
public static void deleteDenied(final Plot plot) {
|
||||
public static void deleteDenied(Plot plot) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -200,7 +200,7 @@ public class DBFunc {
|
||||
* Delete the comments in a plot
|
||||
* @param plot
|
||||
*/
|
||||
public static void deleteComments(final Plot plot) {
|
||||
public static void deleteComments(Plot plot) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -215,14 +215,14 @@ public class DBFunc {
|
||||
* This shouldn't ever be needed
|
||||
* @param plot
|
||||
*/
|
||||
public static void deleteSettings(final Plot plot) {
|
||||
public static void deleteSettings(Plot plot) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.deleteSettings(plot);
|
||||
}
|
||||
|
||||
public static void delete(final PlotCluster toDelete) {
|
||||
public static void delete(PlotCluster toDelete) {
|
||||
dbManager.delete(toDelete);
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ public class DBFunc {
|
||||
* @param id Plot ID
|
||||
* @param plot Plot Object
|
||||
*/
|
||||
public static void createPlotSettings(final int id, final Plot plot) {
|
||||
public static void createPlotSettings(int id, Plot plot) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -246,7 +246,7 @@ public class DBFunc {
|
||||
*
|
||||
* @return ID
|
||||
*/
|
||||
public static int getId(final Plot plot) {
|
||||
public static int getId(Plot plot) {
|
||||
return dbManager.getId(plot);
|
||||
}
|
||||
|
||||
@ -256,22 +256,22 @@ public class DBFunc {
|
||||
public static HashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
||||
return dbManager.getPlots();
|
||||
}
|
||||
|
||||
public static void setMerged(final Plot plot, final boolean[] merged) {
|
||||
|
||||
public static void setMerged(Plot plot, boolean[] merged) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setMerged(plot, merged);
|
||||
}
|
||||
|
||||
public static void setFlags(final Plot plot, final Collection<Flag> flags) {
|
||||
|
||||
public static void setFlags(Plot plot, Collection<Flag> flags) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setFlags(plot, flags);
|
||||
}
|
||||
|
||||
public static void setFlags(final PlotCluster cluster, final Collection<Flag> flags) {
|
||||
|
||||
public static void setFlags(PlotCluster cluster, Collection<Flag> flags) {
|
||||
dbManager.setFlags(cluster, flags);
|
||||
}
|
||||
|
||||
@ -279,18 +279,18 @@ public class DBFunc {
|
||||
* @param plot
|
||||
* @param alias
|
||||
*/
|
||||
public static void setAlias(final Plot plot, final String alias) {
|
||||
public static void setAlias(Plot plot, String alias) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setAlias(plot, alias);
|
||||
}
|
||||
|
||||
public static void purgeIds(final Set<Integer> uniqueIds) {
|
||||
|
||||
public static void purgeIds(Set<Integer> uniqueIds) {
|
||||
dbManager.purgeIds(uniqueIds);
|
||||
}
|
||||
|
||||
public static void purge(final PlotArea area, final Set<PlotId> plotIds) {
|
||||
|
||||
public static void purge(PlotArea area, Set<PlotId> plotIds) {
|
||||
dbManager.purge(area, plotIds);
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ public class DBFunc {
|
||||
* @param plot
|
||||
* @param position
|
||||
*/
|
||||
public static void setPosition(final Plot plot, final String position) {
|
||||
public static void setPosition(Plot plot, String position) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -309,14 +309,14 @@ public class DBFunc {
|
||||
* @param plot
|
||||
* @param comment
|
||||
*/
|
||||
public static void removeComment(final Plot plot, final PlotComment comment) {
|
||||
public static void removeComment(Plot plot, PlotComment comment) {
|
||||
if ((plot != null) && (plot.temp == -1)) {
|
||||
return;
|
||||
}
|
||||
dbManager.removeComment(plot, comment);
|
||||
}
|
||||
|
||||
public static void clearInbox(final Plot plot, final String inbox) {
|
||||
|
||||
public static void clearInbox(Plot plot, String inbox) {
|
||||
if ((plot != null) && (plot.temp == -1)) {
|
||||
return;
|
||||
}
|
||||
@ -327,7 +327,7 @@ public class DBFunc {
|
||||
* @param plot
|
||||
* @param comment
|
||||
*/
|
||||
public static void setComment(final Plot plot, final PlotComment comment) {
|
||||
public static void setComment(Plot plot, PlotComment comment) {
|
||||
if ((plot != null) && (plot.temp == -1)) {
|
||||
return;
|
||||
}
|
||||
@ -337,7 +337,7 @@ public class DBFunc {
|
||||
/**
|
||||
* @param plot
|
||||
*/
|
||||
public static void getComments(final Plot plot, final String inbox, final RunnableVal<List<PlotComment>> whenDone) {
|
||||
public static void getComments(Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone) {
|
||||
if ((plot != null) && (plot.temp == -1)) {
|
||||
return;
|
||||
}
|
||||
@ -348,7 +348,7 @@ public class DBFunc {
|
||||
* @param plot
|
||||
* @param uuid
|
||||
*/
|
||||
public static void removeTrusted(final Plot plot, final UUID uuid) {
|
||||
public static void removeTrusted(Plot plot, UUID uuid) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -359,14 +359,14 @@ public class DBFunc {
|
||||
* @param cluster
|
||||
* @param uuid
|
||||
*/
|
||||
public static void removeHelper(final PlotCluster cluster, final UUID uuid) {
|
||||
public static void removeHelper(PlotCluster cluster, UUID uuid) {
|
||||
dbManager.removeHelper(cluster, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cluster
|
||||
*/
|
||||
public static void createCluster(final PlotCluster cluster) {
|
||||
public static void createCluster(PlotCluster cluster) {
|
||||
dbManager.createCluster(cluster);
|
||||
}
|
||||
|
||||
@ -375,7 +375,7 @@ public class DBFunc {
|
||||
* @param min
|
||||
* @param max
|
||||
*/
|
||||
public static void resizeCluster(final PlotCluster current, final PlotId min, PlotId max) {
|
||||
public static void resizeCluster(PlotCluster current, PlotId min, PlotId max) {
|
||||
dbManager.resizeCluster(current, min, max);
|
||||
}
|
||||
|
||||
@ -383,7 +383,7 @@ public class DBFunc {
|
||||
* @param plot
|
||||
* @param uuid
|
||||
*/
|
||||
public static void removeMember(final Plot plot, final UUID uuid) {
|
||||
public static void removeMember(Plot plot, UUID uuid) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -395,7 +395,7 @@ public class DBFunc {
|
||||
* @param cluster
|
||||
* @param uuid
|
||||
*/
|
||||
public static void removeInvited(final PlotCluster cluster, final UUID uuid) {
|
||||
public static void removeInvited(PlotCluster cluster, UUID uuid) {
|
||||
dbManager.removeInvited(cluster, uuid);
|
||||
}
|
||||
|
||||
@ -403,14 +403,14 @@ public class DBFunc {
|
||||
* @param plot
|
||||
* @param uuid
|
||||
*/
|
||||
public static void setTrusted(final Plot plot, final UUID uuid) {
|
||||
public static void setTrusted(Plot plot, UUID uuid) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setTrusted(plot, uuid);
|
||||
}
|
||||
|
||||
public static void setHelper(final PlotCluster cluster, final UUID uuid) {
|
||||
|
||||
public static void setHelper(PlotCluster cluster, UUID uuid) {
|
||||
dbManager.setHelper(cluster, uuid);
|
||||
}
|
||||
|
||||
@ -418,14 +418,14 @@ public class DBFunc {
|
||||
* @param plot
|
||||
* @param uuid
|
||||
*/
|
||||
public static void setMember(final Plot plot, final UUID uuid) {
|
||||
public static void setMember(Plot plot, UUID uuid) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setMember(plot, uuid);
|
||||
}
|
||||
|
||||
public static void setInvited(final PlotCluster cluster, final UUID uuid) {
|
||||
|
||||
public static void setInvited(PlotCluster cluster, UUID uuid) {
|
||||
dbManager.setInvited(cluster, uuid);
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ public class DBFunc {
|
||||
* @param plot
|
||||
* @param uuid
|
||||
*/
|
||||
public static void removeDenied(final Plot plot, final UUID uuid) {
|
||||
public static void removeDenied(Plot plot, UUID uuid) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -444,21 +444,21 @@ public class DBFunc {
|
||||
* @param plot
|
||||
* @param uuid
|
||||
*/
|
||||
public static void setDenied(final Plot plot, final UUID uuid) {
|
||||
public static void setDenied(Plot plot, UUID uuid) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setDenied(plot, uuid);
|
||||
}
|
||||
|
||||
public static HashMap<UUID, Integer> getRatings(final Plot plot) {
|
||||
|
||||
public static HashMap<UUID, Integer> getRatings(Plot plot) {
|
||||
if (plot.temp == -1) {
|
||||
return new HashMap<>(0);
|
||||
}
|
||||
return dbManager.getRatings(plot);
|
||||
}
|
||||
|
||||
public static void setRating(final Plot plot, final UUID rater, final int value) {
|
||||
|
||||
public static void setRating(Plot plot, UUID rater, int value) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
@ -468,8 +468,8 @@ public class DBFunc {
|
||||
public static HashMap<String, Set<PlotCluster>> getClusters() {
|
||||
return dbManager.getClusters();
|
||||
}
|
||||
|
||||
public static void setPosition(final PlotCluster cluster, final String position) {
|
||||
|
||||
public static void setPosition(PlotCluster cluster, String position) {
|
||||
dbManager.setPosition(cluster, position);
|
||||
}
|
||||
|
||||
@ -482,7 +482,7 @@ public class DBFunc {
|
||||
* @param old
|
||||
* @param now
|
||||
*/
|
||||
public static void replaceUUID(final UUID old, final UUID now) {
|
||||
public static void replaceUUID(UUID old, UUID now) {
|
||||
dbManager.replaceUUID(old, now);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,10 +31,7 @@ import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
/**
|
||||
* Connects to and uses a SQLite database
|
||||
*
|
||||
|
||||
* @author tips48
|
||||
* Connects to and uses a SQLite database.
|
||||
*/
|
||||
public class SQLite extends Database {
|
||||
private final String dbLocation;
|
||||
@ -45,67 +42,67 @@ public class SQLite extends Database {
|
||||
*
|
||||
* @param dbLocation Location of the Database (Must end in .db)
|
||||
*/
|
||||
public SQLite(final String dbLocation) {
|
||||
public SQLite(String dbLocation) {
|
||||
this.dbLocation = dbLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection openConnection() throws SQLException, ClassNotFoundException {
|
||||
if (checkConnection()) {
|
||||
return connection;
|
||||
return this.connection;
|
||||
}
|
||||
if (!PS.get().IMP.getDirectory().exists()) {
|
||||
PS.get().IMP.getDirectory().mkdirs();
|
||||
}
|
||||
final File file = new File(dbLocation);
|
||||
if (!(file.exists())) {
|
||||
File file = new File(this.dbLocation);
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (final IOException e) {
|
||||
} catch (IOException e) {
|
||||
PS.debug("&cUnable to create database!");
|
||||
}
|
||||
}
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:" + dbLocation);
|
||||
return connection;
|
||||
this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.dbLocation);
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkConnection() throws SQLException {
|
||||
return (connection != null) && !connection.isClosed();
|
||||
return (this.connection != null) && !this.connection.isClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean closeConnection() throws SQLException {
|
||||
if (connection == null) {
|
||||
if (this.connection == null) {
|
||||
return false;
|
||||
}
|
||||
connection.close();
|
||||
connection = null;
|
||||
this.connection.close();
|
||||
this.connection = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet querySQL(final String query) throws SQLException, ClassNotFoundException {
|
||||
public ResultSet querySQL(String query) throws SQLException, ClassNotFoundException {
|
||||
if (checkConnection()) {
|
||||
openConnection();
|
||||
}
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
try (Statement statement = this.connection.createStatement()) {
|
||||
return statement.executeQuery(query);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSQL(final String query) throws SQLException, ClassNotFoundException {
|
||||
public int updateSQL(String query) throws SQLException, ClassNotFoundException {
|
||||
if (checkConnection()) {
|
||||
openConnection();
|
||||
}
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
try (Statement statement = this.connection.createStatement()) {
|
||||
return statement.executeUpdate(query);
|
||||
}
|
||||
}
|
||||
@ -113,7 +110,7 @@ public class SQLite extends Database {
|
||||
@Override
|
||||
public Connection forceConnection() throws SQLException, ClassNotFoundException {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:" + dbLocation);
|
||||
return connection;
|
||||
this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.dbLocation);
|
||||
return this.connection;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.object.LazyResult;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
@ -9,9 +14,9 @@ import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import java.util.Set;
|
||||
|
||||
public class AugmentedUtils {
|
||||
|
||||
|
||||
private static boolean enabled = true;
|
||||
|
||||
|
||||
public static void bypass(boolean bypass, Runnable run) {
|
||||
enabled = bypass;
|
||||
run.run();
|
||||
@ -37,7 +42,7 @@ public class AugmentedUtils {
|
||||
if (areas.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
final PseudoRandom r = new PseudoRandom();
|
||||
PseudoRandom r = new PseudoRandom();
|
||||
r.state = (cx << 16) | (cz & 0xFFFF);
|
||||
ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(world, cx, cz);
|
||||
boolean toReturn = false;
|
||||
@ -55,7 +60,10 @@ public class AugmentedUtils {
|
||||
final PlotChunk<?> result = lazyChunk.getOrCreate();
|
||||
final PlotChunk<?> primaryMask;
|
||||
// coords
|
||||
int bxx,bzz,txx,tzz;
|
||||
int bxx;
|
||||
int bzz;
|
||||
int txx;
|
||||
int tzz;
|
||||
// gen
|
||||
if (area.TYPE == 2) {
|
||||
bxx = Math.max(0, area.getRegion().minX - bx);
|
||||
@ -67,26 +75,26 @@ public class AugmentedUtils {
|
||||
public Object getChunkAbs() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, int id, byte data) {
|
||||
if (area.contains(bx + x, bz + z)) {
|
||||
result.setBlock(x, y, z, id, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, int biome) {
|
||||
if (area.contains(bx + x, bz + z)) {
|
||||
result.setBiome(x, z, biome);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PlotChunk clone() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PlotChunk shallowClone() {
|
||||
return null;
|
||||
@ -127,22 +135,23 @@ public class AugmentedUtils {
|
||||
public Object getChunkAbs() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, int id, byte data) {
|
||||
if (canPlace[x][z]) {
|
||||
primaryMask.setBlock(x, y, z, id, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, int biome) {}
|
||||
|
||||
public void setBiome(int x, int z, int biome) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotChunk clone() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PlotChunk shallowClone() {
|
||||
return null;
|
||||
|
@ -13,11 +13,12 @@ import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* A plot manager with square plots which tessellate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot)
|
||||
* A plot manager with square plots which tessellate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot).
|
||||
*/
|
||||
public class ClassicPlotManager extends SquarePlotManager {
|
||||
|
||||
@Override
|
||||
public boolean setComponent(final PlotArea plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks) {
|
||||
public boolean setComponent(PlotArea plotworld, PlotId plotid, String component, PlotBlock[] blocks) {
|
||||
switch (component) {
|
||||
case "floor": {
|
||||
setFloor(plotworld, plotid, blocks);
|
||||
@ -54,22 +55,22 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean unclaimPlot(final PlotArea plotworld, final Plot plot, final Runnable whenDone) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
setWallFilling(dpw, plot.getId(), new PlotBlock[] { dpw.WALL_FILLING });
|
||||
public boolean unclaimPlot(PlotArea plotworld, Plot plot, Runnable whenDone) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
setWallFilling(dpw, plot.getId(), new PlotBlock[]{dpw.WALL_FILLING});
|
||||
if (dpw.WALL_BLOCK.id != 0 || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) {
|
||||
setWall(dpw, plot.getId(), new PlotBlock[] { dpw.WALL_BLOCK });
|
||||
setWall(dpw, plot.getId(), new PlotBlock[]{dpw.WALL_BLOCK});
|
||||
}
|
||||
SetQueue.IMP.addTask(whenDone);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setFloor(final PlotArea plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
|
||||
public boolean setFloor(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
if (plot.isBasePlot()) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotworld.worldname, region.minX, dpw.PLOT_HEIGHT, region.minZ);
|
||||
Location pos2 = new Location(plotworld.worldname, region.maxX, dpw.PLOT_HEIGHT, region.maxZ);
|
||||
@ -78,8 +79,8 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setAll(final PlotArea plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
|
||||
public boolean setAll(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
@ -92,12 +93,12 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setAir(final PlotArea plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
public boolean setAir(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotworld.worldname, region.minX, dpw.PLOT_HEIGHT + 1, region.minZ);
|
||||
Location pos2 = new Location(plotworld.worldname, region.maxX, 255, region.maxZ);
|
||||
@ -105,13 +106,13 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setMain(final PlotArea plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
|
||||
public boolean setMain(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotworld.worldname, region.minX, 1, region.minZ);
|
||||
Location pos2 = new Location(plotworld.worldname, region.maxX, dpw.PLOT_HEIGHT - 1, region.maxZ);
|
||||
@ -119,27 +120,28 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setMiddle(final PlotArea plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
|
||||
public boolean setMiddle(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
Location[] corners = plot.getCorners();
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, (corners[0].getX() + corners[1].getX()) / 2, dpw.PLOT_HEIGHT, (corners[0].getZ() + corners[1].getZ()) / 2, blocks[0]);
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, (corners[0].getX() + corners[1].getX()) / 2, dpw.PLOT_HEIGHT,
|
||||
(corners[0].getZ() + corners[1].getZ()) / 2, blocks[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setOutline(final PlotArea plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
public boolean setOutline(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
final Location bottom = plot.getBottomAbs();
|
||||
final Location top = plot.getExtendedTopAbs();
|
||||
final PseudoRandom random = new PseudoRandom();
|
||||
Location bottom = plot.getBottomAbs();
|
||||
Location top = plot.getExtendedTopAbs();
|
||||
PseudoRandom random = new PseudoRandom();
|
||||
if (!plot.getMerged(0)) {
|
||||
int z = bottom.getZ();
|
||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||
@ -156,7 +158,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!plot.getMerged(2)) {
|
||||
int z = top.getZ();
|
||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||
@ -182,16 +184,16 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setWallFilling(final PlotArea plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
|
||||
public boolean setWallFilling(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
final Location bot = plot.getExtendedBottomAbs().subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1);
|
||||
final Location top = plot.getExtendedTopAbs().add(1, 0, 1);
|
||||
final PseudoRandom random = new PseudoRandom();
|
||||
Location bot = plot.getExtendedBottomAbs().subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1);
|
||||
Location top = plot.getExtendedTopAbs().add(1, 0, 1);
|
||||
PseudoRandom random = new PseudoRandom();
|
||||
if (!plot.getMerged(0)) {
|
||||
int z = bot.getZ();
|
||||
for (int x = bot.getX(); x < top.getX(); x++) {
|
||||
@ -226,17 +228,17 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setWall(final PlotArea plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
|
||||
public boolean setWall(PlotArea plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
Plot plot = plotworld.getPlotAbs(plotid);
|
||||
final Location bot = plot.getExtendedBottomAbs().subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1);
|
||||
final Location top = plot.getExtendedTopAbs().add(1, 0, 1);
|
||||
final PseudoRandom random = new PseudoRandom();
|
||||
final int y = dpw.WALL_HEIGHT + 1;
|
||||
Location bot = plot.getExtendedBottomAbs().subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1);
|
||||
Location top = plot.getExtendedTopAbs().add(1, 0, 1);
|
||||
PseudoRandom random = new PseudoRandom();
|
||||
int y = dpw.WALL_HEIGHT + 1;
|
||||
if (!plot.getMerged(0)) {
|
||||
int z = bot.getZ();
|
||||
for (int x = bot.getX(); x < top.getX(); x++) {
|
||||
@ -263,172 +265,200 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PLOT MERGING
|
||||
*/
|
||||
@Override
|
||||
public boolean createRoadEast(final PlotArea plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sx = pos2.getX() + 1;
|
||||
final int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
final int sz = pos1.getZ() - 2;
|
||||
final int ez = pos2.getZ() + 2;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(plotworld.worldname, ex, 255, ez - 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 0, sz + 1), new Location(plotworld.worldname, ex, 0, ez - 1), new PlotBlock((short) 7,
|
||||
(byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1), new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT, ez - 1), dpw.WALL_FILLING);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT + 1, ez - 1),
|
||||
dpw.WALL_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, ex, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT, ez - 1), dpw.WALL_FILLING);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, ez - 1),
|
||||
dpw.WALL_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
|
||||
public boolean createRoadEast(PlotArea plotworld, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
int sx = pos2.getX() + 1;
|
||||
int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
int sz = pos1.getZ() - 2;
|
||||
int ez = pos2.getZ() + 2;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname,
|
||||
new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1),
|
||||
new Location(plotworld.worldname, ex, 255, ez - 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 0, sz + 1),
|
||||
new Location(plotworld.worldname, ex, 0, ez - 1), new PlotBlock((short) 7,
|
||||
(byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1),
|
||||
new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT, ez - 1), dpw.WALL_FILLING);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT + 1, sz + 1),
|
||||
new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT + 1, ez - 1),
|
||||
dpw.WALL_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, ex, 1, sz + 1),
|
||||
new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT, ez - 1), dpw.WALL_FILLING);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, sz + 1),
|
||||
new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, ez - 1),
|
||||
dpw.WALL_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean createRoadSouth(final PlotArea plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sz = pos2.getZ() + 1;
|
||||
final int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
final int sx = pos1.getX() - 2;
|
||||
final int ex = pos2.getX() + 2;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex - 1, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz), new Location(plotworld.worldname, ex - 1, 0, ez), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz), new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT, sz), dpw.WALL_FILLING);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT + 1, sz),
|
||||
dpw.WALL_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, ez), new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT, ez), dpw.WALL_FILLING);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, ez), new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT + 1, ez),
|
||||
dpw.WALL_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
|
||||
public boolean createRoadSouth(PlotArea plotworld, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
int sz = pos2.getZ() + 1;
|
||||
int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
int sx = pos1.getX() - 2;
|
||||
int ex = pos2.getX() + 2;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname,
|
||||
new Location(plotworld.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
|
||||
new Location(plotworld.worldname, ex - 1, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz),
|
||||
new Location(plotworld.worldname, ex - 1, 0, ez), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT, sz), dpw.WALL_FILLING);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT + 1, sz),
|
||||
dpw.WALL_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, ez),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT, ez), dpw.WALL_FILLING);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, ez),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT + 1, ez),
|
||||
dpw.WALL_BLOCK);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean createRoadSouthEast(final PlotArea plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sx = pos2.getX() + 1;
|
||||
final int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
final int sz = pos2.getZ() + 1;
|
||||
final int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, ex - 1, 255, ez - 1), new PlotBlock(
|
||||
(short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz + 1), new Location(plotworld.worldname, ex - 1, 0, ez - 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
|
||||
public boolean createRoadSouthEast(PlotArea plotworld, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
int sx = pos2.getX() + 1;
|
||||
int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
int sz = pos2.getZ() + 1;
|
||||
int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1),
|
||||
new Location(plotworld.worldname, ex - 1, 255, ez - 1), new PlotBlock(
|
||||
(short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz + 1),
|
||||
new Location(plotworld.worldname, ex - 1, 0, ez - 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean removeRoadEast(final PlotArea plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sx = pos2.getX() + 1;
|
||||
final int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
final int sz = pos1.getZ() - 1;
|
||||
final int ez = pos2.getZ() + 1;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT - 1, ez - 1), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.PLOT_HEIGHT, sz + 1), new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT, ez - 1), dpw.TOP_BLOCK);
|
||||
public boolean removeRoadEast(PlotArea plotworld, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
int sx = pos2.getX() + 1;
|
||||
int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
int sz = pos1.getZ() - 1;
|
||||
int ez = pos2.getZ() + 1;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
|
||||
new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1),
|
||||
new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT - 1, ez - 1), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.PLOT_HEIGHT, sz + 1),
|
||||
new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT, ez - 1), dpw.TOP_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean removeRoadSouth(final PlotArea plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sz = pos2.getZ() + 1;
|
||||
final int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
final int sx = pos1.getX() - 1;
|
||||
final int ex = pos2.getX() + 1;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz), new Location(plotworld.worldname, ex - 1, dpw.PLOT_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.PLOT_HEIGHT, sz), new Location(plotworld.worldname, ex - 1, dpw.PLOT_HEIGHT, ez), dpw.TOP_BLOCK);
|
||||
public boolean removeRoadSouth(PlotArea plotworld, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
int sz = pos2.getZ() + 1;
|
||||
int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
int sx = pos1.getX() - 1;
|
||||
int ex = pos2.getX() + 1;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
|
||||
new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.PLOT_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.PLOT_HEIGHT, sz),
|
||||
new Location(plotworld.worldname, ex - 1, dpw.PLOT_HEIGHT, ez), dpw.TOP_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean removeRoadSouthEast(final PlotArea plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location loc = getPlotTopLocAbs(dpw, plot.getId());
|
||||
final int sx = loc.getX() + 1;
|
||||
final int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
final int sz = loc.getZ() + 1;
|
||||
final int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT, sz), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT, ez), dpw.TOP_BLOCK);
|
||||
public boolean removeRoadSouthEast(PlotArea plotworld, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
Location loc = getPlotTopLocAbs(dpw, plot.getId());
|
||||
int sx = loc.getX() + 1;
|
||||
int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
int sz = loc.getZ() + 1;
|
||||
int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT + 1, sz),
|
||||
new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz),
|
||||
new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT, sz),
|
||||
new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT, ez), dpw.TOP_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED)
|
||||
*/
|
||||
@Override
|
||||
public boolean finishPlotMerge(final PlotArea plotworld, final ArrayList<PlotId> plotIds) {
|
||||
final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
public boolean finishPlotMerge(PlotArea plotworld, ArrayList<PlotId> plotIds) {
|
||||
PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
if (block.id != 0 || !block.equals(unclaim)) {
|
||||
for (final PlotId id : plotIds) {
|
||||
setWall(plotworld, id, new PlotBlock[] { block });
|
||||
for (PlotId id : plotIds) {
|
||||
setWall(plotworld, id, new PlotBlock[]{block});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean finishPlotUnlink(final PlotArea plotworld, final ArrayList<PlotId> plotIds) {
|
||||
final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
for (final PlotId id : plotIds) {
|
||||
public boolean finishPlotUnlink(PlotArea plotworld, ArrayList<PlotId> plotIds) {
|
||||
PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
for (PlotId id : plotIds) {
|
||||
if (block.id != 0 || !block.equals(unclaim)) {
|
||||
setWall(plotworld, id, new PlotBlock[] { block });
|
||||
setWall(plotworld, id, new PlotBlock[]{block});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean startPlotMerge(final PlotArea plotworld, final ArrayList<PlotId> plotIds) {
|
||||
public boolean startPlotMerge(PlotArea plotworld, ArrayList<PlotId> plotIds) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean startPlotUnlink(final PlotArea plotworld, final ArrayList<PlotId> plotIds) {
|
||||
public boolean startPlotUnlink(PlotArea plotworld, ArrayList<PlotId> plotIds) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean claimPlot(final PlotArea plotworld, final Plot plot) {
|
||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
public boolean claimPlot(PlotArea plotworld, Plot plot) {
|
||||
PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
if (claim.id != 0 || !claim.equals(unclaim)) {
|
||||
setWall(plotworld, plot.getId(), new PlotBlock[] { claim });
|
||||
setWall(plotworld, plot.getId(), new PlotBlock[]{claim});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String[] getPlotComponents(final PlotArea plotworld, final PlotId plotid) {
|
||||
return new String[] { "main", "floor", "air", "all", "border", "wall", "outline", "middle" };
|
||||
public String[] getPlotComponents(PlotArea plotworld, PlotId plotid) {
|
||||
return new String[]{"main", "floor", "air", "all", "border", "wall", "outline", "middle"};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove sign for a plot
|
||||
* Remove sign for a plot.
|
||||
*/
|
||||
@Override
|
||||
public Location getSignLoc(final PlotArea plotworld, Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
public Location getSignLoc(PlotArea plotworld, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
plot = plot.getBasePlot(false);
|
||||
final Location bot = plot.getBottomAbs();
|
||||
Location bot = plot.getBottomAbs();
|
||||
return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getX() - 1, dpw.ROAD_HEIGHT + 1, bot.getZ() - 2);
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,6 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
||||
|
||||
public ClassicPlotWorld(String worldname, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||
super(worldname, id, generator, min, max);
|
||||
}
|
||||
|
||||
public int ROAD_HEIGHT = 64;
|
||||
public int PLOT_HEIGHT = 64;
|
||||
public int WALL_HEIGHT = 64;
|
||||
@ -23,29 +19,33 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
||||
public PlotBlock WALL_FILLING = new PlotBlock((short) 1, (byte) 0);
|
||||
public PlotBlock ROAD_BLOCK = new PlotBlock((short) 155, (byte) 0);
|
||||
public boolean PLOT_BEDROCK = true;
|
||||
|
||||
public ClassicPlotWorld(String worldName, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||
super(worldName, id, generator, min, max);
|
||||
}
|
||||
|
||||
/**
|
||||
* CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED FOR INITIAL SETUP
|
||||
* CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED FOR INITIAL SETUP.
|
||||
*
|
||||
* Set the last boolean to false if you do not require a specific config node to be set while using the setup
|
||||
* <p>Set the last boolean to false if you do not require a specific config node to be set while using the setup
|
||||
* command - this may be useful if a config value can be changed at a later date, and has no impact on the actual
|
||||
* world generation
|
||||
* world generation</p>
|
||||
*/
|
||||
@Override
|
||||
public ConfigurationNode[] getSettingNodes() {
|
||||
return new ConfigurationNode[] {
|
||||
new ConfigurationNode("plot.height", PLOT_HEIGHT, "Plot height", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("plot.size", PLOT_WIDTH, "Plot width", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("plot.filling", MAIN_BLOCK, "Plot block", Configuration.BLOCKLIST, true),
|
||||
new ConfigurationNode("plot.floor", TOP_BLOCK, "Plot floor block", Configuration.BLOCKLIST, true),
|
||||
new ConfigurationNode("wall.block", WALL_BLOCK, "Top wall block", Configuration.BLOCK, true),
|
||||
new ConfigurationNode("wall.block_claimed", CLAIMED_WALL_BLOCK, "Wall block (claimed)", Configuration.BLOCK, true),
|
||||
new ConfigurationNode("road.width", ROAD_WIDTH, "Road width", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("road.height", ROAD_HEIGHT, "Road height", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("road.block", ROAD_BLOCK, "Road block", Configuration.BLOCK, true),
|
||||
new ConfigurationNode("wall.filling", WALL_FILLING, "Wall filling block", Configuration.BLOCK, true),
|
||||
new ConfigurationNode("wall.height", WALL_HEIGHT, "Wall height", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("plot.bedrock", PLOT_BEDROCK, "Plot bedrock generation", Configuration.BOOLEAN, true) };
|
||||
new ConfigurationNode("plot.height", this.PLOT_HEIGHT, "Plot height", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("plot.size", this.PLOT_WIDTH, "Plot width", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("plot.filling", this.MAIN_BLOCK, "Plot block", Configuration.BLOCKLIST, true),
|
||||
new ConfigurationNode("plot.floor", this.TOP_BLOCK, "Plot floor block", Configuration.BLOCKLIST, true),
|
||||
new ConfigurationNode("wall.block", this.WALL_BLOCK, "Top wall block", Configuration.BLOCK, true),
|
||||
new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK, "Wall block (claimed)", Configuration.BLOCK, true),
|
||||
new ConfigurationNode("road.width", this.ROAD_WIDTH, "Road width", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("road.height", this.ROAD_HEIGHT, "Road height", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("road.block", this.ROAD_BLOCK, "Road block", Configuration.BLOCK, true),
|
||||
new ConfigurationNode("wall.filling", this.WALL_FILLING, "Wall filling block", Configuration.BLOCK, true),
|
||||
new ConfigurationNode("wall.height", this.WALL_HEIGHT, "Wall height", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("plot.bedrock", this.PLOT_BEDROCK, "Plot bedrock generation", Configuration.BOOLEAN, true)};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,17 +53,17 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
||||
* configuration section for that specific world.
|
||||
*/
|
||||
@Override
|
||||
public void loadConfiguration(final ConfigurationSection config) {
|
||||
public void loadConfiguration(ConfigurationSection config) {
|
||||
super.loadConfiguration(config);
|
||||
PLOT_BEDROCK = config.getBoolean("plot.bedrock");
|
||||
PLOT_HEIGHT = Math.min(255, config.getInt("plot.height"));
|
||||
MAIN_BLOCK = Configuration.BLOCKLIST.parseString(StringMan.join(config.getStringList("plot.filling"), ','));
|
||||
TOP_BLOCK = Configuration.BLOCKLIST.parseString(StringMan.join(config.getStringList("plot.floor"), ','));
|
||||
WALL_BLOCK = Configuration.BLOCK.parseString(config.getString("wall.block"));
|
||||
ROAD_HEIGHT = Math.min(255, config.getInt("road.height"));
|
||||
ROAD_BLOCK = Configuration.BLOCK.parseString(config.getString("road.block"));
|
||||
WALL_FILLING = Configuration.BLOCK.parseString(config.getString("wall.filling"));
|
||||
WALL_HEIGHT = Math.min(254, config.getInt("wall.height"));
|
||||
CLAIMED_WALL_BLOCK = Configuration.BLOCK.parseString(config.getString("wall.block_claimed"));
|
||||
this.PLOT_BEDROCK = config.getBoolean("plot.bedrock");
|
||||
this.PLOT_HEIGHT = Math.min(255, config.getInt("plot.height"));
|
||||
this.MAIN_BLOCK = Configuration.BLOCKLIST.parseString(StringMan.join(config.getStringList("plot.filling"), ','));
|
||||
this.TOP_BLOCK = Configuration.BLOCKLIST.parseString(StringMan.join(config.getStringList("plot.floor"), ','));
|
||||
this.WALL_BLOCK = Configuration.BLOCK.parseString(config.getString("wall.block"));
|
||||
this.ROAD_HEIGHT = Math.min(255, config.getInt("road.height"));
|
||||
this.ROAD_BLOCK = Configuration.BLOCK.parseString(config.getString("road.block"));
|
||||
this.WALL_FILLING = Configuration.BLOCK.parseString(config.getString("wall.filling"));
|
||||
this.WALL_HEIGHT = Math.min(254, config.getInt("wall.height"));
|
||||
this.CLAIMED_WALL_BLOCK = Configuration.BLOCK.parseString(config.getString("wall.block_claimed"));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
public abstract class GeneratorManager {
|
||||
|
||||
}
|
@ -3,6 +3,8 @@ package com.intellectualcrafters.plot.generator;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
|
||||
/**
|
||||
* A plot manager where plots tessellate in a grid formation symmetrical about x=z
|
||||
* A plot manager where plots tessellate in a grid formation symmetrical about x=z.
|
||||
*/
|
||||
public abstract class GridPlotManager extends PlotManager {}
|
||||
public abstract class GridPlotManager extends PlotManager {
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
|
||||
@ -13,7 +17,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
public String getName() {
|
||||
return "PlotSquared";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void generateChunk(PlotChunk<?> result, PlotArea settings, PseudoRandom random) {
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
||||
@ -36,8 +40,18 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
int cz = result.getZ();
|
||||
int bx = (cx << 4) - hpw.ROAD_OFFSET_X;
|
||||
int bz = (cz << 4) - hpw.ROAD_OFFSET_Z;
|
||||
short rbx = (short) ((bx < 0) ? (hpw.SIZE + (bx % hpw.SIZE)) : bx % hpw.SIZE);
|
||||
short rbz = (short) ((bz < 0) ? (hpw.SIZE + (bz % hpw.SIZE)) : bz % hpw.SIZE);
|
||||
short rbx;
|
||||
if (bx < 0) {
|
||||
rbx = (short) (hpw.SIZE + (bx % hpw.SIZE));
|
||||
} else {
|
||||
rbx = (short) (bx % hpw.SIZE);
|
||||
}
|
||||
short rbz;
|
||||
if (bz < 0) {
|
||||
rbz = (short) (hpw.SIZE + (bz % hpw.SIZE));
|
||||
} else {
|
||||
rbz = (short) (bz % hpw.SIZE);
|
||||
}
|
||||
short[] rx = new short[16];
|
||||
boolean[] gx = new boolean[16];
|
||||
boolean[] wx = new boolean[16];
|
||||
@ -165,17 +179,17 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
||||
return new HybridPlotWorld(world, id, this, min, max);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PlotManager getNewPlotManager() {
|
||||
return new HybridPlotManager();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize(PlotArea area) {
|
||||
// All initialization is done in the PlotArea class
|
||||
|
@ -22,8 +22,19 @@ package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.Template;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.FileBytes;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -34,23 +45,23 @@ import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class HybridPlotManager extends ClassicPlotManager {
|
||||
|
||||
|
||||
@Override
|
||||
public void exportTemplate(final PlotArea plotworld) throws IOException {
|
||||
final HashSet<FileBytes> files = new HashSet<>(
|
||||
public void exportTemplate(PlotArea plotworld) throws IOException {
|
||||
HashSet<FileBytes> files = new HashSet<>(
|
||||
Collections.singletonList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld))));
|
||||
final String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator;
|
||||
final String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator;
|
||||
String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator;
|
||||
String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator;
|
||||
try {
|
||||
final File sideroad = MainUtil.getFile(PS.get().IMP.getDirectory(), dir + "sideroad.schematic");
|
||||
File sideroad = MainUtil.getFile(PS.get().IMP.getDirectory(), dir + "sideroad.schematic");
|
||||
if (sideroad.exists()) {
|
||||
files.add(new FileBytes(newDir + "sideroad.schematic", Files.readAllBytes(sideroad.toPath())));
|
||||
}
|
||||
final File intersection = MainUtil.getFile(PS.get().IMP.getDirectory(), "intersection.schematic");
|
||||
File intersection = MainUtil.getFile(PS.get().IMP.getDirectory(), "intersection.schematic");
|
||||
if (intersection.exists()) {
|
||||
files.add(new FileBytes(newDir + "intersection.schematic", Files.readAllBytes(intersection.toPath())));
|
||||
}
|
||||
final File plot = MainUtil.getFile(PS.get().IMP.getDirectory(), dir + "plot.schematic");
|
||||
File plot = MainUtil.getFile(PS.get().IMP.getDirectory(), dir + "plot.schematic");
|
||||
if (plot.exists()) {
|
||||
files.add(new FileBytes(newDir + "plot.schematic", Files.readAllBytes(plot.toPath())));
|
||||
}
|
||||
@ -59,17 +70,17 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
}
|
||||
Template.zipAll(plotworld.worldname, files);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean createRoadEast(final PlotArea plotworld, final Plot plot) {
|
||||
public boolean createRoadEast(PlotArea plotworld, Plot plot) {
|
||||
super.createRoadEast(plotworld, plot);
|
||||
final HybridPlotWorld hpw = (HybridPlotWorld) plotworld;
|
||||
final PlotId id = plot.getId();
|
||||
final PlotId id2 = new PlotId(id.x + 1, id.y);
|
||||
final Location bot = getPlotBottomLocAbs(hpw, id2);
|
||||
final Location top = getPlotTopLocAbs(hpw, id);
|
||||
final Location pos1 = new Location(plotworld.worldname, top.getX() + 1, 0, bot.getZ() - 1);
|
||||
final Location pos2 = new Location(plotworld.worldname, bot.getX(), 255, top.getZ() + 1);
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) plotworld;
|
||||
PlotId id = plot.getId();
|
||||
PlotId id2 = new PlotId(id.x + 1, id.y);
|
||||
Location bot = getPlotBottomLocAbs(hpw, id2);
|
||||
Location top = getPlotTopLocAbs(hpw, id);
|
||||
Location pos1 = new Location(plotworld.worldname, top.getX() + 1, 0, bot.getZ() - 1);
|
||||
Location pos2 = new Location(plotworld.worldname, bot.getX(), 255, top.getZ() + 1);
|
||||
MainUtil.resetBiome(plotworld, pos1, pos2);
|
||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
return true;
|
||||
@ -78,21 +89,21 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void createSchemAbs(final HybridPlotWorld hpw, final Location pos1, final Location pos2, final int height, final boolean clear) {
|
||||
final int size = hpw.SIZE;
|
||||
private void createSchemAbs(HybridPlotWorld hpw, Location pos1, Location pos2, int height, boolean clear) {
|
||||
int size = hpw.SIZE;
|
||||
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||
short absX = (short) ((x - hpw.ROAD_OFFSET_X) % (size));
|
||||
short absX = (short) ((x - hpw.ROAD_OFFSET_X) % size);
|
||||
if (absX < 0) {
|
||||
absX += size;
|
||||
}
|
||||
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
|
||||
short absZ = (short) ((z - hpw.ROAD_OFFSET_Z) % (size));
|
||||
short absZ = (short) ((z - hpw.ROAD_OFFSET_Z) % size);
|
||||
if (absZ < 0) {
|
||||
absZ += size;
|
||||
}
|
||||
final HashMap<Integer, PlotBlock> blocks = hpw.G_SCH.get(MathMan.pair(absX, absZ));
|
||||
HashMap<Integer, PlotBlock> blocks = hpw.G_SCH.get(MathMan.pair(absX, absZ));
|
||||
if (clear) {
|
||||
for (short y = (short) (height); y <= (height + hpw.SCHEMATIC_HEIGHT); y++) {
|
||||
for (short y = (short) height; y <= (height + hpw.SCHEMATIC_HEIGHT); y++) {
|
||||
SetQueue.IMP.setBlock(hpw.worldname, x, y, z, 0);
|
||||
}
|
||||
}
|
||||
@ -104,17 +115,17 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean createRoadSouth(final PlotArea plotworld, final Plot plot) {
|
||||
public boolean createRoadSouth(PlotArea plotworld, Plot plot) {
|
||||
super.createRoadSouth(plotworld, plot);
|
||||
final HybridPlotWorld hpw = (HybridPlotWorld) plotworld;
|
||||
final PlotId id = plot.getId();
|
||||
final PlotId id2 = new PlotId(id.x, id.y + 1);
|
||||
final Location bot = getPlotBottomLocAbs(hpw, id2);
|
||||
final Location top = getPlotTopLocAbs(hpw, id);
|
||||
final Location pos1 = new Location(plotworld.worldname, bot.getX() - 1, 0, top.getZ() + 1);
|
||||
final Location pos2 = new Location(plotworld.worldname, top.getX() + 1, 255, bot.getZ());
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) plotworld;
|
||||
PlotId id = plot.getId();
|
||||
PlotId id2 = new PlotId(id.x, id.y + 1);
|
||||
Location bot = getPlotBottomLocAbs(hpw, id2);
|
||||
Location top = getPlotTopLocAbs(hpw, id);
|
||||
Location pos1 = new Location(plotworld.worldname, bot.getX() - 1, 0, top.getZ() + 1);
|
||||
Location pos2 = new Location(plotworld.worldname, top.getX() + 1, 255, bot.getZ());
|
||||
MainUtil.resetBiome(plotworld, pos1, pos2);
|
||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
return true;
|
||||
@ -122,15 +133,15 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
createSchemAbs(hpw, pos1, pos2, 0, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean createRoadSouthEast(final PlotArea plotworld, final Plot plot) {
|
||||
public boolean createRoadSouthEast(PlotArea plotworld, Plot plot) {
|
||||
super.createRoadSouthEast(plotworld, plot);
|
||||
final HybridPlotWorld hpw = (HybridPlotWorld) plotworld;
|
||||
final PlotId id = plot.getId();
|
||||
final PlotId id2 = new PlotId(id.x + 1, id.y + 1);
|
||||
final Location pos1 = getPlotTopLocAbs(hpw, id).add(1, 0, 1);
|
||||
final Location pos2 = getPlotBottomLocAbs(hpw, id2);
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) plotworld;
|
||||
PlotId id = plot.getId();
|
||||
PlotId id2 = new PlotId(id.x + 1, id.y + 1);
|
||||
Location pos1 = getPlotTopLocAbs(hpw, id).add(1, 0, 1);
|
||||
Location pos2 = getPlotBottomLocAbs(hpw, id2);
|
||||
pos1.setY(0);
|
||||
pos2.setY(256);
|
||||
createSchemAbs(hpw, pos1, pos2, 0, true);
|
||||
@ -140,25 +151,30 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
createSchemAbs(hpw, pos1, pos2, 0, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clearing the plot needs to only consider removing the blocks - This implementation has used the setCuboidAsync
|
||||
* <p>Clearing the plot needs to only consider removing the blocks - This implementation has used the setCuboidAsync
|
||||
* function, as it is fast, and uses NMS code - It also makes use of the fact that deleting chunks is a lot faster
|
||||
* than block updates This code is very messy, but you don't need to do something quite as complex unless you happen
|
||||
* to have 512x512 sized plots
|
||||
* to have 512x512 sized plots. </p>
|
||||
*/
|
||||
@Override
|
||||
public boolean clearPlot(final PlotArea plotworld, final Plot plot, final Runnable whenDone) {
|
||||
public boolean clearPlot(PlotArea plotworld, Plot plot, final Runnable whenDone) {
|
||||
final String world = plotworld.worldname;
|
||||
final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld);
|
||||
final Location pos1 = plot.getBottomAbs();
|
||||
final Location pos2 = plot.getExtendedTopAbs();
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld;
|
||||
Location pos1 = plot.getBottomAbs();
|
||||
Location pos2 = plot.getExtendedTopAbs();
|
||||
// If augmented
|
||||
final boolean canRegen = (plotworld.TYPE == 0) && (plotworld.TERRAIN == 0);
|
||||
// The component blocks
|
||||
final PlotBlock[] plotfloor = dpw.TOP_BLOCK;
|
||||
final PlotBlock[] filling = dpw.MAIN_BLOCK;
|
||||
final PlotBlock bedrock = (dpw.PLOT_BEDROCK ? new PlotBlock((short) 7, (byte) 0) : new PlotBlock((short) 0, (byte) 0));
|
||||
final PlotBlock bedrock;
|
||||
if (dpw.PLOT_BEDROCK) {
|
||||
bedrock = new PlotBlock((short) 7, (byte) 0);
|
||||
} else {
|
||||
bedrock = new PlotBlock((short) 0, (byte) 0);
|
||||
}
|
||||
final PlotBlock air = new PlotBlock((short) 0, (byte) 0);
|
||||
final String biome = WorldUtil.IMP.getBiomeList()[dpw.PLOT_BIOME];
|
||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||
@ -175,8 +191,8 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
// Set the biome
|
||||
MainUtil.setBiome(world, value[2], value[3], value[4], value[5], biome);
|
||||
// These two locations are for each component (e.g. bedrock, main block, floor, air)
|
||||
final Location bot = new Location(world, value[2], 0, value[3]);
|
||||
final Location top = new Location(world, value[4], 1, value[5]);
|
||||
Location bot = new Location(world, value[2], 0, value[3]);
|
||||
Location top = new Location(world, value[4], 1, value[5]);
|
||||
MainUtil.setSimpleCuboidAsync(world, bot, top, bedrock);
|
||||
// Each component has a different layer
|
||||
bot.setY(1);
|
||||
@ -200,8 +216,8 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
}, 10);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void pastePlotSchematic(final HybridPlotWorld plotworld, final Location l1, final Location l2) {
|
||||
|
||||
public void pastePlotSchematic(HybridPlotWorld plotworld, Location l1, Location l2) {
|
||||
if (!plotworld.PLOT_SCHEMATIC) {
|
||||
return;
|
||||
}
|
||||
|
@ -32,11 +32,13 @@ import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
|
||||
public boolean ROAD_SCHEMATIC_ENABLED;
|
||||
public short SCHEMATIC_HEIGHT;
|
||||
public boolean PLOT_SCHEMATIC = false;
|
||||
@ -50,14 +52,14 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
super(worldname, id, generator, min, max);
|
||||
}
|
||||
|
||||
public static byte wrap(byte data, final int start) {
|
||||
public static byte wrap(byte data, int start) {
|
||||
if ((data >= start) && (data < (start + 4))) {
|
||||
data = (byte) ((((data - start) + 2) & 3) + start);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static byte wrap2(byte data, final int start) {
|
||||
public static byte wrap2(byte data, int start) {
|
||||
if ((data >= start) && (data < (start + 2))) {
|
||||
data = (byte) ((((data - start) + 1) & 1) + start);
|
||||
}
|
||||
@ -66,7 +68,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
|
||||
// FIXME depends on block ids
|
||||
// Possibly make abstract?
|
||||
public static byte rotate(final short id, byte data) {
|
||||
public static byte rotate(short id, byte data) {
|
||||
switch (id) {
|
||||
case 162:
|
||||
case 17:
|
||||
@ -158,21 +160,25 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when a world loads. Make sure you set all your constants here. You are provided with the
|
||||
* configuration section for that specific world.
|
||||
* <p>This method is called when a world loads. Make sure you set all your constants here. You are provided with the
|
||||
* configuration section for that specific world.</p>
|
||||
*/
|
||||
@Override
|
||||
public void loadConfiguration(final ConfigurationSection config) {
|
||||
public void loadConfiguration(ConfigurationSection config) {
|
||||
super.loadConfiguration(config);
|
||||
if ((ROAD_WIDTH & 1) == 0) {
|
||||
PATH_WIDTH_LOWER = (short) (Math.floor(ROAD_WIDTH / 2) - 1);
|
||||
if ((this.ROAD_WIDTH & 1) == 0) {
|
||||
this.PATH_WIDTH_LOWER = (short) (Math.floor(this.ROAD_WIDTH / 2) - 1);
|
||||
} else {
|
||||
PATH_WIDTH_LOWER = (short) (Math.floor(ROAD_WIDTH / 2));
|
||||
this.PATH_WIDTH_LOWER = (short) Math.floor(this.ROAD_WIDTH / 2);
|
||||
}
|
||||
if (this.ROAD_WIDTH == 0) {
|
||||
this.PATH_WIDTH_UPPER = (short) (this.SIZE + 1);
|
||||
} else {
|
||||
this.PATH_WIDTH_UPPER = (short) (this.PATH_WIDTH_LOWER + this.PLOT_WIDTH + 1);
|
||||
}
|
||||
PATH_WIDTH_UPPER = (short) (ROAD_WIDTH == 0 ? SIZE + 1 : PATH_WIDTH_LOWER + PLOT_WIDTH + 1);
|
||||
try {
|
||||
setupSchematics();
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
PS.debug("&c - road schematics are disabled for this world.");
|
||||
}
|
||||
}
|
||||
@ -182,104 +188,106 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
if (!(plotworld instanceof SquarePlotWorld)) {
|
||||
return false;
|
||||
}
|
||||
return ((SquarePlotWorld) plotworld).PLOT_WIDTH == PLOT_WIDTH;
|
||||
return ((SquarePlotWorld) plotworld).PLOT_WIDTH == this.PLOT_WIDTH;
|
||||
}
|
||||
|
||||
public void setupSchematics() {
|
||||
G_SCH = new HashMap<>();
|
||||
final File schem1File = MainUtil.getFile(PS.get().IMP.getDirectory(),"schematics/GEN_ROAD_SCHEMATIC/" + worldname + "/sideroad.schematic");
|
||||
final File schem2File = MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + worldname + "/intersection.schematic");
|
||||
final File schem3File = MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + worldname + "/plot.schematic");
|
||||
final Schematic schem1 = SchematicHandler.manager.getSchematic(schem1File);
|
||||
final Schematic schem2 = SchematicHandler.manager.getSchematic(schem2File);
|
||||
final Schematic schem3 = SchematicHandler.manager.getSchematic(schem3File);
|
||||
final int shift = ROAD_WIDTH / 2;
|
||||
this.G_SCH = new HashMap<>();
|
||||
File schem1File = MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname + "/sideroad.schematic");
|
||||
File schem2File =
|
||||
MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname + "/intersection.schematic");
|
||||
File schem3File = MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname + "/plot.schematic");
|
||||
Schematic schem1 = SchematicHandler.manager.getSchematic(schem1File);
|
||||
Schematic schem2 = SchematicHandler.manager.getSchematic(schem2File);
|
||||
Schematic schem3 = SchematicHandler.manager.getSchematic(schem3File);
|
||||
int shift = this.ROAD_WIDTH / 2;
|
||||
int oddshift = 0;
|
||||
if ((ROAD_WIDTH & 1) != 0) {
|
||||
if ((this.ROAD_WIDTH & 1) != 0) {
|
||||
oddshift = 1;
|
||||
}
|
||||
if (schem3 != null) {
|
||||
PLOT_SCHEMATIC = true;
|
||||
final short[] ids = schem3.getIds();
|
||||
final byte[] datas = schem3.getDatas();
|
||||
final Dimension d3 = schem3.getSchematicDimension();
|
||||
final short w3 = (short) d3.getX();
|
||||
final short l3 = (short) d3.getZ();
|
||||
final short h3 = (short) d3.getY();
|
||||
int center_shift_z = 0;
|
||||
if (l3 < PLOT_WIDTH) {
|
||||
center_shift_z = (PLOT_WIDTH - l3) / 2;
|
||||
this.PLOT_SCHEMATIC = true;
|
||||
short[] ids = schem3.getIds();
|
||||
byte[] datas = schem3.getDatas();
|
||||
Dimension d3 = schem3.getSchematicDimension();
|
||||
short w3 = (short) d3.getX();
|
||||
short l3 = (short) d3.getZ();
|
||||
short h3 = (short) d3.getY();
|
||||
int centerShiftZ = 0;
|
||||
if (l3 < this.PLOT_WIDTH) {
|
||||
centerShiftZ = (this.PLOT_WIDTH - l3) / 2;
|
||||
}
|
||||
int center_shift_x = 0;
|
||||
if (w3 < PLOT_WIDTH) {
|
||||
center_shift_x = (PLOT_WIDTH - w3) / 2;
|
||||
int centerShiftX = 0;
|
||||
if (w3 < this.PLOT_WIDTH) {
|
||||
centerShiftX = (this.PLOT_WIDTH - w3) / 2;
|
||||
}
|
||||
for (short x = 0; x < w3; x++) {
|
||||
for (short z = 0; z < l3; z++) {
|
||||
for (short y = 0; y < h3; y++) {
|
||||
final int index = (y * w3 * l3) + (z * w3) + x;
|
||||
final short id = ids[index];
|
||||
final byte data = datas[index];
|
||||
int index = (y * w3 * l3) + (z * w3) + x;
|
||||
short id = ids[index];
|
||||
byte data = datas[index];
|
||||
if (id != 0) {
|
||||
addOverlayBlock((short) (x + shift + oddshift + center_shift_x), (short) (y + PLOT_HEIGHT), (short) (z + shift + oddshift + center_shift_z), id,
|
||||
addOverlayBlock((short) (x + shift + oddshift + centerShiftX), (short) (y + this.PLOT_HEIGHT),
|
||||
(short) (z + shift + oddshift + centerShiftZ), id,
|
||||
data, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final HashSet<PlotItem> items = schem3.getItems();
|
||||
HashSet<PlotItem> items = schem3.getItems();
|
||||
if (items != null) {
|
||||
G_SCH_STATE = new HashMap<>();
|
||||
for (final PlotItem item : items) {
|
||||
item.x += shift + oddshift + center_shift_x;
|
||||
item.z += shift + oddshift + center_shift_z;
|
||||
item.y += PLOT_HEIGHT;
|
||||
final short x = (short) item.x;
|
||||
final short z = (short) item.z;
|
||||
this.G_SCH_STATE = new HashMap<>();
|
||||
for (PlotItem item : items) {
|
||||
item.x += shift + oddshift + centerShiftX;
|
||||
item.z += shift + oddshift + centerShiftZ;
|
||||
item.y += this.PLOT_HEIGHT;
|
||||
short x = (short) item.x;
|
||||
short z = (short) item.z;
|
||||
int pair = MathMan.pair(x, z);
|
||||
|
||||
|
||||
HashSet<PlotItem> existing = G_SCH_STATE.get(pair);
|
||||
HashSet<PlotItem> existing = this.G_SCH_STATE.get(pair);
|
||||
if (existing == null) {
|
||||
existing = new HashSet<>();
|
||||
G_SCH_STATE.put(pair, existing);
|
||||
this.G_SCH_STATE.put(pair, existing);
|
||||
}
|
||||
existing.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (schem1 == null || schem2 == null || ROAD_WIDTH == 0) {
|
||||
if (schem1 == null || schem2 == null || this.ROAD_WIDTH == 0) {
|
||||
PS.debug(C.PREFIX + "&3 - schematic: &7false");
|
||||
return;
|
||||
}
|
||||
ROAD_SCHEMATIC_ENABLED = true;
|
||||
this.ROAD_SCHEMATIC_ENABLED = true;
|
||||
// Do not populate road if using schematic population
|
||||
ROAD_BLOCK = new PlotBlock(ROAD_BLOCK.id, (byte) 0);
|
||||
this.ROAD_BLOCK = new PlotBlock(this.ROAD_BLOCK.id, (byte) 0);
|
||||
|
||||
final short[] ids1 = schem1.getIds();
|
||||
final byte[] datas1 = schem1.getDatas();
|
||||
short[] ids1 = schem1.getIds();
|
||||
byte[] datas1 = schem1.getDatas();
|
||||
|
||||
final short[] ids2 = schem2.getIds();
|
||||
final byte[] datas2 = schem2.getDatas();
|
||||
short[] ids2 = schem2.getIds();
|
||||
byte[] datas2 = schem2.getDatas();
|
||||
|
||||
final Dimension d1 = schem1.getSchematicDimension();
|
||||
final short w1 = (short) d1.getX();
|
||||
final short l1 = (short) d1.getZ();
|
||||
final short h1 = (short) d1.getY();
|
||||
final Dimension d2 = schem2.getSchematicDimension();
|
||||
final short w2 = (short) d2.getX();
|
||||
final short l2 = (short) d2.getZ();
|
||||
final short h2 = (short) d2.getY();
|
||||
SCHEMATIC_HEIGHT = (short) Math.max(h2, h1);
|
||||
Dimension d1 = schem1.getSchematicDimension();
|
||||
short w1 = (short) d1.getX();
|
||||
short l1 = (short) d1.getZ();
|
||||
short h1 = (short) d1.getY();
|
||||
Dimension d2 = schem2.getSchematicDimension();
|
||||
short w2 = (short) d2.getX();
|
||||
short l2 = (short) d2.getZ();
|
||||
short h2 = (short) d2.getY();
|
||||
this.SCHEMATIC_HEIGHT = (short) Math.max(h2, h1);
|
||||
for (short x = 0; x < w1; x++) {
|
||||
for (short z = 0; z < l1; z++) {
|
||||
for (short y = 0; y < h1; y++) {
|
||||
final int index = (y * w1 * l1) + (z * w1) + x;
|
||||
final short id = ids1[index];
|
||||
final byte data = datas1[index];
|
||||
int index = (y * w1 * l1) + (z * w1) + x;
|
||||
short id = ids1[index];
|
||||
byte data = datas1[index];
|
||||
if (id != 0) {
|
||||
addOverlayBlock((short) (x - shift), (short) (y + ROAD_HEIGHT), (short) (z + shift + oddshift), id, data, false);
|
||||
addOverlayBlock((short) (z + shift + oddshift), (short) (y + ROAD_HEIGHT), (short) (x - shift), id, data, true);
|
||||
addOverlayBlock((short) (x - shift), (short) (y + this.ROAD_HEIGHT), (short) (z + shift + oddshift), id, data, false);
|
||||
addOverlayBlock((short) (z + shift + oddshift), (short) (y + this.ROAD_HEIGHT), (short) (x - shift), id, data, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -287,35 +295,35 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
for (short x = 0; x < w2; x++) {
|
||||
for (short z = 0; z < l2; z++) {
|
||||
for (short y = 0; y < h2; y++) {
|
||||
final int index = (y * w2 * l2) + (z * w2) + x;
|
||||
final short id = ids2[index];
|
||||
final byte data = datas2[index];
|
||||
int index = (y * w2 * l2) + (z * w2) + x;
|
||||
short id = ids2[index];
|
||||
byte data = datas2[index];
|
||||
if (id != 0) {
|
||||
addOverlayBlock((short) (x - shift), (short) (y + ROAD_HEIGHT), (short) (z - shift), id, data, false);
|
||||
addOverlayBlock((short) (x - shift), (short) (y + this.ROAD_HEIGHT), (short) (z - shift), id, data, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addOverlayBlock(short x, final short y, short z, final short id, byte data, final boolean rotate) {
|
||||
public void addOverlayBlock(short x, short y, short z, short id, byte data, boolean rotate) {
|
||||
if (z < 0) {
|
||||
z += SIZE;
|
||||
z += this.SIZE;
|
||||
}
|
||||
if (x < 0) {
|
||||
x += SIZE;
|
||||
x += this.SIZE;
|
||||
}
|
||||
if (rotate) {
|
||||
final byte newdata = rotate(id, data);
|
||||
byte newdata = rotate(id, data);
|
||||
if (data != 0 || newdata != 0) {
|
||||
data = newdata;
|
||||
}
|
||||
}
|
||||
int pair = MathMan.pair(x, z);
|
||||
HashMap<Integer, PlotBlock> existing = G_SCH.get(pair);
|
||||
HashMap<Integer, PlotBlock> existing = this.G_SCH.get(pair);
|
||||
if (existing == null) {
|
||||
existing = new HashMap<>();
|
||||
G_SCH.put(pair, existing);
|
||||
this.G_SCH.put(pair, existing);
|
||||
}
|
||||
existing.put((int) y, new PlotBlock(id, data));
|
||||
}
|
||||
|
@ -34,14 +34,14 @@ import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public abstract class HybridUtils {
|
||||
|
||||
|
||||
public static HybridUtils manager;
|
||||
public static Set<ChunkLoc> regions;
|
||||
public static Set<ChunkLoc> chunks = new HashSet<>();
|
||||
public static PlotArea area;
|
||||
public static boolean UPDATE = false;
|
||||
|
||||
public abstract void analyzeRegion(final String world, final RegionWrapper region, final RunnableVal<PlotAnalysis> whenDone);
|
||||
public abstract void analyzeRegion(String world, RegionWrapper region, RunnableVal<PlotAnalysis> whenDone);
|
||||
|
||||
public void analyzePlot(final Plot origin, final RunnableVal<PlotAnalysis> whenDone) {
|
||||
final ArrayDeque<RegionWrapper> zones = new ArrayDeque<>(origin.getRegions());
|
||||
@ -74,11 +74,10 @@ public abstract class HybridUtils {
|
||||
whenDone.value.faces_sd /= analysis.size();
|
||||
whenDone.value.variety /= analysis.size();
|
||||
whenDone.value.variety_sd /= analysis.size();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
whenDone.value = analysis.get(0);
|
||||
}
|
||||
final List<Integer> result = new ArrayList<>();
|
||||
List<Integer> result = new ArrayList<>();
|
||||
result.add(whenDone.value.changes);
|
||||
result.add(whenDone.value.faces);
|
||||
result.add(whenDone.value.data);
|
||||
@ -90,7 +89,7 @@ public abstract class HybridUtils {
|
||||
result.add(whenDone.value.data_sd);
|
||||
result.add(whenDone.value.air_sd);
|
||||
result.add(whenDone.value.variety_sd);
|
||||
final Flag flag = new Flag(FlagManager.getFlag("analysis"), result);
|
||||
Flag flag = new Flag(FlagManager.getFlag("analysis"), result);
|
||||
FlagManager.addPlotFlag(origin, flag);
|
||||
TaskManager.runTask(whenDone);
|
||||
return;
|
||||
@ -109,12 +108,12 @@ public abstract class HybridUtils {
|
||||
run.run();
|
||||
}
|
||||
|
||||
public abstract int checkModified(final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks);
|
||||
|
||||
public final ArrayList<ChunkLoc> getChunks(final ChunkLoc region) {
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||
final int sx = region.x << 5;
|
||||
final int sz = region.z << 5;
|
||||
public abstract int checkModified(String world, int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks);
|
||||
|
||||
public final ArrayList<ChunkLoc> getChunks(ChunkLoc region) {
|
||||
ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||
int sx = region.x << 5;
|
||||
int sz = region.z << 5;
|
||||
for (int x = sx; x < sx + 32; x++) {
|
||||
for (int z = sz; z < sz + 32; z++) {
|
||||
chunks.add(new ChunkLoc(x, z));
|
||||
@ -122,9 +121,9 @@ public abstract class HybridUtils {
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks all connected plots
|
||||
* Checks all connected plots.
|
||||
* @param plot
|
||||
* @param whenDone
|
||||
*/
|
||||
@ -132,7 +131,7 @@ public abstract class HybridUtils {
|
||||
if (whenDone == null) {
|
||||
return;
|
||||
}
|
||||
final PlotArea plotworld = plot.getArea();
|
||||
PlotArea plotworld = plot.getArea();
|
||||
if (!(plotworld instanceof ClassicPlotWorld)) {
|
||||
whenDone.value = -1;
|
||||
TaskManager.runTask(whenDone);
|
||||
@ -145,7 +144,7 @@ public abstract class HybridUtils {
|
||||
@Override
|
||||
public void run() {
|
||||
if (zones.isEmpty()) {
|
||||
|
||||
|
||||
TaskManager.runTask(whenDone);
|
||||
return;
|
||||
}
|
||||
@ -155,34 +154,35 @@ public abstract class HybridUtils {
|
||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||
@Override
|
||||
public void run(int[] value) {
|
||||
final ChunkLoc loc = new ChunkLoc(value[0], value[1]);
|
||||
ChunkLoc loc = new ChunkLoc(value[0], value[1]);
|
||||
ChunkManager.manager.loadChunk(plot.getArea().worldname, loc, false);
|
||||
final int bx = value[2];
|
||||
final int bz = value[3];
|
||||
final int ex = value[4];
|
||||
final int ez = value[5];
|
||||
int bx = value[2];
|
||||
int bz = value[3];
|
||||
int ex = value[4];
|
||||
int ez = value[5];
|
||||
whenDone.value += checkModified(plot.getArea().worldname, bx, ex, 1, cpw.PLOT_HEIGHT - 1, bz, ez, cpw.MAIN_BLOCK);
|
||||
whenDone.value += checkModified(plot.getArea().worldname, bx, ex, cpw.PLOT_HEIGHT, cpw.PLOT_HEIGHT, bz, ez, cpw.TOP_BLOCK);
|
||||
whenDone.value += checkModified(
|
||||
plot.getArea().worldname, bx, ex, cpw.PLOT_HEIGHT + 1, 255, bz, ez, new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) });
|
||||
plot.getArea().worldname, bx, ex, cpw.PLOT_HEIGHT + 1, 255, bz, ez,
|
||||
new PlotBlock[]{new PlotBlock((short) 0, (byte) 0)});
|
||||
}
|
||||
}, this, 5);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
run.run();
|
||||
}
|
||||
|
||||
public boolean scheduleRoadUpdate(final PlotArea area, final int extend) {
|
||||
|
||||
public boolean scheduleRoadUpdate(PlotArea area, int extend) {
|
||||
if (HybridUtils.UPDATE) {
|
||||
return false;
|
||||
}
|
||||
HybridUtils.UPDATE = true;
|
||||
final Set<ChunkLoc> regions = ChunkManager.manager.getChunkChunks(area.worldname);
|
||||
Set<ChunkLoc> regions = ChunkManager.manager.getChunkChunks(area.worldname);
|
||||
return scheduleRoadUpdate(area, regions, extend);
|
||||
}
|
||||
|
||||
public boolean scheduleRoadUpdate(final PlotArea area, final Set<ChunkLoc> rgs, final int extend) {
|
||||
|
||||
public boolean scheduleRoadUpdate(final PlotArea area, Set<ChunkLoc> rgs, final int extend) {
|
||||
HybridUtils.regions = rgs;
|
||||
HybridUtils.area = area;
|
||||
chunks = new HashSet<>();
|
||||
@ -196,7 +196,7 @@ public abstract class HybridUtils {
|
||||
last.set(0);
|
||||
Iterator<ChunkLoc> iter = chunks.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final ChunkLoc chunk = iter.next();
|
||||
ChunkLoc chunk = iter.next();
|
||||
iter.remove();
|
||||
regenerateRoad(area, chunk, extend);
|
||||
ChunkManager.manager.unloadChunk(area.worldname, chunk, true, true);
|
||||
@ -224,7 +224,7 @@ public abstract class HybridUtils {
|
||||
if (chunks.size() < 1024) {
|
||||
if (!regions.isEmpty()) {
|
||||
Iterator<ChunkLoc> iter = regions.iterator();
|
||||
final ChunkLoc loc = iter.next();
|
||||
ChunkLoc loc = iter.next();
|
||||
iter.remove();
|
||||
PS.debug("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)");
|
||||
PS.debug(" - Remaining: " + regions.size());
|
||||
@ -233,7 +233,7 @@ public abstract class HybridUtils {
|
||||
}
|
||||
}
|
||||
if (!chunks.isEmpty()) {
|
||||
final long diff = System.currentTimeMillis() + 1;
|
||||
long diff = System.currentTimeMillis() + 1;
|
||||
if (System.currentTimeMillis() - baseTime - last.get() > 2000 && last.get() != 0) {
|
||||
last.set(0);
|
||||
PS.debug(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
|
||||
@ -265,14 +265,15 @@ public abstract class HybridUtils {
|
||||
}
|
||||
last.set((int) (System.currentTimeMillis() - baseTime));
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Iterator<ChunkLoc> iter = regions.iterator();
|
||||
final ChunkLoc loc = iter.next();
|
||||
ChunkLoc loc = iter.next();
|
||||
iter.remove();
|
||||
PS.debug("&c[ERROR]&7 Could not update '" + area.worldname + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)");
|
||||
final int sx = loc.x << 5;
|
||||
final int sz = loc.z << 5;
|
||||
PS.debug("&c[ERROR]&7 Could not update '" + area.worldname + "/region/r." + loc.x + "." + loc.z
|
||||
+ ".mca' (Corrupt chunk?)");
|
||||
int sx = loc.x << 5;
|
||||
int sz = loc.z << 5;
|
||||
for (int x = sx; x < sx + 32; x++) {
|
||||
for (int z = sz; z < sz + 32; z++) {
|
||||
ChunkManager.manager.unloadChunk(area.worldname, new ChunkLoc(x, z), true, true);
|
||||
@ -294,23 +295,23 @@ public abstract class HybridUtils {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setupRoadSchematic(final Plot plot) {
|
||||
|
||||
public boolean setupRoadSchematic(Plot plot) {
|
||||
final String world = plot.getArea().worldname;
|
||||
final Location bot = plot.getBottomAbs().subtract(1, 0, 1);
|
||||
final Location top = plot.getTopAbs();
|
||||
Location bot = plot.getBottomAbs().subtract(1, 0, 1);
|
||||
Location top = plot.getTopAbs();
|
||||
final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea();
|
||||
final int sx = bot.getX() - plotworld.ROAD_WIDTH + 1;
|
||||
final int sz = bot.getZ() + 1;
|
||||
final int sy = plotworld.ROAD_HEIGHT;
|
||||
final int ex = bot.getX();
|
||||
final int ez = top.getZ();
|
||||
final int ey = get_ey(world, sx, ex, sz, ez, sy);
|
||||
final int bz = sz - plotworld.ROAD_WIDTH;
|
||||
final int tz = sz - 1;
|
||||
final int ty = get_ey(world, sx, ex, bz, tz, sy);
|
||||
|
||||
final Set<RegionWrapper> sideroad = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ey, sz, ez)));
|
||||
int sx = bot.getX() - plotworld.ROAD_WIDTH + 1;
|
||||
int sz = bot.getZ() + 1;
|
||||
int sy = plotworld.ROAD_HEIGHT;
|
||||
int ex = bot.getX();
|
||||
int ez = top.getZ();
|
||||
int ey = get_ey(world, sx, ex, sz, ez, sy);
|
||||
int bz = sz - plotworld.ROAD_WIDTH;
|
||||
int tz = sz - 1;
|
||||
int ty = get_ey(world, sx, ex, bz, tz, sy);
|
||||
|
||||
Set<RegionWrapper> sideroad = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ey, sz, ez)));
|
||||
final Set<RegionWrapper> intersection = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ty, bz, tz)));
|
||||
|
||||
final String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot
|
||||
@ -331,50 +332,50 @@ public abstract class HybridUtils {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract int get_ey(final String world, final int sx, final int ex, final int sz, final int ez, final int sy);
|
||||
|
||||
|
||||
public abstract int get_ey(String world, int sx, int ex, int sz, int ez, int sy);
|
||||
|
||||
public boolean regenerateRoad(final PlotArea area, final ChunkLoc chunk, int extend) {
|
||||
int x = chunk.x << 4;
|
||||
int z = chunk.z << 4;
|
||||
final int ex = x + 15;
|
||||
final int ez = z + 15;
|
||||
final HybridPlotWorld plotworld = (HybridPlotWorld) area;
|
||||
int ex = x + 15;
|
||||
int ez = z + 15;
|
||||
HybridPlotWorld plotworld = (HybridPlotWorld) area;
|
||||
extend = Math.min(extend, 255 - plotworld.ROAD_HEIGHT - plotworld.SCHEMATIC_HEIGHT);
|
||||
if (!plotworld.ROAD_SCHEMATIC_ENABLED) {
|
||||
return false;
|
||||
}
|
||||
boolean toCheck = false;
|
||||
if (plotworld.TYPE == 2) {
|
||||
final boolean c1 = area.contains(x, z);
|
||||
final boolean c2 = area.contains(ex, ez);
|
||||
boolean c1 = area.contains(x, z);
|
||||
boolean c2 = area.contains(ex, ez);
|
||||
if (!c1 && !c2) {
|
||||
return false;
|
||||
} else {
|
||||
toCheck = c1 ^ c2;
|
||||
}
|
||||
}
|
||||
final PlotManager manager = area.getPlotManager();
|
||||
final PlotId id1 = manager.getPlotId(plotworld, x, 0, z);
|
||||
final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez);
|
||||
PlotManager manager = area.getPlotManager();
|
||||
PlotId id1 = manager.getPlotId(plotworld, x, 0, z);
|
||||
PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez);
|
||||
x -= plotworld.ROAD_OFFSET_X;
|
||||
z -= plotworld.ROAD_OFFSET_Z;
|
||||
if (id1 == null || id2 == null || id1 != id2) {
|
||||
final boolean result = ChunkManager.manager.loadChunk(area.worldname, chunk, false);
|
||||
boolean result = ChunkManager.manager.loadChunk(area.worldname, chunk, false);
|
||||
if (result) {
|
||||
if (id1 != null) {
|
||||
final Plot p1 = area.getPlotAbs(id1);
|
||||
Plot p1 = area.getPlotAbs(id1);
|
||||
if (p1 != null && p1.hasOwner() && p1.isMerged()) {
|
||||
toCheck = true;
|
||||
}
|
||||
}
|
||||
if (id2 != null && !toCheck) {
|
||||
final Plot p2 = area.getPlotAbs(id2);
|
||||
Plot p2 = area.getPlotAbs(id2);
|
||||
if (p2 != null && p2.hasOwner() && p2.isMerged()) {
|
||||
toCheck = true;
|
||||
}
|
||||
}
|
||||
final int size = plotworld.SIZE;
|
||||
int size = plotworld.SIZE;
|
||||
for (int X = 0; X < 16; X++) {
|
||||
short absX = (short) ((x + X) % size);
|
||||
for (int Z = 0; Z < 16; Z++) {
|
||||
@ -390,20 +391,21 @@ public abstract class HybridUtils {
|
||||
condition = manager.getPlotId(plotworld, x + X + plotworld.ROAD_OFFSET_X, 1, z + Z + plotworld.ROAD_OFFSET_Z) == null;
|
||||
// condition = MainUtil.isPlotRoad(new Location(plotworld.worldname, x + X, 1, z + Z));
|
||||
} else {
|
||||
final boolean gx = absX > plotworld.PATH_WIDTH_LOWER;
|
||||
final boolean gz = absZ > plotworld.PATH_WIDTH_LOWER;
|
||||
final boolean lx = absX < plotworld.PATH_WIDTH_UPPER;
|
||||
final boolean lz = absZ < plotworld.PATH_WIDTH_UPPER;
|
||||
boolean gx = absX > plotworld.PATH_WIDTH_LOWER;
|
||||
boolean gz = absZ > plotworld.PATH_WIDTH_LOWER;
|
||||
boolean lx = absX < plotworld.PATH_WIDTH_UPPER;
|
||||
boolean lz = absZ < plotworld.PATH_WIDTH_UPPER;
|
||||
condition = !gx || !gz || !lx || !lz;
|
||||
}
|
||||
if (condition) {
|
||||
final HashMap<Integer, PlotBlock> blocks = plotworld.G_SCH.get(MathMan.pair(absX, absZ));
|
||||
HashMap<Integer, PlotBlock> blocks = plotworld.G_SCH.get(MathMan.pair(absX, absZ));
|
||||
for (short y = (short) plotworld.ROAD_HEIGHT; y <= plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT + extend; y++) {
|
||||
SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, y, z + Z + plotworld.ROAD_OFFSET_Z, 0);
|
||||
}
|
||||
if (blocks != null) {
|
||||
for (Entry<Integer, PlotBlock> entry : blocks.entrySet()) {
|
||||
SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, entry.getKey(), z + Z + plotworld.ROAD_OFFSET_Z, entry.getValue());
|
||||
SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, entry.getKey(),
|
||||
z + Z + plotworld.ROAD_OFFSET_Z, entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,24 +14,24 @@ import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
* Use the specify method to get the generator for that platform.
|
||||
*/
|
||||
public abstract class IndependentPlotGenerator {
|
||||
|
||||
|
||||
/**
|
||||
* Get the name of this generator
|
||||
* Get the name of this generator.
|
||||
*/
|
||||
public abstract String getName();
|
||||
|
||||
|
||||
/**
|
||||
* Use the setBlock or setBiome method of the PlotChunk result parameter to make changes.<br>
|
||||
* The PlotArea settings is the same one this was initialized with<br>
|
||||
* The PseudoRandom random is a fast random object<br>
|
||||
* Use the setBlock or setBiome method of the PlotChunk result parameter to make changes.
|
||||
* The PlotArea settings is the same one this was initialized with.
|
||||
* The PseudoRandom random is a fast random object.
|
||||
* @param result
|
||||
* @param settings
|
||||
* @param random
|
||||
*/
|
||||
public abstract void generateChunk(PlotChunk<?> result, PlotArea settings, PseudoRandom random);
|
||||
|
||||
|
||||
/**
|
||||
* Return a new PlotArea object
|
||||
* Return a new PlotArea object.
|
||||
* @param world world name
|
||||
* @param id (May be null) Area name
|
||||
* @param min Min plot id (may be null)
|
||||
@ -39,26 +39,27 @@ public abstract class IndependentPlotGenerator {
|
||||
* @return
|
||||
*/
|
||||
public abstract PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max);
|
||||
|
||||
|
||||
/**
|
||||
* Return a new PlotManager object
|
||||
* Return a new PlotManager object.
|
||||
* @return
|
||||
*/
|
||||
public abstract PlotManager getNewPlotManager();
|
||||
|
||||
|
||||
/**
|
||||
* If any additional setup options need to be changed before world creation<br>
|
||||
* If any additional setup options need to be changed before world creation.
|
||||
* - e.g. If setup doesn't support some standard options
|
||||
* @param setup
|
||||
*/
|
||||
public void processSetup(SetupObject setup) {}
|
||||
|
||||
public void processSetup(SetupObject setup) {
|
||||
}
|
||||
|
||||
/**
|
||||
* It is preferred for the PlotArea object to do most of the initialization necessary.<br>
|
||||
* It is preferred for the PlotArea object to do most of the initialization necessary.
|
||||
* @param area
|
||||
*/
|
||||
public abstract void initialize(PlotArea area);
|
||||
|
||||
|
||||
/**
|
||||
* Get the generator for your specific implementation (bukkit/sponge).<br>
|
||||
* - e.g. YourIndependentGenerator.<ChunkGenerator>specify() - Would return a ChunkGenerator object<br>
|
||||
@ -69,7 +70,7 @@ public abstract class IndependentPlotGenerator {
|
||||
public <T> GeneratorWrapper<T> specify() {
|
||||
return (GeneratorWrapper<T>) PS.get().IMP.wrapPlotGenerator(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
|
@ -7,30 +7,29 @@ import com.intellectualcrafters.plot.object.SetupObject;
|
||||
|
||||
public abstract class PlotGenerator<T> {
|
||||
public T generator;
|
||||
|
||||
public PlotGenerator(final T generator) {
|
||||
|
||||
public PlotGenerator(T generator) {
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
public abstract void initialize(final PlotArea plotworld);
|
||||
|
||||
public abstract void initialize(PlotArea plotworld);
|
||||
|
||||
/**
|
||||
* TYPE = 2;
|
||||
* new AugmentedPopulator(world, generator, cluster, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2);
|
||||
* TYPE = 1
|
||||
* new AugmentedPopulator(world, gen_class, null, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2);
|
||||
* @param cluster Will be the cluster, or null
|
||||
* @param plotworld
|
||||
* @param area
|
||||
*/
|
||||
public abstract void augment(PlotArea area);
|
||||
|
||||
public abstract PlotArea getNewPlotArea(final String world, final String id, PlotId min, PlotId max);
|
||||
|
||||
public abstract PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max);
|
||||
|
||||
public abstract PlotManager getPlotManager();
|
||||
|
||||
public abstract boolean isFull();
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract void processSetup(final SetupObject object);
|
||||
|
||||
public abstract void processSetup(SetupObject object);
|
||||
}
|
||||
|
@ -14,11 +14,12 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* A plot manager with a square grid layout, with square shaped plots
|
||||
* A plot manager with a square grid layout, with square shaped plots.
|
||||
*/
|
||||
public abstract class SquarePlotManager extends GridPlotManager {
|
||||
|
||||
@Override
|
||||
public boolean clearPlot(final PlotArea plotworld, final Plot plot, final Runnable whenDone) {
|
||||
public boolean clearPlot(PlotArea plotworld, final Plot plot, final Runnable whenDone) {
|
||||
final HashSet<RegionWrapper> regions = plot.getRegions();
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
@ -38,20 +39,20 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
run.run();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Location getPlotTopLocAbs(final PlotArea plotworld, final PlotId plotid) {
|
||||
final SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
final int px = plotid.x;
|
||||
final int pz = plotid.y;
|
||||
final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1;
|
||||
final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1;
|
||||
public Location getPlotTopLocAbs(PlotArea plotworld, PlotId plotid) {
|
||||
SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
int px = plotid.x;
|
||||
int pz = plotid.y;
|
||||
int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1;
|
||||
int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1;
|
||||
return new Location(plotworld.worldname, x, Math.min(plotworld.MAX_BUILD_HEIGHT, 255), z);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PlotId getPlotIdAbs(final PlotArea plotworld, int x, final int y, int z) {
|
||||
final SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
public PlotId getPlotIdAbs(PlotArea plotworld, int x, int y, int z) {
|
||||
SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
if (dpw.ROAD_OFFSET_X != 0) {
|
||||
x -= dpw.ROAD_OFFSET_X;
|
||||
}
|
||||
@ -71,7 +72,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
}
|
||||
end = pathWidthLower + dpw.PLOT_WIDTH;
|
||||
}
|
||||
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
||||
int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
||||
int idx;
|
||||
if (x < 0) {
|
||||
idx = x / size;
|
||||
@ -88,21 +89,25 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
idz = (z / size) + 1;
|
||||
z = z % size;
|
||||
}
|
||||
return ((z <= pathWidthLower) || (z > end) || (x <= pathWidthLower) || (x > end)) ? null : new PlotId(idx, idz);
|
||||
if (z <= pathWidthLower || z > end || x <= pathWidthLower || x > end) {
|
||||
return null;
|
||||
} else {
|
||||
return new PlotId(idx, idz);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PlotId getPlotId(final PlotArea plotworld, int x, final int y, int z) {
|
||||
public PlotId getPlotId(PlotArea plotworld, int x, int y, int z) {
|
||||
try {
|
||||
final SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
if (plotworld == null) {
|
||||
return null;
|
||||
}
|
||||
x -= dpw.ROAD_OFFSET_X;
|
||||
z -= dpw.ROAD_OFFSET_Z;
|
||||
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
||||
int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
||||
int pathWidthLower;
|
||||
final int end;
|
||||
int end;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
pathWidthLower = -1;
|
||||
end = dpw.PLOT_WIDTH;
|
||||
@ -176,17 +181,17 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the bottom plot loc (some basic math)
|
||||
*/
|
||||
@Override
|
||||
public Location getPlotBottomLocAbs(final PlotArea plotworld, final PlotId plotid) {
|
||||
final SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
final int px = plotid.x;
|
||||
final int pz = plotid.y;
|
||||
final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - (int) Math.floor(dpw.ROAD_WIDTH / 2);
|
||||
final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - (int) Math.floor(dpw.ROAD_WIDTH / 2);
|
||||
public Location getPlotBottomLocAbs(PlotArea plotworld, PlotId plotid) {
|
||||
SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
int px = plotid.x;
|
||||
int pz = plotid.y;
|
||||
int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - (int) Math.floor(dpw.ROAD_WIDTH / 2);
|
||||
int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - (int) Math.floor(dpw.ROAD_WIDTH / 2);
|
||||
return new Location(plotworld.worldname, x, plotworld.MIN_BUILD_HEIGHT, z);
|
||||
}
|
||||
}
|
||||
|
@ -6,24 +6,24 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
||||
public abstract class SquarePlotWorld extends GridPlotWorld {
|
||||
|
||||
public SquarePlotWorld(String worldname, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||
super(worldname, id, generator, min, max);
|
||||
}
|
||||
|
||||
public int PLOT_WIDTH = 42;
|
||||
public int ROAD_WIDTH = 7;
|
||||
public int ROAD_OFFSET_X = 0;
|
||||
public int ROAD_OFFSET_Z = 0;
|
||||
|
||||
public SquarePlotWorld(String worldname, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||
super(worldname, id, generator, min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadConfiguration(final ConfigurationSection config) {
|
||||
public void loadConfiguration(ConfigurationSection config) {
|
||||
if (!config.contains("plot.height")) {
|
||||
PS.debug(" - &cConfiguration is null? (" + config.getCurrentPath() + ")");
|
||||
}
|
||||
PLOT_WIDTH = config.getInt("plot.size");
|
||||
ROAD_WIDTH = config.getInt("road.width");
|
||||
ROAD_OFFSET_X = config.getInt("road.offset.x");
|
||||
ROAD_OFFSET_Z = config.getInt("road.offset.z");
|
||||
SIZE = (short) (PLOT_WIDTH + ROAD_WIDTH);
|
||||
this.PLOT_WIDTH = config.getInt("plot.size");
|
||||
this.ROAD_WIDTH = config.getInt("road.width");
|
||||
this.ROAD_OFFSET_X = config.getInt("road.offset.x");
|
||||
this.ROAD_OFFSET_Z = config.getInt("road.offset.z");
|
||||
this.SIZE = (short) (this.PLOT_WIDTH + this.ROAD_WIDTH);
|
||||
}
|
||||
}
|
||||
|
@ -7,52 +7,55 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import java.io.File;
|
||||
|
||||
public class BO3 {
|
||||
|
||||
private final ChunkLoc chunk;
|
||||
private final String world;
|
||||
private final StringBuilder blocks;
|
||||
private final StringBuilder children;
|
||||
private final String name;
|
||||
|
||||
public BO3(final String name, final String world, final ChunkLoc loc) {
|
||||
|
||||
public BO3(String name, String world, ChunkLoc loc) {
|
||||
this.world = world;
|
||||
this.name = name;
|
||||
chunk = loc;
|
||||
blocks = new StringBuilder();
|
||||
children = new StringBuilder();
|
||||
this.chunk = loc;
|
||||
this.blocks = new StringBuilder();
|
||||
this.children = new StringBuilder();
|
||||
}
|
||||
|
||||
public void addChild(final BO3 child) {
|
||||
final ChunkLoc childloc = child.getLoc();
|
||||
children.append("Branch(" + (childloc.x - chunk.x) + ",0," + (childloc.z - chunk.z) + "," + name + "_" + childloc.x + "_" + childloc.z + ")\n");
|
||||
|
||||
public void addChild(BO3 child) {
|
||||
ChunkLoc childloc = child.getLoc();
|
||||
this.children.append("Branch(").append(childloc.x - this.chunk.x).append(",0,").append(childloc.z - this.chunk.z).append(",")
|
||||
.append(this.name).append("_").append(childloc.x).append("_").append(childloc.z).append(")\n");
|
||||
}
|
||||
|
||||
|
||||
public ChunkLoc getLoc() {
|
||||
return chunk;
|
||||
return this.chunk;
|
||||
}
|
||||
|
||||
public String getWorld() {
|
||||
return world;
|
||||
return this.world;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void addBlock(final int x, final int y, final int z, final PlotBlock block) {
|
||||
|
||||
public void addBlock(int x, int y, int z, PlotBlock block) {
|
||||
if (block.data == 0) {
|
||||
// Block(-3,1,-2,AIR)
|
||||
blocks.append("Block(" + x + "," + y + "," + z + "," + block.id + ")\n");
|
||||
this.blocks.append("Block(").append(x).append(",").append(y).append(",").append(z).append(",").append(block.id).append(")\n");
|
||||
} else {
|
||||
blocks.append("Block(" + x + "," + y + "," + z + "," + block.id + ":" + block.data + ")\n");
|
||||
this.blocks.append("Block(").append(x).append(",").append(y).append(",").append(z).append(",").append(block.id).append(":")
|
||||
.append(block.data).append(")\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getBlocks() {
|
||||
return blocks.toString();
|
||||
return this.blocks.toString();
|
||||
}
|
||||
|
||||
|
||||
public String getChildren() {
|
||||
return children.toString();
|
||||
return this.children.toString();
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
@ -60,6 +63,10 @@ public class BO3 {
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return name + (chunk.x == 0 && chunk.z == 0 ? "" : "_" + chunk.x + "_" + chunk.z) + ".bo3";
|
||||
if (this.chunk.x == 0 && this.chunk.z == 0) {
|
||||
return this.name + "" + ".bo3";
|
||||
} else {
|
||||
return this.name + ("_" + this.chunk.x + "_" + this.chunk.z) + ".bo3";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,26 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
public class ChunkLoc {
|
||||
|
||||
public int x;
|
||||
public int z;
|
||||
|
||||
public ChunkLoc(final int x, final int z) {
|
||||
|
||||
public ChunkLoc(int x, int z) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int prime = 31;
|
||||
int result = 1;
|
||||
result = (prime * result) + x;
|
||||
result = (prime * result) + z;
|
||||
result = (prime * result) + this.x;
|
||||
result = (prime * result) + this.z;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
@ -29,12 +30,12 @@ public class ChunkLoc {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final ChunkLoc other = (ChunkLoc) obj;
|
||||
return ((x == other.x) && (z == other.z));
|
||||
ChunkLoc other = (ChunkLoc) obj;
|
||||
return (this.x == other.x) && (this.z == other.z);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + "," + z;
|
||||
return this.x + "," + this.z;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.intellectualcrafters.plot.object;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||
import com.intellectualcrafters.plot.util.PlotGameMode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -14,16 +14,8 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
private static ConsolePlayer instance;
|
||||
private final HashMap<String, Object> meta;
|
||||
|
||||
public static ConsolePlayer getConsole() {
|
||||
if (instance == null) {
|
||||
instance = new ConsolePlayer();
|
||||
instance.teleport(instance.getLocation());
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Direct access is deprecated
|
||||
* Direct access is deprecated.
|
||||
*/
|
||||
@Deprecated
|
||||
public ConsolePlayer() {
|
||||
@ -35,11 +27,19 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
} else {
|
||||
loc = new Location("world", 0, 0, 0);
|
||||
}
|
||||
meta = new HashMap<>();
|
||||
this.meta = new HashMap<>();
|
||||
setMeta("location", loc);
|
||||
}
|
||||
|
||||
public static boolean isConsole(final PlotPlayer plr) {
|
||||
|
||||
public static ConsolePlayer getConsole() {
|
||||
if (instance == null) {
|
||||
instance = new ConsolePlayer();
|
||||
instance.teleport(instance.getLocation());
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static boolean isConsole(PlotPlayer plr) {
|
||||
return plr instanceof ConsolePlayer;
|
||||
}
|
||||
|
||||
@ -64,20 +64,20 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String perm) {
|
||||
public boolean hasPermission(String permission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final String message) {
|
||||
public void sendMessage(String message) {
|
||||
PS.log(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(final Location loc) {
|
||||
final Plot plot = loc.getPlot();
|
||||
public void teleport(Location location) {
|
||||
Plot plot = location.getPlot();
|
||||
setMeta("lastplot", plot);
|
||||
setMeta("location", loc);
|
||||
setMeta("location", location);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -91,38 +91,35 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompassTarget(final Location loc) {}
|
||||
public void setCompassTarget(Location location) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String key) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData() {}
|
||||
|
||||
@Override
|
||||
public void saveData() {}
|
||||
|
||||
@Override
|
||||
public void setAttribute(final String key) {}
|
||||
|
||||
@Override
|
||||
public boolean getAttribute(final String key) {
|
||||
public boolean getAttribute(String key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(final String key) {}
|
||||
|
||||
@Override
|
||||
public void setMeta(final String key, final Object value) {
|
||||
meta.put(key, value);
|
||||
public void removeAttribute(String key) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMeta(final String key) {
|
||||
return meta.get(key);
|
||||
public void setMeta(String key, Object value) {
|
||||
this.meta.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deleteMeta(final String key) {
|
||||
return meta.remove(key);
|
||||
public Object getMeta(String key) {
|
||||
return this.meta.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deleteMeta(String key) {
|
||||
return this.meta.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -131,27 +128,33 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeather(final PlotWeather weather) {}
|
||||
|
||||
@Override
|
||||
public PlotGamemode getGamemode() {
|
||||
return PlotGamemode.CREATIVE;
|
||||
public void setWeather(PlotWeather weather) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGamemode(final PlotGamemode gamemode) {}
|
||||
public PlotGameMode getGameMode() {
|
||||
return PlotGameMode.CREATIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTime(final long time) {}
|
||||
public void setGameMode(PlotGameMode gameMode) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlight(final boolean fly) {}
|
||||
public void setTime(long time) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playMusic(final Location loc, final int id) {}
|
||||
public void setFlight(boolean fly) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kick(final String message) {}
|
||||
public void playMusic(Location location, int id) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kick(String message) {
|
||||
}
|
||||
|
||||
@Override public void stopSpectating() {}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user