diff --git a/README.md b/README.md
index ab1fb5b69..b90b8a6f2 100644
--- a/README.md
+++ b/README.md
@@ -13,12 +13,12 @@ is to provide a lag-free and smooth experience.
* [Spigot Page](https://www.spigotmc.org/resources/plotsquared.1177/)
* [WebChat/IRC](http://webchat.esper.net/?nick=&channels=IntellectualCrafters&fg_color=000&fg_sec_color=000&bg_color=FFF)
* [Wiki](https://github.com/intellectualcrafters/plotsquared/wiki)
-* [Website](http://plotsquared.com)
+* [~~Website~~](http://plotsquared.com)
### Developer Resources
* *Outdated* [JavaDocs](http://empcraft.com/plotsquared/doc/)
-* [Build Server](http://ci.intellectualsites.com/job/PlotSquared/)
-* [Maven Repo](http://mvn.intellectualsites.com/content/repositories/intellectualsites/)
+* [~~Build Server~~](http://ci.intellectualsites.com/job/PlotSquared/)
+* [~~Maven Repo~~](http://mvn.intellectualsites.com/content/repositories/intellectualsites/)
# Maven
@@ -52,4 +52,4 @@ Feel free to contribute, if you feel like you can improve the plugin in any way.
* [BiomeGenerator](https://www.spigotmc.org/resources/biomegenerator.1663/)
* [PlotSquaredMG](https://www.spigotmc.org/resources/plotsquaredmg.8025/)
* [BasicPlots](https://www.spigotmc.org/resources/basicplots.6901/)
-* [HoloPlots](https://www.spigotmc.org/resources/holoplots.4880/)
\ No newline at end of file
+* [HoloPlots](https://www.spigotmc.org/resources/holoplots.4880/)
diff --git a/pom.xml b/pom.xml
index a9966f278..76de12486 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
UTF-8
PlotSquared
- 3.2.17
+ 3.2.21
PlotSquared
jar
diff --git a/src/main/java/com/intellectualcrafters/plot/PS.java b/src/main/java/com/intellectualcrafters/plot/PS.java
index 4db8d5303..a5d67f3b3 100644
--- a/src/main/java/com/intellectualcrafters/plot/PS.java
+++ b/src/main/java/com/intellectualcrafters/plot/PS.java
@@ -90,7 +90,7 @@ import com.sk89q.worldedit.WorldEdit;
public class PS {
// protected static:
- public static PS instance;
+ private static PS instance;
// private final:
private final HashMap plotworlds = new HashMap<>();
@@ -699,7 +699,7 @@ public class PS {
try {
final ArrayList overflow = new ArrayList<>();
if ((range > limit) && (size > 1024)) {
- plots = new Plot[Math.min((int) range, limit)];
+ plots = new Plot[limit];
final int factor = (int) ((range / limit));
for (int i = 0; i < size; i++) {
Plot plot = list.get(i);
@@ -846,7 +846,7 @@ public class PS {
*/
@Deprecated
public void sortPlotsByHash(final Plot[] input) {
- final List[] bucket = new ArrayList[64];
+ final List[] bucket = new ArrayList[32];
for (int i = 0; i < bucket.length; i++) {
bucket[i] = new ArrayList();
}
@@ -856,19 +856,19 @@ public class PS {
maxLength = true;
for (final Plot i : input) {
tmp = MathMan.getPositiveId(i.hashCode()) / placement;
- bucket[tmp & 63].add(i);
+ bucket[tmp & 31].add(i);
if (maxLength && (tmp > 0)) {
maxLength = false;
}
}
int a = 0;
- for (int b = 0; b < 64; b++) {
+ for (int b = 0; b < 32; b++) {
for (final Plot i : bucket[b]) {
input[a++] = i;
}
bucket[b].clear();
}
- placement *= 64;
+ placement *= 32;
}
}
@@ -1068,8 +1068,8 @@ public class PS {
return strings.toArray(new String[strings.size()]);
}
- private String lastWorld;
- private Map lastMap;
+ private volatile String lastWorld;
+ private volatile Map lastMap;
/**
* Get a map of the plots for a world
@@ -1112,12 +1112,9 @@ public class PS {
return null;
}
lastWorld = world;
- if (plots.containsKey(world)) {
- lastMap = plots.get(world);
- if (lastMap != null) {
- return lastMap.get(id);
- }
- return null;
+ lastMap = plots.get(world);
+ if (lastMap != null) {
+ return lastMap.get(id);
}
return null;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Copy.java b/src/main/java/com/intellectualcrafters/plot/commands/Copy.java
index efdb27a66..ffcfe4bd0 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Copy.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Copy.java
@@ -67,7 +67,7 @@ public class Copy extends SubCommand {
C.COMMAND_SYNTAX.send(plr, getUsage());
return false;
}
- if (!plot1.getWorld().equals(plot2.getWorld())) {
+ if (!plot1.getWorld().isCompatible(plot2.getWorld())) {
C.PLOTWORLD_INCOMPATIBLE.send(plr);
return false;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Debug.java b/src/main/java/com/intellectualcrafters/plot/commands/Debug.java
index 76e5279a8..a5e8bb592 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Debug.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Debug.java
@@ -53,7 +53,6 @@ public class Debug extends SubCommand {
worlds.append(world).append(" ");
}
information.append(header);
- information.append(getSection(section, "Lag / TPS"));
information.append(getSection(section, "PlotWorld"));
information.append(getLine(line, "Plot Worlds", worlds));
information.append(getLine(line, "Owned Plots", PS.get().getPlots().size()));
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java
index aeaacb70a..0e44ff916 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java
@@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException;
import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
import org.bukkit.plugin.Plugin;
import com.intellectualcrafters.plot.PS;
@@ -34,7 +35,7 @@ public class DebugPaste extends SubCommand {
try {
latestLOG = HastebinUtility.upload(new File(BukkitMain.THIS.getDirectory(), "../../logs/latest.log"));
} catch (final Exception e) {
- plr.sendMessage("&clatest.log is too big to be pasted, will ignore");
+ plr.sendMessage(ChatColor.RED + "latest.log is too big to be pasted, will ignore");
latestLOG = "too big :(";
}
final StringBuilder b = new StringBuilder();
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/src/main/java/com/intellectualcrafters/plot/commands/Delete.java
index 0ed9a050e..29f9559c2 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Delete.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Delete.java
@@ -34,7 +34,6 @@ import com.intellectualcrafters.plot.util.EconHandler;
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;
@CommandDeclaration(
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java
index df84ccf02..9bc503dac 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java
@@ -158,6 +158,10 @@ public class FlagCmd extends SubCommand {
}
final 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(",")) {
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) {
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + entry);
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/src/main/java/com/intellectualcrafters/plot/commands/Info.java
index 7616317af..3a34d193e 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Info.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Info.java
@@ -134,12 +134,9 @@ public class Info extends SubCommand {
full = false;
}
MainUtil.format(info, plot, player, full, new RunnableVal() {
-
@Override
public void run() {
- MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
- MainUtil.sendMessage(player, value, false);
- MainUtil.sendMessage(player, C.PLOT_INFO_FOOTER);
+ MainUtil.sendMessage(player, C.PLOT_INFO_HEADER.s() + '\n' + value + '\n' + C.PLOT_INFO_FOOTER.s(), false);
}
});
return true;
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java
index 0d515cf6b..6fd9611be 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java
@@ -320,6 +320,9 @@ public class MainCommand extends CommandManager {
@Override
public int handle(final PlotPlayer plr, final String input) {
+ // Clear perm caching //
+ plr.deleteMeta("perm");
+ ////////////////////////
final String[] parts = input.split(" ");
String[] args;
String label;
@@ -333,7 +336,7 @@ public class MainCommand extends CommandManager {
}
Command cmd;
if (label != null) {
- cmd = getInstance().commands.get(label);
+ cmd = getInstance().commands.get(label.toLowerCase());
} else {
cmd = null;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/src/main/java/com/intellectualcrafters/plot/commands/Move.java
index 296d85f1e..8de95945c 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Move.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Move.java
@@ -67,7 +67,7 @@ public class Move extends SubCommand {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy ");
return false;
}
- if (!plot1.getWorld().equals(plot2.getWorld())) {
+ if (!plot1.getWorld().isCompatible(plot2.getWorld())) {
C.PLOTWORLD_INCOMPATIBLE.send(plr);
return false;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Owner.java b/src/main/java/com/intellectualcrafters/plot/commands/Owner.java
index e38b04835..896cf06fc 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Owner.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Owner.java
@@ -45,19 +45,32 @@ public class Owner extends SetCommand {
@Override
public boolean set(PlotPlayer plr, Plot plot, String value) {
HashSet plots = MainUtil.getConnectedPlots(plot);
- final PlotPlayer other = UUIDHandler.getPlayer(value);
- UUID uuid;
- uuid = other == null ? (Permissions.hasPermission(plr, "plots.admin.command.setowner") ? UUIDHandler.getUUID(value, null) : null) : other.getUUID();
+ UUID uuid = null;
+ String name = null;
+ if (value.length() == 36) {
+ try {
+ uuid = UUID.fromString(value);
+ name = MainUtil.getName(uuid);
+ } catch (Exception e) {}
+ } else {
+ uuid = UUIDHandler.getUUID(value, null);
+ name = UUIDHandler.getName(uuid);
+ name = name == null ? value : name;
+ }
if (uuid == null) {
- MainUtil.sendMessage(plr, C.INVALID_PLAYER, value);
+ C.INVALID_PLAYER.send(plr, value);
return false;
}
- String name = other == null ? UUIDHandler.getName(uuid) : other.getName();
if (plot.isOwner(uuid)) {
C.ALREADY_OWNER.send(plr);
return false;
}
+ PlotPlayer other = UUIDHandler.getPlayer(uuid);
if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
+ if (other == null) {
+ C.INVALID_PLAYER_OFFLINE.send(plr, value);
+ return false;
+ }
final int size = plots.size();
final int currentPlots = (Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(other) : MainUtil.getPlayerPlotCount(plot.world, other)) + size;
if (currentPlots > MainUtil.getAllowedPlots(other)) {
@@ -65,6 +78,7 @@ public class Owner extends SetCommand {
return false;
}
}
+
plot.setOwner(uuid);
MainUtil.setSign(name, plot);
MainUtil.sendMessage(plr, C.SET_OWNER);
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/src/main/java/com/intellectualcrafters/plot/commands/Rate.java
index 41eae2a02..13a73593c 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Rate.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Rate.java
@@ -77,6 +77,9 @@ public class Rate extends SubCommand {
v2 -= 11 - entry.getValue().getAverageRating();
}
}
+ if (v1 == v2) {
+ return -0;
+ }
return v2 > v1 ? 1 : -1;
}
});
@@ -184,7 +187,7 @@ public class Rate extends SubCommand {
final int rating;
if (MathMan.isInteger(arg) && (arg.length() < 3) && (arg.length() > 0)) {
rating = Integer.parseInt(arg);
- if (rating > 10) {
+ if (rating > 10 || rating < 1) {
sendMessage(player, C.RATING_NOT_VALID);
return false;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java b/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java
index 1d2c84e9d..54c24a1d5 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java
@@ -20,7 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
-import java.util.List;
import java.util.Set;
import com.intellectualcrafters.plot.PS;
@@ -32,23 +31,18 @@ import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
-import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(
command = "regenallroads",
description = "Regenerate all roads in the map using the set road schematic",
aliases = { "rgar" },
-usage = "/plot regenallroads ",
+usage = "/plot regenallroads [height]",
category = CommandCategory.DEBUG,
requiredType = RequiredType.CONSOLE,
permission = "plots.regenallroads")
public class RegenAllRoads extends SubCommand {
- public RegenAllRoads() {
- requiredArguments = new Argument[] { Argument.String };
- }
-
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
int height = 0;
@@ -60,6 +54,9 @@ public class RegenAllRoads extends SubCommand {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads [height]");
return false;
}
+ } else {
+ MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads [height]");
+ return false;
}
final String name = args[0];
final PlotManager manager = PS.get().getPlotManager(name);
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/src/main/java/com/intellectualcrafters/plot/commands/Set.java
index b510da328..f85042991 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Set.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Set.java
@@ -59,6 +59,12 @@ public class Set extends SubCommand {
public Set() {
component = new SetCommand() {
+
+ @Override
+ public String getCommand() {
+ return "set.component";
+ }
+
@Override
public boolean set(PlotPlayer plr, final Plot plot, String value) {
final String world = plr.getLocation().getWorld();
@@ -171,7 +177,7 @@ public class Set extends SubCommand {
// components
HashSet components = new HashSet(Arrays.asList(plot.getManager().getPlotComponents(plot.getWorld(), plot.id)));
if (components.contains(args[0].toLowerCase())) {
- return component.set(plr, plot, StringMan.join(args, " "));
+ return component.onCommand(plr, Arrays.copyOfRange(args, 0, args.length));
}
// flag
{
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/src/main/java/com/intellectualcrafters/plot/commands/Swap.java
index ec66d3b8d..473697f4f 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Swap.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Swap.java
@@ -55,7 +55,7 @@ public class Swap extends SubCommand {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy ");
return false;
}
- if (!plot1.getWorld().equals(plot2.getWorld())) {
+ if (!plot1.getWorld().isCompatible(plot2.getWorld())) {
C.PLOTWORLD_INCOMPATIBLE.send(plr);
return false;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Update.java b/src/main/java/com/intellectualcrafters/plot/commands/Update.java
index f52f26f52..1192fa221 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Update.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Update.java
@@ -31,7 +31,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(
command = "update",
-permission = "plots.admin",
+permission = "plots.admin.command.update",
description = "Update PlotSquared",
usage = "/plot update",
requiredType = RequiredType.NONE,
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/list.java b/src/main/java/com/intellectualcrafters/plot/commands/list.java
index 5398b7499..aea24b87a 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/list.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/list.java
@@ -331,7 +331,7 @@ public class list extends SubCommand {
}
}
if (sort) {
- plots = PS.get().sortPlots(plots, SortType.DISTANCE_FROM_ORIGIN, world);
+ plots = PS.get().sortPlots(plots, SortType.CREATION_DATE, world);
}
if (page < 0) {
page = 0;
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/plugin.java b/src/main/java/com/intellectualcrafters/plot/commands/plugin.java
index 4b42d63ab..ebc514c6f 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/plugin.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/plugin.java
@@ -34,7 +34,6 @@ public class plugin extends SubCommand {
MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().IMP.getPluginVersion(), ".")));
MainUtil.sendMessage(plr, String.format("$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92"));
MainUtil.sendMessage(plr, String.format("$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki"));
- MainUtil.sendMessage(plr, String.format("$2>> $1&lWebsite$2: $1http://plotsquared.com"));
MainUtil.sendMessage(plr, String.format("$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? StringMan.join(PS.get().IMP.getPluginVersion(), ".") : PS.get().update)));
return true;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/config/C.java b/src/main/java/com/intellectualcrafters/plot/config/C.java
index 2f64e35e3..f4aa447d7 100644
--- a/src/main/java/com/intellectualcrafters/plot/config/C.java
+++ b/src/main/java/com/intellectualcrafters/plot/config/C.java
@@ -90,6 +90,7 @@ public enum C {
PERMISSION_ADMIN_INTERACT_UNOWNED("plots.admin.interact.unowned", "static.permissions"),
PERMISSION_ADMIN_INTERACT_OTHER("plots.admin.interact.other", "static.permissions"),
PERMISSION_ADMIN_BUILD_HEIGHTLIMIT("plots.admin.build.heightlimit", "static.permissions"),
+ PERMISSION_ADMIN_UPDATE("plots.admin.command.update", "static.permissions"),
/*
* Static console
*/
@@ -373,7 +374,8 @@ public enum C {
* Player not found
*/
INVALID_PLAYER_WAIT("$2Player not found: $1%s$2, fetching it. Try again soon.", "Errors"),
- INVALID_PLAYER("$2Player not found: $1%s.", "Errors"),
+ INVALID_PLAYER("$2Player not found: $1%s$2.", "Errors"),
+ INVALID_PLAYER_OFFLINE("$2The player must be online: $1%s.", "Errors"),
// SETTINGS_PASTE_UPLOADED("$2settings.yml was uploaded to: $1%url%", "Paste"),
// LATEST_LOG_UPLOADED("$2latest.log was uploaded to: $1%url%", "Paste"),
DEBUG_REPORT_CREATED("$1Uploaded a full debug to: $1%url%", "Paste"),
@@ -673,14 +675,18 @@ public enum C {
final Map map = new LinkedHashMap();
if (args.length > 0) {
for (int i = args.length - 1; i >= 0; i--) {
- if (args[i] == null) {
- args[i] = "";
+ String arg = args[i].toString();
+ if (arg == null || arg.length() == 0) {
+ map.put("%s" + i, "");
+ } else {
+ arg = C.color(arg);
+ map.put("%s" + i, arg);
+ }
+ if (i == 0) {
+ map.put("%s", arg);
}
- map.put("%s" + i, args[i].toString());
}
- map.put("%s", args[0].toString());
}
- map.putAll(replacements);
m = StringMan.replaceFromMap(m, map);
return m;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/src/main/java/com/intellectualcrafters/plot/config/Settings.java
index 889b27e75..7300e6d45 100644
--- a/src/main/java/com/intellectualcrafters/plot/config/Settings.java
+++ b/src/main/java/com/intellectualcrafters/plot/config/Settings.java
@@ -40,7 +40,7 @@ public class Settings {
/**
* Default UUID_FECTHING: false
*/
- public static boolean PERMISSION_CACHING = false;
+ public static boolean PERMISSION_CACHING = true;
public static boolean CACHE_RATINGS = true;
public static boolean UUID_FROM_DISK = false;
diff --git a/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
index 208298ce0..ac6d556a1 100644
--- a/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
+++ b/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
@@ -575,9 +575,9 @@ public class SQLManager implements AbstractDB {
stmt.setInt((i * 5) + 1, plot.id.x);
stmt.setInt((i * 5) + 2, plot.id.y);
try {
- stmt.setString((i * 4) + 3, plot.owner.toString());
+ stmt.setString((i * 5) + 3, plot.owner.toString());
} catch (final Exception e) {
- stmt.setString((i * 4) + 3, everyone.toString());
+ stmt.setString((i * 5) + 3, everyone.toString());
}
stmt.setString((i * 5) + 4, plot.world);
stmt.setTimestamp((i * 5) + 5, new Timestamp(plot.getTimestamp()));
@@ -1193,6 +1193,9 @@ public class SQLManager implements AbstractDB {
@Override
public void deleteSettings(final Plot plot) {
+ if (plot.settings == null) {
+ return;
+ }
addPlotTask(plot, new UniqueStatement("delete_plot_settings") {
@Override
public void set(final PreparedStatement stmt) throws SQLException {
@@ -1301,7 +1304,6 @@ public class SQLManager implements AbstractDB {
*/
@Override
public void delete(final Plot plot) {
- PS.get().removePlot(plot.world, plot.id, false);
deleteSettings(plot);
deleteDenied(plot);
deleteHelpers(plot);
@@ -1736,7 +1738,7 @@ public class SQLManager implements AbstractDB {
map = new ConcurrentHashMap();
newplots.put(plot.world, map);
}
- newplots.get(plot.world).put(plot.id, plot);
+ map.put(plot.id, plot);
}
}
boolean invalidPlot = false;
@@ -2817,7 +2819,7 @@ public class SQLManager implements AbstractDB {
final ConcurrentHashMap map = entry.getValue();
if (map.size() > 0) {
for (final Entry entry2 : map.entrySet()) {
- PS.debug("$1Plot was deleted: " + entry.getValue() + "// TODO implement this when sure safe");
+ PS.debug("$1Plot was deleted: " + entry2.getValue() + "// TODO implement this when sure safe");
}
}
}
diff --git a/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java
index 6fe60e347..3c59ccec2 100644
--- a/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java
+++ b/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java
@@ -157,8 +157,16 @@ public class FlagManager {
return result == null ? null : (Flag) result.clone();
}
+ /**
+ * Returns the raw flag
+ * - Faster
+ * - You should not modify the flag
+ * @param plot
+ * @param flag
+ * @return
+ */
public static Flag getPlotFlagRaw(final Plot plot, final String flag) {
- if (!plot.hasOwner()) {
+ if (plot.owner == null) {
return null;
}
return getSettingFlag(plot.world, plot.getSettings(), flag);
diff --git a/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java b/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java
index 730217706..860116ff2 100644
--- a/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java
+++ b/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java
@@ -28,9 +28,21 @@ public class ClassicPlotManager extends SquarePlotManager {
return true;
}
case "all": {
+ setAll(plotworld, plotid, blocks);
+ return true;
+ }
+ case "air": {
setAir(plotworld, plotid, blocks);
return true;
}
+ case "main": {
+ setMain(plotworld, plotid, blocks);
+ return true;
+ }
+ case "middle": {
+ setMiddle(plotworld, plotid, blocks);
+ return true;
+ }
case "outline": {
setOutline(plotworld, plotid, blocks);
return true;
@@ -67,6 +79,20 @@ public class ClassicPlotManager extends SquarePlotManager {
return true;
}
+ public boolean setAll(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
+ Plot plot = MainUtil.getPlotAbs(plotworld.worldname, plotid);
+ if (!plot.isBasePlot()) {
+ return false;
+ }
+ final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
+ for (RegionWrapper region : MainUtil.getRegions(plot)) {
+ Location pos1 = new Location(plot.world, region.minX, 1, region.minZ);
+ Location pos2 = new Location(plot.world, region.maxX, 255, region.maxZ);
+ MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks);
+ }
+ return true;
+ }
+
public boolean setAir(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
Plot plot = MainUtil.getPlotAbs(plotworld.worldname, plotid);
if (!plot.isBasePlot()) {
@@ -81,6 +107,31 @@ public class ClassicPlotManager extends SquarePlotManager {
return true;
}
+ public boolean setMain(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
+ Plot plot = MainUtil.getPlotAbs(plotworld.worldname, plotid);
+ if (!plot.isBasePlot()) {
+ return false;
+ }
+ final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
+ for (RegionWrapper region : MainUtil.getRegions(plot)) {
+ Location pos1 = new Location(plot.world, region.minX, 1, region.minZ);
+ Location pos2 = new Location(plot.world, region.maxX, dpw.PLOT_HEIGHT - 1, region.maxZ);
+ MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks);
+ }
+ return true;
+ }
+
+ public boolean setMiddle(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
+ Plot plot = MainUtil.getPlotAbs(plotworld.worldname, plotid);
+ if (!plot.isBasePlot()) {
+ return false;
+ }
+ Location[] corners = plot.getCorners();
+ final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
+ SetBlockQueue.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 PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
if (dpw.ROAD_WIDTH == 0) {
@@ -227,7 +278,7 @@ public class ClassicPlotManager extends SquarePlotManager {
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, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT, ez - 1), new PlotBlock((short) 7,
+ 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),
@@ -368,7 +419,7 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override
public String[] getPlotComponents(final PlotWorld plotworld, final PlotId plotid) {
- return new String[] { "floor", "wall", "border", "all", "outline" };
+ return new String[] { "main", "floor", "air", "all", "border", "wall", "outline", "middle" };
}
/**
diff --git a/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java b/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java
index dba8884d6..2cdda4176 100644
--- a/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java
+++ b/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java
@@ -28,6 +28,7 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotLoc;
+import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.schematic.PlotItem;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
@@ -72,6 +73,14 @@ public class HybridPlotWorld extends ClassicPlotWorld {
}
}
+ @Override
+ public boolean isCompatible(PlotWorld plotworld) {
+ if (plotworld == null || !(plotworld instanceof SquarePlotWorld)) {
+ return false;
+ }
+ return ((ClassicPlotWorld) plotworld).PLOT_WIDTH == PLOT_WIDTH;
+ }
+
public void setupSchematics() {
G_SCH_DATA = new HashMap<>();
G_SCH = new HashMap<>();
diff --git a/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java b/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java
index 7db5fc771..938aea5de 100644
--- a/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java
+++ b/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java
@@ -11,7 +11,6 @@ import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
-import com.intellectualcrafters.plot.util.StringMan;
/**
* A plot manager with a square grid layout, with square shaped plots
@@ -93,83 +92,87 @@ public abstract class SquarePlotManager extends GridPlotManager {
@Override
public PlotId getPlotId(final PlotWorld plotworld, int x, final int y, int z) {
- final 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 pathWidthLower;
- final int end;
- if (dpw.ROAD_WIDTH == 0) {
- pathWidthLower = -1;
- end = dpw.PLOT_WIDTH;
- } else {
- if ((dpw.ROAD_WIDTH % 2) == 0) {
- pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1;
- } else {
- pathWidthLower = dpw.ROAD_WIDTH / 2;
+ try {
+ final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
+ if (plotworld == null) {
+ return null;
}
- end = pathWidthLower + dpw.PLOT_WIDTH;
+ x -= dpw.ROAD_OFFSET_X;
+ z -= dpw.ROAD_OFFSET_Z;
+ final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
+ int pathWidthLower;
+ final int end;
+ if (dpw.ROAD_WIDTH == 0) {
+ pathWidthLower = -1;
+ end = dpw.PLOT_WIDTH;
+ } else {
+ if ((dpw.ROAD_WIDTH % 2) == 0) {
+ pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1;
+ } else {
+ pathWidthLower = dpw.ROAD_WIDTH / 2;
+ }
+ end = pathWidthLower + dpw.PLOT_WIDTH;
+ }
+ int dx;
+ int dz;
+ int rx;
+ int rz;
+ if (x < 0) {
+ dx = (x / size);
+ rx = size + (x % size);
+ } else {
+ dx = (x / size) + 1;
+ rx = (x % size);
+ }
+ if (z < 0) {
+ dz = (z / size);
+ rz = size + (z % size);
+ } else {
+ dz = (z / size) + 1;
+ rz = (z % size);
+ }
+ PlotId id = new PlotId(dx, dz);
+ boolean[] merged = new boolean[] { (rz <= pathWidthLower), (rx > end), (rz > end), (rx <= pathWidthLower) };
+ int hash = MainUtil.hash(merged);
+ // Not merged, and no need to check if it is
+ if (hash == 0) {
+ return id;
+ }
+ Plot plot = PS.get().getPlot(plotworld.worldname, id);
+ // Not merged, and standing on road
+ if (plot == null) {
+ return null;
+ }
+ switch (hash) {
+ case 8:
+ // north
+ return plot.getMerged(0) ? id : null;
+ case 4:
+ // east
+ return plot.getMerged(1) ? id : null;
+ case 2:
+ // south
+ return plot.getMerged(2) ? id : null;
+ case 1:
+ // west
+ return plot.getMerged(3) ? id : null;
+ case 12:
+ // northest
+ return plot.getMerged(4) ? id : null;
+ case 6:
+ // southeast
+ return plot.getMerged(5) ? id : null;
+ case 3:
+ // southwest
+ return plot.getMerged(6) ? id : null;
+ case 9:
+ // northwest
+ return plot.getMerged(7) ? id : null;
+ }
+ PS.debug("invalid location: " + merged);
+ } catch (Exception e) {
+ PS.debug("Invalid plot / road width in settings.yml for world: " + plotworld.worldname);
}
- int dx;
- int dz;
- int rx;
- int rz;
- if (x < 0) {
- dx = (x / size);
- rx = size + (x % size);
- } else {
- dx = (x / size) + 1;
- rx = (x % size);
- }
- if (z < 0) {
- dz = (z / size);
- rz = size + (z % size);
- } else {
- dz = (z / size) + 1;
- rz = (z % size);
- }
- PlotId id = new PlotId(dx, dz);
- boolean[] merged = new boolean[] {(rz <= pathWidthLower), (rx > end), (rz > end), (rx <= pathWidthLower)};
- int hash = MainUtil.hash(merged);
- // Not merged, and no need to check if it is
- if (hash == 0) {
- return id;
- }
- Plot plot = PS.get().getPlot(plotworld.worldname, id);
- // Not merged, and standing on road
- if (plot == null) {
- return null;
- }
- switch (hash) {
- case 8:
- // north
- return plot.getMerged(0) ? id : null;
- case 4:
- // east
- return plot.getMerged(1) ? id : null;
- case 2:
- // south
- return plot.getMerged(2) ? id : null;
- case 1:
- // west
- return plot.getMerged(3) ? id : null;
- case 12:
- // northest
- return plot.getMerged(4) ? id : null;
- case 6:
- // southeast
- return plot.getMerged(5) ? id : null;
- case 3:
- // southwest
- return plot.getMerged(6) ? id : null;
- case 9:
- // northwest
- return plot.getMerged(7) ? id : null;
- }
- PS.debug("invalid location: " + merged);
return null;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java b/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java
index b24515c78..140b73f10 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java
@@ -129,8 +129,8 @@ public class ConsolePlayer extends PlotPlayer {
}
@Override
- public void deleteMeta(final String key) {
- meta.remove(key);
+ public Object deleteMeta(final String key) {
+ return meta.remove(key);
}
@Override
diff --git a/src/main/java/com/intellectualcrafters/plot/object/Location.java b/src/main/java/com/intellectualcrafters/plot/object/Location.java
index 0fd71e17c..9a06d4c92 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/Location.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/Location.java
@@ -84,6 +84,10 @@ public class Location implements Cloneable, Comparable {
public Plot getPlot() {
return MainUtil.getPlot(this);
}
+
+ public ChunkLoc getChunkLoc() {
+ return new ChunkLoc(x >> 4, z >> 4);
+ }
public void setWorld(final String world) {
this.world = world;
diff --git a/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/src/main/java/com/intellectualcrafters/plot/object/Plot.java
index 9ac9d13d0..865a68e5d 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/Plot.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/Plot.java
@@ -416,7 +416,6 @@ public class Plot {
*/
private Plot origin;
-
/**
* The base plot is an arbitrary but specific connected plot. It is useful for the following:
* - Merged plots need to be treated as a single plot for most purposes
@@ -721,7 +720,7 @@ public class Plot {
*/
public double getAverageRating() {
double sum = 0;
- final Collection ratings = getBasePlot(false).getRatings().values();
+ final Collection ratings = getRatings().values();
for (final Rating rating : ratings) {
sum += rating.getAverageRating();
}
@@ -1013,7 +1012,7 @@ public class Plot {
public boolean removeDenied(final UUID uuid) {
if (uuid == DBFunc.everyone) {
boolean result = false;
- for (UUID other : getDenied()) {
+ for (UUID other : new HashSet<>(getDenied())) {
result = result || PlotHandler.removeDenied(this, other);
}
return result;
@@ -1029,7 +1028,7 @@ public class Plot {
public boolean removeTrusted(final UUID uuid) {
if (uuid == DBFunc.everyone) {
boolean result = false;
- for (UUID other : getTrusted()) {
+ for (UUID other : new HashSet<>(getTrusted())) {
result = result || PlotHandler.removeTrusted(this, other);
}
return result;
@@ -1045,7 +1044,7 @@ public class Plot {
public boolean removeMember(final UUID uuid) {
if (uuid == DBFunc.everyone) {
boolean result = false;
- for (UUID other : getMembers()) {
+ for (UUID other : new HashSet<>(getMembers())) {
result = result || PlotHandler.removeMember(this, other);
}
return result;
diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java b/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java
index f0f13ea72..5996cb125 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java
@@ -237,9 +237,9 @@ public class PlotHandler {
return false;
}
for (Plot current : MainUtil.getConnectedPlots(plot)) {
- current.settings = null;
PS.get().removePlot(current.world, current.id, true);
DBFunc.delete(current);
+ current.settings = null;
}
return true;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java
index 51e21c44c..bf6804dfe 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java
@@ -80,10 +80,8 @@ public abstract class PlotPlayer implements CommandCaller {
* - deleting other plugin's metadata may cause issues
* @param key
*/
- public void deleteMeta(final String key) {
- if (meta != null) {
- meta.remove(key);
- }
+ public Object deleteMeta(final String key) {
+ return meta == null ? null : meta.remove(key);
}
/**
diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java
index d5f4e58b7..5781a0c25 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java
@@ -126,6 +126,10 @@ public abstract class PlotWorld {
return true;
}
+ public boolean isCompatible(PlotWorld plotworld) {
+ return equals(plotworld);
+ }
+
/**
* When a world is created, the following method will be called for each
*
@@ -275,6 +279,9 @@ public abstract class PlotWorld {
config.set(option, options.get(option));
}
}
+ if (!config.contains("flags")) {
+ config.set("flags.use", "63,64,68,69,71,77,96,143,167,193,194,195,196,197,77,143,69,70,72,147,148,107,183,184,185,186,187,132");
+ }
}
/**
diff --git a/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java b/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java
index d90e429be..119c5f7c8 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java
@@ -107,12 +107,11 @@ public abstract class ChunkManager {
public abstract void unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe);
public Set getChunkChunks(final String world) {
- final String directory = PS.get().IMP.getWorldContainer() + File.separator + world + File.separator + "region";
- final File folder = new File(directory);
+ final File folder = new File(PS.get().IMP.getWorldContainer(), world + File.separator + "region");
final File[] regionFiles = folder.listFiles();
final HashSet chunks = new HashSet<>();
if (regionFiles == null) {
- throw new RuntimeException("Could not find worlds folder.");
+ throw new RuntimeException("Could not find worlds folder: " + folder + " ? (no read access?)");
}
for (final File file : regionFiles) {
final String name = file.getName();
diff --git a/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java b/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java
index 54d5e551a..f5c7e88f2 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java
@@ -63,12 +63,11 @@ public abstract class EventUtil {
public boolean checkPlayerBlockEvent(final PlotPlayer pp, final PlayerBlockEventType type, final Location loc, final LazyBlock block, boolean notifyPerms) {
final Plot plot = MainUtil.getPlotAbs(loc);
- final UUID uuid = pp.getUUID();
if (plot == null) {
if (!MainUtil.isPlotAreaAbs(loc)) {
return true;
}
- } else if (plot.isAdded(uuid)) {
+ } else if (plot.isAdded(pp.getUUID())) {
return true;
}
switch (type) {
@@ -83,7 +82,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
}
- if (!plot.hasOwner()) {
+ if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
final Flag use = FlagManager.getPlotFlagRaw(plot, "use");
@@ -151,7 +150,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
}
- if (!plot.hasOwner()) {
+ if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
@@ -168,7 +167,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD.s(), notifyPerms);
}
- if (!plot.hasOwner()) {
+ if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED.s(), notifyPerms);
}
final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
@@ -185,7 +184,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), false);
}
- if (!plot.hasOwner()) {
+ if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), false);
}
if (FlagManager.isPlotFlagTrue(plot, "device-interact")) {
@@ -194,12 +193,10 @@ public abstract class EventUtil {
final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
final HashSet value = flag == null ? null : (HashSet) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
- long time = System.currentTimeMillis();
- notifyPerms = notifyPerms && (31 * (time / 31) == time);
- if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
+ if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
return true;
}
- return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_DEVICE_INTERACT.s()));
+ return !(!false || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_DEVICE_INTERACT.s()));
}
return true;
}
@@ -207,7 +204,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
}
- if (!plot.hasOwner()) {
+ if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
if (FlagManager.isPlotFlagTrue(plot, "hanging-interact")) {
@@ -227,7 +224,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
}
- if (!plot.hasOwner()) {
+ if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
if (FlagManager.isPlotFlagTrue(plot, "misc-interact")) {
@@ -247,7 +244,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
}
- if (!plot.hasOwner()) {
+ if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
if (FlagManager.isPlotFlagTrue(plot, "vehicle-use")) {
@@ -267,7 +264,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
}
- if (!plot.hasOwner()) {
+ if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
@@ -288,7 +285,7 @@ public abstract class EventUtil {
// if (plot == null) {
// return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
// }
- // if (!plot.hasOwner()) {
+ // if (plot.owner == null) {
// return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
// }
//
@@ -306,7 +303,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
}
- if (!plot.hasOwner()) {
+ if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
@@ -327,7 +324,7 @@ public abstract class EventUtil {
if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
}
- if (!plot.hasOwner()) {
+ if (plot.owner == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
diff --git a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
index fe993580b..5dc1ff85a 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
@@ -20,6 +20,7 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.util;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
@@ -36,6 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
+import com.google.common.collect.BiMap;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
@@ -56,6 +58,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
+import com.intellectualcrafters.plot.object.StringWrapper;
import com.plotsquared.listener.PlotListener;
/**
@@ -563,6 +566,9 @@ public class MainUtil {
}
public static boolean isPlotAreaAbs(final Location location) {
+ if (!Settings.ENABLE_CLUSTERS) {
+ return true;
+ }
final PlotWorld plotworld = PS.get().getPlotWorld(location.getWorld());
if (plotworld == null) {
return false;
@@ -586,6 +592,9 @@ public class MainUtil {
}
public static boolean isPlotArea(final Plot plot) {
+ if (!Settings.ENABLE_CLUSTERS) {
+ return true;
+ }
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
if (plotworld.TYPE == 2) {
return plot.getCluster() != null;
@@ -1421,7 +1430,9 @@ public class MainUtil {
final HashSet regions = getRegions(plot);
final HashSet plots = getConnectedPlots(plot);
final ArrayDeque queue = new ArrayDeque<>(plots);
- removeSign(plot);
+ if (isDelete) {
+ removeSign(plot);
+ }
MainUtil.unlinkPlot(plot, true, !isDelete);
final PlotManager manager = PS.get().getPlotManager(plot.world);
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
@@ -1718,6 +1729,12 @@ public class MainUtil {
return true;
}
+ /**
+ * Check if a plot can be claimed
+ * @param player
+ * @param plot
+ * @return
+ */
public static boolean canClaim(final PlotPlayer player, final Plot plot) {
if (plot == null) {
return false;
@@ -1730,7 +1747,66 @@ public class MainUtil {
}
}
}
- return plot.owner == null;
+ return guessOwner(plot) == null;
+ }
+
+ /**
+ * Try to guess who the plot owner is:
+ * - Checks cache
+ * - Checks sign text
+ * @param plot
+ * @return
+ */
+ public static UUID guessOwner(Plot plot) {
+ if (plot.owner != null) {
+ return plot.owner;
+ }
+ PlotWorld pw = plot.getWorld();
+ if (!pw.ALLOW_SIGNS) {
+ return null;
+ }
+ try {
+ Location loc = plot.getManager().getSignLoc(pw, plot);
+ ChunkManager.manager.loadChunk(loc.getWorld(), loc.getChunkLoc(), false);
+ String[] lines = BlockManager.manager.getSign(loc);
+ if (lines == null) {
+ return null;
+ }
+ loop: for (int i = 4; i > 0; i--) {
+ String caption = C.valueOf("OWNER_SIGN_LINE_" + i).s();
+ int index = caption.indexOf("%plr%");
+ if (index == -1) {
+ continue;
+ }
+ String name = lines[i - 1].substring(index);
+ if (name.length() == 0) {
+ return null;
+ }
+ UUID owner = UUIDHandler.getUUID(name, null);
+ if (owner != null) {
+ plot.owner = owner;
+ break;
+ }
+ if (lines[i - 1].length() == 15) {
+ BiMap map = UUIDHandler.getUuidMap();
+ for (Entry entry : map.entrySet()) {
+ String key = entry.getKey().value;
+ if (key.length() > name.length() && key.startsWith(name)) {
+ plot.owner = entry.getValue();
+ break loop;
+ }
+ }
+ }
+ plot.owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8));
+ break;
+ }
+ if (plot.owner != null) {
+ plot.create();
+ }
+ return plot.owner;
+ } catch (Exception e) {
+ return null;
+ }
}
public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) {
@@ -2104,18 +2180,7 @@ public class MainUtil {
* @return boolean success
*/
public static boolean sendMessage(final PlotPlayer plr, final C c, final String... args) {
- if (c.s().length() > 1) {
- String msg = c.s();
- if ((args != null) && (args.length > 0)) {
- msg = C.format(c, args);
- }
- if (plr == null) {
- ConsolePlayer.getConsole().sendMessage(msg);
- } else {
- sendMessage(plr, msg, c.usePrefix());
- }
- }
- return true;
+ return sendMessage(plr, c, (Object[]) args);
}
/**
@@ -2127,17 +2192,23 @@ public class MainUtil {
* @return boolean success
*/
public static boolean sendMessage(final PlotPlayer plr, final C c, final Object... args) {
- if (c.s().length() > 1) {
- String msg = c.s();
- if ((args != null) && (args.length > 0)) {
- msg = C.format(c, args);
- }
- if (plr == null) {
- ConsolePlayer.getConsole().sendMessage(msg);
- } else {
- sendMessage(plr, msg, c.usePrefix());
- }
+ if (c.s().length() == 0) {
+ return true;
}
+ TaskManager.runTaskAsync(new Runnable() {
+ @Override
+ public void run() {
+ String msg = c.s();
+ if (args.length != 0) {
+ msg = c.format(c, args);
+ }
+ if (plr != null) {
+ plr.sendMessage((c.usePrefix() ? C.PREFIX.s() + msg : msg));
+ } else {
+ ConsolePlayer.getConsole().sendMessage((c.usePrefix() ? C.PREFIX.s() : "") + msg);
+ }
+ }
+ });
return true;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/util/Permissions.java b/src/main/java/com/intellectualcrafters/plot/util/Permissions.java
index b2f82d302..cf93cb97d 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/Permissions.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/Permissions.java
@@ -1,6 +1,9 @@
package com.intellectualcrafters.plot.util;
+import java.util.HashMap;
+
import com.intellectualcrafters.plot.config.C;
+import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.general.commands.CommandCaller;
@@ -10,7 +13,22 @@ public class Permissions {
}
public static boolean hasPermission(final PlotPlayer player, final String perm) {
- return hasPermission((CommandCaller) player, perm);
+ if (!Settings.PERMISSION_CACHING) {
+ return hasPermission((CommandCaller) player, perm);
+ }
+ HashMap map = (HashMap) player.getMeta("perm");
+ if (map != null) {
+ Boolean result = map.get(perm);
+ if (result != null) {
+ return result;
+ }
+ } else {
+ map = new HashMap<>();
+ player.setMeta("perm", map);
+ }
+ boolean result = hasPermission((CommandCaller) player, perm);
+ map.put(perm, result);
+ return result;
}
public static boolean hasPermission(final CommandCaller player, String perm) {
diff --git a/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java
index 5cd5c8980..107c253ec 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java
@@ -519,6 +519,7 @@ public abstract class SchematicHandler {
}
public List getSaves(final UUID uuid) {
+ final StringBuilder rawJSON = new StringBuilder();
try {
final String website = Settings.WEB_URL + "list.php?" + uuid.toString();
final URL url = new URL(website);
@@ -526,7 +527,6 @@ public abstract class SchematicHandler {
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
- final StringBuilder rawJSON = new StringBuilder();
while ((line = reader.readLine()) != null) {
rawJSON.append(line);
}
@@ -540,6 +540,7 @@ public abstract class SchematicHandler {
return Lists.reverse(schematics);
} catch (final Exception e) {
e.printStackTrace();
+ PS.debug("ERROR PARSING: " + rawJSON);
}
return null;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java b/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java
index 4eeeabb9e..3004c965e 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java
@@ -116,11 +116,11 @@ public abstract class UUIDHandlerImplementation {
offline = null;
}
}
- if (offline != null) {
+ if (offline != null && !offline.equals(uuid)) {
unknown.remove(offline);
final Set plots = PS.get().getPlots(offline);
if (plots.size() > 0) {
- for (final Plot plot : PS.get().getPlots(offline)) {
+ for (final Plot plot : plots) {
plot.owner = uuid;
}
DBFunc.replaceUUID(offline, uuid);
@@ -132,17 +132,21 @@ public abstract class UUIDHandlerImplementation {
}
try {
final UUID offline = uuidMap.put(name, uuid);
- if ((offline != null) && !offline.equals(uuid)) {
- final Set plots = PS.get().getPlots(offline);
- if (plots.size() > 0) {
- for (final Plot plot : PS.get().getPlots(offline)) {
- plot.owner = uuid;
+ if (offline != null) {
+ if (!offline.equals(uuid)) {
+ final Set plots = PS.get().getPlots(offline);
+ if (plots.size() > 0) {
+ for (final Plot plot : plots) {
+ plot.owner = uuid;
+ }
+ DBFunc.replaceUUID(offline, uuid);
+ PS.debug("&cDetected invalid UUID stored for (1): " + name.value);
+ PS.debug("&7 - Did you recently switch to online-mode storage without running `uuidconvert`?");
+ PS.debug("&6PlotSquared will update incorrect entries when the user logs in, or you can reconstruct your database.");
}
- DBFunc.replaceUUID(offline, uuid);
- PS.debug("&cDetected invalid UUID stored for (1): " + name.value);
- PS.debug("&7 - Did you recently switch to online-mode storage without running `uuidconvert`?");
- PS.debug("&6PlotSquared will update incorrect entries when the user logs in, or you can reconstruct your database.");
+ return true;
}
+ return false;
}
} catch (final Exception e) {
final BiMap inverse = uuidMap.inverse();
diff --git a/src/main/java/com/intellectualcrafters/plot/uuid/NameFetcher.java b/src/main/java/com/intellectualcrafters/plot/uuid/NameFetcher.java
new file mode 100644
index 000000000..2e5e5da23
--- /dev/null
+++ b/src/main/java/com/intellectualcrafters/plot/uuid/NameFetcher.java
@@ -0,0 +1,44 @@
+package com.intellectualcrafters.plot.uuid;
+
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.ArrayDeque;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+
+public class NameFetcher implements Callable