diff --git a/pom.xml b/pom.xml
index 1d8d57db0..f861585a4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
UTF-8
PlotSquared
- 3.2.8
+ 3.2.9
PlotSquared
jar
@@ -150,7 +150,7 @@
org.spongepowered
spongeapi
- 2.1-20150828.013112-189
+ 2.1-SNAPSHOT
org.bukkit
diff --git a/src/main/java/com/intellectualcrafters/plot/PS.java b/src/main/java/com/intellectualcrafters/plot/PS.java
index d94128fc5..78ba23484 100644
--- a/src/main/java/com/intellectualcrafters/plot/PS.java
+++ b/src/main/java/com/intellectualcrafters/plot/PS.java
@@ -100,6 +100,7 @@ public class PS {
private final HashMap plotmanagers = new HashMap<>();
// public:
+ public File styleFile;
public File configFile;
public File translationFile;
public YamlConfiguration style;
@@ -111,7 +112,6 @@ public class PS {
public URL update;
// private:
- private File styleFile;
private File storageFile;
private File FILE = null; // This file
private int[] VERSION = null;
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Buy.java b/src/main/java/com/intellectualcrafters/plot/commands/Buy.java
index 6d28bb431..01a3332b0 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Buy.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Buy.java
@@ -80,7 +80,7 @@ public class Buy extends SubCommand {
if (currentPlots > MainUtil.getAllowedPlots(plr)) {
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
}
- final Flag flag = FlagManager.getPlotFlag(plot, "price");
+ final Flag flag = FlagManager.getPlotFlagRaw(plot, "price");
if (flag == null) {
return sendMessage(plr, C.NOT_FOR_SALE);
}
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/src/main/java/com/intellectualcrafters/plot/commands/Clear.java
index 6580fbfa6..762a31d16 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Clear.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Clear.java
@@ -79,7 +79,7 @@ public class Clear extends SubCommand {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
return false;
}
- if ((FlagManager.getPlotFlag(plot, "done") != null)
+ if ((FlagManager.getPlotFlagRaw(plot, "done") != null)
&& (!Permissions.hasPermission(plr, "plots.continue") || (Settings.DONE_COUNTS_TOWARDS_LIMIT && (MainUtil.getAllowedPlots(plr) >= MainUtil.getPlayerPlotCount(plr))))) {
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
return false;
@@ -97,10 +97,10 @@ public class Clear extends SubCommand {
public void run() {
plot.removeRunning();
// If the state changes, then mark it as no longer done
- if (FlagManager.getPlotFlag(plot, "done") != null) {
+ if (FlagManager.getPlotFlagRaw(plot, "done") != null) {
FlagManager.removePlotFlag(plot, "done");
}
- if (FlagManager.getPlotFlag(plot, "analysis") != null) {
+ if (FlagManager.getPlotFlagRaw(plot, "analysis") != null) {
FlagManager.removePlotFlag(plot, "analysis");
}
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java
index 2cfbc636a..c7e919af1 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java
@@ -219,7 +219,7 @@ public class DebugExec extends SubCommand {
}
final String flag = args[1];
for (final Plot plot : PS.get().getPlots()) {
- if (FlagManager.getPlotFlag(plot, flag) != null) {
+ if (FlagManager.getPlotFlagRaw(plot, flag) != null) {
FlagManager.removePlotFlag(plot, flag);
}
}
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Download.java b/src/main/java/com/intellectualcrafters/plot/commands/Download.java
index 47c88b1e6..7f1daa27e 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Download.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Download.java
@@ -38,7 +38,7 @@ public class Download extends SubCommand {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
return false;
}
- if ((!plot.isOwner(plr.getUUID()) || (Settings.DOWNLOAD_REQUIRES_DONE && (FlagManager.getPlotFlag(plot, "done") != null))) && !Permissions.hasPermission(plr, "plots.admin.command.download")) {
+ if ((!plot.isOwner(plr.getUUID()) || (Settings.DOWNLOAD_REQUIRES_DONE && (FlagManager.getPlotFlagRaw(plot, "done") != null))) && !Permissions.hasPermission(plr, "plots.admin.command.download")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/src/main/java/com/intellectualcrafters/plot/commands/Info.java
index a74ed37ad..7616317af 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Info.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Info.java
@@ -20,65 +20,21 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.UUID;
-import java.util.regex.Matcher;
import com.intellectualcrafters.plot.config.C;
-import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
-import com.intellectualcrafters.plot.flag.Flag;
-import com.intellectualcrafters.plot.flag.FlagManager;
-import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
-import com.intellectualcrafters.plot.object.PlotBlock;
-import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotInventory;
import com.intellectualcrafters.plot.object.PlotItemStack;
import com.intellectualcrafters.plot.object.PlotPlayer;
-import com.intellectualcrafters.plot.object.RegionWrapper;
-import com.intellectualcrafters.plot.util.BlockManager;
+import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil;
-import com.intellectualcrafters.plot.util.StringMan;
-import com.intellectualcrafters.plot.util.TaskManager;
-import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "info", aliases = { "i" }, description = "Display plot info", usage = "/plot info ", category = CommandCategory.INFO)
public class Info extends SubCommand {
- public static String getPlayerList(final Collection uuids) {
- final ArrayList l = new ArrayList<>(uuids);
- if ((l == null) || (l.size() < 1)) {
- return C.NONE.s();
- }
- final String c = C.PLOT_USER_LIST.s();
- final StringBuilder list = new StringBuilder();
- for (int x = 0; x < l.size(); x++) {
- if ((x + 1) == l.size()) {
- list.append(c.replace("%user%", getPlayerName(l.get(x))).replace(",", ""));
- } else {
- list.append(c.replace("%user%", getPlayerName(l.get(x))));
- }
- }
- return list.toString();
- }
-
- public static String getPlayerName(final UUID uuid) {
- if (uuid == null) {
- return C.UNKNOWN.s();
- }
- if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) {
- return "everyone";
- }
- final String name = UUIDHandler.getName(uuid);
- if (name == null) {
- return "unknown";
- }
- return name;
- }
-
@Override
public boolean onCommand(final PlotPlayer player, String[] args) {
String arg = null;
@@ -166,16 +122,26 @@ public class Info extends SubCommand {
return true;
}
String info = C.PLOT_INFO.s();
+ boolean full;
if (arg != null) {
info = getCaption(arg);
if (info == null) {
MainUtil.sendMessage(player, "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating");
return false;
}
- formatAndSend(info, plot.world, plot, player, true);
+ full = true;
} else {
- formatAndSend(info, plot.world, plot, player, false);
+ 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);
+ }
+ });
return true;
}
@@ -205,71 +171,4 @@ public class Info extends SubCommand {
return null;
}
}
-
- private void formatAndSend(String info, final String world, final Plot plot, final PlotPlayer player, final boolean full) {
- final int num = MainUtil.getConnectedPlots(plot).size();
- final String alias = plot.getAlias().length() > 0 ? plot.getAlias() : C.NONE.s();
- final Location top = MainUtil.getPlotTopLocAbs(world, plot.id);
- final Location bot = MainUtil.getPlotBottomLocAbs(world, plot.id);
- final String biome = BlockManager.manager.getBiome(plot.world, bot.getX() + ((top.getX() - bot.getX()) / 2), bot.getZ() + ((top.getZ() - bot.getZ()) / 2));
- final String trusted = getPlayerList(plot.getTrusted());
- final String members = getPlayerList(plot.getMembers());
- final String denied = getPlayerList(plot.getDenied());
-
- final Flag descriptionFlag = FlagManager.getPlotFlag(plot, "description");
- final String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString();
-
- final String flags = StringMan.replaceFromMap(
- "$2"
- + (StringMan.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true).values(), "").length() > 0 ? StringMan.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true)
- .values(), "$1, $2") : C.NONE.s()), C.replacements);
- final boolean build = plot.isAdded(player.getUUID());
-
- final String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners());
-
- info = info.replaceAll("%id%", plot.id.toString());
- info = info.replaceAll("%alias%", alias);
- info = info.replaceAll("%num%", num + "");
- info = info.replaceAll("%desc%", description);
- info = info.replaceAll("%biome%", biome);
- info = info.replaceAll("%owner%", owner);
- info = info.replaceAll("%members%", members);
- info = info.replaceAll("%trusted%", trusted);
- info = info.replaceAll("%helpers%", members);
- info = info.replaceAll("%denied%", denied);
- info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
- info = info.replaceAll("%build%", build + "");
- info = info.replaceAll("%desc%", "No description set.");
- if (info.contains("%rating%")) {
- final String newInfo = info;
- TaskManager.runTaskAsync(new Runnable() {
- @Override
- public void run() {
- int max = 10;
- if ((Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 0)) {
- max = 8;
- }
- String info;
- if (full && (Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 1)) {
- String rating = "";
- String prefix = "";
- final double[] ratings = MainUtil.getAverageRatings(plot);
- for (int i = 0; i < ratings.length; i++) {
- rating += prefix + Settings.RATING_CATEGORIES.get(i) + "=" + String.format("%.1f", ratings[i]);
- prefix = ",";
- }
- info = newInfo.replaceAll("%rating%", rating);
- } else {
- info = newInfo.replaceAll("%rating%", String.format("%.1f", MainUtil.getAverageRating(plot)) + "/" + max);
- }
- MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
- MainUtil.sendMessage(player, info, false);
- MainUtil.sendMessage(player, C.PLOT_INFO_FOOTER);
- }
- });
- return;
- }
- MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
- MainUtil.sendMessage(player, info, false);
- }
}
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java
index 4e34c3c09..247a7fb2b 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java
@@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import com.intellectualcrafters.plot.PS;
@@ -311,15 +310,11 @@ public class MainCommand extends CommandManager {
displayHelp(player, category, help_index, cmd);
return true;
}
- final StringBuilder builder = new StringBuilder(cmd).append(" ");
- final Iterator iterator = Arrays.asList(args).iterator();
- while (iterator.hasNext()) {
- builder.append(iterator.next());
- if (iterator.hasNext()) {
- builder.append(" ");
- }
+ if (args[0].contains(":")) {
+ args[0] = args[0].replaceFirst(":", " ");
}
- getInstance().handle(player, builder.toString());
+ String fullCmd = StringMan.join(args, " ");
+ getInstance().handle(player, cmd + " " + fullCmd);
return true;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Reload.java b/src/main/java/com/intellectualcrafters/plot/commands/Reload.java
index 734fa8ebf..e63c870fb 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Reload.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Reload.java
@@ -36,6 +36,7 @@ public class Reload extends SubCommand {
try {
// The following won't affect world generation, as that has to be
// loaded during startup unfortunately.
+ PS.get().style.load(PS.get().styleFile);
PS.get().config.load(PS.get().configFile);
PS.get().setupConfig();
C.load(PS.get().translationFile);
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/list.java b/src/main/java/com/intellectualcrafters/plot/commands/list.java
index b031ba780..b91783267 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/list.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/list.java
@@ -252,7 +252,7 @@ public class list extends SubCommand {
}
plots = new ArrayList<>();
for (final Plot plot : PS.get().getPlots()) {
- final Flag price = FlagManager.getPlotFlag(plot, "price");
+ final Flag price = FlagManager.getPlotFlagRaw(plot, "price");
if (price != null) {
plots.add(plot);
}
@@ -378,9 +378,9 @@ public class list extends SubCommand {
} else {
color = "$1";
}
- final PlotMessage trusted = new PlotMessage().text(C.color(C.PLOT_INFO_TRUSTED.s().replaceAll("%trusted%", Info.getPlayerList(plot.getTrusted())))).color("$1");
+ final PlotMessage trusted = new PlotMessage().text(C.color(C.PLOT_INFO_TRUSTED.s().replaceAll("%trusted%", MainUtil.getPlayerList(plot.getTrusted())))).color("$1");
- final PlotMessage members = new PlotMessage().text(C.color(C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", Info.getPlayerList(plot.getMembers())))).color("$1");
+ final PlotMessage members = new PlotMessage().text(C.color(C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers())))).color("$1");
String strFlags = StringMan.join(plot.getFlags().values(), ",");
if (strFlags.length() == 0) {
diff --git a/src/main/java/com/intellectualcrafters/plot/config/C.java b/src/main/java/com/intellectualcrafters/plot/config/C.java
index 7fde029e1..766e9ca35 100644
--- a/src/main/java/com/intellectualcrafters/plot/config/C.java
+++ b/src/main/java/com/intellectualcrafters/plot/config/C.java
@@ -451,6 +451,7 @@ public enum C {
*/
NONE("None", "Info"),
UNKNOWN("Unknown", "Info"),
+ EVERYONE("Everyone", "Info"),
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"),
diff --git a/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
index 855015f09..b381073fe 100644
--- a/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
+++ b/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
@@ -1297,7 +1297,7 @@ public class SQLManager implements AbstractDB {
if (plot.temp > 0) {
return plot.temp;
}
- id = 1 / 0;
+ throw new SQLException("Plot does not exist in database");
}
plot.temp = id;
return id;
diff --git a/src/main/java/com/intellectualcrafters/plot/flag/Flag.java b/src/main/java/com/intellectualcrafters/plot/flag/Flag.java
index a7b8a85e6..a8a976e00 100644
--- a/src/main/java/com/intellectualcrafters/plot/flag/Flag.java
+++ b/src/main/java/com/intellectualcrafters/plot/flag/Flag.java
@@ -20,9 +20,11 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.flag;
+import java.lang.reflect.Method;
+
import com.intellectualcrafters.plot.util.StringMan;
-public class Flag {
+public class Flag implements Cloneable {
private AbstractFlag key;
private Object value;
@@ -122,4 +124,24 @@ public class Flag {
public int hashCode() {
return key.getKey().hashCode();
}
+
+ @Override
+ protected Object clone() {
+ try {
+ if (value == null) {
+ return super.clone();
+ }
+ if (value instanceof Cloneable) {
+ Method method = value.getClass().getDeclaredMethod("clone");
+ if (!method.isAccessible()) {
+ method.setAccessible(true);
+ }
+ return new Flag(key, method.invoke(value));
+ }
+ return new Flag(key, key.parseValueRaw(value.toString()));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return this;
+ }
+ }
}
diff --git a/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java
index f6e075f07..6fe60e347 100644
--- a/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java
+++ b/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java
@@ -129,13 +129,13 @@ public class FlagManager {
if (plotworld.DEFAULT_FLAGS.size() == 0) {
return null;
}
- return ((HashMap) plotworld.DEFAULT_FLAGS.clone()).get(id);
+ return plotworld.DEFAULT_FLAGS.get(id);
}
return flag;
}
public static boolean isBooleanFlag(final Plot plot, final String key, final boolean defaultValue) {
- final Flag flag = FlagManager.getPlotFlag(plot, key);
+ final Flag flag = FlagManager.getPlotFlagRaw(plot, key);
if (flag == null) {
return defaultValue;
}
@@ -153,6 +153,11 @@ public class FlagManager {
* @return Flag
*/
public static Flag getPlotFlag(final Plot plot, final String flag) {
+ Flag result = getPlotFlagRaw(plot, flag);
+ return result == null ? null : (Flag) result.clone();
+ }
+
+ public static Flag getPlotFlagRaw(final Plot plot, final String flag) {
if (!plot.hasOwner()) {
return null;
}
@@ -163,7 +168,7 @@ public class FlagManager {
if (plot.owner == null) {
return false;
}
- final Flag flag = getPlotFlag(plot, strFlag);
+ final Flag flag = getPlotFlagRaw(plot, strFlag);
return !((flag == null) || !((Boolean) flag.getValue()));
}
@@ -171,7 +176,7 @@ public class FlagManager {
if (plot.owner == null) {
return false;
}
- final Flag flag = getPlotFlag(plot, strFlag);
+ final Flag flag = getPlotFlagRaw(plot, strFlag);
if ((flag == null) || ((Boolean) flag.getValue())) {
return false;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java b/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java
index 12653ad06..540266445 100644
--- a/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java
+++ b/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java
@@ -286,7 +286,7 @@ public abstract class FlagValue {
}
}
- public interface ListValue {
+ public interface ListValue extends Cloneable {
void add(final Object t, final String value);
void remove(final Object t, final String value);
diff --git a/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java b/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java
index 2a3b6aa54..e9be75aa4 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java
@@ -157,4 +157,9 @@ public class ConsolePlayer extends PlotPlayer {
@Override
public void kick(final String message) {}
+ @Override
+ public boolean isBanned() {
+ return false;
+ }
+
}
diff --git a/src/main/java/com/intellectualcrafters/plot/object/Location.java b/src/main/java/com/intellectualcrafters/plot/object/Location.java
index bc3f5ad0c..0fd71e17c 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/Location.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/Location.java
@@ -4,6 +4,9 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import com.intellectualcrafters.plot.PS;
+import com.intellectualcrafters.plot.util.MainUtil;
+
/**
* Created 2015-02-11 for PlotSquared
*
@@ -70,6 +73,18 @@ public class Location implements Cloneable, Comparable {
return world;
}
+ public PlotWorld getPlotWorld() {
+ return PS.get().getPlotWorld(world);
+ }
+
+ public PlotManager getPlotManager() {
+ return PS.get().getPlotManager(world);
+ }
+
+ public Plot getPlot() {
+ return MainUtil.getPlot(this);
+ }
+
public void setWorld(final String world) {
this.world = world;
built = false;
@@ -184,7 +199,7 @@ public class Location implements Cloneable, Comparable {
private Object getBukkitWorld() {
try {
- final Class clazz = Class.forName("org.bukkit.Bukkit");
+ final Class> clazz = Class.forName("org.bukkit.Bukkit");
return clazz.getMethod("getWorld", String.class).invoke(null, world);
} catch (final Exception e) {
return null;
@@ -196,7 +211,8 @@ public class Location implements Cloneable, Comparable {
return o;
}
try {
- final Constructor constructor = Class.forName("org.bukkit.Location").getConstructor(Class.forName("org.bukkit.World"), double.class, double.class, double.class, float.class, float.class);
+ final Constructor> constructor = Class.forName("org.bukkit.Location").getConstructor(Class.forName("org.bukkit.World"), double.class, double.class, double.class, float.class,
+ float.class);
built = true;
return (o = constructor.newInstance(Class.forName("org.bukkit.World").cast(getBukkitWorld()), x, y, z, yaw, pitch));
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | ClassNotFoundException | NoSuchMethodException e) {
diff --git a/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/src/main/java/com/intellectualcrafters/plot/object/Plot.java
index 003c131f3..7e5ff65d4 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/Plot.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/Plot.java
@@ -286,7 +286,7 @@ public class Plot {
if (owner == null) {
return ClusterManager.getCluster(this);
}
- Flag flag = FlagManager.getPlotFlag(this, "cluster");
+ Flag flag = FlagManager.getPlotFlagRaw(this, "cluster");
if (flag != null) {
PlotCluster cluster = (PlotCluster) flag.getValue();
cluster = ClusterManager.getCluster(cluster.world, cluster.getName());
@@ -650,7 +650,7 @@ public class Plot {
* @param flag
*/
public Flag getFlag(final String key) {
- return FlagManager.getPlotFlag(this, key);
+ return FlagManager.getPlotFlagRaw(this, key);
}
/**
diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java b/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java
index 57b84a59e..336af7e11 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java
@@ -36,7 +36,7 @@ public class PlotAnalysis {
public static PlotAnalysis MODIFIERS = new PlotAnalysis();
public static PlotAnalysis getAnalysis(final Plot plot) {
- final Flag flag = FlagManager.getPlotFlag(plot, "analysis");
+ final Flag flag = FlagManager.getPlotFlagRaw(plot, "analysis");
if (flag != null) {
final PlotAnalysis analysis = new PlotAnalysis();
final List values = (List) flag.getValue();
diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java
index 37f99a36a..51e21c44c 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java
@@ -6,11 +6,15 @@ import java.util.concurrent.ConcurrentHashMap;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.RequiredType;
+import com.intellectualcrafters.plot.config.Settings;
+import com.intellectualcrafters.plot.util.EventUtil;
+import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandCaller;
+import com.plotsquared.listener.PlotListener;
/**
* Created 2015-02-20 for PlotSquared
@@ -301,9 +305,35 @@ public abstract class PlotPlayer implements CommandCaller {
*/
public abstract void playMusic(final Location loc, final int id);
+ /**
+ * Check if the player is banned
+ * @return
+ */
+ public abstract boolean isBanned();
+
/**
* Kick the player from the game
* @param message
*/
public abstract void kick(final String message);
+
+ /**
+ * Called when the player quits
+ */
+ public void unregister() {
+ final Plot plot = getCurrentPlot();
+ if (plot != null) {
+ PlotListener.plotExit(this, plot);
+ }
+ ExpireManager.dates.put(getUUID(), System.currentTimeMillis());
+ EventUtil.unregisterPlayer(this);
+ if (Settings.DELETE_PLOTS_ON_BAN && isBanned()) {
+ for (final Plot owned : PS.get().getPlotsInWorld(getName())) {
+ owned.deletePlot(null);
+ PS.debug(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), getName()));
+ }
+ }
+ UUIDHandler.getPlayers().remove(getName());
+ PS.get().IMP.unregister(this);
+ }
}
diff --git a/src/main/java/com/intellectualcrafters/plot/object/RunnableVal.java b/src/main/java/com/intellectualcrafters/plot/object/RunnableVal.java
index bc0421ef0..3b99d5c0e 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/RunnableVal.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/RunnableVal.java
@@ -5,4 +5,9 @@ public abstract class RunnableVal implements Runnable {
@Override
public abstract void run();
+
+ public void run(T value) {
+ this.value = value;
+ run();
+ }
}
diff --git a/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java b/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java
index 4b88ecf76..accf49424 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java
@@ -1,15 +1,17 @@
package com.intellectualcrafters.plot.util;
+import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
-import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotLoc;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
@@ -103,17 +105,72 @@ public abstract class ChunkManager {
public abstract void unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe);
- public abstract Set getChunkChunks(final String world);
+ 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[] regionFiles = folder.listFiles();
+ final HashSet chunks = new HashSet<>();
+ if (regionFiles == null) {
+ throw new RuntimeException("Could not find worlds folder.");
+ }
+ for (final File file : regionFiles) {
+ final String name = file.getName();
+ if (name.endsWith("mca")) {
+ final String[] split = name.split("\\.");
+ try {
+ final int x = Integer.parseInt(split[1]);
+ final int z = Integer.parseInt(split[2]);
+ final ChunkLoc loc = new ChunkLoc(x, z);
+ chunks.add(loc);
+ } catch (final Exception e) {}
+ }
+ }
+ return chunks;
+ }
public abstract void regenerateChunk(final String world, final ChunkLoc loc);
- public abstract void deleteRegionFile(final String world, final ChunkLoc loc);
+ public void deleteRegionFiles(String world, List chunks) {
+ deleteRegionFiles(world, chunks, null);
+ }
- public abstract void deleteRegionFiles(final String world, final List chunks);
+ public void deleteRegionFiles(final String world, final List chunks, final Runnable whenDone) {
+ TaskManager.runTaskAsync(new Runnable() {
+ @Override
+ public void run() {
+ for (final ChunkLoc loc : chunks) {
+ final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
+ final File file = new File(PS.get().IMP.getWorldContainer(), directory);
+ PS.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
+ if (file.exists()) {
+ file.delete();
+ }
+ }
+ if (whenDone != null) {
+ whenDone.run();
+ }
+ }
+ });
+ }
- public abstract void deleteRegionFiles(final String world, final List chunks, final Runnable whenDone);
-
- public abstract Plot hasPlot(String world, ChunkLoc chunk);
+ public Plot hasPlot(String world, ChunkLoc chunk) {
+ final int x1 = chunk.x << 4;
+ final int z1 = chunk.z << 4;
+ final int x2 = x1 + 15;
+ final int z2 = z1 + 15;
+ final Location bot = new Location(world, x1, 0, z1);
+ Plot plot;
+ plot = MainUtil.getPlotAbs(bot);
+ if ((plot != null) && (plot.owner != null)) {
+ return plot;
+ }
+ final Location top = new Location(world, x2, 0, z2);
+ plot = MainUtil.getPlotAbs(top);
+ if ((plot != null) && (plot.owner != null)) {
+ return plot;
+ }
+ return null;
+ }
/**
* Copy a region to a new location (in the same world)
diff --git a/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java b/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java
index beca331a6..73d562f19 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java
@@ -86,14 +86,14 @@ public abstract class EventUtil {
if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
- final Flag use = FlagManager.getPlotFlag(plot, "use");
+ final Flag use = FlagManager.getPlotFlagRaw(plot, "use");
if (use != null) {
final HashSet value = (HashSet) use.getValue();
if (value.contains(PlotBlock.EVERYTHING) || value.contains(block.getPlotBlock())) {
return true;
}
}
- final Flag destroy = FlagManager.getPlotFlag(plot, "break");
+ final Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
if (destroy != null) {
final HashSet value = (HashSet) destroy.getValue();
if (value.contains(PlotBlock.EVERYTHING) || value.contains(block.getPlotBlock())) {
@@ -142,7 +142,7 @@ public abstract class EventUtil {
if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
- final Flag flag = FlagManager.getPlotFlag(plot, "use");
+ 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()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
@@ -156,7 +156,7 @@ public abstract class EventUtil {
if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED.s(), notifyPerms);
}
- final Flag flag = FlagManager.getPlotFlag(plot, "place");
+ final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
final HashSet value = flag == null ? null : (HashSet) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER.s(), notifyPerms);
@@ -173,7 +173,7 @@ public abstract class EventUtil {
if (FlagManager.isPlotFlagTrue(plot, "device-interact")) {
return true;
}
- final Flag flag = FlagManager.getPlotFlag(plot, "use");
+ 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()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
@@ -190,7 +190,7 @@ public abstract class EventUtil {
if (FlagManager.isPlotFlagTrue(plot, "hanging-interact")) {
return true;
}
- final Flag flag = FlagManager.getPlotFlag(plot, "use");
+ 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()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
@@ -207,7 +207,7 @@ public abstract class EventUtil {
if (FlagManager.isPlotFlagTrue(plot, "misc-interact")) {
return true;
}
- final Flag flag = FlagManager.getPlotFlag(plot, "use");
+ 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()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
@@ -224,7 +224,7 @@ public abstract class EventUtil {
if (FlagManager.isPlotFlagTrue(plot, "vehicle-use")) {
return true;
}
- final Flag flag = FlagManager.getPlotFlag(plot, "use");
+ 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()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
@@ -242,7 +242,7 @@ public abstract class EventUtil {
if (FlagManager.isPlotFlagTrue(plot, "mob-place")) {
return true;
}
- final Flag flag = FlagManager.getPlotFlag(plot, "place");
+ final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
final HashSet value = flag == null ? null : (HashSet) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
@@ -278,7 +278,7 @@ public abstract class EventUtil {
if (FlagManager.isPlotFlagTrue(plot, "misc-place")) {
return true;
}
- final Flag flag = FlagManager.getPlotFlag(plot, "place");
+ final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
final HashSet value = flag == null ? null : (HashSet) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
@@ -296,7 +296,7 @@ public abstract class EventUtil {
if (FlagManager.isPlotFlagTrue(plot, "vehicle-place")) {
return true;
}
- final Flag flag = FlagManager.getPlotFlag(plot, "place");
+ final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
final HashSet value = flag == null ? null : (HashSet) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
diff --git a/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java
index d23096a9b..805fa1cd7 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java
@@ -223,7 +223,7 @@ public class ExpireManager {
final Iterator iter = plots.iterator();
while (iter.hasNext()) {
final Plot plot = iter.next();
- final Flag keepFlag = FlagManager.getPlotFlag(plot, "keep");
+ final Flag keepFlag = FlagManager.getPlotFlagRaw(plot, "keep");
if ((keepFlag != null) && (Boolean) keepFlag.getValue()) {
continue;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
index 5b775419f..f6238140c 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
@@ -34,12 +34,14 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Matcher;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag;
+import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
@@ -269,6 +271,8 @@ public class MainUtil {
public static String getName(final UUID owner) {
if (owner == null) {
return C.NONE.s();
+ } else if (owner.equals(DBFunc.everyone)) {
+ return C.EVERYONE.s();
}
final String name = UUIDHandler.getName(owner);
if (name == null) {
@@ -518,10 +522,14 @@ public class MainUtil {
if (!result) {
return false;
}
- plot.removeSign();
+ if (createSign) {
+ plot.removeSign();
+ }
final PlotManager manager = PS.get().getPlotManager(plot.world);
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
- manager.startPlotUnlink(plotworld, ids);
+ if (createRoad) {
+ manager.startPlotUnlink(plotworld, ids);
+ }
if ((plotworld.TERRAIN != 3) && createRoad) {
for (Plot current : plots) {
if (current.getMerged(1)) {
@@ -545,7 +553,9 @@ public class MainUtil {
MainUtil.setSign(getName(current.owner), current);
}
}
- manager.finishPlotUnlink(plotworld, ids);
+ if (createRoad) {
+ manager.finishPlotUnlink(plotworld, ids);
+ }
return true;
}
@@ -2157,8 +2167,13 @@ public class MainUtil {
if (!tmp.getMerged(2)) {
// invalid merge
PS.debug("Fixing invalid merge: " + plot);
- tmp.getSettings().setMerged(2, true);
- DBFunc.setMerged(tmp, tmp.settings.getMerged());
+ if (tmp.hasOwner()) {
+ tmp.getSettings().setMerged(2, true);
+ DBFunc.setMerged(tmp, tmp.settings.getMerged());
+ } else {
+ plot.getSettings().setMerged(0, false);
+ DBFunc.setMerged(plot, plot.settings.getMerged());
+ }
}
queuecache.add(tmp);
frontier.add(tmp);
@@ -2168,8 +2183,13 @@ public class MainUtil {
if (!tmp.getMerged(3)) {
// invalid merge
PS.debug("Fixing invalid merge: " + plot);
- tmp.getSettings().setMerged(3, true);
- DBFunc.setMerged(tmp, tmp.settings.getMerged());
+ if (tmp.hasOwner()) {
+ tmp.getSettings().setMerged(3, true);
+ DBFunc.setMerged(tmp, tmp.settings.getMerged());
+ } else {
+ plot.getSettings().setMerged(1, false);
+ DBFunc.setMerged(plot, plot.settings.getMerged());
+ }
}
queuecache.add(tmp);
frontier.add(tmp);
@@ -2179,8 +2199,13 @@ public class MainUtil {
if (!tmp.getMerged(0)) {
// invalid merge
PS.debug("Fixing invalid merge: " + plot);
- tmp.getSettings().setMerged(0, true);
- DBFunc.setMerged(tmp, tmp.settings.getMerged());
+ if (tmp.hasOwner()) {
+ tmp.getSettings().setMerged(0, true);
+ DBFunc.setMerged(tmp, tmp.settings.getMerged());
+ } else {
+ plot.getSettings().setMerged(2, false);
+ DBFunc.setMerged(plot, plot.settings.getMerged());
+ }
}
queuecache.add(tmp);
frontier.add(tmp);
@@ -2190,8 +2215,13 @@ public class MainUtil {
if (!tmp.getMerged(1)) {
// invalid merge
PS.debug("Fixing invalid merge: " + plot);
- tmp.getSettings().setMerged(1, true);
- DBFunc.setMerged(tmp, tmp.settings.getMerged());
+ if (tmp.hasOwner()) {
+ tmp.getSettings().setMerged(1, true);
+ DBFunc.setMerged(tmp, tmp.settings.getMerged());
+ } else {
+ plot.getSettings().setMerged(3, false);
+ DBFunc.setMerged(plot, plot.settings.getMerged());
+ }
}
queuecache.add(tmp);
frontier.add(tmp);
@@ -2381,4 +2411,84 @@ public class MainUtil {
public static boolean setComponent(final Plot plot, final String component, final PlotBlock[] blocks) {
return PS.get().getPlotManager(plot.world).setComponent(PS.get().getPlotWorld(plot.world), plot.id, component, blocks);
}
+
+ public static void format(String info, final Plot plot, final PlotPlayer player, final boolean full, final RunnableVal whenDone) {
+ final int num = MainUtil.getConnectedPlots(plot).size();
+ final String alias = plot.getAlias().length() > 0 ? plot.getAlias() : C.NONE.s();
+ final Location bot = plot.getBottom();
+ final String biome = BlockManager.manager.getBiome(plot.world, bot.getX(), bot.getZ());
+ final String trusted = getPlayerList(plot.getTrusted());
+ final String members = getPlayerList(plot.getMembers());
+ final String denied = getPlayerList(plot.getDenied());
+
+ final Flag descriptionFlag = FlagManager.getPlotFlagRaw(plot, "description");
+ final String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString();
+
+ final String flags = StringMan.replaceFromMap(
+ "$2"
+ + (StringMan.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true).values(), "").length() > 0 ? StringMan.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true)
+ .values(), "$1, $2") : C.NONE.s()), C.replacements);
+ final boolean build = plot.isAdded(player.getUUID());
+
+ final String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners());
+
+ info = info.replaceAll("%id%", plot.id.toString());
+ info = info.replaceAll("%alias%", alias);
+ info = info.replaceAll("%num%", num + "");
+ info = info.replaceAll("%desc%", description);
+ info = info.replaceAll("%biome%", biome);
+ info = info.replaceAll("%owner%", owner);
+ info = info.replaceAll("%members%", members);
+ info = info.replaceAll("%trusted%", trusted);
+ info = info.replaceAll("%helpers%", members);
+ info = info.replaceAll("%denied%", denied);
+ info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
+ info = info.replaceAll("%build%", build + "");
+ info = info.replaceAll("%desc%", "No description set.");
+ if (info.contains("%rating%")) {
+ final String newInfo = info;
+ TaskManager.runTaskAsync(new Runnable() {
+ @Override
+ public void run() {
+ int max = 10;
+ if ((Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 0)) {
+ max = 8;
+ }
+ String info;
+ if (full && (Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 1)) {
+ String rating = "";
+ String prefix = "";
+ final double[] ratings = MainUtil.getAverageRatings(plot);
+ for (int i = 0; i < ratings.length; i++) {
+ rating += prefix + Settings.RATING_CATEGORIES.get(i) + "=" + String.format("%.1f", ratings[i]);
+ prefix = ",";
+ }
+ info = newInfo.replaceAll("%rating%", rating);
+ } else {
+ info = newInfo.replaceAll("%rating%", String.format("%.1f", MainUtil.getAverageRating(plot)) + "/" + max);
+ }
+ whenDone.run(info);
+ }
+ });
+ return;
+ }
+ whenDone.run(info);
+ }
+
+ public static String getPlayerList(final Collection uuids) {
+ final ArrayList l = new ArrayList<>(uuids);
+ if ((l == null) || (l.size() < 1)) {
+ return C.NONE.s();
+ }
+ final String c = C.PLOT_USER_LIST.s();
+ final StringBuilder list = new StringBuilder();
+ for (int x = 0; x < l.size(); x++) {
+ if ((x + 1) == l.size()) {
+ list.append(c.replace("%user%", getName(l.get(x))).replace(",", ""));
+ } else {
+ list.append(c.replace("%user%", getName(l.get(x))));
+ }
+ }
+ return list.toString();
+ }
}
diff --git a/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/src/main/java/com/plotsquared/bukkit/BukkitMain.java
index 06eec4f04..32807f713 100644
--- a/src/main/java/com/plotsquared/bukkit/BukkitMain.java
+++ b/src/main/java/com/plotsquared/bukkit/BukkitMain.java
@@ -301,7 +301,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
if (MainUtil.isPlotRoad(BukkitUtil.getLocation(loc))) {
final Entity passenger = entity.getPassenger();
if (!(passenger instanceof Player)) {
- entity.remove();
+ if (entity.getMetadata("keep").size() == 0) {
+ entity.remove();
+ }
}
}
break;
diff --git a/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java b/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java
index b8f12be3f..f3bf16a19 100644
--- a/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java
+++ b/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java
@@ -100,7 +100,7 @@ public class ForceFieldListener implements Listener {
if (plot == null) {
return;
}
- if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) {
+ if ((FlagManager.getPlotFlagRaw(plot, "forcefield") != null) && FlagManager.getPlotFlagRaw(plot, "forcefield").getValue().equals("true")) {
if (!FlagManager.isBooleanFlag(plot, "forcefield", false)) {
final UUID uuid = pp.getUUID();
if (plot.isAdded(uuid)) {
diff --git a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java
index 7d74d25ee..d25d80d42 100644
--- a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java
+++ b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java
@@ -198,7 +198,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if ((plot == null) || !plot.hasOwner()) {
return;
}
- final Flag redstone = FlagManager.getPlotFlag(plot, "redstone");
+ final Flag redstone = FlagManager.getPlotFlagRaw(plot, "redstone");
if (redstone != null) {
if ((Boolean) redstone.getValue()) {
return;
@@ -343,7 +343,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
Flag flag;
- if (((flag = FlagManager.getPlotFlag(plot, "blocked-cmds")) != null) && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
+ if (((flag = FlagManager.getPlotFlagRaw(plot, "blocked-cmds")) != null) && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
final List v = (List) flag.getValue();
String msg = event.getMessage().toLowerCase().replaceFirst("/", "");
@@ -648,7 +648,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
event.setCancelled(true);
return;
} else if (!plot.isAdded(pp.getUUID())) {
- final Flag destroy = FlagManager.getPlotFlag(plot, "break");
+ final Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
final Block block = event.getBlock();
if ((destroy != null) && ((HashSet) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
return;
@@ -871,7 +871,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
final PlotPlayer pp = BukkitUtil.getPlayer(player);
if (!plot.isAdded(pp.getUUID())) {
- final Flag destroy = FlagManager.getPlotFlag(plot, "break");
+ final Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
final Block block = event.getBlock();
if ((destroy != null) && ((HashSet) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
return;
@@ -1267,6 +1267,9 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
final Location loc = BukkitUtil.getLocation(block.getLocation());
final Plot plot = MainUtil.getPlot(loc);
if (plot == null) {
+ if (MainUtil.isPlotAreaAbs(loc)) {
+ event.setCancelled(true);
+ }
return;
}
if (FlagManager.isPlotFlagTrue(plot, "disable-physics")) {
@@ -1299,7 +1302,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
public boolean checkEntity(final Entity entity, final Plot plot) {
if ((plot != null) && (plot.owner != null)) {
- final Flag entityFlag = FlagManager.getPlotFlag(plot, "entity-cap");
+ final Flag entityFlag = FlagManager.getPlotFlagRaw(plot, "entity-cap");
int[] mobs = null;
if (entityFlag != null) {
final int cap = ((Integer) entityFlag.getValue());
@@ -1312,7 +1315,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
}
if (entity instanceof Creature) {
- final Flag mobFlag = FlagManager.getPlotFlag(plot, "mob-cap");
+ final Flag mobFlag = FlagManager.getPlotFlagRaw(plot, "mob-cap");
if (mobFlag != null) {
final int cap = ((Integer) mobFlag.getValue());
if (cap == 0) {
@@ -1326,7 +1329,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
}
if (entity instanceof Animals) {
- final Flag animalFlag = FlagManager.getPlotFlag(plot, "animal-cap");
+ final Flag animalFlag = FlagManager.getPlotFlagRaw(plot, "animal-cap");
if (animalFlag != null) {
final int cap = ((Integer) animalFlag.getValue());
if (cap == 0) {
@@ -1340,7 +1343,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
}
} else if (entity instanceof Monster) {
- final Flag monsterFlag = FlagManager.getPlotFlag(plot, "hostile-cap");
+ final Flag monsterFlag = FlagManager.getPlotFlagRaw(plot, "hostile-cap");
if (monsterFlag != null) {
final int cap = ((Integer) monsterFlag.getValue());
if (cap == 0) {
@@ -1355,7 +1358,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
}
} else if (entity instanceof Vehicle) {
- final Flag vehicleFlag = FlagManager.getPlotFlag(plot, "vehicle-cap");
+ final Flag vehicleFlag = FlagManager.getPlotFlagRaw(plot, "vehicle-cap");
if (vehicleFlag != null) {
final int cap = ((Integer) vehicleFlag.getValue());
if (cap == 0) {
@@ -1609,7 +1612,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
e.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) {
- final Flag use = FlagManager.getPlotFlag(plot, C.FLAG_USE.s());
+ final Flag use = FlagManager.getPlotFlagRaw(plot, C.FLAG_USE.s());
if ((use != null) && ((HashSet) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) {
return;
}
@@ -1655,19 +1658,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
@EventHandler(priority = EventPriority.MONITOR)
public void onLeave(final PlayerQuitEvent event) {
final PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
- final Plot plot = pp.getCurrentPlot();
- if (plot != null) {
- plotExit(pp, plot);
- }
- ExpireManager.dates.put(pp.getUUID(), System.currentTimeMillis());
- EventUtil.unregisterPlayer(pp);
- if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) {
- for (final Plot owned : PS.get().getPlotsInWorld(pp.getName())) {
- owned.deletePlot(null);
- PS.debug(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
- }
- }
- BukkitUtil.removePlayer(pp.getName());
+ pp.unregister();
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -1694,7 +1685,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
e.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) {
- final Flag use = FlagManager.getPlotFlag(plot, C.FLAG_USE.s());
+ final Flag use = FlagManager.getPlotFlagRaw(plot, C.FLAG_USE.s());
final Block block = e.getBlockClicked();
if ((use != null) && ((HashSet) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
return;
@@ -1983,16 +1974,16 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if ((plot != null) && ((FlagManager.isPlotFlagTrue(plot, "hanging-break") || plot.isAdded(pp.getUUID())))) {
return true;
}
- if (!Permissions.hasPermission(pp, "plots.admin.break." + stub)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.break." + stub);
+ if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) {
+ MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
return false;
}
} else if (victim.getEntityId() == 30) {
if ((plot != null) && ((FlagManager.isPlotFlagTrue(plot, "misc-break") || plot.isAdded(pp.getUUID())))) {
return true;
}
- if (!Permissions.hasPermission(pp, "plots.admin.break." + stub)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.break." + stub);
+ if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) {
+ MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
return false;
}
} else if ((victim instanceof Monster) || (victim instanceof EnderDragon)) { // victim is monster
@@ -2013,7 +2004,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
} else if (victim instanceof Player) {
if (plot != null) {
- final Flag pvp = FlagManager.getPlotFlag(plot, C.FLAG_PVP.s());
+ final Flag pvp = FlagManager.getPlotFlagRaw(plot, C.FLAG_PVP.s());
if (pvp == null) {
return true;
} else {
@@ -2108,7 +2099,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return;
}
} else if (!plot.isAdded(pp.getUUID())) {
- final Flag place = FlagManager.getPlotFlag(plot, C.FLAG_PLACE.s());
+ final Flag place = FlagManager.getPlotFlagRaw(plot, C.FLAG_PLACE.s());
final Block block = event.getBlock();
if (((place == null) || !((HashSet) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData())))
&& !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
diff --git a/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener.java b/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener.java
index a1f0111ce..545457dc3 100644
--- a/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener.java
+++ b/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener.java
@@ -165,12 +165,12 @@ public class PlotPlusListener extends PlotListener implements Listener {
public void onPlotEnter(final PlayerEnterPlotEvent event) {
final Player player = event.getPlayer();
final Plot plot = event.getPlot();
- final Flag feed = FlagManager.getPlotFlag(plot, "feed");
+ final Flag feed = FlagManager.getPlotFlagRaw(plot, "feed");
if (feed != null) {
final Integer[] value = (Integer[]) feed.getValue();
feedRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
}
- final Flag heal = FlagManager.getPlotFlag(plot, "heal");
+ final Flag heal = FlagManager.getPlotFlagRaw(plot, "heal");
if (heal != null) {
final Integer[] value = (Integer[]) heal.getValue();
healRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
diff --git a/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java b/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java
index 22c9b9d5f..3d8a7f575 100644
--- a/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java
+++ b/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java
@@ -279,4 +279,9 @@ public class BukkitPlayer extends PlotPlayer {
public void kick(final String message) {
player.kickPlayer(message);
}
+
+ @Override
+ public boolean isBanned() {
+ return player.isBanned();
+ }
}
diff --git a/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java b/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java
index 2422da661..5119a033d 100644
--- a/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java
+++ b/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java
@@ -1,6 +1,5 @@
package com.plotsquared.bukkit.util;
-import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -69,25 +68,7 @@ import com.plotsquared.bukkit.object.entity.EntityWrapper;
public class BukkitChunkManager extends ChunkManager {
@Override
public Set getChunkChunks(final String world) {
- final String directory = Bukkit.getWorldContainer() + File.separator + world + File.separator + "region";
- final File folder = new File(directory);
- final File[] regionFiles = folder.listFiles();
- final HashSet chunks = new HashSet<>();
- if (regionFiles == null) {
- throw new RuntimeException("Could not find worlds folder.");
- }
- for (final File file : regionFiles) {
- final String name = file.getName();
- if (name.endsWith("mca")) {
- final String[] split = name.split("\\.");
- try {
- final int x = Integer.parseInt(split[1]);
- final int z = Integer.parseInt(split[2]);
- final ChunkLoc loc = new ChunkLoc(x, z);
- chunks.add(loc);
- } catch (final Exception e) {}
- }
- }
+ Set chunks = super.getChunkChunks(world);
for (final Chunk chunk : Bukkit.getWorld(world).getLoadedChunks()) {
final ChunkLoc loc = new ChunkLoc(chunk.getX() >> 5, chunk.getZ() >> 5);
if (!chunks.contains(loc)) {
@@ -117,69 +98,6 @@ public class BukkitChunkManager extends ChunkManager {
}
}
- @Override
- public void deleteRegionFile(final String world, final ChunkLoc loc) {
- TaskManager.runTaskAsync(new Runnable() {
- @Override
- public void run() {
- final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
- final File file = new File(PS.get().IMP.getWorldContainer(), directory);
- PS.log("&6 - Deleting region: " + file.getName() + " (approx 1024 chunks)");
- if (file.exists()) {
- file.delete();
- }
- try {
- Thread.sleep(100);
- } catch (final InterruptedException e) {}
- }
- });
- }
-
- @Override
- public void deleteRegionFiles(String world, List chunks) {
- deleteRegionFiles(world, chunks, null);
- }
-
- @Override
- public void deleteRegionFiles(final String world, final List chunks, final Runnable whenDone) {
- TaskManager.runTaskAsync(new Runnable() {
- @Override
- public void run() {
- for (final ChunkLoc loc : chunks) {
- final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
- final File file = new File(PS.get().IMP.getWorldContainer(), directory);
- PS.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
- if (file.exists()) {
- file.delete();
- }
- }
- if (whenDone != null) {
- whenDone.run();
- }
- }
- });
- }
-
- @Override
- public Plot hasPlot(final String world, final ChunkLoc chunk) {
- final int x1 = chunk.x << 4;
- final int z1 = chunk.z << 4;
- final int x2 = x1 + 15;
- final int z2 = z1 + 15;
- final Location bot = new Location(world, x1, 0, z1);
- Plot plot;
- plot = MainUtil.getPlotAbs(bot);
- if ((plot != null) && (plot.owner != null)) {
- return plot;
- }
- final Location top = new Location(world, x2, 0, z2);
- plot = MainUtil.getPlotAbs(top);
- if ((plot != null) && (plot.owner != null)) {
- return plot;
- }
- return null;
- }
-
private static HashMap chestContents;
private static HashMap furnaceContents;
private static HashMap dispenserContents;
diff --git a/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java
index 2af80ef19..b5368193e 100644
--- a/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java
+++ b/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java
@@ -44,9 +44,8 @@ public class BukkitUtil extends BlockManager {
public static void removePlayer(final String plr) {
lastPlayer = null;
lastPlotPlayer = null;
- UUIDHandler.getPlayers().remove(plr);
}
-
+
// These weren't being used, but they might be useful later, so I'm just commenting them out
// private static int getMaxHeight(final String world) {
// return getWorld(world).getMaxHeight();
diff --git a/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java b/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java
index 4415dfc32..4c8d96213 100644
--- a/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java
+++ b/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java
@@ -261,7 +261,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
if (block.getData() == data) {
return;
}
- block.setData(data);
+ block.setData(data, false);
return;
}
// blockstate
diff --git a/src/main/java/com/plotsquared/listener/PlotListener.java b/src/main/java/com/plotsquared/listener/PlotListener.java
index be8ac7bde..652c9e133 100644
--- a/src/main/java/com/plotsquared/listener/PlotListener.java
+++ b/src/main/java/com/plotsquared/listener/PlotListener.java
@@ -25,8 +25,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import org.bukkit.ChatColor;
-
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
@@ -37,6 +35,7 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotHandler;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
+import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.CommentManager;
import com.intellectualcrafters.plot.util.EventUtil;
@@ -76,7 +75,12 @@ public class PlotListener {
final Flag greetingFlag = flags.get("greeting");
if (greetingFlag != null) {
greeting = (String) greetingFlag.getValue();
- pp.sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + greeting));
+ MainUtil.format(C.PREFIX_GREETING.s() + greeting, plot, pp, false, new RunnableVal() {
+ @Override
+ public void run() {
+ MainUtil.sendMessage(pp, value);
+ }
+ });
} else {
greeting = "";
}
@@ -189,7 +193,7 @@ public class PlotListener {
if (pw == null) {
return true;
}
- if (FlagManager.getPlotFlag(plot, "gamemode") != null) {
+ if (FlagManager.getPlotFlagRaw(plot, "gamemode") != null) {
if (pp.getGamemode() != pw.GAMEMODE) {
if (!Permissions.hasPermission(pp, "plots.gamemode.bypass")) {
pp.setGamemode(pw.GAMEMODE);
@@ -198,11 +202,16 @@ public class PlotListener {
}
}
}
- final Flag farewell = FlagManager.getPlotFlag(plot, "farewell");
+ final Flag farewell = FlagManager.getPlotFlagRaw(plot, "farewell");
if (farewell != null) {
- pp.sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + farewell.getValueString()));
+ MainUtil.format(C.PREFIX_FAREWELL.s() + farewell.getValueString(), plot, pp, false, new RunnableVal() {
+ @Override
+ public void run() {
+ MainUtil.sendMessage(pp, value);
+ }
+ });
}
- final Flag leave = FlagManager.getPlotFlag(plot, "notify-leave");
+ final Flag leave = FlagManager.getPlotFlagRaw(plot, "notify-leave");
if ((leave != null) && ((Boolean) leave.getValue())) {
if (!Permissions.hasPermission(pp, "plots.flag.notify-enter.bypass")) {
for (final UUID uuid : PlotHandler.getOwners(plot)) {
@@ -213,16 +222,16 @@ public class PlotListener {
}
}
}
- if (FlagManager.getPlotFlag(plot, "fly") != null) {
+ if (FlagManager.getPlotFlagRaw(plot, "fly") != null) {
final PlotGamemode gamemode = pp.getGamemode();
if ((gamemode == PlotGamemode.SURVIVAL) || (gamemode == PlotGamemode.ADVENTURE)) {
pp.setFlight(false);
}
}
- if (FlagManager.getPlotFlag(plot, "time") != null) {
+ if (FlagManager.getPlotFlagRaw(plot, "time") != null) {
pp.setTime(Long.MAX_VALUE);
}
- if (FlagManager.getPlotFlag(plot, "weather") != null) {
+ if (FlagManager.getPlotFlagRaw(plot, "weather") != null) {
pp.setWeather(PlotWeather.RESET);
}
final Location lastLoc = (Location) pp.getMeta("music");
diff --git a/src/main/java/com/plotsquared/listener/WEManager.java b/src/main/java/com/plotsquared/listener/WEManager.java
index c7d766a33..585e15597 100644
--- a/src/main/java/com/plotsquared/listener/WEManager.java
+++ b/src/main/java/com/plotsquared/listener/WEManager.java
@@ -43,7 +43,7 @@ public class WEManager {
return regions;
}
for (final Plot plot : PS.get().getPlotsInWorld(player.getLocation().getWorld())) {
- if (!plot.isBasePlot() || (Settings.DONE_RESTRICTS_BUILDING && (FlagManager.getPlotFlag(plot, "done") != null))) {
+ if (!plot.isBasePlot() || (Settings.DONE_RESTRICTS_BUILDING && (FlagManager.getPlotFlagRaw(plot, "done") != null))) {
continue;
}
if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) {
diff --git a/src/main/java/com/plotsquared/object/schematic/StateWrapper.java b/src/main/java/com/plotsquared/object/schematic/StateWrapper.java
index 38be62869..ab3658fa6 100644
--- a/src/main/java/com/plotsquared/object/schematic/StateWrapper.java
+++ b/src/main/java/com/plotsquared/object/schematic/StateWrapper.java
@@ -49,7 +49,7 @@ public class StateWrapper {
short id = itemComp.getShort("id");
String idStr = itemComp.getString("id");
if ((idStr != null) && !MathMan.isInteger(idStr)) {
- idStr = idStr.split(":")[1].toLowerCase();
+ idStr = idStr.split(":")[0].toLowerCase();
id = (short) ItemType.getId(idStr);
}
ids[i] = id;
diff --git a/src/main/java/com/plotsquared/sponge/SpongeHybridUtils.java b/src/main/java/com/plotsquared/sponge/SpongeHybridUtils.java
index 350d39250..45daf2aac 100644
--- a/src/main/java/com/plotsquared/sponge/SpongeHybridUtils.java
+++ b/src/main/java/com/plotsquared/sponge/SpongeHybridUtils.java
@@ -6,23 +6,14 @@ import org.spongepowered.api.world.World;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.HybridUtils;
-import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotBlock;
+import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.plotsquared.sponge.util.SpongeUtil;
public class SpongeHybridUtils extends HybridUtils {
- @Override
- public void analyzePlot(final Plot plot, final RunnableVal whenDone) {
- // TODO Auto-generated method stub
- PS.debug("analyzePlot is not implemented");
- if (whenDone != null) {
- whenDone.run();
- }
- }
-
@Override
public int checkModified(final String worldname, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) {
PS.debug("checkModified is not implemented");
@@ -68,4 +59,10 @@ public class SpongeHybridUtils extends HybridUtils {
return ey;
}
+ @Override
+ public void analyzeRegion(String world, RegionWrapper region, RunnableVal whenDone) {
+ // TODO Auto-generated method stub
+ whenDone.run();
+ }
+
}
diff --git a/src/main/java/com/plotsquared/sponge/SpongeMain.java b/src/main/java/com/plotsquared/sponge/SpongeMain.java
index 437cb118f..02fdb0c79 100644
--- a/src/main/java/com/plotsquared/sponge/SpongeMain.java
+++ b/src/main/java/com/plotsquared/sponge/SpongeMain.java
@@ -11,6 +11,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
import java.util.UUID;
import org.slf4j.Logger;
@@ -20,12 +21,11 @@ import org.spongepowered.api.Server;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.block.BlockTypes;
-import org.spongepowered.api.entity.player.Player;
-import org.spongepowered.api.event.Subscribe;
-import org.spongepowered.api.event.entity.player.PlayerChatEvent;
-import org.spongepowered.api.event.state.InitializationEvent;
-import org.spongepowered.api.event.state.PreInitializationEvent;
-import org.spongepowered.api.event.state.ServerAboutToStartEvent;
+import org.spongepowered.api.entity.living.player.Player;
+import org.spongepowered.api.event.Listener;
+import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
+import org.spongepowered.api.event.game.state.GameInitializationEvent;
+import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginContainer;
import org.spongepowered.api.service.profile.GameProfileResolver;
@@ -37,7 +37,6 @@ import org.spongepowered.api.world.DimensionTypes;
import org.spongepowered.api.world.GeneratorTypes;
import org.spongepowered.api.world.World;
-import com.google.common.base.Optional;
import com.google.inject.Inject;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.plot.IPlotMain;
@@ -71,6 +70,7 @@ import com.plotsquared.sponge.util.SpongeBlockManager;
import com.plotsquared.sponge.util.SpongeChatManager;
import com.plotsquared.sponge.util.SpongeChunkManager;
import com.plotsquared.sponge.util.SpongeCommand;
+import com.plotsquared.sponge.util.SpongeEconHandler;
import com.plotsquared.sponge.util.SpongeEventUtil;
import com.plotsquared.sponge.util.SpongeInventoryUtil;
import com.plotsquared.sponge.util.SpongeMetrics;
@@ -215,19 +215,19 @@ public class SpongeMain implements IPlotMain, PluginContainer {
///////////////////////////////////////////////////////////////////////
///////////////////// ON ENABLE /////////////////////
- @Subscribe
- public void init(final InitializationEvent event) {
- log("INIT");
+ @Listener
+ public void init(final GameInitializationEvent event) {
+ log("P^2 INIT");
}
- @Subscribe
- public void onInit(final PreInitializationEvent event) {
- log("PRE INIT");
+ @Listener
+ public void onInit(final GamePreInitializationEvent event) {
+ log("P^2 PRE INIT");
}
- @Subscribe
- public void onServerAboutToStart(final ServerAboutToStartEvent event) {
- log("ABOUT START");
+ @Listener
+ public void onServerAboutToStart(final GameAboutToStartServerEvent event) {
+ log("P^2 ABOUT START");
THIS = this;
//
@@ -381,13 +381,6 @@ public class SpongeMain implements IPlotMain, PluginContainer {
}
}
- @Subscribe
- public void onPlayerChat(final PlayerChatEvent event) {
- // This is how events sort of work?
- final Player player = event.getUser();
- log(player.getWorld().getName());
- }
-
@Override
public void log(String message) {
message = C.format(message, C.replacements);
@@ -455,8 +448,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
public EconHandler getEconomyHandler() {
// TODO Auto-generated method stub
// Nothing like Vault exists yet
- PS.log("getEconomyHandler NOT IMPLEMENTED YET");
- return null;
+ return new SpongeEconHandler();
}
@Override
@@ -506,7 +498,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
@Override
public void registerPlayerEvents() {
- game.getEventManager().register(this, new MainListener());
+ game.getEventManager().registerListeners(this, new MainListener());
}
@Override
diff --git a/src/main/java/com/plotsquared/sponge/SpongeSchematicHandler.java b/src/main/java/com/plotsquared/sponge/SpongeSchematicHandler.java
index d8c7a834b..e54e2fa38 100644
--- a/src/main/java/com/plotsquared/sponge/SpongeSchematicHandler.java
+++ b/src/main/java/com/plotsquared/sponge/SpongeSchematicHandler.java
@@ -1,8 +1,10 @@
package com.plotsquared.sponge;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Set;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.world.World;
@@ -17,7 +19,9 @@ import com.intellectualcrafters.jnbt.Tag;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotBlock;
+import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
+import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.sponge.util.SpongeUtil;
@@ -25,32 +29,21 @@ import com.plotsquared.sponge.util.SpongeUtil;
public class SpongeSchematicHandler extends SchematicHandler {
@Override
- public void getCompoundTag(final String world, final Location pos1, final Location pos2, final RunnableVal whenDone) {
-
+ public void getCompoundTag(final String world, final Set regions, final RunnableVal whenDone) {
// async
TaskManager.runTaskAsync(new Runnable() {
-
@Override
public void run() {
// Main positions
- final int p1x = pos1.getX();
- final int p1z = pos1.getZ();
- final int p2x = pos2.getX();
- final int p2z = pos2.getZ();
- final int bcx = p1x >> 4;
- final int bcz = p1z >> 4;
- final int tcx = p2x >> 4;
- final int tcz = p2z >> 4;
- final int sy = pos1.getY();
- final int ey = pos2.getY();
-
- final int width = (pos2.getX() - pos1.getX()) + 1;
- final int height = (pos2.getY() - pos1.getY()) + 1;
- final int length = (pos2.getZ() - pos1.getZ()) + 1;
+ Location[] corners = MainUtil.getCorners(world, regions);
+ final Location bot = corners[0];
+ final Location top = corners[1];
+ final int width = (top.getX() - bot.getX()) + 1;
+ final int height = (top.getY() - bot.getY()) + 1;
+ final int length = (top.getZ() - bot.getZ()) + 1;
// Main Schematic tag
final HashMap schematic = new HashMap<>();
-
schematic.put("Width", new ShortTag("Width", (short) width));
schematic.put("Length", new ShortTag("Length", (short) length));
schematic.put("Height", new ShortTag("Height", (short) height));
@@ -61,196 +54,16 @@ public class SpongeSchematicHandler extends SchematicHandler {
schematic.put("WEOffsetX", new IntTag("WEOffsetX", 0));
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
-
// Arrays of data types
final List tileEntities = new ArrayList();
final byte[] blocks = new byte[width * height * length];
final byte[] blockData = new byte[width * height * length];
-
- // Generate list of chunks
- final ArrayList chunks = new ArrayList();
- for (int x = bcx; x <= tcx; x++) {
- for (int z = bcz; z <= tcz; z++) {
- chunks.add(new ChunkLoc(x, z));
- }
- }
-
- final World worldObj = SpongeUtil.getWorld(world);
- // Main thread
+ // Queue
+ final ArrayDeque queue = new ArrayDeque<>(regions);
TaskManager.runTask(new Runnable() {
@Override
public void run() {
- final long start = System.currentTimeMillis();
- while ((chunks.size() > 0) && ((System.currentTimeMillis() - start) < 20)) {
- // save schematics
- final ChunkLoc chunk = chunks.remove(0);
-
- if (!worldObj.loadChunk(chunk.x << 4, 1, chunk.z << 4, false).isPresent()) {
- System.out.println("COULD NOT LOAD CHUNK AT: " + chunk.x + "," + chunk.z);
- // TODO continue - right now sponge chunk api seems to be broken :(
- // continue;
- }
-
- final int X = chunk.x;
- final int Z = chunk.z;
- int xxb = X << 4;
- int zzb = Z << 4;
- int xxt = xxb + 15;
- int zzt = zzb + 15;
-
- if (X == bcx) {
- xxb = p1x;
- }
- if (X == tcx) {
- xxt = p2x;
- }
- if (Z == bcz) {
- zzb = p1z;
- }
- if (Z == tcz) {
- zzt = p2z;
- }
- for (int y = sy; y <= Math.min(255, ey); y++) {
- final int ry = y - sy;
- final int i1 = (ry * width * length);
- for (int z = zzb; z <= zzt; z++) {
- final int rz = z - p1z;
- final int i2 = i1 + (rz * width);
- for (int x = xxb; x <= xxt; x++) {
- final int rx = x - p1x;
- final int index = i2 + rx;
-
- final BlockState state = worldObj.getBlock(x, y, z);
- PlotBlock block = SpongeMain.THIS.getPlotBlock(state);
- if (block == null) {
- block = SpongeMain.THIS.registerBlock(state);
- }
- final int id = block.id;
- switch (id) {
- case 0:
- case 2:
- case 4:
- case 13:
- case 14:
- case 15:
- case 20:
- case 21:
- case 22:
- case 24:
- case 30:
- case 32:
- case 37:
- case 39:
- case 40:
- case 41:
- case 42:
- case 45:
- case 46:
- case 47:
- case 48:
- case 49:
- case 50:
- case 51:
- case 55:
- case 56:
- case 57:
- case 58:
- case 60:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- case 73:
- case 74:
- case 75:
- case 76:
- case 78:
- case 79:
- case 80:
- case 81:
- case 82:
- case 83:
- case 85:
- case 87:
- case 88:
- case 101:
- case 102:
- case 103:
- case 110:
- case 112:
- case 113:
- case 121:
- case 122:
- case 129:
- case 133:
- case 165:
- case 166:
- case 169:
- case 170:
- case 172:
- case 173:
- case 174:
- case 181:
- case 182:
- case 188:
- case 189:
- case 190:
- case 191:
- case 192: {
- break;
- }
- case 54:
- case 130:
- case 142:
- case 27:
- case 137:
- case 52:
- case 154:
- case 84:
- case 25:
- case 144:
- case 138:
- case 176:
- case 177:
- case 63:
- case 68:
- case 323:
- case 117:
- case 116:
- case 28:
- case 66:
- case 157:
- case 61:
- case 62:
- case 140:
- case 146:
- case 149:
- case 150:
- case 158:
- case 23:
- case 123:
- case 124:
- case 29:
- case 33:
- case 151:
- case 178: {
- // TODO wrap block state...
- // TODO add block state to map
- }
- default: {
- blockData[index] = block.data;
- }
- }
- blocks[index] = (byte) id;
- }
- }
- }
-
- }
- if (chunks.size() != 0) {
- TaskManager.runTaskLater(this, 1);
- } else {
+ if (queue.size() == 0) {
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
@@ -264,7 +77,207 @@ public class SpongeSchematicHandler extends SchematicHandler {
System.gc();
}
});
+ return;
}
+ final Runnable regionTask = this;
+ RegionWrapper region = queue.poll();
+ Location pos1 = new Location(world, region.minX, region.minY, region.minZ);
+ Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ);
+ final int bx = bot.getX();
+ final int bz = bot.getZ();
+ final int p1x = pos1.getX();
+ final int p1z = pos1.getZ();
+ final int p2x = pos2.getX();
+ final int p2z = pos2.getZ();
+ final int bcx = p1x >> 4;
+ final int bcz = p1z >> 4;
+ final int tcx = p2x >> 4;
+ final int tcz = p2z >> 4;
+ final int sy = pos1.getY();
+ final int ey = pos2.getY();
+ // Generate list of chunks
+ final ArrayList chunks = new ArrayList();
+ for (int x = bcx; x <= tcx; x++) {
+ for (int z = bcz; z <= tcz; z++) {
+ chunks.add(new ChunkLoc(x, z));
+ }
+ }
+ final World worldObj = SpongeUtil.getWorld(world);
+ // Main thread
+ TaskManager.runTask(new Runnable() {
+ @Override
+ public void run() {
+ final long start = System.currentTimeMillis();
+ while ((chunks.size() > 0) && ((System.currentTimeMillis() - start) < 20)) {
+ // save schematics
+ final ChunkLoc chunk = chunks.remove(0);
+ final int X = chunk.x;
+ final int Z = chunk.z;
+ int xxb = X << 4;
+ int zzb = Z << 4;
+ if (!worldObj.getChunk(xxb, 1, zzb).isPresent() && !worldObj.loadChunk(xxb, 1, zzb, false).isPresent()) {
+ System.out.println("COULD NOT LOAD CHUNK AT: " + chunk.x + "," + chunk.z);
+ continue;
+ }
+ int xxt = xxb + 15;
+ int zzt = zzb + 15;
+
+ if (X == bcx) {
+ xxb = p1x;
+ }
+ if (X == tcx) {
+ xxt = p2x;
+ }
+ if (Z == bcz) {
+ zzb = p1z;
+ }
+ if (Z == tcz) {
+ zzt = p2z;
+ }
+ for (int y = sy; y <= Math.min(255, ey); y++) {
+ final int ry = y - sy;
+ final int i1 = (ry * width * length);
+ for (int z = zzb; z <= zzt; z++) {
+ final int rz = z - p1z;
+ final int i2 = i1 + (rz * width);
+ for (int x = xxb; x <= xxt; x++) {
+ final int rx = x - p1x;
+ final int index = i2 + rx;
+
+ final BlockState state = worldObj.getBlock(x, y, z);
+ PlotBlock block = SpongeMain.THIS.getPlotBlock(state);
+ if (block == null) {
+ block = SpongeMain.THIS.registerBlock(state);
+ }
+ final int id = block.id;
+ switch (id) {
+ case 0:
+ case 2:
+ case 4:
+ case 13:
+ case 14:
+ case 15:
+ case 20:
+ case 21:
+ case 22:
+ case 24:
+ case 30:
+ case 32:
+ case 37:
+ case 39:
+ case 40:
+ case 41:
+ case 42:
+ case 45:
+ case 46:
+ case 47:
+ case 48:
+ case 49:
+ case 50:
+ case 51:
+ case 55:
+ case 56:
+ case 57:
+ case 58:
+ case 60:
+ case 7:
+ case 8:
+ case 9:
+ case 10:
+ case 11:
+ case 73:
+ case 74:
+ case 75:
+ case 76:
+ case 78:
+ case 79:
+ case 80:
+ case 81:
+ case 82:
+ case 83:
+ case 85:
+ case 87:
+ case 88:
+ case 101:
+ case 102:
+ case 103:
+ case 110:
+ case 112:
+ case 113:
+ case 121:
+ case 122:
+ case 129:
+ case 133:
+ case 165:
+ case 166:
+ case 169:
+ case 170:
+ case 172:
+ case 173:
+ case 174:
+ case 181:
+ case 182:
+ case 188:
+ case 189:
+ case 190:
+ case 191:
+ case 192: {
+ break;
+ }
+ case 54:
+ case 130:
+ case 142:
+ case 27:
+ case 137:
+ case 52:
+ case 154:
+ case 84:
+ case 25:
+ case 144:
+ case 138:
+ case 176:
+ case 177:
+ case 63:
+ case 68:
+ case 323:
+ case 117:
+ case 116:
+ case 28:
+ case 66:
+ case 157:
+ case 61:
+ case 62:
+ case 140:
+ case 146:
+ case 149:
+ case 150:
+ case 158:
+ case 23:
+ case 123:
+ case 124:
+ case 29:
+ case 33:
+ case 151:
+ case 178: {
+ // TODO wrap block state...
+ // TODO add block state to map
+ }
+ default: {
+ blockData[index] = block.data;
+ }
+ }
+ blocks[index] = (byte) id;
+ }
+ }
+ }
+ }
+ if (chunks.size() != 0) {
+ TaskManager.runTaskLater(this, 1);
+ } else {
+ regionTask.run();
+ }
+ }
+ });
}
});
}
diff --git a/src/main/java/com/plotsquared/sponge/events/ClusterFlagRemoveEvent.java b/src/main/java/com/plotsquared/sponge/events/ClusterFlagRemoveEvent.java
index b27a10aee..53b02d5a0 100644
--- a/src/main/java/com/plotsquared/sponge/events/ClusterFlagRemoveEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/ClusterFlagRemoveEvent.java
@@ -1,6 +1,6 @@
package com.plotsquared.sponge.events;
-import org.spongepowered.api.event.AbstractEvent;
+import org.spongepowered.api.event.impl.AbstractEvent;
import org.spongepowered.api.event.Cancellable;
import com.intellectualcrafters.plot.flag.Flag;
diff --git a/src/main/java/com/plotsquared/sponge/events/PlayerClaimPlotEvent.java b/src/main/java/com/plotsquared/sponge/events/PlayerClaimPlotEvent.java
index 6534dc6c2..b1285ce3b 100644
--- a/src/main/java/com/plotsquared/sponge/events/PlayerClaimPlotEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/PlayerClaimPlotEvent.java
@@ -1,6 +1,6 @@
package com.plotsquared.sponge.events;
-import org.spongepowered.api.entity.player.Player;
+import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Cancellable;
import com.intellectualcrafters.plot.object.Plot;
diff --git a/src/main/java/com/plotsquared/sponge/events/PlayerEnterPlotEvent.java b/src/main/java/com/plotsquared/sponge/events/PlayerEnterPlotEvent.java
index 453efa582..60299226a 100644
--- a/src/main/java/com/plotsquared/sponge/events/PlayerEnterPlotEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/PlayerEnterPlotEvent.java
@@ -1,6 +1,6 @@
package com.plotsquared.sponge.events;
-import org.spongepowered.api.entity.player.Player;
+import org.spongepowered.api.entity.living.player.Player;
import com.intellectualcrafters.plot.object.Plot;
diff --git a/src/main/java/com/plotsquared/sponge/events/PlayerEvent.java b/src/main/java/com/plotsquared/sponge/events/PlayerEvent.java
index daf4a035f..3c30de943 100644
--- a/src/main/java/com/plotsquared/sponge/events/PlayerEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/PlayerEvent.java
@@ -1,7 +1,7 @@
package com.plotsquared.sponge.events;
-import org.spongepowered.api.entity.player.Player;
-import org.spongepowered.api.event.AbstractEvent;
+import org.spongepowered.api.entity.living.player.Player;
+import org.spongepowered.api.event.impl.AbstractEvent;
public abstract class PlayerEvent extends AbstractEvent {
diff --git a/src/main/java/com/plotsquared/sponge/events/PlayerLeavePlotEvent.java b/src/main/java/com/plotsquared/sponge/events/PlayerLeavePlotEvent.java
index 956dac9ca..8b95328df 100644
--- a/src/main/java/com/plotsquared/sponge/events/PlayerLeavePlotEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/PlayerLeavePlotEvent.java
@@ -1,6 +1,6 @@
package com.plotsquared.sponge.events;
-import org.spongepowered.api.entity.player.Player;
+import org.spongepowered.api.entity.living.player.Player;
import com.intellectualcrafters.plot.object.Plot;
diff --git a/src/main/java/com/plotsquared/sponge/events/PlayerPlotDeniedEvent.java b/src/main/java/com/plotsquared/sponge/events/PlayerPlotDeniedEvent.java
index f6facaec9..83cce7d16 100644
--- a/src/main/java/com/plotsquared/sponge/events/PlayerPlotDeniedEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/PlayerPlotDeniedEvent.java
@@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
import java.util.UUID;
-import org.spongepowered.api.entity.player.Player;
+import org.spongepowered.api.entity.living.player.Player;
import com.intellectualcrafters.plot.object.Plot;
diff --git a/src/main/java/com/plotsquared/sponge/events/PlayerPlotHelperEvent.java b/src/main/java/com/plotsquared/sponge/events/PlayerPlotHelperEvent.java
index 32b5980a8..7b23f2bec 100644
--- a/src/main/java/com/plotsquared/sponge/events/PlayerPlotHelperEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/PlayerPlotHelperEvent.java
@@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
import java.util.UUID;
-import org.spongepowered.api.entity.player.Player;
+import org.spongepowered.api.entity.living.player.Player;
import com.intellectualcrafters.plot.object.Plot;
diff --git a/src/main/java/com/plotsquared/sponge/events/PlayerPlotTrustedEvent.java b/src/main/java/com/plotsquared/sponge/events/PlayerPlotTrustedEvent.java
index 39f4fd9bd..dd93a4734 100644
--- a/src/main/java/com/plotsquared/sponge/events/PlayerPlotTrustedEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/PlayerPlotTrustedEvent.java
@@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
import java.util.UUID;
-import org.spongepowered.api.entity.player.Player;
+import org.spongepowered.api.entity.living.player.Player;
import com.intellectualcrafters.plot.object.Plot;
diff --git a/src/main/java/com/plotsquared/sponge/events/PlayerTeleportToPlotEvent.java b/src/main/java/com/plotsquared/sponge/events/PlayerTeleportToPlotEvent.java
index 1f8fcd2a1..9ee52568c 100644
--- a/src/main/java/com/plotsquared/sponge/events/PlayerTeleportToPlotEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/PlayerTeleportToPlotEvent.java
@@ -1,6 +1,6 @@
package com.plotsquared.sponge.events;
-import org.spongepowered.api.entity.player.Player;
+import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Cancellable;
import com.intellectualcrafters.plot.object.Location;
diff --git a/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java b/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java
index 91c46902e..7c1cdbfa9 100644
--- a/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java
@@ -1,6 +1,6 @@
package com.plotsquared.sponge.events;
-import org.spongepowered.api.event.AbstractEvent;
+import org.spongepowered.api.event.impl.AbstractEvent;
import org.spongepowered.api.event.Cancellable;
import com.intellectualcrafters.plot.object.PlotId;
diff --git a/src/main/java/com/plotsquared/sponge/events/PlotDeleteEvent.java b/src/main/java/com/plotsquared/sponge/events/PlotDeleteEvent.java
index f4db875dc..214e74dcf 100644
--- a/src/main/java/com/plotsquared/sponge/events/PlotDeleteEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/PlotDeleteEvent.java
@@ -1,6 +1,6 @@
package com.plotsquared.sponge.events;
-import org.spongepowered.api.event.AbstractEvent;
+import org.spongepowered.api.event.impl.AbstractEvent;
import com.intellectualcrafters.plot.object.PlotId;
diff --git a/src/main/java/com/plotsquared/sponge/events/PlotEvent.java b/src/main/java/com/plotsquared/sponge/events/PlotEvent.java
index 57e289a27..6342628a5 100644
--- a/src/main/java/com/plotsquared/sponge/events/PlotEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/PlotEvent.java
@@ -1,6 +1,6 @@
package com.plotsquared.sponge.events;
-import org.spongepowered.api.event.AbstractEvent;
+import org.spongepowered.api.event.impl.AbstractEvent;
import com.intellectualcrafters.plot.object.Plot;
diff --git a/src/main/java/com/plotsquared/sponge/events/PlotMergeEvent.java b/src/main/java/com/plotsquared/sponge/events/PlotMergeEvent.java
index 063a1c4ed..ff4110cbd 100644
--- a/src/main/java/com/plotsquared/sponge/events/PlotMergeEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/PlotMergeEvent.java
@@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
import java.util.ArrayList;
-import org.spongepowered.api.event.AbstractEvent;
+import org.spongepowered.api.event.impl.AbstractEvent;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.world.World;
diff --git a/src/main/java/com/plotsquared/sponge/events/PlotUnlinkEvent.java b/src/main/java/com/plotsquared/sponge/events/PlotUnlinkEvent.java
index 0be4cf5e0..6496b8399 100644
--- a/src/main/java/com/plotsquared/sponge/events/PlotUnlinkEvent.java
+++ b/src/main/java/com/plotsquared/sponge/events/PlotUnlinkEvent.java
@@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
import java.util.ArrayList;
-import org.spongepowered.api.event.AbstractEvent;
+import org.spongepowered.api.event.impl.AbstractEvent;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.world.World;
diff --git a/src/main/java/com/plotsquared/sponge/listener/MainListener.java b/src/main/java/com/plotsquared/sponge/listener/MainListener.java
index d4ac8d024..d4836f846 100644
--- a/src/main/java/com/plotsquared/sponge/listener/MainListener.java
+++ b/src/main/java/com/plotsquared/sponge/listener/MainListener.java
@@ -3,49 +3,54 @@ package com.plotsquared.sponge.listener;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.Predicate;
+import org.spongepowered.api.GameProfile;
+import org.spongepowered.api.block.BlockSnapshot;
import org.spongepowered.api.block.BlockState;
+import org.spongepowered.api.block.BlockTransaction;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.EntityTypes;
+import org.spongepowered.api.entity.Transform;
+import org.spongepowered.api.entity.explosive.Explosive;
+import org.spongepowered.api.entity.explosive.PrimedTNT;
import org.spongepowered.api.entity.living.Ambient;
import org.spongepowered.api.entity.living.Living;
import org.spongepowered.api.entity.living.animal.Animal;
import org.spongepowered.api.entity.living.monster.Monster;
-import org.spongepowered.api.entity.player.Player;
+import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.vehicle.Boat;
import org.spongepowered.api.entity.vehicle.minecart.Minecart;
-import org.spongepowered.api.event.Subscribe;
-import org.spongepowered.api.event.block.BlockMoveEvent;
-import org.spongepowered.api.event.block.BlockRedstoneUpdateEvent;
-import org.spongepowered.api.event.block.FloraGrowEvent;
-import org.spongepowered.api.event.block.FluidSpreadEvent;
-import org.spongepowered.api.event.entity.EntityChangeBlockEvent;
-import org.spongepowered.api.event.entity.EntitySpawnEvent;
-import org.spongepowered.api.event.entity.EntityTeleportEvent;
-import org.spongepowered.api.event.entity.player.PlayerBreakBlockEvent;
-import org.spongepowered.api.event.entity.player.PlayerChangeWorldEvent;
-import org.spongepowered.api.event.entity.player.PlayerChatEvent;
-import org.spongepowered.api.event.entity.player.PlayerInteractBlockEvent;
-import org.spongepowered.api.event.entity.player.PlayerJoinEvent;
-import org.spongepowered.api.event.entity.player.PlayerMoveEvent;
-import org.spongepowered.api.event.entity.player.PlayerPlaceBlockEvent;
-import org.spongepowered.api.event.entity.player.PlayerQuitEvent;
-import org.spongepowered.api.event.message.CommandEvent;
-import org.spongepowered.api.event.network.PlayerConnectionEvent;
-import org.spongepowered.api.event.world.ChunkPreGenerateEvent;
-import org.spongepowered.api.event.world.WorldOnExplosionEvent;
-import org.spongepowered.api.network.PlayerConnection;
+import org.spongepowered.api.event.Listener;
+import org.spongepowered.api.event.action.LightningEvent;
+import org.spongepowered.api.event.action.MessageEvent;
+import org.spongepowered.api.event.block.BreakBlockEvent;
+import org.spongepowered.api.event.block.ChangeBlockEvent;
+import org.spongepowered.api.event.block.GrowBlockEvent;
+import org.spongepowered.api.event.block.HarvestBlockEvent;
+import org.spongepowered.api.event.block.InteractBlockEvent;
+import org.spongepowered.api.event.block.MoveBlockEvent;
+import org.spongepowered.api.event.block.NotifyNeighborBlockEvent;
+import org.spongepowered.api.event.block.PlaceBlockEvent;
+import org.spongepowered.api.event.cause.Cause;
+import org.spongepowered.api.event.command.SendCommandEvent;
+import org.spongepowered.api.event.entity.BreedEntityEvent;
+import org.spongepowered.api.event.entity.DisplaceEntityEvent;
+import org.spongepowered.api.event.entity.SpawnEntityEvent;
+import org.spongepowered.api.event.network.ClientConnectionEvent;
+import org.spongepowered.api.event.world.ExplosionEvent;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.Texts;
-import org.spongepowered.api.util.command.CommandSource;
+import org.spongepowered.api.util.Direction;
import org.spongepowered.api.world.World;
-import org.spongepowered.api.world.explosion.Explosion;
import org.spongepowered.api.world.extent.Extent;
import com.flowpowered.math.vector.Vector3d;
-import com.flowpowered.math.vector.Vector3i;
-import com.google.common.base.Predicate;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
@@ -60,10 +65,9 @@ import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.StringWrapper;
-import com.intellectualcrafters.plot.util.ChunkManager;
-import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.MainUtil;
+import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
@@ -78,56 +82,117 @@ public class MainListener {
/*
* TODO:
* - Anything marked with a TODO below
- * - BlockSpreadEvent
* - BlockPhysicsEvent
* - BlockFormEvent
* - BlockFadeEvent
* - BlockFromToEvent
* - BlockDamageEvent
* - Structure (tree etc)
+ * - ChunkPreGenerateEvent
* - PlayerIgniteBlockEvent
* - PlayerBucketEmptyEvent
* - PlayerBucketFillEvent
* - VehicleCreateEvent
* - HangingPlaceEvent
* - HangingBreakEvent
- * - Liquid flow
+ * - EntityChangeBlockEvent
* - PVP
* - block dispense
* - PVE
* - VehicleDestroy
* - Projectile
+ * - enderman harvest
*/
- @Subscribe
- public void onFluidSpread(final FluidSpreadEvent event) {
- // TODO This event isn't called
- final Location loc = SpongeUtil.getLocation(event.getLocation());
- final Plot plot = MainUtil.getPlot(loc);
- if (plot == null) {
- if (MainUtil.isPlotAreaAbs(loc)) {
- event.setCancelled(true);
- }
- return;
- }
- event.filterLocations(new Predicate>() {
+ @Listener
+ public void onFluidSpread(final NotifyNeighborBlockEvent.Spread event) {
+ onPhysics(event);
+ }
+
+ @Listener
+ public void onFluidSpread(final NotifyNeighborBlockEvent.Burn event) {
+ onPhysics(event);
+ }
+
+ @Listener
+ public void onFluidSpread(final NotifyNeighborBlockEvent.Ignite event) {
+ onPhysics(event);
+ }
+
+ @Listener
+ public void onFluidSpread(final NotifyNeighborBlockEvent.Power event) {
+ // TODO redstone
+ }
+
+ public void onPhysics(final NotifyNeighborBlockEvent event) {
+ final AtomicBoolean cancelled = new AtomicBoolean(false);
+ final Map> relatives = event.getRelatives();
+ event.filterDirections(new Predicate() {
+
@Override
- public boolean apply(final org.spongepowered.api.world.Location loc) {
- if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
- return false;
+ public boolean test(Direction dir) {
+ if (cancelled.get()) {
+ return true;
}
- return true;
+ org.spongepowered.api.world.Location loc = relatives.get(dir);
+ com.intellectualcrafters.plot.object.Location plotloc = SpongeUtil.getLocation(loc.getExtent().getName(), loc);
+ Plot plot = MainUtil.getPlot(plotloc);
+ if (plot == null) {
+ if (MainUtil.isPlotAreaAbs(plotloc)) {
+ cancelled.set(true);
+ return false;
+ }
+ cancelled.set(true);
+ return true;
+ }
+ org.spongepowered.api.world.Location relative = loc.getRelative(dir);
+ com.intellectualcrafters.plot.object.Location relLoc = SpongeUtil.getLocation(relative.getExtent().getName(), relative);
+ if (plot.equals(MainUtil.getPlot(relLoc))) {
+ return true;
+ }
+ return false;
}
});
}
- @Subscribe
- public void onMobSpawn(final EntitySpawnEvent event) {
- final Entity entity = event.getEntity();
+ public T getCause(Cause cause, Class clazz) {
+ Optional> root = cause.root();
+ if (root.isPresent()) {
+ Object source = root.get();
+ if (clazz.isInstance(source)) {
+ return (T) source;
+ }
+ }
+ return null;
+ }
+
+ @Listener
+ public void onCommand(final BreedEntityEvent.Breed event) {
+ final Location loc = SpongeUtil.getLocation(event.getTargetEntity());
+ final String world = loc.getWorld();
+ final PlotWorld plotworld = PS.get().getPlotWorld(world);
+ if (plotworld == null) {
+ return;
+ }
+ final Plot plot = MainUtil.getPlot(loc);
+ if (plot == null) {
+ if (MainUtil.isPlotRoad(loc)) {
+ event.setCancelled(true);
+ }
+ return;
+ }
+ if (!plotworld.SPAWN_BREEDING) {
+ event.setCancelled(true);
+ }
+ }
+
+ @Listener
+ public void onMobSpawn(final SpawnEntityEvent event) {
+ final Entity entity = event.getTargetEntity();
if (entity instanceof Player) {
return;
}
- final Location loc = SpongeUtil.getLocation(event.getLocation());
+ final Location loc = SpongeUtil.getLocation(entity);
final String world = loc.getWorld();
final PlotWorld plotworld = PS.get().getPlotWorld(world);
if (plotworld == null) {
@@ -141,11 +206,15 @@ public class MainListener {
return;
}
PS.get().getPlotWorld(world);
-
+ // Player player = this. getCause(event.getCause());
// TODO selectively cancel depending on spawn reason
// - Not sure if possible to get spawn reason (since there are no callbacks)
-
- if (entity.getType() == EntityTypes.DROPPED_ITEM) {
+ // if (player != null && !plotworld.SPAWN_EGGS) {
+ // event.setCancelled(true);
+ // return;
+ // }
+
+ if (entity.getType() == EntityTypes.ITEM) {
if (FlagManager.isPlotFlagFalse(plot, "item-drop")) {
event.setCancelled(true);
}
@@ -157,7 +226,7 @@ public class MainListener {
event.setCancelled(true);
return;
}
- final Flag mobCap = FlagManager.getPlotFlag(plot, "mob-cap");
+ final Flag mobCap = FlagManager.getPlotFlagRaw(plot, "mob-cap");
if (mobCap != null) {
final Integer cap = (Integer) mobCap.getValue();
if (cap == 0) {
@@ -173,7 +242,7 @@ public class MainListener {
}
}
if ((entity instanceof Ambient) || (entity instanceof Animal)) {
- final Flag animalFlag = FlagManager.getPlotFlag(plot, "animal-cap");
+ final Flag animalFlag = FlagManager.getPlotFlagRaw(plot, "animal-cap");
if (animalFlag != null) {
final int cap = ((Integer) animalFlag.getValue());
if (cap == 0) {
@@ -190,7 +259,7 @@ public class MainListener {
}
}
if (entity instanceof Monster) {
- final Flag monsterFlag = FlagManager.getPlotFlag(plot, "hostile-cap");
+ final Flag monsterFlag = FlagManager.getPlotFlagRaw(plot, "hostile-cap");
if (monsterFlag != null) {
final int cap = ((Integer) monsterFlag.getValue());
if (cap == 0) {
@@ -209,7 +278,7 @@ public class MainListener {
return;
}
if ((entity instanceof Minecart) || (entity instanceof Boat)) {
- final Flag vehicleFlag = FlagManager.getPlotFlag(plot, "vehicle-cap");
+ final Flag vehicleFlag = FlagManager.getPlotFlagRaw(plot, "vehicle-cap");
if (vehicleFlag != null) {
final int cap = ((Integer) vehicleFlag.getValue());
if (cap == 0) {
@@ -225,7 +294,7 @@ public class MainListener {
}
}
}
- final Flag entityCap = FlagManager.getPlotFlag(plot, "entity-cap");
+ final Flag entityCap = FlagManager.getPlotFlagRaw(plot, "entity-cap");
if (entityCap != null) {
final Integer cap = (Integer) entityCap.getValue();
if (cap == 0) {
@@ -240,25 +309,20 @@ public class MainListener {
return;
}
}
-
- }
-
- @Subscribe
- public void onBlockChange(final EntityChangeBlockEvent event) {
- final Entity entity = event.getEntity();
- if (entity.getType() == EntityTypes.PLAYER) {
- return;
- }
- if (PS.get().isPlotWorld(entity.getWorld().getName())) {
- event.setCancelled(true);
+ if (entity instanceof PrimedTNT) {
+ Vector3d pos = entity.getLocation().getPosition();
+ entity.setRotation(new Vector3d(MathMan.roundInt(pos.getX()), MathMan.roundInt(pos.getY()), MathMan.roundInt(pos.getZ())));
}
}
- @Subscribe
- public void onCommand(final CommandEvent event) {
+ @Listener
+ public void onCommand(final SendCommandEvent event) {
switch (event.getCommand().toLowerCase()) {
case "plotme": {
- final CommandSource source = event.getSource();
+ Player source = this. getCause(event.getCause(), Player.class);
+ if (source == null) {
+ return;
+ }
if (Settings.USE_PLOTME_ALIAS) {
SpongeMain.THIS.getGame().getCommandDispatcher().process(source, ("plots " + event.getArguments()).trim());
} else {
@@ -269,47 +333,64 @@ public class MainListener {
}
}
- @Subscribe
- public void onBlockMove(final BlockMoveEvent event) {
- final org.spongepowered.api.world.Location block = event.getLocations().get(0);
- final Extent extent = block.getExtent();
- if (extent instanceof World) {
- final World world = (World) extent;
- final String worldname = world.getName();
- if (!PS.get().isPlotWorld(worldname)) {
+ public void onBlockChange(ChangeBlockEvent event) {
+ final World world = event.getTargetWorld();
+ final String worldname = world.getName();
+ if (!PS.get().isPlotWorld(worldname)) {
+ return;
+ }
+ List transactions = event.getTransactions();
+ BlockTransaction first = transactions.get(0);
+ Location loc = SpongeUtil.getLocation(worldname, first.getOriginal().getPosition());
+ Plot plot = MainUtil.getPlot(loc);
+ if (plot == null) {
+ if (!MainUtil.isPlotAreaAbs(loc)) {
return;
}
- event.filterLocations(new Predicate>() {
- @Override
- public boolean apply(final org.spongepowered.api.world.Location loc) {
- if (MainUtil.isPlotRoad(SpongeUtil.getLocation(worldname, loc))) {
- return false;
- }
- return true;
+ event.setCancelled(true);
+ return;
+ }
+ event.filter(new Predicate>() {
+
+ @Override
+ public boolean test(org.spongepowered.api.world.Location loc) {
+ if (MainUtil.isPlotRoad(SpongeUtil.getLocation(worldname, loc))) {
+ return false;
}
- });
- }
+ return true;
+ }
+ });
}
- @Subscribe
- public void onFloraGrow(final FloraGrowEvent event) {
- final org.spongepowered.api.world.Location block = event.getLocation();
- final Extent extent = block.getExtent();
- if (extent instanceof World) {
- final World world = (World) extent;
- final String worldname = world.getName();
- if (!PS.get().isPlotWorld(worldname)) {
- return;
- }
- if (MainUtil.isPlotRoad(SpongeUtil.getLocation(worldname, block))) {
- event.setCancelled(true);
- }
- }
+ @Listener
+ public void onBlockMove(final MoveBlockEvent event) {
+ onBlockChange(event);
}
- @Subscribe
- public void onChat(final PlayerChatEvent event) {
- final Player player = event.getEntity();
+ @Listener
+ public void onFloraGrow(final GrowBlockEvent event) {
+ onBlockChange(event);
+ }
+
+ @Listener
+ public void onLightning(final LightningEvent.Strike event) {
+ onBlockChange(event);
+ }
+
+
+ public void printCause(String method, Cause cause) {
+ System.out.println(method + ": " + cause.toString());
+ System.out.println(method + ": " + cause.getClass());
+ System.out.println(method + ": " + (cause.root().isPresent() ? cause.root().get() : null));
+ }
+
+ @Listener
+ public void onChat(final MessageEvent event) {
+ // TODO
+ Player player = this. getCause(event.getCause(), Player.class);
+ if (player == null) {
+ return;
+ }
final String world = player.getWorld().getName();
if (!PS.get().isPlotWorld(world)) {
return;
@@ -324,7 +405,7 @@ public class MainListener {
if (plot == null) {
return;
}
- final Text message = event.getUnformattedMessage();
+ final Text message = event.getMessage();
// TODO use display name rather than username
// - Getting displayname currently causes NPE, so wait until sponge fixes that
@@ -357,150 +438,101 @@ public class MainListener {
}
((SpongePlayer) user).player.sendMessage(Texts.join(components));
}
- event.setNewMessage(Texts.of());
+ event.setMessage(Texts.of());
event.setCancelled(true);
}
- @Subscribe
- public void onBigBoom(final WorldOnExplosionEvent event) {
- final World worldObj = event.getWorld();
- final String world = worldObj.getName();
- if (!PS.get().isPlotWorld(world)) {
+ @Listener
+ public void onBigBoom(final ExplosionEvent.Detonate event) {
+ final World world = event.getTargetWorld();
+ final String worldname = world.getName();
+ if (!PS.get().isPlotWorld(worldname)) {
return;
}
- final Explosion explosion = event.getExplosion();
- final Vector3d origin = explosion.getOrigin();
- final Location loc = new Location(world, origin.getFloorX(), origin.getFloorY(), origin.getFloorZ());
- final Plot plot = MainUtil.getPlot(loc);
- if ((plot != null) && plot.hasOwner()) {
- if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
- event.filterLocations(new Predicate>() {
- @Override
- public boolean apply(final org.spongepowered.api.world.Location loc) {
- if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
- return false;
- }
- return true;
- }
- });
- event.filterEntities(new Predicate() {
- @Override
- public boolean apply(final Entity entity) {
- if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) {
- return false;
- }
- return true;
- }
- });
+ Optional source = event.getExplosion().getSourceExplosive();
+ if (!source.isPresent()) {
+ event.setCancelled(true);
+ return;
+ }
+ Explosive tnt = source.get();
+ Location origin = SpongeUtil.getLocation(worldname, tnt.getRotation());
+ Plot originPlot = origin.getPlot();
+ Location current = SpongeUtil.getLocation(tnt);
+ final Plot currentPlot = current.getPlot();
+ if (!Objects.equals(originPlot, currentPlot)) {
+ event.setCancelled(true);
+ return;
+ }
+ if (originPlot == null && !MainUtil.isPlotAreaAbs(current)) {
+ return;
+ }
+ if (!FlagManager.isPlotFlagTrue(currentPlot, "explosion")) {
+ event.setCancelled(true);
+ return;
+ }
+ event.filter(new Predicate>() {
+ @Override
+ public boolean test(org.spongepowered.api.world.Location loc) {
+ return currentPlot.equals(SpongeUtil.getLocation(loc.getExtent().getName(), loc).getPlot());
+ }
+ });
+ event.filterEntities(new Predicate() {
+ @Override
+ public boolean test(Entity entity) {
+ return currentPlot.equals(SpongeUtil.getLocation(entity).getPlot());
+ }
+ });
+ }
+
+ // @Listener
+ // public void onChunkPreGenerator(final ChunkPreGenerateEvent event) {
+ // final org.spongepowered.api.world.Chunk chunk = event.getChunk();
+ // final World world = chunk.getWorld();
+ // final String worldname = world.getName();
+ // if (MainUtil.worldBorder.containsKey(worldname)) {
+ // final int border = MainUtil.getBorder(worldname);
+ // final Vector3i min = world.getBlockMin();
+ // final int x = Math.abs(min.getX());
+ // final int z = Math.abs(min.getZ());
+ // if ((x > border) || (z > border)) {
+ // // TODO cancel this chunk from loading
+ // // - Currently not possible / this event doesn't seem to be called
+ // }
+ // }
+ // }
+
+ @Listener
+ public void onBlockBreak(final HarvestBlockEvent event) {
+
+ }
+
+ @Listener
+ public void onBlockBreak(final BreakBlockEvent event) {
+ Player player = this. getCause(event.getCause(), Player.class);
+ if (player == null) {
+ event.setCancelled(true);
+ return;
+ }
+ final PlotPlayer pp = SpongeUtil.getPlayer(player);
+ final World world = event.getTargetWorld();
+ final String worldname = world.getName();
+ if (!PS.get().isPlotWorld(worldname)) {
+ return;
+ }
+ List transactions = event.getTransactions();
+ BlockTransaction first = transactions.get(0);
+ BlockSnapshot pos = first.getOriginal();
+ Location loc = SpongeUtil.getLocation(worldname, pos.getPosition());
+ Plot plot = MainUtil.getPlot(loc);
+ if (plot == null) {
+ if (!MainUtil.isPlotAreaAbs(loc)) {
return;
}
- }
- if (MainUtil.isPlotArea(loc)) {
- explosion.shouldBreakBlocks(false);
- explosion.canCauseFire(false);
- explosion.setRadius(0);
- event.filterEntities(new Predicate() {
- @Override
- public boolean apply(final Entity entity) {
- if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) {
- return false;
- }
- return true;
- }
- });
- return;
- } else {
- if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
- event.filterLocations(new Predicate>() {
- @Override
- public boolean apply(final org.spongepowered.api.world.Location loc) {
- if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
- return false;
- }
- return true;
- }
- });
- event.filterEntities(new Predicate() {
- @Override
- public boolean apply(final Entity entity) {
- if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) {
- return false;
- }
- return true;
- }
- });
- return;
- }
- }
- }
-
- @Subscribe
- public void onChunkPreGenerator(final ChunkPreGenerateEvent event) {
- final org.spongepowered.api.world.Chunk chunk = event.getChunk();
- final World world = chunk.getWorld();
- final String worldname = world.getName();
- if (MainUtil.worldBorder.containsKey(worldname)) {
- final int border = MainUtil.getBorder(worldname);
- final Vector3i min = world.getBlockMin();
- final int x = Math.abs(min.getX());
- final int z = Math.abs(min.getZ());
- if ((x > border) || (z > border)) {
- // TODO cancel this chunk from loading
- // - Currently not possible / this event doesn't seem to be called
- }
- }
- }
-
- @Subscribe
- public void onRedstoneEvent(final BlockRedstoneUpdateEvent event) {
- final org.spongepowered.api.world.Location block = event.getLocation();
- final Location loc = SpongeUtil.getLocation(block);
- if ((loc == null) || !PS.get().isPlotWorld(loc.getWorld())) {
- return;
- }
- final Plot plot = MainUtil.getPlot(loc);
- if ((plot == null) || !plot.hasOwner()) {
- return;
- }
- if (event.getOldSignalStrength() > event.getNewSignalStrength()) {
- return;
- }
- if (Settings.REDSTONE_DISABLER) {
- if (UUIDHandler.getPlayer(plot.owner) == null) {
- boolean disable = true;
- for (final UUID trusted : plot.getTrusted()) {
- if (UUIDHandler.getPlayer(trusted) != null) {
- disable = false;
- break;
- }
- }
- if (disable) {
- event.setNewSignalStrength(0);
- return;
- }
- }
- }
- FlagManager.getPlotFlag(plot, "redstone");
- if (FlagManager.isPlotFlagFalse(plot, "redstone")) {
- event.setNewSignalStrength(0);
- // TODO only disable clocks
- }
- }
-
- @Subscribe
- public void onBlockBreak(final PlayerBreakBlockEvent event) {
- final Player player = event.getEntity();
- final World world = player.getWorld();
- final String worldname = world.getName();
- final org.spongepowered.api.world.Location blockLoc = event.getLocation();
- final Location loc = SpongeUtil.getLocation(worldname, blockLoc);
- final Plot plot = MainUtil.getPlot(loc);
- if (plot != null) {
- if (blockLoc.getY() == 0) {
+ if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
event.setCancelled(true);
return;
}
- final PlotPlayer pp = SpongeUtil.getPlayer(player);
+ } else if (transactions.size() == 1) {
if (!plot.hasOwner()) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
return;
@@ -508,50 +540,83 @@ public class MainListener {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
event.setCancelled(true);
return;
- } else if (!plot.isAdded(pp.getUUID())) {
- final Flag destroy = FlagManager.getPlotFlag(plot, "break");
- final BlockState state = blockLoc.getBlock();
- if ((destroy != null) && ((HashSet) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) {
- return;
- }
- if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
- return;
- }
+ }
+ if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
+ return;
+ } else {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
- event.setCancelled(true);
- } else if (Settings.DONE_RESTRICTS_BUILDING && plot.getFlags().containsKey("done")) {
- if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
+ final Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
+ final BlockState state = pos.getState();
+ if ((destroy == null) || !((HashSet) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) {
event.setCancelled(true);
return;
}
}
+ }
+ event.filter(new Predicate>() {
+
+ @Override
+ public boolean test(org.spongepowered.api.world.Location l) {
+ Location loc = SpongeUtil.getLocation(worldname, l);
+ Plot plot = loc.getPlot();
+ if (plot == null) {
+ if (!MainUtil.isPlotAreaAbs(loc)) {
+ return true;
+ }
+ if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
+ return false;
+ }
+ return true;
+ }
+ if (!plot.hasOwner()) {
+ if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
+ return true;
+ }
+ MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
+ return false;
+ }
+ if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
+ return true;
+ } else {
+ final Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
+ final BlockState state = l.getBlock();
+ if ((destroy != null) && ((HashSet) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) {
+ return true;
+ }
+ MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
+ return false;
+ }
+ }
+ });
+ }
+
+ @Listener
+ public void onBlockPlace(final PlaceBlockEvent event) {
+ Player player = this. getCause(event.getCause(), Player.class);
+ if (player == null) {
+ event.setCancelled(true);
return;
}
final PlotPlayer pp = SpongeUtil.getPlayer(player);
- if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
+ final World world = event.getTargetWorld();
+ final String worldname = world.getName();
+ if (!PS.get().isPlotWorld(worldname)) {
return;
}
- if (MainUtil.isPlotArea(loc)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_ROAD);
- event.setCancelled(true);
- }
- }
-
- @Subscribe
- public void onBlockPlace(final PlayerPlaceBlockEvent event) {
- final Player player = event.getEntity();
- final World world = player.getWorld();
- final String worldname = world.getName();
- final org.spongepowered.api.world.Location blockLoc = event.getLocation();
- final Location loc = SpongeUtil.getLocation(worldname, blockLoc);
- final Plot plot = MainUtil.getPlot(loc);
- if (plot != null) {
- if (blockLoc.getY() == 0) {
+ List transactions = event.getTransactions();
+ BlockTransaction first = transactions.get(0);
+ BlockSnapshot pos = first.getOriginal();
+ Location loc = SpongeUtil.getLocation(worldname, pos.getPosition());
+ Plot plot = MainUtil.getPlot(loc);
+ if (plot == null) {
+ if (!MainUtil.isPlotAreaAbs(loc)) {
+ return;
+ }
+ if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD)) {
event.setCancelled(true);
return;
}
- final PlotPlayer pp = SpongeUtil.getPlayer(player);
+ } else if (transactions.size() == 1) {
if (!plot.hasOwner()) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
return;
@@ -559,98 +624,116 @@ public class MainListener {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true);
return;
- } else if (!plot.isAdded(pp.getUUID())) {
- final Flag destroy = FlagManager.getPlotFlag(plot, "place");
- final BlockState state = blockLoc.getBlock();
- if ((destroy != null) && ((HashSet) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) {
- return;
- }
- if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
- return;
- }
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
- event.setCancelled(true);
- } else if (Settings.DONE_RESTRICTS_BUILDING && plot.getFlags().containsKey("done")) {
- if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
+ }
+ if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
+ return;
+ } else {
+ MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
+ final Flag BUILD = FlagManager.getPlotFlagRaw(plot, C.FLAG_PLACE.s());
+ final BlockState state = pos.getState();
+ if ((BUILD == null) || !((HashSet) BUILD.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) {
event.setCancelled(true);
return;
}
}
+ }
+ event.filter(new Predicate>() {
+
+ @Override
+ public boolean test(org.spongepowered.api.world.Location l) {
+ Location loc = SpongeUtil.getLocation(worldname, l);
+ Plot plot = loc.getPlot();
+ if (plot == null) {
+ if (!MainUtil.isPlotAreaAbs(loc)) {
+ return true;
+ }
+ if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD)) {
+ return false;
+ }
+ return true;
+ }
+ if (!plot.hasOwner()) {
+ if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
+ return true;
+ }
+ MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
+ return false;
+ }
+ if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
+ return true;
+ } else {
+ final Flag build = FlagManager.getPlotFlagRaw(plot, C.FLAG_PLACE.s());
+ final BlockState state = l.getBlock();
+ if ((build != null) && ((HashSet) build.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) {
+ return true;
+ }
+ MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
+ return false;
+ }
+ }
+ });
+ }
+
+ @Listener
+ public void onBlockInteract(final InteractBlockEvent.Secondary event) {
+ final Player player = this. getCause(event.getCause(), Player.class);
+ if (player == null) {
+ event.setCancelled(true);
return;
}
- final PlotPlayer pp = SpongeUtil.getPlayer(player);
- if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD)) {
+ Optional> target = event.getTargetBlock().getLocation();
+ if (!target.isPresent()) {
return;
}
- if (MainUtil.isPlotArea(loc)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
+ org.spongepowered.api.world.Location l = target.get();
+ Location loc = SpongeUtil.getLocation(l);
+ Plot plot = MainUtil.getPlot(loc);
+ PlotPlayer pp = SpongeUtil.getPlayer(player);
+ if (plot == null) {
+ if (!MainUtil.isPlotAreaAbs(loc)) {
+ return;
+ }
+ if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD)) {
+ event.setCancelled(true);
+ return;
+ }
+ return;
+ }
+ if (!plot.hasOwner()) {
+ if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
+ return;
+ }
+ MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_UNOWNED);
+ event.setCancelled(true);
+ return;
+ }
+ if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER)) {
+ return;
+ } else {
+ final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
+ if ((flag != null) && ((HashSet) flag.getValue()).contains(SpongeMain.THIS.getPlotBlock(l.getBlock()))) {
+ return;
+ }
+ MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_OTHER);
+ event.setCancelled(true);
+ return;
+ }
+ }
+
+ @Listener
+ public void onConnect(final ClientConnectionEvent.Login event) {
+ GameProfile profile = event.getProfile();
+ if (profile == null) {
+ return;
+ }
+ if (profile.getName().equals("PlotSquared") || profile.getUniqueId().equals(DBFunc.everyone) || DBFunc.everyone.equals(UUIDHandler.getUUID(profile.getName(), null))) {
event.setCancelled(true);
}
}
- @Subscribe
- public void onBlockInteract(final PlayerInteractBlockEvent event) {
- final Player player = event.getEntity();
- final World world = player.getWorld();
- final String worldname = world.getName();
- final org.spongepowered.api.world.Location blockLoc = event.getLocation();
- final Location loc = SpongeUtil.getLocation(worldname, blockLoc);
- final Plot plot = MainUtil.getPlot(loc);
- if (plot != null) {
- if (blockLoc.getY() == 0) {
- event.setCancelled(true);
- return;
- }
- if (!plot.hasOwner()) {
- final PlotPlayer pp = SpongeUtil.getPlayer(player);
- if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
- return;
- }
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_UNOWNED);
- event.setCancelled(true);
- return;
- }
- final PlotPlayer pp = SpongeUtil.getPlayer(player);
- if (!plot.isAdded(pp.getUUID())) {
- final Flag destroy = FlagManager.getPlotFlag(plot, "use");
- final BlockState state = blockLoc.getBlock();
- if ((destroy != null) && ((HashSet) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) {
- return;
- }
- if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER)) {
- return;
- }
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_OTHER);
- event.setCancelled(true);
- }
- return;
- }
- final PlotPlayer pp = SpongeUtil.getPlayer(player);
- if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD)) {
- return;
- }
- if (MainUtil.isPlotArea(loc)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_ROAD);
- event.setCancelled(true);
- }
- }
-
- @Subscribe
- public void onConnect(final PlayerConnectionEvent event) {
- final PlayerConnection connection = event.getConnection();
- final Player player = connection.getPlayer();
- final String name = player.getName();
- final PlotPlayer pp = SpongeUtil.getPlayer(player);
- if (name.equals("PlotSquared") || pp.getUUID().equals(DBFunc.everyone)) {
- player.kick();
- SpongeUtil.removePlayer(pp.getName());
- }
- }
-
- @Subscribe
- public void onJoin(final PlayerJoinEvent event) {
- final Player player = event.getUser();
+ @Listener
+ public void onJoin(final ClientConnectionEvent.Join event) {
+ final Player player = event.getTargetEntity();
SpongeUtil.removePlayer(player.getName());
final PlotPlayer pp = SpongeUtil.getPlayer(player);
final String username = pp.getName();
@@ -678,30 +761,24 @@ public class MainListener {
PlotListener.plotEntry(pp, plot);
}
- @Subscribe
- public void onQuit(final PlayerQuitEvent event) {
- final Player player = event.getEntity();
+ @Listener
+ public void onQuit(final ClientConnectionEvent.Disconnect event) {
+ final Player player = event.getTargetEntity();
final PlotPlayer pp = SpongeUtil.getPlayer(player);
- ExpireManager.dates.put(pp.getUUID(), System.currentTimeMillis());
- EventUtil.unregisterPlayer(pp);
-
- // TODO unregister WorldEdit manager
- // TODO delete plots on ban
-
- SpongeUtil.removePlayer(pp.getName());
+ pp.unregister();
}
public int getInt(final double value) {
return (int) (value < 0 ? value - 1 : value);
}
- @Subscribe
- public void onMove(final PlayerMoveEvent event) {
- final org.spongepowered.api.world.Location from = event.getOldLocation();
- org.spongepowered.api.world.Location to = event.getNewLocation();
+ @Listener
+ public void onMove(final DisplaceEntityEvent.TargetPlayer event) {
+ final org.spongepowered.api.world.Location from = event.getFromTransform().getLocation();
+ org.spongepowered.api.world.Location to = event.getToTransform().getLocation();
int x2;
if (getInt(from.getX()) != (x2 = getInt(to.getX()))) {
- final Player player = event.getUser();
+ final Player player = event.getTargetEntity();
final PlotPlayer pp = SpongeUtil.getPlayer(player);
final Extent extent = to.getExtent();
if (!(extent instanceof World)) {
@@ -725,9 +802,9 @@ public class MainListener {
if (!PlotListener.plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
- event.setNewLocation(from);
+ event.setCancelled(true);
} else {
- event.setNewLocation(world.getSpawnLocation());
+ event.setToTransform(new Transform<>(world.getSpawnLocation()));
}
return;
}
@@ -738,9 +815,9 @@ public class MainListener {
if (!PlotListener.plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.getBasePlot(false).equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
- event.setNewLocation(from);
+ event.setCancelled(true);
} else {
- event.setNewLocation(world.getSpawnLocation());
+ event.setToTransform(new Transform<>(world.getSpawnLocation()));
}
return;
}
@@ -750,12 +827,12 @@ public class MainListener {
if (x2 > border) {
final Vector3d pos = to.getPosition();
to = to.setPosition(new Vector3d(border - 4, pos.getY(), pos.getZ()));
- event.setNewLocation(to);
+ event.setToTransform(new Transform(to));
MainUtil.sendMessage(pp, C.BORDER);
} else if (x2 < -border) {
final Vector3d pos = to.getPosition();
to = to.setPosition(new Vector3d(-border + 4, pos.getY(), pos.getZ()));
- event.setNewLocation(to);
+ event.setToTransform(new Transform(to));
MainUtil.sendMessage(pp, C.BORDER);
}
}
@@ -763,7 +840,7 @@ public class MainListener {
}
int z2;
if (getInt(from.getZ()) != (z2 = getInt(to.getZ()))) {
- final Player player = event.getUser();
+ final Player player = event.getTargetEntity();
final PlotPlayer pp = SpongeUtil.getPlayer(player);
final Extent extent = to.getExtent();
if (!(extent instanceof World)) {
@@ -787,9 +864,9 @@ public class MainListener {
if (!PlotListener.plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
- event.setNewLocation(from);
+ event.setCancelled(true);
} else {
- event.setNewLocation(world.getSpawnLocation());
+ event.setToTransform(new Transform<>(world.getSpawnLocation()));
}
return;
}
@@ -800,9 +877,9 @@ public class MainListener {
if (!PlotListener.plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
- event.setNewLocation(from);
+ event.setCancelled(true);
} else {
- event.setNewLocation(world.getSpawnLocation());
+ event.setToTransform(new Transform<>(world.getSpawnLocation()));
}
return;
}
@@ -812,158 +889,15 @@ public class MainListener {
if (z2 > border) {
final Vector3d pos = to.getPosition();
to = to.setPosition(new Vector3d(pos.getX(), pos.getY(), border - 4));
- event.setNewLocation(to);
+ event.setToTransform(new Transform(to));
MainUtil.sendMessage(pp, C.BORDER);
} else if (z2 < -border) {
final Vector3d pos = to.getPosition();
to = to.setPosition(new Vector3d(pos.getX(), pos.getY(), -border + 4));
- event.setNewLocation(to);
+ event.setToTransform(new Transform(to));
MainUtil.sendMessage(pp, C.BORDER);
}
}
}
}
-
- @Subscribe
- public void onWorldChange(final EntityTeleportEvent event) {
- final Entity entity = event.getEntity();
- if (entity instanceof Player) {
- final org.spongepowered.api.world.Location from = event.getOldLocation();
- org.spongepowered.api.world.Location to = event.getNewLocation();
- int x2;
- if (getInt(from.getX()) != (x2 = getInt(to.getX()))) {
- final Player player = (Player) entity;
- final PlotPlayer pp = SpongeUtil.getPlayer(player);
- final Extent extent = to.getExtent();
- if (!(extent instanceof World)) {
- pp.deleteMeta("location");
- return;
- }
- pp.setMeta("location", SpongeUtil.getLocation(player));
- final World world = (World) extent;
- final String worldname = ((World) extent).getName();
- final PlotWorld plotworld = PS.get().getPlotWorld(worldname);
- if (plotworld == null) {
- return;
- }
- final PlotManager plotManager = PS.get().getPlotManager(worldname);
- final PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ()));
- final Plot lastPlot = (Plot) pp.getMeta("lastplot");
- if (id == null) {
- if (lastPlot == null) {
- return;
- }
- if (!PlotListener.plotExit(pp, lastPlot)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
- if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
- event.setNewLocation(from);
- } else {
- event.setNewLocation(world.getSpawnLocation());
- }
- return;
- }
- } else if ((lastPlot != null) && id.equals(lastPlot.id)) {
- return;
- } else {
- final Plot plot = MainUtil.getPlot(worldname, id);
- if (!PlotListener.plotEntry(pp, plot)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
- if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
- event.setNewLocation(from);
- } else {
- event.setNewLocation(world.getSpawnLocation());
- }
- return;
- }
- }
- final Integer border = MainUtil.worldBorder.get(worldname);
- if (border != null) {
- if (x2 > border) {
- final Vector3d pos = to.getPosition();
- to = to.setPosition(new Vector3d(border - 4, pos.getY(), pos.getZ()));
- event.setNewLocation(to);
- MainUtil.sendMessage(pp, C.BORDER);
- } else if (x2 < -border) {
- final Vector3d pos = to.getPosition();
- to = to.setPosition(new Vector3d(-border + 4, pos.getY(), pos.getZ()));
- event.setNewLocation(to);
- MainUtil.sendMessage(pp, C.BORDER);
- }
- }
- return;
- }
- int z2;
- if (getInt(from.getZ()) != (z2 = getInt(to.getZ()))) {
- final Player player = (Player) entity;
- final PlotPlayer pp = SpongeUtil.getPlayer(player);
- final Extent extent = to.getExtent();
- if (!(extent instanceof World)) {
- pp.deleteMeta("location");
- return;
- }
- pp.setMeta("location", SpongeUtil.getLocation(player));
- final String worldname = ((World) extent).getName();
- final PlotWorld plotworld = PS.get().getPlotWorld(worldname);
- if (plotworld == null) {
- return;
- }
- final PlotManager plotManager = PS.get().getPlotManager(worldname);
- final PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2);
- final Plot lastPlot = (Plot) pp.getMeta("lastplot");
- if (id == null) {
- if (lastPlot == null) {
- return;
- }
- if (!PlotListener.plotExit(pp, lastPlot)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
- if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
- event.setNewLocation(from);
- } else {
- event.setNewLocation(player.getWorld().getSpawnLocation());
- }
- return;
- }
- } else if ((lastPlot != null) && id.equals(lastPlot.id)) {
- return;
- } else {
- final Plot plot = MainUtil.getPlot(worldname, id);
- if (!PlotListener.plotEntry(pp, plot)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
- if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
- event.setNewLocation(from);
- } else {
- event.setNewLocation(player.getWorld().getSpawnLocation());
- }
- return;
- }
- }
- final Integer border = MainUtil.worldBorder.get(worldname);
- if (border != null) {
- if (z2 > border) {
- final Vector3d pos = to.getPosition();
- to = to.setPosition(new Vector3d(pos.getX(), pos.getY(), border - 4));
- event.setNewLocation(to);
- MainUtil.sendMessage(pp, C.BORDER);
- } else if (z2 < -border) {
- final Vector3d pos = to.getPosition();
- to = to.setPosition(new Vector3d(pos.getX(), pos.getY(), -border + 4));
- event.setNewLocation(to);
- MainUtil.sendMessage(pp, C.BORDER);
- }
- }
- }
- }
- }
-
- @Subscribe
- public void onWorldChange(final PlayerChangeWorldEvent event) {
- final PlotPlayer player = SpongeUtil.getPlayer(event.getUser());
-
- player.deleteMeta("location");
- player.deleteMeta("lastplot");
- if (Settings.PERMISSION_CACHING) {
- ((SpongePlayer) player).hasPerm = new HashSet<>();
- ((SpongePlayer) player).noPerm = new HashSet<>();
- }
- }
}
diff --git a/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java b/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java
index 2bf08e580..425c539ad 100644
--- a/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java
+++ b/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java
@@ -7,9 +7,11 @@ import java.util.UUID;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.data.manipulator.mutable.TargetedLocationData;
import org.spongepowered.api.data.value.mutable.Value;
-import org.spongepowered.api.entity.player.Player;
-import org.spongepowered.api.entity.player.gamemode.GameMode;
-import org.spongepowered.api.entity.player.gamemode.GameModes;
+import org.spongepowered.api.effect.sound.SoundTypes;
+import org.spongepowered.api.entity.living.player.Player;
+import org.spongepowered.api.entity.living.player.gamemode.GameMode;
+import org.spongepowered.api.entity.living.player.gamemode.GameModes;
+import org.spongepowered.api.service.ban.BanService;
import org.spongepowered.api.text.Texts;
import org.spongepowered.api.text.chat.ChatTypes;
@@ -19,6 +21,7 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer;
+import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather;
@@ -152,21 +155,27 @@ public class SpongePlayer extends PlotPlayer {
@Override
public void setAttribute(String key) {
key = "plotsquared_user_attributes." + key;
- // EconHandler.manager.setPermission(getName(), key, true);
- setMeta(key, true);
+ if ((EconHandler.manager == null) || player.hasPermission("plotsquared_user_attributes.*")) {
+ setMeta(key, true);
+ return;
+ }
+ EconHandler.manager.setPermission(getName(), key, true);
}
@Override
public boolean getAttribute(String key) {
key = "plotsquared_user_attributes." + key;
- return getMeta(key) != null;
- // TODO register attributes
+ if ((EconHandler.manager == null) || player.hasPermission("plotsquared_user_attributes.*")) {
+ final Object v = getMeta(key);
+ return v == null ? false : (Boolean) v;
+ }
+ return player.hasPermission(key);
}
@Override
public void removeAttribute(String key) {
key = "plotsquared_user_attributes." + key;
- // EconHandler.manager.setPermission(getName(), key, false);
+ EconHandler.manager.setPermission(getName(), key, false);
deleteMeta(key);
}
@@ -197,20 +206,20 @@ public class SpongePlayer extends PlotPlayer {
@Override
public void setGamemode(final PlotGamemode gamemode) {
// TODO Auto-generated method stub
- // switch (gamemode) {
- // case ADVENTURE:
- // player.offer(Keys.GAME_MODE, GameModes.ADVENTURE);
- // return;
- // case CREATIVE:
- // player.offer(Keys.GAME_MODE, GameModes.CREATIVE);
- // return;
- // case SPECTATOR:
- // player.offer(Keys.GAME_MODE, GameModes.SPECTATOR);
- // return;
- // case SURVIVAL:
- // player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
- // return;
- // }
+ switch (gamemode) {
+ case ADVENTURE:
+ player.offer(Keys.GAME_MODE, GameModes.ADVENTURE);
+ return;
+ case CREATIVE:
+ player.offer(Keys.GAME_MODE, GameModes.CREATIVE);
+ return;
+ case SPECTATOR:
+ player.offer(Keys.GAME_MODE, GameModes.SPECTATOR);
+ return;
+ case SURVIVAL:
+ player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
+ return;
+ }
}
@Override
@@ -221,18 +230,63 @@ public class SpongePlayer extends PlotPlayer {
@Override
public void setFlight(final boolean fly) {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
+ player.offer(Keys.IS_FLYING, fly);
+ player.offer(Keys.CAN_FLY, fly);
}
@Override
public void playMusic(final Location loc, final int id) {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
+ switch (id) {
+ case 0:
+ player.playSound(null, SpongeUtil.getLocation(loc).getPosition(), 1);
+ break;
+ case 2256:
+ player.playSound(SoundTypes.RECORDS_11, SpongeUtil.getLocation(loc).getPosition(), 1);
+ break;
+ case 2257:
+ player.playSound(SoundTypes.RECORDS_13, SpongeUtil.getLocation(loc).getPosition(), 1);
+ break;
+ case 2258:
+ player.playSound(SoundTypes.RECORDS_BLOCKS, SpongeUtil.getLocation(loc).getPosition(), 1);
+ break;
+ case 2259:
+ player.playSound(SoundTypes.RECORDS_CAT, SpongeUtil.getLocation(loc).getPosition(), 1);
+ break;
+ case 2260:
+ player.playSound(SoundTypes.RECORDS_CHIRP, SpongeUtil.getLocation(loc).getPosition(), 1);
+ break;
+ case 2261:
+ player.playSound(SoundTypes.RECORDS_FAR, SpongeUtil.getLocation(loc).getPosition(), 1);
+ break;
+ case 2262:
+ player.playSound(SoundTypes.RECORDS_MALL, SpongeUtil.getLocation(loc).getPosition(), 1);
+ break;
+ case 2263:
+ player.playSound(SoundTypes.RECORDS_MELLOHI, SpongeUtil.getLocation(loc).getPosition(), 1);
+ break;
+ case 2264:
+ player.playSound(SoundTypes.RECORDS_STAL, SpongeUtil.getLocation(loc).getPosition(), 1);
+ break;
+ case 2265:
+ player.playSound(SoundTypes.RECORDS_STRAD, SpongeUtil.getLocation(loc).getPosition(), 1);
+ break;
+ case 2266:
+ player.playSound(SoundTypes.RECORDS_WAIT, SpongeUtil.getLocation(loc).getPosition(), 1);
+ break;
+ case 2267:
+ player.playSound(SoundTypes.RECORDS_WARD, SpongeUtil.getLocation(loc).getPosition(), 1);
+ break;
+ }
}
@Override
public void kick(final String message) {
player.kick(SpongeMain.THIS.getText(message));
}
+
+ @Override
+ public boolean isBanned() {
+ BanService service = SpongeMain.THIS.getGame().getServiceManager().provide(BanService.class).get();
+ return service.isBanned(player);
+ }
}
diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java b/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java
index 03d2f70c8..bfcf53636 100644
--- a/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java
+++ b/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java
@@ -2,6 +2,7 @@ package com.plotsquared.sponge.util;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockType;
@@ -15,7 +16,6 @@ import org.spongepowered.api.world.World;
import org.spongepowered.api.world.biome.BiomeType;
import org.spongepowered.api.world.biome.BiomeTypes;
-import com.google.common.base.Optional;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.schematic.PlotItem;
@@ -30,7 +30,8 @@ public class SpongeBlockManager extends BlockManager {
public boolean isBlockSolid(final PlotBlock block) {
final BlockState state = SpongeMain.THIS.getBlockState(block);
final BlockType type = state.getType();
- return type.isSolidCube() && !type.isAffectedByGravity();
+ // TODO check if solid;
+ return true;
}
@Override
@@ -220,7 +221,6 @@ public class SpongeBlockManager extends BlockManager {
if (block != state) {
world.setBlock(x, y, z, state);
}
-
}
@Override
diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java b/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java
index 54a2059a7..a9a373667 100644
--- a/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java
+++ b/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java
@@ -1,9 +1,8 @@
package com.plotsquared.sponge.util;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
+import java.util.Optional;
import java.util.Set;
+import java.util.function.Predicate;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.living.Living;
@@ -11,15 +10,11 @@ import org.spongepowered.api.entity.living.animal.Animal;
import org.spongepowered.api.entity.living.monster.Monster;
import org.spongepowered.api.world.Chunk;
import org.spongepowered.api.world.World;
-import org.spongepowered.api.world.storage.ChunkDataStream;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
-import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper;
import com.intellectualcrafters.plot.util.TaskManager;
@@ -29,7 +24,6 @@ public class SpongeChunkManager extends ChunkManager {
@Override
public void setChunk(final ChunkWrapper loc, final PlotBlock[][] result) {
// TODO Auto-generated method stub
-
}
@Override
@@ -46,7 +40,7 @@ public class SpongeChunkManager extends ChunkManager {
final int[] count = new int[5];
world.getEntities(new Predicate() {
@Override
- public boolean apply(final Entity entity) {
+ public boolean test(final Entity entity) {
final org.spongepowered.api.world.Location loc = entity.getLocation();
final int x = loc.getBlockX();
if ((x >= bx) && (x <= tx)) {
@@ -78,27 +72,10 @@ public class SpongeChunkManager extends ChunkManager {
return worldObj.loadChunk(loc.x << 4, 0, loc.z << 4, force).isPresent();
}
- @Override
- public boolean unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe) {
- final World worldObj = SpongeUtil.getWorld(world);
- final Optional chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4);
- if (chunk.isPresent()) {
- return worldObj.unloadChunk(chunk.get());
- }
- return false;
- }
-
@Override
public Set getChunkChunks(final String world) {
- final HashSet chunks = new HashSet();
- final World worldObj = SpongeUtil.getWorld(world);
- final ChunkDataStream storage = worldObj.getWorldStorage().getGeneratedChunks();
- while (storage.hasNext()) {
- storage.next();
-
- // TODO get chunk from DataContainer
- }
- return chunks;
+ // TODO save world;
+ return super.getChunkChunks(world);
}
@Override
@@ -110,55 +87,19 @@ public class SpongeChunkManager extends ChunkManager {
}
}
- @Override
- public void deleteRegionFile(final String world, final ChunkLoc loc) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void deleteRegionFiles(final String world, final List chunks) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void deleteRegionFiles(String world, List chunks, Runnable whenDone) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public Plot hasPlot(final String world, final ChunkLoc chunk) {
- // TODO Auto-generated method stub
- return null;
- }
-
@Override
public boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone) {
- // TODO Auto-generated method stub
+ // TODO copy a region
TaskManager.runTask(whenDone);
return false;
}
@Override
public boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone) {
- // TODO Auto-generated method stub
TaskManager.runTask(whenDone);
return false;
}
- @Override
- public void swap(final String world, final PlotId id, final PlotId plotid) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void swap(final String worldname, final Location bot1, final Location top1, final Location bot2, final Location top2) {
- // TODO Auto-generated method stub
-
- }
-
@Override
public void clearAllEntities(final Location pos1, final Location pos2) {
final String worldname = pos1.getWorld();
@@ -169,7 +110,7 @@ public class SpongeChunkManager extends ChunkManager {
final int tz = pos2.getZ();
world.getEntities(new Predicate() {
@Override
- public boolean apply(final Entity entity) {
+ public boolean test(final Entity entity) {
final org.spongepowered.api.world.Location loc = entity.getLocation();
final int x = loc.getBlockX();
if ((x >= bx) && (x <= tx)) {
@@ -183,4 +124,19 @@ public class SpongeChunkManager extends ChunkManager {
});
}
+ @Override
+ public void swap(Location bot1, Location top1, Location bot2, Location top2, Runnable whenDone) {
+ // TODO swap region
+
+ }
+
+ @Override
+ public void unloadChunk(String world, ChunkLoc loc, boolean save, boolean safe) {
+ final World worldObj = SpongeUtil.getWorld(world);
+ final Optional chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4);
+ if (chunk.isPresent()) {
+ worldObj.unloadChunk(chunk.get());
+ }
+ }
+
}
diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java b/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java
index 8f4246e36..53222db6d 100644
--- a/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java
+++ b/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java
@@ -5,7 +5,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.UUID;
-import org.spongepowered.api.entity.player.Player;
+import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.Texts;
import org.spongepowered.api.util.command.CommandCallable;
@@ -13,7 +13,7 @@ import org.spongepowered.api.util.command.CommandException;
import org.spongepowered.api.util.command.CommandResult;
import org.spongepowered.api.util.command.CommandSource;
-import com.google.common.base.Optional;
+import java.util.Optional;
import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.PlotPlayer;
diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeEconHandler.java b/src/main/java/com/plotsquared/sponge/util/SpongeEconHandler.java
new file mode 100644
index 000000000..8752ab0e0
--- /dev/null
+++ b/src/main/java/com/plotsquared/sponge/util/SpongeEconHandler.java
@@ -0,0 +1,44 @@
+package com.plotsquared.sponge.util;
+
+import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
+import com.intellectualcrafters.plot.object.PlotPlayer;
+import com.intellectualcrafters.plot.util.EconHandler;
+import com.intellectualcrafters.plot.util.UUIDHandler;
+import com.plotsquared.sponge.object.SpongePlayer;
+
+public class SpongeEconHandler extends EconHandler {
+
+ @Override
+ public void withdrawMoney(PlotPlayer player, double amount) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void depositMoney(PlotPlayer player, double amount) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void depositMoney(OfflinePlotPlayer player, double amount) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setPermission(String world, String player, String perm, boolean value) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public boolean hasPermission(String world, String player, String perm) {
+ SpongePlayer obj = (SpongePlayer) UUIDHandler.getPlayer(player);
+ if (obj != null) {
+ return obj.player.hasPermission(perm);
+ }
+ // TODO offline
+ return false;
+ }
+
+}
diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java b/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java
index 26f9aa32f..b75844a3a 100644
--- a/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java
+++ b/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java
@@ -3,7 +3,6 @@ package com.plotsquared.sponge.util;
import java.util.ArrayList;
import java.util.UUID;
-import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.Event;
import org.spongepowered.api.service.event.EventManager;
@@ -41,11 +40,7 @@ public class SpongeEventUtil extends EventUtil {
}
public boolean callEvent(final Event event) {
- events.post(event);
- if (event instanceof Cancellable) {
- return !((Cancellable) event).isCancelled();
- }
- return true;
+ return !events.post(event);
}
@Override
diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeInventoryUtil.java b/src/main/java/com/plotsquared/sponge/util/SpongeInventoryUtil.java
index 98747a8d2..8ab2db6fd 100644
--- a/src/main/java/com/plotsquared/sponge/util/SpongeInventoryUtil.java
+++ b/src/main/java/com/plotsquared/sponge/util/SpongeInventoryUtil.java
@@ -3,7 +3,7 @@ package com.plotsquared.sponge.util;
import java.util.ArrayList;
import java.util.Locale;
-import org.spongepowered.api.entity.player.Player;
+import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.Carrier;
diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java b/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java
index fc530a92f..a95b9a74c 100644
--- a/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java
+++ b/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java
@@ -1,13 +1,14 @@
package com.plotsquared.sponge.util;
+import java.util.Optional;
+
import org.spongepowered.api.entity.Entity;
-import org.spongepowered.api.entity.player.Player;
+import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.extent.Extent;
import com.flowpowered.math.vector.Vector3d;
import com.flowpowered.math.vector.Vector3i;
-import com.google.common.base.Optional;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MathMan;
@@ -24,12 +25,8 @@ public class SpongeUtil {
return new Location(world, pos.getX(), pos.getY(), pos.getZ());
}
- public static Location getLocation(final org.spongepowered.api.world.Location block) {
- final Extent extent = block.getExtent();
- if (extent instanceof World) {
- return getLocation(((World) extent).getName(), block);
- }
- return null;
+ public static Location getLocation(final org.spongepowered.api.world.Location block) {
+ return getLocation(block.getExtent().getName(), block);
}
public static Location getLocationFull(final Entity player) {
@@ -83,7 +80,6 @@ public class SpongeUtil {
public static void removePlayer(final String player) {
lastPlayer = null;
lastPlotPlayer = null;
- UUIDHandler.getPlayers().remove(player);
}
public static Location getLocation(final String world, final org.spongepowered.api.world.Location spawn) {
@@ -110,4 +106,12 @@ public class SpongeUtil {
}
return new org.spongepowered.api.world.Location(world.get(), loc.getX(), loc.getY(), loc.getZ());
}
+
+ public static Location getLocation(String world, Vector3i position) {
+ return new Location(world, position.getX(), position.getY(), position.getZ());
+ }
+
+ public static Location getLocation(String world, Vector3d position) {
+ return new Location(world, MathMan.roundInt(position.getX()), MathMan.roundInt(position.getY()), MathMan.roundInt(position.getZ()));
+ }
}
diff --git a/src/main/java/com/plotsquared/sponge/uuid/SpongeLowerOfflineUUIDWrapper.java b/src/main/java/com/plotsquared/sponge/uuid/SpongeLowerOfflineUUIDWrapper.java
index f3e4a70bb..fcd3ab024 100644
--- a/src/main/java/com/plotsquared/sponge/uuid/SpongeLowerOfflineUUIDWrapper.java
+++ b/src/main/java/com/plotsquared/sponge/uuid/SpongeLowerOfflineUUIDWrapper.java
@@ -3,7 +3,7 @@ package com.plotsquared.sponge.uuid;
import java.util.UUID;
import org.spongepowered.api.GameProfile;
-import org.spongepowered.api.entity.player.Player;
+import org.spongepowered.api.entity.living.player.Player;
import com.google.common.base.Charsets;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index cee370fe9..4e6bc0902 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -85,6 +85,15 @@ permissions:
plots.inbox.read.owner: true
plots.comment: true
plots.inbox: true
+ plots.permpack.wilderness:
+ default: op
+ children:
+ plots.admin.interact.unowned: true
+ plots.admin.destroy.unowned: true
+ plots.admin.build.unowned: true
+ plots.projectile.unowned: true
+ plots.admin.vehicle.break.unowned: true
+ plots.admin.pve.unowned: true
plots.permpack.basic:
default: op
children:
diff --git a/target/PlotSquared-Bukkit.jar b/target/PlotSquared-Bukkit.jar
index 9910dccc5..cda0393f6 100644
Binary files a/target/PlotSquared-Bukkit.jar and b/target/PlotSquared-Bukkit.jar differ
diff --git a/target/PlotSquared-Sponge.jar b/target/PlotSquared-Sponge.jar
index f867d8721..8a71508c9 100644
Binary files a/target/PlotSquared-Sponge.jar and b/target/PlotSquared-Sponge.jar differ