Fix for sponge

This commit is contained in:
Jesse Boyd 2015-10-07 17:33:33 +11:00
parent 74a967b535
commit 0c4b703510
66 changed files with 1266 additions and 1198 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<artifactId>PlotSquared</artifactId> <artifactId>PlotSquared</artifactId>
<version>3.2.8</version> <version>3.2.9</version>
<name>PlotSquared</name> <name>PlotSquared</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>
@ -150,7 +150,7 @@
<dependency> <dependency>
<groupId>org.spongepowered</groupId> <groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId> <artifactId>spongeapi</artifactId>
<version>2.1-20150828.013112-189</version> <version>2.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>

View File

@ -100,6 +100,7 @@ public class PS {
private final HashMap<String, PlotManager> plotmanagers = new HashMap<>(); private final HashMap<String, PlotManager> plotmanagers = new HashMap<>();
// public: // public:
public File styleFile;
public File configFile; public File configFile;
public File translationFile; public File translationFile;
public YamlConfiguration style; public YamlConfiguration style;
@ -111,7 +112,6 @@ public class PS {
public URL update; public URL update;
// private: // private:
private File styleFile;
private File storageFile; private File storageFile;
private File FILE = null; // This file private File FILE = null; // This file
private int[] VERSION = null; private int[] VERSION = null;

View File

@ -80,7 +80,7 @@ public class Buy extends SubCommand {
if (currentPlots > MainUtil.getAllowedPlots(plr)) { if (currentPlots > MainUtil.getAllowedPlots(plr)) {
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); 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) { if (flag == null) {
return sendMessage(plr, C.NOT_FOR_SALE); return sendMessage(plr, C.NOT_FOR_SALE);
} }

View File

@ -79,7 +79,7 @@ public class Clear extends SubCommand {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
return false; 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))))) { && (!Permissions.hasPermission(plr, "plots.continue") || (Settings.DONE_COUNTS_TOWARDS_LIMIT && (MainUtil.getAllowedPlots(plr) >= MainUtil.getPlayerPlotCount(plr))))) {
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE); MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
return false; return false;
@ -97,10 +97,10 @@ public class Clear extends SubCommand {
public void run() { public void run() {
plot.removeRunning(); plot.removeRunning();
// If the state changes, then mark it as no longer done // 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"); FlagManager.removePlotFlag(plot, "done");
} }
if (FlagManager.getPlotFlag(plot, "analysis") != null) { if (FlagManager.getPlotFlagRaw(plot, "analysis") != null) {
FlagManager.removePlotFlag(plot, "analysis"); FlagManager.removePlotFlag(plot, "analysis");
} }
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));

View File

@ -219,7 +219,7 @@ public class DebugExec extends SubCommand {
} }
final String flag = args[1]; final String flag = args[1];
for (final Plot plot : PS.get().getPlots()) { for (final Plot plot : PS.get().getPlots()) {
if (FlagManager.getPlotFlag(plot, flag) != null) { if (FlagManager.getPlotFlagRaw(plot, flag) != null) {
FlagManager.removePlotFlag(plot, flag); FlagManager.removePlotFlag(plot, flag);
} }
} }

View File

@ -38,7 +38,7 @@ public class Download extends SubCommand {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED); MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
return false; 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); MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;
} }

View File

@ -20,65 +20,21 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import java.util.Collection;
import java.util.UUID; import java.util.UUID;
import java.util.regex.Matcher;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc; 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.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotInventory; import com.intellectualcrafters.plot.object.PlotInventory;
import com.intellectualcrafters.plot.object.PlotItemStack; import com.intellectualcrafters.plot.object.PlotItemStack;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.MainUtil; 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; import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "info", aliases = { "i" }, description = "Display plot info", usage = "/plot info <id>", category = CommandCategory.INFO) @CommandDeclaration(command = "info", aliases = { "i" }, description = "Display plot info", usage = "/plot info <id>", category = CommandCategory.INFO)
public class Info extends SubCommand { public class Info extends SubCommand {
public static String getPlayerList(final Collection<UUID> uuids) {
final ArrayList<UUID> 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 @Override
public boolean onCommand(final PlotPlayer player, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
String arg = null; String arg = null;
@ -166,16 +122,26 @@ public class Info extends SubCommand {
return true; return true;
} }
String info = C.PLOT_INFO.s(); String info = C.PLOT_INFO.s();
boolean full;
if (arg != null) { if (arg != null) {
info = getCaption(arg); info = getCaption(arg);
if (info == null) { if (info == null) {
MainUtil.sendMessage(player, "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); MainUtil.sendMessage(player, "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating");
return false; return false;
} }
formatAndSend(info, plot.world, plot, player, true); full = true;
} else { } else {
formatAndSend(info, plot.world, plot, player, false); full = false;
} }
MainUtil.format(info, plot, player, full, new RunnableVal<String>() {
@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; return true;
} }
@ -205,71 +171,4 @@ public class Info extends SubCommand {
return null; 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);
}
} }

View File

@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
@ -311,15 +310,11 @@ public class MainCommand extends CommandManager<PlotPlayer> {
displayHelp(player, category, help_index, cmd); displayHelp(player, category, help_index, cmd);
return true; return true;
} }
final StringBuilder builder = new StringBuilder(cmd).append(" "); if (args[0].contains(":")) {
final Iterator<String> iterator = Arrays.asList(args).iterator(); args[0] = args[0].replaceFirst(":", " ");
while (iterator.hasNext()) {
builder.append(iterator.next());
if (iterator.hasNext()) {
builder.append(" ");
}
} }
getInstance().handle(player, builder.toString()); String fullCmd = StringMan.join(args, " ");
getInstance().handle(player, cmd + " " + fullCmd);
return true; return true;
} }

View File

@ -36,6 +36,7 @@ public class Reload extends SubCommand {
try { try {
// The following won't affect world generation, as that has to be // The following won't affect world generation, as that has to be
// loaded during startup unfortunately. // loaded during startup unfortunately.
PS.get().style.load(PS.get().styleFile);
PS.get().config.load(PS.get().configFile); PS.get().config.load(PS.get().configFile);
PS.get().setupConfig(); PS.get().setupConfig();
C.load(PS.get().translationFile); C.load(PS.get().translationFile);

View File

@ -252,7 +252,7 @@ public class list extends SubCommand {
} }
plots = new ArrayList<>(); plots = new ArrayList<>();
for (final Plot plot : PS.get().getPlots()) { for (final Plot plot : PS.get().getPlots()) {
final Flag price = FlagManager.getPlotFlag(plot, "price"); final Flag price = FlagManager.getPlotFlagRaw(plot, "price");
if (price != null) { if (price != null) {
plots.add(plot); plots.add(plot);
} }
@ -378,9 +378,9 @@ public class list extends SubCommand {
} else { } else {
color = "$1"; 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(), ","); String strFlags = StringMan.join(plot.getFlags().values(), ",");
if (strFlags.length() == 0) { if (strFlags.length() == 0) {

View File

@ -451,6 +451,7 @@ public enum C {
*/ */
NONE("None", "Info"), NONE("None", "Info"),
UNKNOWN("Unknown", "Info"), UNKNOWN("Unknown", "Info"),
EVERYONE("Everyone", "Info"),
PLOT_UNOWNED("$2The current plot must have an owner to perform this action", "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_UNCLAIMED("$2Plot $1%s$2 is not yet claimed", "Info"),
PLOT_INFO_HEADER("$3&m---------&r $1INFO $3&m---------", false, "Info"), PLOT_INFO_HEADER("$3&m---------&r $1INFO $3&m---------", false, "Info"),

View File

@ -1297,7 +1297,7 @@ public class SQLManager implements AbstractDB {
if (plot.temp > 0) { if (plot.temp > 0) {
return plot.temp; return plot.temp;
} }
id = 1 / 0; throw new SQLException("Plot does not exist in database");
} }
plot.temp = id; plot.temp = id;
return id; return id;

View File

@ -20,9 +20,11 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.flag; package com.intellectualcrafters.plot.flag;
import java.lang.reflect.Method;
import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.StringMan;
public class Flag { public class Flag implements Cloneable {
private AbstractFlag key; private AbstractFlag key;
private Object value; private Object value;
@ -122,4 +124,24 @@ public class Flag {
public int hashCode() { public int hashCode() {
return key.getKey().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;
}
}
} }

View File

@ -129,13 +129,13 @@ public class FlagManager {
if (plotworld.DEFAULT_FLAGS.size() == 0) { if (plotworld.DEFAULT_FLAGS.size() == 0) {
return null; return null;
} }
return ((HashMap<String, Flag>) plotworld.DEFAULT_FLAGS.clone()).get(id); return plotworld.DEFAULT_FLAGS.get(id);
} }
return flag; return flag;
} }
public static boolean isBooleanFlag(final Plot plot, final String key, final boolean defaultValue) { 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) { if (flag == null) {
return defaultValue; return defaultValue;
} }
@ -153,6 +153,11 @@ public class FlagManager {
* @return Flag * @return Flag
*/ */
public static Flag getPlotFlag(final Plot plot, final String 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()) { if (!plot.hasOwner()) {
return null; return null;
} }
@ -163,7 +168,7 @@ public class FlagManager {
if (plot.owner == null) { if (plot.owner == null) {
return false; return false;
} }
final Flag flag = getPlotFlag(plot, strFlag); final Flag flag = getPlotFlagRaw(plot, strFlag);
return !((flag == null) || !((Boolean) flag.getValue())); return !((flag == null) || !((Boolean) flag.getValue()));
} }
@ -171,7 +176,7 @@ public class FlagManager {
if (plot.owner == null) { if (plot.owner == null) {
return false; return false;
} }
final Flag flag = getPlotFlag(plot, strFlag); final Flag flag = getPlotFlagRaw(plot, strFlag);
if ((flag == null) || ((Boolean) flag.getValue())) { if ((flag == null) || ((Boolean) flag.getValue())) {
return false; return false;
} }

View File

@ -286,7 +286,7 @@ public abstract class FlagValue<T> {
} }
} }
public interface ListValue { public interface ListValue extends Cloneable {
void add(final Object t, final String value); void add(final Object t, final String value);
void remove(final Object t, final String value); void remove(final Object t, final String value);

View File

@ -157,4 +157,9 @@ public class ConsolePlayer extends PlotPlayer {
@Override @Override
public void kick(final String message) {} public void kick(final String message) {}
@Override
public boolean isBanned() {
return false;
}
} }

View File

@ -4,6 +4,9 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.util.MainUtil;
/** /**
* Created 2015-02-11 for PlotSquared * Created 2015-02-11 for PlotSquared
* *
@ -70,6 +73,18 @@ public class Location implements Cloneable, Comparable<Location> {
return world; 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) { public void setWorld(final String world) {
this.world = world; this.world = world;
built = false; built = false;
@ -184,7 +199,7 @@ public class Location implements Cloneable, Comparable<Location> {
private Object getBukkitWorld() { private Object getBukkitWorld() {
try { 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); return clazz.getMethod("getWorld", String.class).invoke(null, world);
} catch (final Exception e) { } catch (final Exception e) {
return null; return null;
@ -196,7 +211,8 @@ public class Location implements Cloneable, Comparable<Location> {
return o; return o;
} }
try { 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; built = true;
return (o = constructor.newInstance(Class.forName("org.bukkit.World").cast(getBukkitWorld()), x, y, z, yaw, pitch)); return (o = constructor.newInstance(Class.forName("org.bukkit.World").cast(getBukkitWorld()), x, y, z, yaw, pitch));
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | ClassNotFoundException | NoSuchMethodException e) { } catch (IllegalAccessException | InstantiationException | InvocationTargetException | ClassNotFoundException | NoSuchMethodException e) {

View File

@ -286,7 +286,7 @@ public class Plot {
if (owner == null) { if (owner == null) {
return ClusterManager.getCluster(this); return ClusterManager.getCluster(this);
} }
Flag flag = FlagManager.getPlotFlag(this, "cluster"); Flag flag = FlagManager.getPlotFlagRaw(this, "cluster");
if (flag != null) { if (flag != null) {
PlotCluster cluster = (PlotCluster) flag.getValue(); PlotCluster cluster = (PlotCluster) flag.getValue();
cluster = ClusterManager.getCluster(cluster.world, cluster.getName()); cluster = ClusterManager.getCluster(cluster.world, cluster.getName());
@ -650,7 +650,7 @@ public class Plot {
* @param flag * @param flag
*/ */
public Flag getFlag(final String key) { public Flag getFlag(final String key) {
return FlagManager.getPlotFlag(this, key); return FlagManager.getPlotFlagRaw(this, key);
} }
/** /**

View File

@ -36,7 +36,7 @@ public class PlotAnalysis {
public static PlotAnalysis MODIFIERS = new PlotAnalysis(); public static PlotAnalysis MODIFIERS = new PlotAnalysis();
public static PlotAnalysis getAnalysis(final Plot plot) { public static PlotAnalysis getAnalysis(final Plot plot) {
final Flag flag = FlagManager.getPlotFlag(plot, "analysis"); final Flag flag = FlagManager.getPlotFlagRaw(plot, "analysis");
if (flag != null) { if (flag != null) {
final PlotAnalysis analysis = new PlotAnalysis(); final PlotAnalysis analysis = new PlotAnalysis();
final List<Integer> values = (List<Integer>) flag.getValue(); final List<Integer> values = (List<Integer>) flag.getValue();

View File

@ -6,11 +6,15 @@ import java.util.concurrent.ConcurrentHashMap;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.RequiredType; 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.MainUtil;
import com.intellectualcrafters.plot.util.PlotGamemode; import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather; import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandCaller; import com.plotsquared.general.commands.CommandCaller;
import com.plotsquared.listener.PlotListener;
/** /**
* Created 2015-02-20 for PlotSquared * 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); 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 * Kick the player from the game
* @param message * @param message
*/ */
public abstract void kick(final String 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);
}
} }

View File

@ -5,4 +5,9 @@ public abstract class RunnableVal<T> implements Runnable {
@Override @Override
public abstract void run(); public abstract void run();
public void run(T value) {
this.value = value;
run();
}
} }

View File

@ -1,15 +1,17 @@
package com.intellectualcrafters.plot.util; package com.intellectualcrafters.plot.util;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotLoc; import com.intellectualcrafters.plot.object.PlotLoc;
import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal; 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 void unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe);
public abstract Set<ChunkLoc> getChunkChunks(final String world); public Set<ChunkLoc> 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<ChunkLoc> 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 regenerateChunk(final String world, final ChunkLoc loc);
public abstract void deleteRegionFile(final String world, final ChunkLoc loc); public void deleteRegionFiles(String world, List<ChunkLoc> chunks) {
deleteRegionFiles(world, chunks, null);
}
public abstract void deleteRegionFiles(final String world, final List<ChunkLoc> chunks); public void deleteRegionFiles(final String world, final List<ChunkLoc> 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<ChunkLoc> chunks, final Runnable whenDone); public Plot hasPlot(String world, ChunkLoc chunk) {
final int x1 = chunk.x << 4;
public abstract Plot hasPlot(String world, ChunkLoc chunk); 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) * Copy a region to a new location (in the same world)

View File

@ -86,14 +86,14 @@ public abstract class EventUtil {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); 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) { if (use != null) {
final HashSet<PlotBlock> value = (HashSet<PlotBlock>) use.getValue(); final HashSet<PlotBlock> value = (HashSet<PlotBlock>) use.getValue();
if (value.contains(PlotBlock.EVERYTHING) || value.contains(block.getPlotBlock())) { if (value.contains(PlotBlock.EVERYTHING) || value.contains(block.getPlotBlock())) {
return true; return true;
} }
} }
final Flag destroy = FlagManager.getPlotFlag(plot, "break"); final Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
if (destroy != null) { if (destroy != null) {
final HashSet<PlotBlock> value = (HashSet<PlotBlock>) destroy.getValue(); final HashSet<PlotBlock> value = (HashSet<PlotBlock>) destroy.getValue();
if (value.contains(PlotBlock.EVERYTHING) || value.contains(block.getPlotBlock())) { if (value.contains(PlotBlock.EVERYTHING) || value.contains(block.getPlotBlock())) {
@ -142,7 +142,7 @@ public abstract class EventUtil {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); 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<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
@ -156,7 +156,7 @@ public abstract class EventUtil {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED.s(), notifyPerms); 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<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER.s(), notifyPerms); 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")) { if (FlagManager.isPlotFlagTrue(plot, "device-interact")) {
return true; return true;
} }
final Flag flag = FlagManager.getPlotFlag(plot, "use"); final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); 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")) { if (FlagManager.isPlotFlagTrue(plot, "hanging-interact")) {
return true; return true;
} }
final Flag flag = FlagManager.getPlotFlag(plot, "use"); final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); 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")) { if (FlagManager.isPlotFlagTrue(plot, "misc-interact")) {
return true; return true;
} }
final Flag flag = FlagManager.getPlotFlag(plot, "use"); final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); 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")) { if (FlagManager.isPlotFlagTrue(plot, "vehicle-use")) {
return true; return true;
} }
final Flag flag = FlagManager.getPlotFlag(plot, "use"); final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); 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")) { if (FlagManager.isPlotFlagTrue(plot, "mob-place")) {
return true; return true;
} }
final Flag flag = FlagManager.getPlotFlag(plot, "place"); final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); 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")) { if (FlagManager.isPlotFlagTrue(plot, "misc-place")) {
return true; return true;
} }
final Flag flag = FlagManager.getPlotFlag(plot, "place"); final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); 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")) { if (FlagManager.isPlotFlagTrue(plot, "vehicle-place")) {
return true; return true;
} }
final Flag flag = FlagManager.getPlotFlag(plot, "place"); final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);

View File

@ -223,7 +223,7 @@ public class ExpireManager {
final Iterator<Plot> iter = plots.iterator(); final Iterator<Plot> iter = plots.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
final Plot plot = iter.next(); 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()) { if ((keepFlag != null) && (Boolean) keepFlag.getValue()) {
continue; continue;
} }

View File

@ -34,12 +34,14 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
@ -269,6 +271,8 @@ public class MainUtil {
public static String getName(final UUID owner) { public static String getName(final UUID owner) {
if (owner == null) { if (owner == null) {
return C.NONE.s(); return C.NONE.s();
} else if (owner.equals(DBFunc.everyone)) {
return C.EVERYONE.s();
} }
final String name = UUIDHandler.getName(owner); final String name = UUIDHandler.getName(owner);
if (name == null) { if (name == null) {
@ -518,10 +522,14 @@ public class MainUtil {
if (!result) { if (!result) {
return false; return false;
} }
plot.removeSign(); if (createSign) {
plot.removeSign();
}
final PlotManager manager = PS.get().getPlotManager(plot.world); final PlotManager manager = PS.get().getPlotManager(plot.world);
final PlotWorld plotworld = PS.get().getPlotWorld(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) { if ((plotworld.TERRAIN != 3) && createRoad) {
for (Plot current : plots) { for (Plot current : plots) {
if (current.getMerged(1)) { if (current.getMerged(1)) {
@ -545,7 +553,9 @@ public class MainUtil {
MainUtil.setSign(getName(current.owner), current); MainUtil.setSign(getName(current.owner), current);
} }
} }
manager.finishPlotUnlink(plotworld, ids); if (createRoad) {
manager.finishPlotUnlink(plotworld, ids);
}
return true; return true;
} }
@ -2157,8 +2167,13 @@ public class MainUtil {
if (!tmp.getMerged(2)) { if (!tmp.getMerged(2)) {
// invalid merge // invalid merge
PS.debug("Fixing invalid merge: " + plot); PS.debug("Fixing invalid merge: " + plot);
tmp.getSettings().setMerged(2, true); if (tmp.hasOwner()) {
DBFunc.setMerged(tmp, tmp.settings.getMerged()); 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); queuecache.add(tmp);
frontier.add(tmp); frontier.add(tmp);
@ -2168,8 +2183,13 @@ public class MainUtil {
if (!tmp.getMerged(3)) { if (!tmp.getMerged(3)) {
// invalid merge // invalid merge
PS.debug("Fixing invalid merge: " + plot); PS.debug("Fixing invalid merge: " + plot);
tmp.getSettings().setMerged(3, true); if (tmp.hasOwner()) {
DBFunc.setMerged(tmp, tmp.settings.getMerged()); 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); queuecache.add(tmp);
frontier.add(tmp); frontier.add(tmp);
@ -2179,8 +2199,13 @@ public class MainUtil {
if (!tmp.getMerged(0)) { if (!tmp.getMerged(0)) {
// invalid merge // invalid merge
PS.debug("Fixing invalid merge: " + plot); PS.debug("Fixing invalid merge: " + plot);
tmp.getSettings().setMerged(0, true); if (tmp.hasOwner()) {
DBFunc.setMerged(tmp, tmp.settings.getMerged()); 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); queuecache.add(tmp);
frontier.add(tmp); frontier.add(tmp);
@ -2190,8 +2215,13 @@ public class MainUtil {
if (!tmp.getMerged(1)) { if (!tmp.getMerged(1)) {
// invalid merge // invalid merge
PS.debug("Fixing invalid merge: " + plot); PS.debug("Fixing invalid merge: " + plot);
tmp.getSettings().setMerged(1, true); if (tmp.hasOwner()) {
DBFunc.setMerged(tmp, tmp.settings.getMerged()); 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); queuecache.add(tmp);
frontier.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) { 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); 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<String> 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<UUID> uuids) {
final ArrayList<UUID> 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();
}
} }

View File

@ -301,7 +301,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
if (MainUtil.isPlotRoad(BukkitUtil.getLocation(loc))) { if (MainUtil.isPlotRoad(BukkitUtil.getLocation(loc))) {
final Entity passenger = entity.getPassenger(); final Entity passenger = entity.getPassenger();
if (!(passenger instanceof Player)) { if (!(passenger instanceof Player)) {
entity.remove(); if (entity.getMetadata("keep").size() == 0) {
entity.remove();
}
} }
} }
break; break;

View File

@ -100,7 +100,7 @@ public class ForceFieldListener implements Listener {
if (plot == null) { if (plot == null) {
return; 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)) { if (!FlagManager.isBooleanFlag(plot, "forcefield", false)) {
final UUID uuid = pp.getUUID(); final UUID uuid = pp.getUUID();
if (plot.isAdded(uuid)) { if (plot.isAdded(uuid)) {

View File

@ -198,7 +198,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if ((plot == null) || !plot.hasOwner()) { if ((plot == null) || !plot.hasOwner()) {
return; return;
} }
final Flag redstone = FlagManager.getPlotFlag(plot, "redstone"); final Flag redstone = FlagManager.getPlotFlagRaw(plot, "redstone");
if (redstone != null) { if (redstone != null) {
if ((Boolean) redstone.getValue()) { if ((Boolean) redstone.getValue()) {
return; return;
@ -343,7 +343,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
Flag flag; 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<String> v = (List<String>) flag.getValue(); final List<String> v = (List<String>) flag.getValue();
String msg = event.getMessage().toLowerCase().replaceFirst("/", ""); String msg = event.getMessage().toLowerCase().replaceFirst("/", "");
@ -648,7 +648,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
event.setCancelled(true); event.setCancelled(true);
return; return;
} else if (!plot.isAdded(pp.getUUID())) { } 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(); final Block block = event.getBlock();
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
return; return;
@ -871,7 +871,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
final PlotPlayer pp = BukkitUtil.getPlayer(player); final PlotPlayer pp = BukkitUtil.getPlayer(player);
if (!plot.isAdded(pp.getUUID())) { if (!plot.isAdded(pp.getUUID())) {
final Flag destroy = FlagManager.getPlotFlag(plot, "break"); final Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
final Block block = event.getBlock(); final Block block = event.getBlock();
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
return; return;
@ -1267,6 +1267,9 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
final Location loc = BukkitUtil.getLocation(block.getLocation()); final Location loc = BukkitUtil.getLocation(block.getLocation());
final Plot plot = MainUtil.getPlot(loc); final Plot plot = MainUtil.getPlot(loc);
if (plot == null) { if (plot == null) {
if (MainUtil.isPlotAreaAbs(loc)) {
event.setCancelled(true);
}
return; return;
} }
if (FlagManager.isPlotFlagTrue(plot, "disable-physics")) { 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) { public boolean checkEntity(final Entity entity, final Plot plot) {
if ((plot != null) && (plot.owner != null)) { 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; int[] mobs = null;
if (entityFlag != null) { if (entityFlag != null) {
final int cap = ((Integer) entityFlag.getValue()); final int cap = ((Integer) entityFlag.getValue());
@ -1312,7 +1315,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
} }
if (entity instanceof Creature) { if (entity instanceof Creature) {
final Flag mobFlag = FlagManager.getPlotFlag(plot, "mob-cap"); final Flag mobFlag = FlagManager.getPlotFlagRaw(plot, "mob-cap");
if (mobFlag != null) { if (mobFlag != null) {
final int cap = ((Integer) mobFlag.getValue()); final int cap = ((Integer) mobFlag.getValue());
if (cap == 0) { if (cap == 0) {
@ -1326,7 +1329,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
} }
if (entity instanceof Animals) { if (entity instanceof Animals) {
final Flag animalFlag = FlagManager.getPlotFlag(plot, "animal-cap"); final Flag animalFlag = FlagManager.getPlotFlagRaw(plot, "animal-cap");
if (animalFlag != null) { if (animalFlag != null) {
final int cap = ((Integer) animalFlag.getValue()); final int cap = ((Integer) animalFlag.getValue());
if (cap == 0) { if (cap == 0) {
@ -1340,7 +1343,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
} }
} else if (entity instanceof Monster) { } else if (entity instanceof Monster) {
final Flag monsterFlag = FlagManager.getPlotFlag(plot, "hostile-cap"); final Flag monsterFlag = FlagManager.getPlotFlagRaw(plot, "hostile-cap");
if (monsterFlag != null) { if (monsterFlag != null) {
final int cap = ((Integer) monsterFlag.getValue()); final int cap = ((Integer) monsterFlag.getValue());
if (cap == 0) { if (cap == 0) {
@ -1355,7 +1358,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
} }
} else if (entity instanceof Vehicle) { } else if (entity instanceof Vehicle) {
final Flag vehicleFlag = FlagManager.getPlotFlag(plot, "vehicle-cap"); final Flag vehicleFlag = FlagManager.getPlotFlagRaw(plot, "vehicle-cap");
if (vehicleFlag != null) { if (vehicleFlag != null) {
final int cap = ((Integer) vehicleFlag.getValue()); final int cap = ((Integer) vehicleFlag.getValue());
if (cap == 0) { 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); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
e.setCancelled(true); e.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) { } 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<PlotBlock>) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) { if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) {
return; return;
} }
@ -1655,19 +1658,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onLeave(final PlayerQuitEvent event) { public void onLeave(final PlayerQuitEvent event) {
final PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); final PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
final Plot plot = pp.getCurrentPlot(); pp.unregister();
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());
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @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); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
e.setCancelled(true); e.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) { } 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(); final Block block = e.getBlockClicked();
if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
return; 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())))) { if ((plot != null) && ((FlagManager.isPlotFlagTrue(plot, "hanging-break") || plot.isAdded(pp.getUUID())))) {
return true; return true;
} }
if (!Permissions.hasPermission(pp, "plots.admin.break." + stub)) { if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.break." + stub); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
return false; return false;
} }
} else if (victim.getEntityId() == 30) { } else if (victim.getEntityId() == 30) {
if ((plot != null) && ((FlagManager.isPlotFlagTrue(plot, "misc-break") || plot.isAdded(pp.getUUID())))) { if ((plot != null) && ((FlagManager.isPlotFlagTrue(plot, "misc-break") || plot.isAdded(pp.getUUID())))) {
return true; return true;
} }
if (!Permissions.hasPermission(pp, "plots.admin.break." + stub)) { if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.break." + stub); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
return false; return false;
} }
} else if ((victim instanceof Monster) || (victim instanceof EnderDragon)) { // victim is monster } 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) { } else if (victim instanceof Player) {
if (plot != null) { 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) { if (pvp == null) {
return true; return true;
} else { } else {
@ -2108,7 +2099,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return; return;
} }
} else if (!plot.isAdded(pp.getUUID())) { } 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(); final Block block = event.getBlock();
if (((place == null) || !((HashSet<PlotBlock>) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) if (((place == null) || !((HashSet<PlotBlock>) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData())))
&& !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) { && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {

View File

@ -165,12 +165,12 @@ public class PlotPlusListener extends PlotListener implements Listener {
public void onPlotEnter(final PlayerEnterPlotEvent event) { public void onPlotEnter(final PlayerEnterPlotEvent event) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final Plot plot = event.getPlot(); final Plot plot = event.getPlot();
final Flag feed = FlagManager.getPlotFlag(plot, "feed"); final Flag feed = FlagManager.getPlotFlagRaw(plot, "feed");
if (feed != null) { if (feed != null) {
final Integer[] value = (Integer[]) feed.getValue(); final Integer[] value = (Integer[]) feed.getValue();
feedRunnable.put(player.getName(), new Interval(value[0], value[1], 20)); 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) { if (heal != null) {
final Integer[] value = (Integer[]) heal.getValue(); final Integer[] value = (Integer[]) heal.getValue();
healRunnable.put(player.getName(), new Interval(value[0], value[1], 20)); healRunnable.put(player.getName(), new Interval(value[0], value[1], 20));

View File

@ -279,4 +279,9 @@ public class BukkitPlayer extends PlotPlayer {
public void kick(final String message) { public void kick(final String message) {
player.kickPlayer(message); player.kickPlayer(message);
} }
@Override
public boolean isBanned() {
return player.isBanned();
}
} }

View File

@ -1,6 +1,5 @@
package com.plotsquared.bukkit.util; package com.plotsquared.bukkit.util;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -69,25 +68,7 @@ import com.plotsquared.bukkit.object.entity.EntityWrapper;
public class BukkitChunkManager extends ChunkManager { public class BukkitChunkManager extends ChunkManager {
@Override @Override
public Set<ChunkLoc> getChunkChunks(final String world) { public Set<ChunkLoc> getChunkChunks(final String world) {
final String directory = Bukkit.getWorldContainer() + File.separator + world + File.separator + "region"; Set<ChunkLoc> chunks = super.getChunkChunks(world);
final File folder = new File(directory);
final File[] regionFiles = folder.listFiles();
final HashSet<ChunkLoc> 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) {}
}
}
for (final Chunk chunk : Bukkit.getWorld(world).getLoadedChunks()) { for (final Chunk chunk : Bukkit.getWorld(world).getLoadedChunks()) {
final ChunkLoc loc = new ChunkLoc(chunk.getX() >> 5, chunk.getZ() >> 5); final ChunkLoc loc = new ChunkLoc(chunk.getX() >> 5, chunk.getZ() >> 5);
if (!chunks.contains(loc)) { 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<ChunkLoc> chunks) {
deleteRegionFiles(world, chunks, null);
}
@Override
public void deleteRegionFiles(final String world, final List<ChunkLoc> 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<BlockLoc, ItemStack[]> chestContents; private static HashMap<BlockLoc, ItemStack[]> chestContents;
private static HashMap<BlockLoc, ItemStack[]> furnaceContents; private static HashMap<BlockLoc, ItemStack[]> furnaceContents;
private static HashMap<BlockLoc, ItemStack[]> dispenserContents; private static HashMap<BlockLoc, ItemStack[]> dispenserContents;

View File

@ -44,7 +44,6 @@ public class BukkitUtil extends BlockManager {
public static void removePlayer(final String plr) { public static void removePlayer(final String plr) {
lastPlayer = null; lastPlayer = null;
lastPlotPlayer = 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 // These weren't being used, but they might be useful later, so I'm just commenting them out

View File

@ -261,7 +261,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
if (block.getData() == data) { if (block.getData() == data) {
return; return;
} }
block.setData(data); block.setData(data, false);
return; return;
} }
// blockstate // blockstate

View File

@ -25,8 +25,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.ChatColor;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings; 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.PlotHandler;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.AbstractTitle; import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.CommentManager; import com.intellectualcrafters.plot.util.CommentManager;
import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.EventUtil;
@ -76,7 +75,12 @@ public class PlotListener {
final Flag greetingFlag = flags.get("greeting"); final Flag greetingFlag = flags.get("greeting");
if (greetingFlag != null) { if (greetingFlag != null) {
greeting = (String) greetingFlag.getValue(); 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<String>() {
@Override
public void run() {
MainUtil.sendMessage(pp, value);
}
});
} else { } else {
greeting = ""; greeting = "";
} }
@ -189,7 +193,7 @@ public class PlotListener {
if (pw == null) { if (pw == null) {
return true; return true;
} }
if (FlagManager.getPlotFlag(plot, "gamemode") != null) { if (FlagManager.getPlotFlagRaw(plot, "gamemode") != null) {
if (pp.getGamemode() != pw.GAMEMODE) { if (pp.getGamemode() != pw.GAMEMODE) {
if (!Permissions.hasPermission(pp, "plots.gamemode.bypass")) { if (!Permissions.hasPermission(pp, "plots.gamemode.bypass")) {
pp.setGamemode(pw.GAMEMODE); 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) { 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<String>() {
@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 ((leave != null) && ((Boolean) leave.getValue())) {
if (!Permissions.hasPermission(pp, "plots.flag.notify-enter.bypass")) { if (!Permissions.hasPermission(pp, "plots.flag.notify-enter.bypass")) {
for (final UUID uuid : PlotHandler.getOwners(plot)) { 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(); final PlotGamemode gamemode = pp.getGamemode();
if ((gamemode == PlotGamemode.SURVIVAL) || (gamemode == PlotGamemode.ADVENTURE)) { if ((gamemode == PlotGamemode.SURVIVAL) || (gamemode == PlotGamemode.ADVENTURE)) {
pp.setFlight(false); pp.setFlight(false);
} }
} }
if (FlagManager.getPlotFlag(plot, "time") != null) { if (FlagManager.getPlotFlagRaw(plot, "time") != null) {
pp.setTime(Long.MAX_VALUE); pp.setTime(Long.MAX_VALUE);
} }
if (FlagManager.getPlotFlag(plot, "weather") != null) { if (FlagManager.getPlotFlagRaw(plot, "weather") != null) {
pp.setWeather(PlotWeather.RESET); pp.setWeather(PlotWeather.RESET);
} }
final Location lastLoc = (Location) pp.getMeta("music"); final Location lastLoc = (Location) pp.getMeta("music");

View File

@ -43,7 +43,7 @@ public class WEManager {
return regions; return regions;
} }
for (final Plot plot : PS.get().getPlotsInWorld(player.getLocation().getWorld())) { 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; continue;
} }
if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) { if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) {

View File

@ -49,7 +49,7 @@ public class StateWrapper {
short id = itemComp.getShort("id"); short id = itemComp.getShort("id");
String idStr = itemComp.getString("id"); String idStr = itemComp.getString("id");
if ((idStr != null) && !MathMan.isInteger(idStr)) { if ((idStr != null) && !MathMan.isInteger(idStr)) {
idStr = idStr.split(":")[1].toLowerCase(); idStr = idStr.split(":")[0].toLowerCase();
id = (short) ItemType.getId(idStr); id = (short) ItemType.getId(idStr);
} }
ids[i] = id; ids[i] = id;

View File

@ -6,23 +6,14 @@ import org.spongepowered.api.world.World;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotAnalysis; import com.intellectualcrafters.plot.object.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.RunnableVal;
import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.util.SpongeUtil;
public class SpongeHybridUtils extends HybridUtils { public class SpongeHybridUtils extends HybridUtils {
@Override
public void analyzePlot(final Plot plot, final RunnableVal<PlotAnalysis> whenDone) {
// TODO Auto-generated method stub
PS.debug("analyzePlot is not implemented");
if (whenDone != null) {
whenDone.run();
}
}
@Override @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) { 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"); PS.debug("checkModified is not implemented");
@ -68,4 +59,10 @@ public class SpongeHybridUtils extends HybridUtils {
return ey; return ey;
} }
@Override
public void analyzeRegion(String world, RegionWrapper region, RunnableVal<PlotAnalysis> whenDone) {
// TODO Auto-generated method stub
whenDone.run();
}
} }

View File

@ -11,6 +11,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -20,12 +21,11 @@ import org.spongepowered.api.Server;
import org.spongepowered.api.block.BlockState; import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockType; import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.block.BlockTypes; import org.spongepowered.api.block.BlockTypes;
import org.spongepowered.api.entity.player.Player; import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Subscribe; import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.entity.player.PlayerChatEvent; import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
import org.spongepowered.api.event.state.InitializationEvent; import org.spongepowered.api.event.game.state.GameInitializationEvent;
import org.spongepowered.api.event.state.PreInitializationEvent; import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
import org.spongepowered.api.event.state.ServerAboutToStartEvent;
import org.spongepowered.api.plugin.Plugin; import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.plugin.PluginContainer;
import org.spongepowered.api.service.profile.GameProfileResolver; 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.GeneratorTypes;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;
import com.google.common.base.Optional;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.intellectualcrafters.configuration.ConfigurationSection; import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.plot.IPlotMain; 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.SpongeChatManager;
import com.plotsquared.sponge.util.SpongeChunkManager; import com.plotsquared.sponge.util.SpongeChunkManager;
import com.plotsquared.sponge.util.SpongeCommand; import com.plotsquared.sponge.util.SpongeCommand;
import com.plotsquared.sponge.util.SpongeEconHandler;
import com.plotsquared.sponge.util.SpongeEventUtil; import com.plotsquared.sponge.util.SpongeEventUtil;
import com.plotsquared.sponge.util.SpongeInventoryUtil; import com.plotsquared.sponge.util.SpongeInventoryUtil;
import com.plotsquared.sponge.util.SpongeMetrics; import com.plotsquared.sponge.util.SpongeMetrics;
@ -215,19 +215,19 @@ public class SpongeMain implements IPlotMain, PluginContainer {
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
///////////////////// ON ENABLE ///////////////////// ///////////////////// ON ENABLE /////////////////////
@Subscribe @Listener
public void init(final InitializationEvent event) { public void init(final GameInitializationEvent event) {
log("INIT"); log("P^2 INIT");
} }
@Subscribe @Listener
public void onInit(final PreInitializationEvent event) { public void onInit(final GamePreInitializationEvent event) {
log("PRE INIT"); log("P^2 PRE INIT");
} }
@Subscribe @Listener
public void onServerAboutToStart(final ServerAboutToStartEvent event) { public void onServerAboutToStart(final GameAboutToStartServerEvent event) {
log("ABOUT START"); log("P^2 ABOUT START");
THIS = this; 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 @Override
public void log(String message) { public void log(String message) {
message = C.format(message, C.replacements); message = C.format(message, C.replacements);
@ -455,8 +448,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
public EconHandler getEconomyHandler() { public EconHandler getEconomyHandler() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
// Nothing like Vault exists yet // Nothing like Vault exists yet
PS.log("getEconomyHandler NOT IMPLEMENTED YET"); return new SpongeEconHandler();
return null;
} }
@Override @Override
@ -506,7 +498,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
@Override @Override
public void registerPlayerEvents() { public void registerPlayerEvents() {
game.getEventManager().register(this, new MainListener()); game.getEventManager().registerListeners(this, new MainListener());
} }
@Override @Override

View File

@ -1,8 +1,10 @@
package com.plotsquared.sponge; package com.plotsquared.sponge;
import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set;
import org.spongepowered.api.block.BlockState; import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.world.World; 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.ChunkLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.util.SpongeUtil;
@ -25,32 +29,21 @@ import com.plotsquared.sponge.util.SpongeUtil;
public class SpongeSchematicHandler extends SchematicHandler { public class SpongeSchematicHandler extends SchematicHandler {
@Override @Override
public void getCompoundTag(final String world, final Location pos1, final Location pos2, final RunnableVal<CompoundTag> whenDone) { public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
// async // async
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
// Main positions // Main positions
final int p1x = pos1.getX(); Location[] corners = MainUtil.getCorners(world, regions);
final int p1z = pos1.getZ(); final Location bot = corners[0];
final int p2x = pos2.getX(); final Location top = corners[1];
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;
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 // Main Schematic tag
final HashMap<String, Tag> schematic = new HashMap<>(); final HashMap<String, Tag> schematic = new HashMap<>();
schematic.put("Width", new ShortTag("Width", (short) width)); schematic.put("Width", new ShortTag("Width", (short) width));
schematic.put("Length", new ShortTag("Length", (short) length)); schematic.put("Length", new ShortTag("Length", (short) length));
schematic.put("Height", new ShortTag("Height", (short) height)); 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("WEOffsetX", new IntTag("WEOffsetX", 0));
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0)); schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0)); schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
// Arrays of data types // Arrays of data types
final List<Tag> tileEntities = new ArrayList<Tag>(); final List<Tag> tileEntities = new ArrayList<Tag>();
final byte[] blocks = new byte[width * height * length]; final byte[] blocks = new byte[width * height * length];
final byte[] blockData = new byte[width * height * length]; final byte[] blockData = new byte[width * height * length];
// Queue
// Generate list of chunks final ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions);
final ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
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() { TaskManager.runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
final long start = System.currentTimeMillis(); if (queue.size() == 0) {
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 {
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -264,7 +77,207 @@ public class SpongeSchematicHandler extends SchematicHandler {
System.gc(); 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<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
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();
}
}
});
} }
}); });
} }

View File

@ -1,6 +1,6 @@
package com.plotsquared.sponge.events; 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 org.spongepowered.api.event.Cancellable;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;

View File

@ -1,6 +1,6 @@
package com.plotsquared.sponge.events; 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 org.spongepowered.api.event.Cancellable;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;

View File

@ -1,6 +1,6 @@
package com.plotsquared.sponge.events; 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; import com.intellectualcrafters.plot.object.Plot;

View File

@ -1,7 +1,7 @@
package com.plotsquared.sponge.events; 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.AbstractEvent; import org.spongepowered.api.event.impl.AbstractEvent;
public abstract class PlayerEvent extends AbstractEvent { public abstract class PlayerEvent extends AbstractEvent {

View File

@ -1,6 +1,6 @@
package com.plotsquared.sponge.events; 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; import com.intellectualcrafters.plot.object.Plot;

View File

@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
import java.util.UUID; 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; import com.intellectualcrafters.plot.object.Plot;

View File

@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
import java.util.UUID; 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; import com.intellectualcrafters.plot.object.Plot;

View File

@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
import java.util.UUID; 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; import com.intellectualcrafters.plot.object.Plot;

View File

@ -1,6 +1,6 @@
package com.plotsquared.sponge.events; 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 org.spongepowered.api.event.Cancellable;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;

View File

@ -1,6 +1,6 @@
package com.plotsquared.sponge.events; 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 org.spongepowered.api.event.Cancellable;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;

View File

@ -1,6 +1,6 @@
package com.plotsquared.sponge.events; package com.plotsquared.sponge.events;
import org.spongepowered.api.event.AbstractEvent; import org.spongepowered.api.event.impl.AbstractEvent;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;

View File

@ -1,6 +1,6 @@
package com.plotsquared.sponge.events; package com.plotsquared.sponge.events;
import org.spongepowered.api.event.AbstractEvent; import org.spongepowered.api.event.impl.AbstractEvent;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;

View File

@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
import java.util.ArrayList; 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.event.Cancellable;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;

View File

@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
import java.util.ArrayList; 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.event.Cancellable;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;

View File

@ -7,9 +7,11 @@ import java.util.UUID;
import org.spongepowered.api.data.key.Keys; import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.data.manipulator.mutable.TargetedLocationData; import org.spongepowered.api.data.manipulator.mutable.TargetedLocationData;
import org.spongepowered.api.data.value.mutable.Value; import org.spongepowered.api.data.value.mutable.Value;
import org.spongepowered.api.entity.player.Player; import org.spongepowered.api.effect.sound.SoundTypes;
import org.spongepowered.api.entity.player.gamemode.GameMode; import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.gamemode.GameModes; 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.Texts;
import org.spongepowered.api.text.chat.ChatTypes; 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.config.Settings;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotGamemode; import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather; import com.intellectualcrafters.plot.util.PlotWeather;
@ -152,21 +155,27 @@ public class SpongePlayer extends PlotPlayer {
@Override @Override
public void setAttribute(String key) { public void setAttribute(String key) {
key = "plotsquared_user_attributes." + key; key = "plotsquared_user_attributes." + key;
// EconHandler.manager.setPermission(getName(), key, true); if ((EconHandler.manager == null) || player.hasPermission("plotsquared_user_attributes.*")) {
setMeta(key, true); setMeta(key, true);
return;
}
EconHandler.manager.setPermission(getName(), key, true);
} }
@Override @Override
public boolean getAttribute(String key) { public boolean getAttribute(String key) {
key = "plotsquared_user_attributes." + key; key = "plotsquared_user_attributes." + key;
return getMeta(key) != null; if ((EconHandler.manager == null) || player.hasPermission("plotsquared_user_attributes.*")) {
// TODO register attributes final Object v = getMeta(key);
return v == null ? false : (Boolean) v;
}
return player.hasPermission(key);
} }
@Override @Override
public void removeAttribute(String key) { public void removeAttribute(String key) {
key = "plotsquared_user_attributes." + key; key = "plotsquared_user_attributes." + key;
// EconHandler.manager.setPermission(getName(), key, false); EconHandler.manager.setPermission(getName(), key, false);
deleteMeta(key); deleteMeta(key);
} }
@ -197,20 +206,20 @@ public class SpongePlayer extends PlotPlayer {
@Override @Override
public void setGamemode(final PlotGamemode gamemode) { public void setGamemode(final PlotGamemode gamemode) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
// switch (gamemode) { switch (gamemode) {
// case ADVENTURE: case ADVENTURE:
// player.offer(Keys.GAME_MODE, GameModes.ADVENTURE); player.offer(Keys.GAME_MODE, GameModes.ADVENTURE);
// return; return;
// case CREATIVE: case CREATIVE:
// player.offer(Keys.GAME_MODE, GameModes.CREATIVE); player.offer(Keys.GAME_MODE, GameModes.CREATIVE);
// return; return;
// case SPECTATOR: case SPECTATOR:
// player.offer(Keys.GAME_MODE, GameModes.SPECTATOR); player.offer(Keys.GAME_MODE, GameModes.SPECTATOR);
// return; return;
// case SURVIVAL: case SURVIVAL:
// player.offer(Keys.GAME_MODE, GameModes.SURVIVAL); player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
// return; return;
// } }
} }
@Override @Override
@ -221,18 +230,63 @@ public class SpongePlayer extends PlotPlayer {
@Override @Override
public void setFlight(final boolean fly) { public void setFlight(final boolean fly) {
// TODO Auto-generated method stub player.offer(Keys.IS_FLYING, fly);
throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); player.offer(Keys.CAN_FLY, fly);
} }
@Override @Override
public void playMusic(final Location loc, final int id) { public void playMusic(final Location loc, final int id) {
// TODO Auto-generated method stub switch (id) {
throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); 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 @Override
public void kick(final String message) { public void kick(final String message) {
player.kick(SpongeMain.THIS.getText(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);
}
} }

View File

@ -2,6 +2,7 @@ package com.plotsquared.sponge.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import org.spongepowered.api.block.BlockState; import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockType; 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.BiomeType;
import org.spongepowered.api.world.biome.BiomeTypes; import org.spongepowered.api.world.biome.BiomeTypes;
import com.google.common.base.Optional;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.intellectualcrafters.plot.object.schematic.PlotItem;
@ -30,7 +30,8 @@ public class SpongeBlockManager extends BlockManager {
public boolean isBlockSolid(final PlotBlock block) { public boolean isBlockSolid(final PlotBlock block) {
final BlockState state = SpongeMain.THIS.getBlockState(block); final BlockState state = SpongeMain.THIS.getBlockState(block);
final BlockType type = state.getType(); final BlockType type = state.getType();
return type.isSolidCube() && !type.isAffectedByGravity(); // TODO check if solid;
return true;
} }
@Override @Override
@ -220,7 +221,6 @@ public class SpongeBlockManager extends BlockManager {
if (block != state) { if (block != state) {
world.setBlock(x, y, z, state); world.setBlock(x, y, z, state);
} }
} }
@Override @Override

View File

@ -1,9 +1,8 @@
package com.plotsquared.sponge.util; package com.plotsquared.sponge.util;
import java.util.ArrayList; import java.util.Optional;
import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate;
import org.spongepowered.api.entity.Entity; import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.living.Living; 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.entity.living.monster.Monster;
import org.spongepowered.api.world.Chunk; import org.spongepowered.api.world.Chunk;
import org.spongepowered.api.world.World; 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.ChunkLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper; import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
@ -29,7 +24,6 @@ public class SpongeChunkManager extends ChunkManager {
@Override @Override
public void setChunk(final ChunkWrapper loc, final PlotBlock[][] result) { public void setChunk(final ChunkWrapper loc, final PlotBlock[][] result) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override @Override
@ -46,7 +40,7 @@ public class SpongeChunkManager extends ChunkManager {
final int[] count = new int[5]; final int[] count = new int[5];
world.getEntities(new Predicate<Entity>() { world.getEntities(new Predicate<Entity>() {
@Override @Override
public boolean apply(final Entity entity) { public boolean test(final Entity entity) {
final org.spongepowered.api.world.Location loc = entity.getLocation(); final org.spongepowered.api.world.Location loc = entity.getLocation();
final int x = loc.getBlockX(); final int x = loc.getBlockX();
if ((x >= bx) && (x <= tx)) { 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(); 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> chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4);
if (chunk.isPresent()) {
return worldObj.unloadChunk(chunk.get());
}
return false;
}
@Override @Override
public Set<ChunkLoc> getChunkChunks(final String world) { public Set<ChunkLoc> getChunkChunks(final String world) {
final HashSet<ChunkLoc> chunks = new HashSet<ChunkLoc>(); // TODO save world;
final World worldObj = SpongeUtil.getWorld(world); return super.getChunkChunks(world);
final ChunkDataStream storage = worldObj.getWorldStorage().getGeneratedChunks();
while (storage.hasNext()) {
storage.next();
// TODO get chunk from DataContainer
}
return chunks;
} }
@Override @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<ChunkLoc> chunks) {
// TODO Auto-generated method stub
}
@Override
public void deleteRegionFiles(String world, List<ChunkLoc> 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 @Override
public boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone) { 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); TaskManager.runTask(whenDone);
return false; return false;
} }
@Override @Override
public boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone) { public boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone) {
// TODO Auto-generated method stub
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return false; 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 @Override
public void clearAllEntities(final Location pos1, final Location pos2) { public void clearAllEntities(final Location pos1, final Location pos2) {
final String worldname = pos1.getWorld(); final String worldname = pos1.getWorld();
@ -169,7 +110,7 @@ public class SpongeChunkManager extends ChunkManager {
final int tz = pos2.getZ(); final int tz = pos2.getZ();
world.getEntities(new Predicate<Entity>() { world.getEntities(new Predicate<Entity>() {
@Override @Override
public boolean apply(final Entity entity) { public boolean test(final Entity entity) {
final org.spongepowered.api.world.Location loc = entity.getLocation(); final org.spongepowered.api.world.Location loc = entity.getLocation();
final int x = loc.getBlockX(); final int x = loc.getBlockX();
if ((x >= bx) && (x <= tx)) { 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> chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4);
if (chunk.isPresent()) {
worldObj.unloadChunk(chunk.get());
}
}
} }

View File

@ -5,7 +5,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; 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.Text;
import org.spongepowered.api.text.Texts; import org.spongepowered.api.text.Texts;
import org.spongepowered.api.util.command.CommandCallable; 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.CommandResult;
import org.spongepowered.api.util.command.CommandSource; 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.commands.MainCommand;
import com.intellectualcrafters.plot.object.ConsolePlayer; import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;

View File

@ -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;
}
}

View File

@ -3,7 +3,6 @@ package com.plotsquared.sponge.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.Event; import org.spongepowered.api.event.Event;
import org.spongepowered.api.service.event.EventManager; import org.spongepowered.api.service.event.EventManager;
@ -41,11 +40,7 @@ public class SpongeEventUtil extends EventUtil {
} }
public boolean callEvent(final Event event) { public boolean callEvent(final Event event) {
events.post(event); return !events.post(event);
if (event instanceof Cancellable) {
return !((Cancellable) event).isCancelled();
}
return true;
} }
@Override @Override

View File

@ -3,7 +3,7 @@ package com.plotsquared.sponge.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale; 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.ItemType;
import org.spongepowered.api.item.ItemTypes; import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.Carrier; import org.spongepowered.api.item.inventory.Carrier;

View File

@ -1,13 +1,14 @@
package com.plotsquared.sponge.util; package com.plotsquared.sponge.util;
import java.util.Optional;
import org.spongepowered.api.entity.Entity; 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.World;
import org.spongepowered.api.world.extent.Extent; import org.spongepowered.api.world.extent.Extent;
import com.flowpowered.math.vector.Vector3d; import com.flowpowered.math.vector.Vector3d;
import com.flowpowered.math.vector.Vector3i; import com.flowpowered.math.vector.Vector3i;
import com.google.common.base.Optional;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.MathMan;
@ -24,12 +25,8 @@ public class SpongeUtil {
return new Location(world, pos.getX(), pos.getY(), pos.getZ()); return new Location(world, pos.getX(), pos.getY(), pos.getZ());
} }
public static Location getLocation(final org.spongepowered.api.world.Location block) { public static Location getLocation(final org.spongepowered.api.world.Location<World> block) {
final Extent extent = block.getExtent(); return getLocation(block.getExtent().getName(), block);
if (extent instanceof World) {
return getLocation(((World) extent).getName(), block);
}
return null;
} }
public static Location getLocationFull(final Entity player) { public static Location getLocationFull(final Entity player) {
@ -83,7 +80,6 @@ public class SpongeUtil {
public static void removePlayer(final String player) { public static void removePlayer(final String player) {
lastPlayer = null; lastPlayer = null;
lastPlotPlayer = null; lastPlotPlayer = null;
UUIDHandler.getPlayers().remove(player);
} }
public static Location getLocation(final String world, final org.spongepowered.api.world.Location spawn) { 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()); 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()));
}
} }

View File

@ -3,7 +3,7 @@ package com.plotsquared.sponge.uuid;
import java.util.UUID; import java.util.UUID;
import org.spongepowered.api.GameProfile; 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.google.common.base.Charsets;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer; import com.intellectualcrafters.plot.object.OfflinePlotPlayer;

View File

@ -85,6 +85,15 @@ permissions:
plots.inbox.read.owner: true plots.inbox.read.owner: true
plots.comment: true plots.comment: true
plots.inbox: 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: plots.permpack.basic:
default: op default: op
children: children:

Binary file not shown.

Binary file not shown.