mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-17 21:04:42 +02:00
@ -1,5 +1,36 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.file.Files;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.configuration.MemorySection;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
@ -56,37 +87,6 @@ import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||
import com.plotsquared.listener.WESubscriber;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.file.Files;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/**
|
||||
* An implementation of the core,
|
||||
* with a static getter for easy access
|
||||
@ -147,7 +147,7 @@ public class PS {
|
||||
try {
|
||||
URL url = PS.class.getProtectionDomain().getCodeSource().getLocation();
|
||||
FILE = new File(new URL(url.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file")).toURI().getPath());
|
||||
} catch (MalformedURLException | URISyntaxException e) {
|
||||
} catch (MalformedURLException | URISyntaxException | SecurityException | NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
FILE = new File(IMP.getDirectory().getParentFile(), "PlotSquared.jar");
|
||||
if (!FILE.exists()) {
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -27,11 +32,6 @@ 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",
|
||||
@ -40,7 +40,6 @@ requiredType = RequiredType.NONE,
|
||||
description = "Create a new PlotArea",
|
||||
aliases = { "world" },
|
||||
usage = "/plot area <create|info|list|tp|regen>")
|
||||
//plot createarea partial
|
||||
public class Area extends SubCommand {
|
||||
|
||||
@Override
|
||||
@ -59,7 +58,7 @@ public class Area extends SubCommand {
|
||||
}
|
||||
switch (args.length) {
|
||||
case 1: {
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:type]] [<modifier>=<value>]...");
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
case 2: {
|
||||
@ -67,7 +66,7 @@ public class Area extends SubCommand {
|
||||
case "pos1": { // Set position 1
|
||||
HybridPlotWorld area = plr.<HybridPlotWorld> getMeta("area_create_area");
|
||||
if (area == null) {
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:type]] [<modifier>=<value>]...");
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
Location loc = plr.getLocation();
|
||||
@ -80,7 +79,7 @@ public class Area extends SubCommand {
|
||||
case "pos2": { // Set position 2 and finish creation for type=2 (partial)
|
||||
final HybridPlotWorld area = plr.<HybridPlotWorld> getMeta("area_create_area");
|
||||
if (area == null) {
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:type]] [<modifier>=<value>]...");
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
Location pos1 = plr.getLocation();
|
||||
@ -170,7 +169,7 @@ public class Area extends SubCommand {
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
String[] pair = args[i].split("=");
|
||||
if (pair.length != 2) {
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:type]] [<modifier>=<value>]...");
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
switch (pair[0].toLowerCase()) {
|
||||
@ -225,7 +224,7 @@ public class Area extends SubCommand {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:type]] [<modifier>=<value>]...");
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -264,7 +263,7 @@ public class Area extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
if (pa.id == null) {
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:type]] [<modifier>=<value>]...");
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
if (WorldUtil.IMP.isWorld(pa.worldname)) {
|
||||
|
@ -20,6 +20,8 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
@ -33,10 +35,8 @@ 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 [type]")
|
||||
usage = "/plot clear [id]")
|
||||
public class Clear extends SubCommand {
|
||||
|
||||
@Override
|
||||
|
@ -20,6 +20,11 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -38,11 +43,6 @@ 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" },
|
||||
@ -103,7 +103,7 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if (args.length != 4) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster create <name> <type-bot> <type-top>");
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster create <name> <id-bot> <id-top>");
|
||||
return false;
|
||||
}
|
||||
// check pos1 / pos2
|
||||
|
@ -1,5 +1,11 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.database.MySQL;
|
||||
@ -13,12 +19,6 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "database",
|
||||
aliases = { "convert" },
|
||||
@ -101,7 +101,7 @@ public class Database extends SubCommand {
|
||||
for (final Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
final Plot plot = entry2.getValue();
|
||||
if (pa.getOwnedPlotAbs(plot.getId()) != null) {
|
||||
MainUtil.sendMessage(player, "Skipping duplicate plot: " + plot + " | type=" + plot.temp);
|
||||
MainUtil.sendMessage(player, "Skipping duplicate plot: " + plot + " | id=" + plot.temp);
|
||||
continue;
|
||||
}
|
||||
PS.get().updatePlot(plot);
|
||||
|
@ -20,6 +20,26 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import javax.script.ScriptContext;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import javax.script.SimpleScriptContext;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -54,26 +74,6 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import javax.script.ScriptContext;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import javax.script.SimpleScriptContext;
|
||||
|
||||
@CommandDeclaration(command = "debugexec", permission = "plots.admin", description = "Mutli-purpose debug command", aliases = "exec",
|
||||
category = CommandCategory.DEBUG)
|
||||
public class DebugExec extends SubCommand {
|
||||
@ -83,19 +83,20 @@ public class DebugExec extends SubCommand {
|
||||
|
||||
public DebugExec() {
|
||||
try {
|
||||
final File file = new File(PS.get().IMP.getDirectory(), "scripts" + File.separator + "start.js");
|
||||
if (file.exists()) {
|
||||
init();
|
||||
final 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);
|
||||
if (PS.get() != null) {
|
||||
final File file = new File(PS.get().IMP.getDirectory(), "scripts" + File.separator + "start.js");
|
||||
if (file.exists()) {
|
||||
init();
|
||||
final 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);
|
||||
}
|
||||
}
|
||||
} catch (IOException | ScriptException e) {
|
||||
}
|
||||
} catch (IOException | ScriptException e) {}
|
||||
}
|
||||
|
||||
public ScriptEngine getEngine() {
|
||||
|
@ -1,10 +1,5 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
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;
|
||||
@ -16,6 +11,11 @@ import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
|
||||
public class GenerateDocs {
|
||||
public static void main(final String[] args) {
|
||||
MainCommand.getInstance().addCommand(new WE_Anywhere());
|
||||
@ -52,6 +52,7 @@ public class GenerateDocs {
|
||||
final File file = new File("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);
|
||||
|
||||
log("#### Description");
|
||||
@ -63,8 +64,20 @@ public class GenerateDocs {
|
||||
log("```");
|
||||
}
|
||||
|
||||
log("#### Usage");
|
||||
log("`" + command.getUsage().replaceAll("\\{label\\}", "plot") + "`");
|
||||
log("#### Usage ");
|
||||
{
|
||||
String mainUsage = command.getUsage().replaceAll("\\{label\\}", "plot");
|
||||
if (!usages.isEmpty() && !usages.get(0).equalsIgnoreCase(mainUsage)) {
|
||||
log("##### Primary ");
|
||||
log(" - `" + mainUsage + "` ");
|
||||
log("");
|
||||
log("##### Other ");
|
||||
log(" - `" + StringMan.join(usages, "`\n - `") + "` ");
|
||||
log("");
|
||||
} else {
|
||||
log("`" + mainUsage + "` ");
|
||||
}
|
||||
}
|
||||
|
||||
if (command.getRequiredType() != RequiredType.NONE) {
|
||||
log("#### Required callers");
|
||||
@ -78,14 +91,16 @@ public class GenerateDocs {
|
||||
}
|
||||
|
||||
log("#### Permissions");
|
||||
log("##### Primary");
|
||||
log(" - `" + command.getPermission() + "` ");
|
||||
if (!perms.isEmpty()) {
|
||||
log("##### Primary");
|
||||
log(" - `" + command.getPermission() + "` ");
|
||||
log("");
|
||||
log("##### Other");
|
||||
log(" - `" + StringMan.join(perms, "`\n - `") + "`");
|
||||
log("");
|
||||
} else {
|
||||
log("`" + command.getPermission() + "` ");
|
||||
}
|
||||
log("");
|
||||
log("***");
|
||||
log("");
|
||||
} catch (final Exception e) {
|
||||
@ -93,6 +108,27 @@ public class GenerateDocs {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getUsage(String cmd, List<String> lines) {
|
||||
final Pattern p = Pattern.compile("\"([^\"]*)\"");
|
||||
HashSet<String> usages = new HashSet<String>();
|
||||
for (final String line : lines) {
|
||||
if (line.contains("COMMAND_SYNTAX") && !line.contains("getUsage()")) {
|
||||
final Matcher m = p.matcher(line);
|
||||
String prefix = "";
|
||||
StringBuilder usage = new StringBuilder();
|
||||
while (m.find()) {
|
||||
String match = m.group(1);
|
||||
usage.append(prefix).append(match);
|
||||
prefix = " <arg> ";
|
||||
}
|
||||
if (usage.length() != 0) {
|
||||
usages.add(usage.toString().trim().replaceAll(" ", " ").replaceAll("\\{label\\}", "plot"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ArrayList<>(usages);
|
||||
}
|
||||
|
||||
public static List<String> getPerms(final String cmd, final List<String> lines) {
|
||||
final HashSet<String> perms = new HashSet<String>();
|
||||
final Pattern p = Pattern.compile("\"([^\"]*)\"");
|
||||
@ -104,7 +140,6 @@ public class GenerateDocs {
|
||||
while (m2.find()) {
|
||||
perms.add(C.valueOf("PERMISSION_" + m2.group(1)).s());
|
||||
}
|
||||
|
||||
if (line.contains("Permissions.hasPermission(")) {
|
||||
String[] split = line.split("Permissions.hasPermission");
|
||||
split = Arrays.copyOfRange(split, 1, split.length);
|
||||
|
@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
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 [type|alias]",
|
||||
@CommandDeclaration(command = "home", aliases = { "h" }, description = "Go to your plot", usage = "/plot home [id|alias]",
|
||||
category = CommandCategory.TELEPORT, requiredType = RequiredType.NONE)
|
||||
public class Home extends SubCommand {
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
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.Plot;
|
||||
@ -30,9 +32,7 @@ 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 <type>",
|
||||
@CommandDeclaration(command = "info", aliases = { "i" }, description = "Display plot info", usage = "/plot info <id>",
|
||||
category = CommandCategory.INFO)
|
||||
public class Info extends SubCommand {
|
||||
|
||||
@ -49,7 +49,7 @@ public class Info extends SubCommand {
|
||||
case "biome":
|
||||
case "denied":
|
||||
case "flags":
|
||||
case "type":
|
||||
case "id":
|
||||
case "size":
|
||||
case "members":
|
||||
case "owner":
|
||||
@ -157,7 +157,7 @@ public class Info extends SubCommand {
|
||||
return C.PLOT_INFO_DENIED.s();
|
||||
case "flags":
|
||||
return C.PLOT_INFO_FLAGS.s();
|
||||
case "type":
|
||||
case "id":
|
||||
return C.PLOT_INFO_ID.s();
|
||||
case "size":
|
||||
return C.PLOT_INFO_SIZE.s();
|
||||
|
@ -20,6 +20,12 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
@ -32,14 +38,8 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
usage = "/plot purge world:<world> area:<area> type:<type> owner:<owner> shared:<shared> unknown:[true|false]",
|
||||
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",
|
||||
@ -80,7 +80,7 @@ public class Purge extends SubCommand {
|
||||
break;
|
||||
}
|
||||
case "plotid":
|
||||
case "type": {
|
||||
case "id": {
|
||||
id = PlotId.fromString(split[1]);
|
||||
if (id == null) {
|
||||
C.NOT_VALID_PLOT_ID.send(plr, split[1]);
|
||||
|
@ -20,6 +20,11 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -36,11 +41,6 @@ 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",
|
||||
@ -153,7 +153,7 @@ public class SchematicCmd extends SubCommand {
|
||||
// }
|
||||
// final int l1 = schematic.getSchematicDimension().getX();
|
||||
// final int l2 = schematic.getSchematicDimension().getZ();
|
||||
// final int length = MainUtil.getPlotWidth(loc.getWorld(), plot.type);
|
||||
// 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;
|
||||
|
@ -20,6 +20,11 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
@ -34,11 +39,6 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "setup",
|
||||
permission = "plots.admin.command.setup",
|
||||
@ -172,14 +172,14 @@ public class Setup extends SubCommand {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: { // area type
|
||||
case 2: { // area id
|
||||
if (!StringMan.isAlphanumericUnd(args[0])) {
|
||||
MainUtil.sendMessage(plr, "&cThe area type must be alphanumerical!");
|
||||
MainUtil.sendMessage(plr, "&cThe area id must be alphanumerical!");
|
||||
return false;
|
||||
}
|
||||
for (PlotArea area : PS.get().getPlotAreas()) {
|
||||
if (area.id != null && area.id.equalsIgnoreCase(args[0])) {
|
||||
MainUtil.sendMessage(plr, "&cYou must choose an area type that is not in use!");
|
||||
MainUtil.sendMessage(plr, "&cYou must choose an area id that is not in use!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,16 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
@ -37,16 +47,6 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "template",
|
||||
permission = "plots.admin",
|
||||
@ -206,7 +206,7 @@ public class Template extends SubCommand {
|
||||
public void run() {
|
||||
try {
|
||||
manager.exportTemplate(area);
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) { // Must recover from any exception thrown a third party template manager
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(plr, "Failed: " + e.getMessage());
|
||||
return;
|
||||
|
@ -20,6 +20,14 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -31,19 +39,11 @@ 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;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "visit",
|
||||
permission = "plots.visit",
|
||||
description = "Visit someones plot",
|
||||
usage = "/plot visit [player|alias|world|type] [#]",
|
||||
usage = "/plot visit [player|alias|world|id] [#]",
|
||||
aliases = { "v", "tp", "teleport", "goto" },
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.TELEPORT)
|
||||
|
@ -20,13 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.config;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandCaller;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
@ -35,6 +28,13 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandCaller;
|
||||
|
||||
/**
|
||||
* Captions class.
|
||||
*
|
||||
@ -150,7 +150,7 @@ public enum C {
|
||||
CLUSTER_REMOVED_HELPER("$4Successfully removed a helper from the cluster", "Cluster"),
|
||||
CLUSTER_REGENERATED("$4Successfully started cluster regeneration", "Cluster"),
|
||||
CLUSTER_TELEPORTING("$4Teleporting...", "Cluster"),
|
||||
CLUSTER_INFO("$1Current cluster: $2%type%&-$1Name: $2%name%&-$1Owner: $2%owner%&-$1Size: $2%size%&-$1Rights: $2%rights%", "Cluster"),
|
||||
CLUSTER_INFO("$1Current cluster: $2%id%&-$1Name: $2%name%&-$1Owner: $2%owner%&-$1Size: $2%size%&-$1Rights: $2%rights%", "Cluster"),
|
||||
/*
|
||||
* Border
|
||||
*/
|
||||
@ -187,7 +187,7 @@ public enum C {
|
||||
*/
|
||||
SWAP_OVERLAP("$2The proposed areas are not allowed to overlap", "Swap"),
|
||||
SWAP_DIMENSIONS("$2The proposed areas must have comparable dimensions", "Swap"),
|
||||
SWAP_SYNTAX("$2/plots swap <plot type>", "Swap"),
|
||||
SWAP_SYNTAX("$2/plots swap <id>", "Swap"),
|
||||
SWAP_SUCCESS("$4Successfully swapped plots", "Swap"),
|
||||
STARTED_SWAP("$2Started plot swap task. You will be notified when it finishes", "Swap"),
|
||||
/*
|
||||
@ -225,7 +225,7 @@ public enum C {
|
||||
PASTED("$4The plot selection was successfully pasted. It has been cleared from your clipboard.", "Clipboard"),
|
||||
PASTE_FAILED("$2Failed to paste the selection. Reason: $2%s", "Clipboard"),
|
||||
NO_CLIPBOARD("$2You don't have a selection in your clipboard", "Clipboard"),
|
||||
CLIPBOARD_INFO("$2Current Selection - Plot ID: $1%type$2, Width: $1%width$2, Total Blocks: $1%total$2", "Clipboard"),
|
||||
CLIPBOARD_INFO("$2Current Selection - Plot ID: $1%id$2, Width: $1%width$2, Total Blocks: $1%total$2", "Clipboard"),
|
||||
/*
|
||||
* Toggle
|
||||
*/
|
||||
@ -298,8 +298,8 @@ public enum C {
|
||||
*/
|
||||
TITLE_ENTERED_PLOT("$1Plot: %world%;%x%;%z%", "Titles"),
|
||||
TITLE_ENTERED_PLOT_SUB("$4Owned by %s", "Titles"),
|
||||
PREFIX_GREETING("$1%type%$2> ", "Titles"),
|
||||
PREFIX_FAREWELL("$1%type%$2> ", "Titles"),
|
||||
PREFIX_GREETING("$1%id%$2> ", "Titles"),
|
||||
PREFIX_FAREWELL("$1%id%$2> ", "Titles"),
|
||||
/*
|
||||
* Core Stuff
|
||||
*/
|
||||
@ -315,7 +315,6 @@ public enum C {
|
||||
/*
|
||||
* BarAPI
|
||||
*/
|
||||
BOSSBAR_CLEARING("$2Clearing plot: $1%type%", "Bar API"),
|
||||
|
||||
DESC_SET("$2Plot description set", "Desc"),
|
||||
DESC_UNSET("$2Plot description unset", "Desc"),
|
||||
@ -443,12 +442,12 @@ public enum C {
|
||||
/*
|
||||
* Invalid
|
||||
*/
|
||||
NOT_VALID_DATA("$2That's not a valid data type.", "Invalid"),
|
||||
NOT_VALID_DATA("$2That's not a valid data id.", "Invalid"),
|
||||
NOT_VALID_BLOCK("$2That's not a valid block: %s", "Invalid"),
|
||||
NOT_ALLOWED_BLOCK("$2That block is not allowed: %s", "Invalid"),
|
||||
NOT_VALID_NUMBER("$2That's not a valid number within the range: %s", "Invalid"),
|
||||
NOT_VALID_PLOT_ID("$2That's not a valid plot type.", "Invalid"),
|
||||
PLOT_ID_FORM("$2The plot type must be in the form: $1X;Y $2e.g. $1-5;7", "Invalid"),
|
||||
NOT_VALID_PLOT_ID("$2That's not a valid plot id.", "Invalid"),
|
||||
PLOT_ID_FORM("$2The plot id must be in the form: $1X;Y $2e.g. $1-5;7", "Invalid"),
|
||||
NOT_YOUR_PLOT("$2That is not your plot.", "Invalid"),
|
||||
NO_SUCH_PLOT("$2There is no such plot", "Invalid"),
|
||||
PLAYER_HAS_NOT_BEEN_ON("$2That player hasn't been in the plotworld", "Invalid"),
|
||||
@ -463,7 +462,7 @@ public enum C {
|
||||
*/
|
||||
NEED_PLOT_NUMBER("$2You've got to specify a plot number or alias", "Need"),
|
||||
NEED_BLOCK("$2You've got to specify a block", "Need"),
|
||||
NEED_PLOT_ID("$2You've got to specify a plot type.", "Need"),
|
||||
NEED_PLOT_ID("$2You've got to specify a plot id.", "Need"),
|
||||
NEED_PLOT_WORLD("$2You've got to specify a plot area.", "Need"),
|
||||
NEED_USER("$2You need to specify a username", "Need"),
|
||||
/*
|
||||
@ -475,7 +474,7 @@ public enum C {
|
||||
PLOT_UNOWNED("$2The current plot must have an owner to perform this action", "Info"),
|
||||
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%type%$1&-"
|
||||
PLOT_INFO("$1ID: $2%id%$1&-"
|
||||
+ "$1Alias: $2%alias%$1&-"
|
||||
+ "$1Owner: $2%owner%$1&-"
|
||||
+ "$1Biome: $2%biome%$1&-"
|
||||
@ -493,7 +492,7 @@ public enum C {
|
||||
PLOT_INFO_BIOME("$1Biome:$2 %biome%", "Info"),
|
||||
PLOT_INFO_RATING("$1Rating:$2 %rating%", "Info"),
|
||||
PLOT_INFO_OWNER("$1Owner:$2 %owner%", "Info"),
|
||||
PLOT_INFO_ID("$1ID:$2 %type%", "Info"),
|
||||
PLOT_INFO_ID("$1ID:$2 %id%", "Info"),
|
||||
PLOT_INFO_ALIAS("$1Alias:$2 %alias%", "Info"),
|
||||
PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"),
|
||||
PLOT_USER_LIST(" $1%user%$2,", "Info"),
|
||||
@ -521,8 +520,8 @@ public enum C {
|
||||
AREA_LIST_HEADER_PAGED("$2(Page $1%cur$2/$1%max$2) $1List of %amount% areas", "List"),
|
||||
PLOT_LIST_HEADER_PAGED("$2(Page $1%cur$2/$1%max$2) $1List of %amount% plots", "List"),
|
||||
PLOT_LIST_HEADER("$1List of %word% plots", "List"),
|
||||
PLOT_LIST_ITEM("$2>> $1%type$2:$1%world $2- $1%owner", "List"),
|
||||
PLOT_LIST_ITEM_ORDERED("$2[$1%in$2] >> $1%type$2:$1%world $2- $1%owner", "List"),
|
||||
PLOT_LIST_ITEM("$2>> $1%id$2:$1%world $2- $1%owner", "List"),
|
||||
PLOT_LIST_ITEM_ORDERED("$2[$1%in$2] >> $1%id$2:$1%world $2- $1%owner", "List"),
|
||||
PLOT_LIST_FOOTER("$2>> $1%word% a total of $2%num% $1claimed %plot%.", "List"),
|
||||
/*
|
||||
* Left
|
||||
@ -595,7 +594,7 @@ public enum C {
|
||||
/*
|
||||
* Signs
|
||||
*/
|
||||
OWNER_SIGN_LINE_1("$1ID: $1%type%", "Signs"),
|
||||
OWNER_SIGN_LINE_1("$1ID: $1%id%", "Signs"),
|
||||
OWNER_SIGN_LINE_2("$1Owner:", "Signs"),
|
||||
OWNER_SIGN_LINE_3("$2%plr%", "Signs"),
|
||||
OWNER_SIGN_LINE_4("$3Claimed", "Signs"),
|
||||
|
@ -20,15 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.database;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
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;
|
||||
@ -38,6 +29,15 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||
|
||||
/**
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ public interface AbstractDB {
|
||||
int getId(final Plot plot);
|
||||
|
||||
/**
|
||||
* Get the type of a given plot cluster
|
||||
* Get the id of a given plot cluster
|
||||
*
|
||||
* @param cluster PlotCluster Object
|
||||
*
|
||||
@ -193,7 +193,7 @@ public interface AbstractDB {
|
||||
/**
|
||||
* Purgle a plot
|
||||
*
|
||||
* @param uniqueIds list of plot type (db) to be purged
|
||||
* @param uniqueIds list of plot id (db) to be purged
|
||||
*/
|
||||
void purgeIds(final Set<Integer> uniqueIds);
|
||||
|
||||
|
@ -20,14 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.database;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
@ -38,6 +30,14 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||
|
||||
/**
|
||||
* Database Functions
|
||||
* - These functions do not update the local plot objects and only make changes to the DB
|
||||
@ -241,22 +241,12 @@ public class DBFunc {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot type
|
||||
* Get a plot id
|
||||
*
|
||||
* @param plot Plot Object
|
||||
*
|
||||
* @return ID
|
||||
*/
|
||||
/*
|
||||
* public static int getId(String plotId id2) { Statement stmt =
|
||||
* null; try { stmt = connection.createStatement(); ResultSet r =
|
||||
* stmt.executeQuery("SELECT `type` FROM `plot` WHERE `plot_id_x` = '" + id2.x
|
||||
* + "' AND `plot_id_z` = '" + id2.y + "' AND `world` = '" + world +
|
||||
* "' ORDER BY `timestamp` ASC"); int type = Integer.MAX_VALUE;
|
||||
* while(r.next()) { type = r.getInt("type"); } stmt.close(); return type; }
|
||||
* catch(SQLException e) { e.printStackTrace(); } return Integer.MAX_VALUE;
|
||||
* }
|
||||
*/
|
||||
public static int getId(final Plot plot) {
|
||||
return dbManager.getId(plot);
|
||||
}
|
||||
|
@ -20,24 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.database;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
import java.sql.Blob;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
@ -62,6 +44,24 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
@ -168,7 +168,7 @@ public class SQLManager implements AbstractDB {
|
||||
// setTimout();
|
||||
// Public final
|
||||
SET_OWNER = "UPDATE `" + prefix + "plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND `world` = ?";
|
||||
GET_ALL_PLOTS = "SELECT `type`, `plot_id_x`, `plot_id_z`, `world` FROM `" + prefix + "plot`";
|
||||
GET_ALL_PLOTS = "SELECT `id`, `plot_id_x`, `plot_id_z`, `world` FROM `" + prefix + "plot`";
|
||||
CREATE_PLOTS = "INSERT INTO `" + prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`, `timestamp`) values ";
|
||||
CREATE_SETTINGS = "INSERT INTO `" + prefix + "plot_settings` (`plot_plot_id`) values ";
|
||||
CREATE_TIERS = "INSERT INTO `" + prefix + "plot_%tier%` (`plot_plot_id`, `user_uuid`) values ";
|
||||
@ -481,7 +481,7 @@ public class SQLManager implements AbstractDB {
|
||||
final PreparedStatement stmt = connection.prepareStatement(GET_ALL_PLOTS);
|
||||
try (ResultSet result = stmt.executeQuery()) {
|
||||
while (result.next()) {
|
||||
final int id = result.getInt("type");
|
||||
final int id = result.getInt("id");
|
||||
final int x = result.getInt("plot_id_x");
|
||||
final int y = result.getInt("plot_id_z");
|
||||
final PlotId plotId = new PlotId(x, y);
|
||||
@ -616,7 +616,7 @@ public class SQLManager implements AbstractDB {
|
||||
@Override
|
||||
public String getCreateSQLite(final int size) {
|
||||
return getCreateSQLite(size, "INSERT INTO `" + prefix
|
||||
+ "plot` SELECT ? AS `type`, ? AS `plot_id_x`, ? AS `plot_id_z`, ? AS `owner`, ? AS `world`, ? AS `timestamp` ", 6);
|
||||
+ "plot` SELECT ? AS `id`, ? AS `plot_id_x`, ? AS `plot_id_z`, ? AS `owner`, ? AS `world`, ? AS `timestamp` ", 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -808,7 +808,7 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void setMySQL(final PreparedStatement stmt, final int i, final SettingsPair pair) throws SQLException {
|
||||
stmt.setInt((i * 10) + 1, pair.id); // type
|
||||
stmt.setInt((i * 10) + 1, pair.id); // id
|
||||
stmt.setNull((i * 10) + 2, 4); // biome
|
||||
stmt.setNull((i * 10) + 3, 4); // rain
|
||||
stmt.setNull((i * 10) + 4, 4); // custom_time
|
||||
@ -848,7 +848,7 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void setSQLite(final PreparedStatement stmt, final int i, final SettingsPair pair) throws SQLException {
|
||||
stmt.setInt((i * 10) + 1, pair.id); // type
|
||||
stmt.setInt((i * 10) + 1, pair.id); // id
|
||||
stmt.setNull((i * 10) + 2, 4); // biome
|
||||
stmt.setNull((i * 10) + 3, 4); // rain
|
||||
stmt.setNull((i * 10) + 4, 4); // custom_time
|
||||
@ -1434,7 +1434,7 @@ public class SQLManager implements AbstractDB {
|
||||
final ResultSet r = stmt.executeQuery();
|
||||
int c_id = Integer.MAX_VALUE;
|
||||
while (r.next()) {
|
||||
c_id = r.getInt("type");
|
||||
c_id = r.getInt("id");
|
||||
}
|
||||
stmt.close();
|
||||
r.close();
|
||||
@ -1470,7 +1470,7 @@ public class SQLManager implements AbstractDB {
|
||||
final ResultSet r = stmt.executeQuery();
|
||||
int id = Integer.MAX_VALUE;
|
||||
while (r.next()) {
|
||||
id = r.getInt("type");
|
||||
id = r.getInt("id");
|
||||
}
|
||||
r.close();
|
||||
stmt.close();
|
||||
@ -1648,7 +1648,7 @@ public class SQLManager implements AbstractDB {
|
||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||
while (r.next()) {
|
||||
PlotId plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
|
||||
id = r.getInt("type");
|
||||
id = r.getInt("id");
|
||||
final String areaid = r.getString("world");
|
||||
if (!areas.contains(areaid)) {
|
||||
if (Settings.AUTO_PURGE) {
|
||||
@ -1701,7 +1701,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
plots.put(id, p);
|
||||
}
|
||||
deleteRows(toDelete, "plot", "type");
|
||||
deleteRows(toDelete, "plot", "id");
|
||||
}
|
||||
if (Settings.CACHE_RATINGS) {
|
||||
try (ResultSet r = stmt.executeQuery("SELECT `plot_plot_id`, `player`, `rating` FROM `" + prefix + "plot_rating`")) {
|
||||
@ -2031,7 +2031,7 @@ public class SQLManager implements AbstractDB {
|
||||
final StringBuilder idstr2 = new StringBuilder("");
|
||||
for (final Integer id : uniqueIds) {
|
||||
idstr2.append(stmt_prefix).append(id);
|
||||
stmt_prefix = " OR `type` = ";
|
||||
stmt_prefix = " OR `id` = ";
|
||||
}
|
||||
stmt_prefix = "";
|
||||
final StringBuilder idstr = new StringBuilder("");
|
||||
@ -2079,7 +2079,7 @@ public class SQLManager implements AbstractDB {
|
||||
while (r.next()) {
|
||||
PlotId plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
|
||||
if (plots.contains(plot_id)) {
|
||||
ids.add(r.getInt("type"));
|
||||
ids.add(r.getInt("id"));
|
||||
}
|
||||
}
|
||||
purgeIds(ids);
|
||||
@ -2539,7 +2539,7 @@ public class SQLManager implements AbstractDB {
|
||||
while (r.next()) {
|
||||
PlotId pos1 = new PlotId(r.getInt("pos1_x"), r.getInt("pos1_z"));
|
||||
PlotId pos2 = new PlotId(r.getInt("pos2_x"), r.getInt("pos2_z"));
|
||||
id = r.getInt("type");
|
||||
id = r.getInt("id");
|
||||
String areaid = r.getString("world");
|
||||
if (!areas.contains(areaid)) {
|
||||
if (noExist.containsKey(areaid)) {
|
||||
|
@ -20,11 +20,11 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
public class Flag implements Cloneable {
|
||||
private AbstractFlag key;
|
||||
private Object value;
|
||||
@ -140,24 +140,9 @@ public class Flag implements Cloneable {
|
||||
return new Flag(key, method.invoke(value));
|
||||
}
|
||||
return new Flag(key, key.parseValueRaw(value.toString()));
|
||||
} catch (CloneNotSupportedException e) {
|
||||
} catch (CloneNotSupportedException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
return this;
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
return this;
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
return this;
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
return this;
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
return this;
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ public abstract class IndependentPlotGenerator {
|
||||
* Return a new PlotArea object
|
||||
* @param world world name
|
||||
* @param id (May be null) Area name
|
||||
* @param min Min plot type (may be null)
|
||||
* @param max Max plot type (may be null)
|
||||
* @param min Min plot id (may be null)
|
||||
* @param max Max plot id (may be null)
|
||||
* @return
|
||||
*/
|
||||
public abstract PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
|
||||
/**
|
||||
* Created 2015-02-11 for PlotSquared
|
||||
@ -162,13 +163,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 127;
|
||||
hash = hash * 31 + x;
|
||||
hash = hash * 31 + y;
|
||||
hash = hash * 31 + z;
|
||||
hash = (int) (hash * 31 + getYaw());
|
||||
hash = (int) (hash * 31 + getPitch());
|
||||
return hash * 31 + (world == null ? 127 : world.hashCode());
|
||||
return MathMan.pair((short) x, (short) z) * 17 + y;
|
||||
}
|
||||
|
||||
public boolean isInAABB(final Location min, final Location max) {
|
||||
@ -178,7 +173,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
public void lookTowards(final int x, final int y) {
|
||||
final double l = this.x - x;
|
||||
final double c = Math.sqrt(l * l + 0.0);
|
||||
if (Math.asin((double) 0 / c) / Math.PI * 180 > 90) {
|
||||
if (Math.asin(0 / c) / Math.PI * 180 > 90) {
|
||||
setYaw((float) (180 - -Math.asin(l / c) / Math.PI * 180));
|
||||
} else {
|
||||
setYaw((float) (-Math.asin(l / c) / Math.PI * 180));
|
||||
|
@ -20,6 +20,25 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
@ -41,22 +60,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* The plot class
|
||||
*/
|
||||
@ -1353,7 +1356,7 @@ public class Plot {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the top and bottom plot type.<br>
|
||||
* Returns the top and bottom plot id.<br>
|
||||
* - If the plot is not connected, it will return itself for the top/bottom<br>
|
||||
* - the returned ids will not necessarily correspond to claimed plots if the connected plots do not form a rectangular shape
|
||||
* @deprecated as merged plots no longer need to be rectangular
|
||||
@ -1427,7 +1430,7 @@ public class Plot {
|
||||
/**
|
||||
* Get plot display name
|
||||
*
|
||||
* @return alias if set, else type
|
||||
* @return alias if set, else id
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
@ -2231,6 +2234,25 @@ public class Plot {
|
||||
}, 1);
|
||||
}
|
||||
|
||||
public List<Location> getAllCorners() {
|
||||
Area area = new Area();
|
||||
for (RegionWrapper region : getRegions()) {
|
||||
Area rectArea = new Area(new Rectangle(region.minX, region.minZ, region.maxX - region.minX, region.maxZ - region.minZ));
|
||||
area.add(rectArea);
|
||||
}
|
||||
PathIterator iter = area.getPathIterator(null);
|
||||
List<Location> locs = new ArrayList<>();
|
||||
while (!iter.isDone()) {
|
||||
iter.next();
|
||||
double[] result = new double[6];
|
||||
iter.currentSegment(result);
|
||||
int x = (int) result[0];
|
||||
int z = (int) result[1];
|
||||
locs.add(new Location(this.area.worldname, x, 0, z));
|
||||
}
|
||||
return locs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleport a player to a plot and send them the teleport message.
|
||||
* @param player
|
||||
|
@ -45,7 +45,7 @@ public class PlotId {
|
||||
/**
|
||||
* Get a Plot Id based on a string
|
||||
*
|
||||
* @param string to create type from
|
||||
* @param string to create id from
|
||||
*
|
||||
* @return null if the string is invalid
|
||||
*/
|
||||
|
@ -36,7 +36,7 @@ public class SetupObject {
|
||||
public String setupGenerator = null;
|
||||
|
||||
/**
|
||||
* The management type
|
||||
* The management type (normal, augmented, partial)
|
||||
*/
|
||||
public int type;
|
||||
|
||||
@ -51,12 +51,12 @@ public class SetupObject {
|
||||
public String id;
|
||||
|
||||
/**
|
||||
* Minimum plot type (may be null)
|
||||
* Minimum plot id (may be null)
|
||||
*/
|
||||
public PlotId min;
|
||||
|
||||
/**
|
||||
* Max plot type (may be null)
|
||||
* Max plot id (may be null)
|
||||
*/
|
||||
public PlotId max;
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
@ -15,10 +19,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Rating;
|
||||
import com.plotsquared.listener.PlayerBlockEventType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class EventUtil {
|
||||
|
||||
public static EventUtil manager = null;
|
||||
@ -250,7 +250,7 @@ public abstract class EventUtil {
|
||||
}
|
||||
case SPAWN_MOB: {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
@ -269,26 +269,11 @@ public abstract class EventUtil {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case PLACE_HANGING:
|
||||
// if (plot == null) {
|
||||
// return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
// }
|
||||
// if (plot.owner == null) {
|
||||
// return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
// }
|
||||
//
|
||||
// if (FlagManager.isPlotFlagTrue(plot, "hanging-place")) {
|
||||
// return true;
|
||||
// }
|
||||
// Flag flag = FlagManager.getPlotFlag(plot, "place");
|
||||
// HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||
// if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||
// return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
// }
|
||||
case PLACE_HANGING: // Handled elsewhere
|
||||
return true;
|
||||
case PLACE_MISC: {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
@ -309,7 +294,7 @@ public abstract class EventUtil {
|
||||
}
|
||||
case PLACE_VEHICLE:
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
|
@ -20,6 +20,15 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -38,15 +47,6 @@ import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
* plot functions
|
||||
*
|
||||
@ -617,7 +617,6 @@ public class MainUtil {
|
||||
|
||||
/**
|
||||
* Format a string with plot information:<br>
|
||||
* %type%, %alias%, %num%, %desc%, %biome%, %owner%, %members%, %trusted%, %helpers%, %denied%, %flags%, %build%, %desc%, %rating%
|
||||
* @param info
|
||||
* @param plot
|
||||
* @param player
|
||||
|
Reference in New Issue
Block a user