mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-29 08:36:45 +01:00
Fix for sponge
This commit is contained in:
parent
74a967b535
commit
0c4b703510
4
pom.xml
4
pom.xml
@ -8,7 +8,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>3.2.8</version>
|
||||
<version>3.2.9</version>
|
||||
<name>PlotSquared</name>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
@ -150,7 +150,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spongepowered</groupId>
|
||||
<artifactId>spongeapi</artifactId>
|
||||
<version>2.1-20150828.013112-189</version>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
|
@ -100,6 +100,7 @@ public class PS {
|
||||
private final HashMap<String, PlotManager> plotmanagers = new HashMap<>();
|
||||
|
||||
// public:
|
||||
public File styleFile;
|
||||
public File configFile;
|
||||
public File translationFile;
|
||||
public YamlConfiguration style;
|
||||
@ -111,7 +112,6 @@ public class PS {
|
||||
public URL update;
|
||||
|
||||
// private:
|
||||
private File styleFile;
|
||||
private File storageFile;
|
||||
private File FILE = null; // This file
|
||||
private int[] VERSION = null;
|
||||
|
@ -80,7 +80,7 @@ public class Buy extends SubCommand {
|
||||
if (currentPlots > MainUtil.getAllowedPlots(plr)) {
|
||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, "price");
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "price");
|
||||
if (flag == null) {
|
||||
return sendMessage(plr, C.NOT_FOR_SALE);
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class Clear extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
if ((FlagManager.getPlotFlag(plot, "done") != null)
|
||||
if ((FlagManager.getPlotFlagRaw(plot, "done") != null)
|
||||
&& (!Permissions.hasPermission(plr, "plots.continue") || (Settings.DONE_COUNTS_TOWARDS_LIMIT && (MainUtil.getAllowedPlots(plr) >= MainUtil.getPlayerPlotCount(plr))))) {
|
||||
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
|
||||
return false;
|
||||
@ -97,10 +97,10 @@ public class Clear extends SubCommand {
|
||||
public void run() {
|
||||
plot.removeRunning();
|
||||
// If the state changes, then mark it as no longer done
|
||||
if (FlagManager.getPlotFlag(plot, "done") != null) {
|
||||
if (FlagManager.getPlotFlagRaw(plot, "done") != null) {
|
||||
FlagManager.removePlotFlag(plot, "done");
|
||||
}
|
||||
if (FlagManager.getPlotFlag(plot, "analysis") != null) {
|
||||
if (FlagManager.getPlotFlagRaw(plot, "analysis") != null) {
|
||||
FlagManager.removePlotFlag(plot, "analysis");
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
|
||||
|
@ -219,7 +219,7 @@ public class DebugExec extends SubCommand {
|
||||
}
|
||||
final String flag = args[1];
|
||||
for (final Plot plot : PS.get().getPlots()) {
|
||||
if (FlagManager.getPlotFlag(plot, flag) != null) {
|
||||
if (FlagManager.getPlotFlagRaw(plot, flag) != null) {
|
||||
FlagManager.removePlotFlag(plot, flag);
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class Download extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if ((!plot.isOwner(plr.getUUID()) || (Settings.DOWNLOAD_REQUIRES_DONE && (FlagManager.getPlotFlag(plot, "done") != null))) && !Permissions.hasPermission(plr, "plots.admin.command.download")) {
|
||||
if ((!plot.isOwner(plr.getUUID()) || (Settings.DOWNLOAD_REQUIRES_DONE && (FlagManager.getPlotFlagRaw(plot, "done") != null))) && !Permissions.hasPermission(plr, "plots.admin.command.download")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -20,65 +20,21 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotInventory;
|
||||
import com.intellectualcrafters.plot.object.PlotItemStack;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "info", aliases = { "i" }, description = "Display plot info", usage = "/plot info <id>", category = CommandCategory.INFO)
|
||||
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
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
String arg = null;
|
||||
@ -166,16 +122,26 @@ public class Info extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
String info = C.PLOT_INFO.s();
|
||||
boolean full;
|
||||
if (arg != null) {
|
||||
info = getCaption(arg);
|
||||
if (info == null) {
|
||||
MainUtil.sendMessage(player, "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating");
|
||||
return false;
|
||||
}
|
||||
formatAndSend(info, plot.world, plot, player, true);
|
||||
full = true;
|
||||
} else {
|
||||
formatAndSend(info, plot.world, plot, player, false);
|
||||
full = false;
|
||||
}
|
||||
MainUtil.format(info, plot, player, full, new RunnableVal<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;
|
||||
}
|
||||
|
||||
@ -205,71 +171,4 @@ public class Info extends SubCommand {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void formatAndSend(String info, final String world, final Plot plot, final PlotPlayer player, final boolean full) {
|
||||
final int num = MainUtil.getConnectedPlots(plot).size();
|
||||
final String alias = plot.getAlias().length() > 0 ? plot.getAlias() : C.NONE.s();
|
||||
final Location top = MainUtil.getPlotTopLocAbs(world, plot.id);
|
||||
final Location bot = MainUtil.getPlotBottomLocAbs(world, plot.id);
|
||||
final String biome = BlockManager.manager.getBiome(plot.world, bot.getX() + ((top.getX() - bot.getX()) / 2), bot.getZ() + ((top.getZ() - bot.getZ()) / 2));
|
||||
final String trusted = getPlayerList(plot.getTrusted());
|
||||
final String members = getPlayerList(plot.getMembers());
|
||||
final String denied = getPlayerList(plot.getDenied());
|
||||
|
||||
final Flag descriptionFlag = FlagManager.getPlotFlag(plot, "description");
|
||||
final String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString();
|
||||
|
||||
final String flags = StringMan.replaceFromMap(
|
||||
"$2"
|
||||
+ (StringMan.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true).values(), "").length() > 0 ? StringMan.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true)
|
||||
.values(), "$1, $2") : C.NONE.s()), C.replacements);
|
||||
final boolean build = plot.isAdded(player.getUUID());
|
||||
|
||||
final String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners());
|
||||
|
||||
info = info.replaceAll("%id%", plot.id.toString());
|
||||
info = info.replaceAll("%alias%", alias);
|
||||
info = info.replaceAll("%num%", num + "");
|
||||
info = info.replaceAll("%desc%", description);
|
||||
info = info.replaceAll("%biome%", biome);
|
||||
info = info.replaceAll("%owner%", owner);
|
||||
info = info.replaceAll("%members%", members);
|
||||
info = info.replaceAll("%trusted%", trusted);
|
||||
info = info.replaceAll("%helpers%", members);
|
||||
info = info.replaceAll("%denied%", denied);
|
||||
info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
|
||||
info = info.replaceAll("%build%", build + "");
|
||||
info = info.replaceAll("%desc%", "No description set.");
|
||||
if (info.contains("%rating%")) {
|
||||
final String newInfo = info;
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int max = 10;
|
||||
if ((Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 0)) {
|
||||
max = 8;
|
||||
}
|
||||
String info;
|
||||
if (full && (Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 1)) {
|
||||
String rating = "";
|
||||
String prefix = "";
|
||||
final double[] ratings = MainUtil.getAverageRatings(plot);
|
||||
for (int i = 0; i < ratings.length; i++) {
|
||||
rating += prefix + Settings.RATING_CATEGORIES.get(i) + "=" + String.format("%.1f", ratings[i]);
|
||||
prefix = ",";
|
||||
}
|
||||
info = newInfo.replaceAll("%rating%", rating);
|
||||
} else {
|
||||
info = newInfo.replaceAll("%rating%", String.format("%.1f", MainUtil.getAverageRating(plot)) + "/" + max);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
|
||||
MainUtil.sendMessage(player, info, false);
|
||||
MainUtil.sendMessage(player, C.PLOT_INFO_FOOTER);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
|
||||
MainUtil.sendMessage(player, info, false);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
@ -311,15 +310,11 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
displayHelp(player, category, help_index, cmd);
|
||||
return true;
|
||||
}
|
||||
final StringBuilder builder = new StringBuilder(cmd).append(" ");
|
||||
final Iterator<String> iterator = Arrays.asList(args).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
builder.append(iterator.next());
|
||||
if (iterator.hasNext()) {
|
||||
builder.append(" ");
|
||||
if (args[0].contains(":")) {
|
||||
args[0] = args[0].replaceFirst(":", " ");
|
||||
}
|
||||
}
|
||||
getInstance().handle(player, builder.toString());
|
||||
String fullCmd = StringMan.join(args, " ");
|
||||
getInstance().handle(player, cmd + " " + fullCmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ public class Reload extends SubCommand {
|
||||
try {
|
||||
// The following won't affect world generation, as that has to be
|
||||
// loaded during startup unfortunately.
|
||||
PS.get().style.load(PS.get().styleFile);
|
||||
PS.get().config.load(PS.get().configFile);
|
||||
PS.get().setupConfig();
|
||||
C.load(PS.get().translationFile);
|
||||
|
@ -252,7 +252,7 @@ public class list extends SubCommand {
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (final Plot plot : PS.get().getPlots()) {
|
||||
final Flag price = FlagManager.getPlotFlag(plot, "price");
|
||||
final Flag price = FlagManager.getPlotFlagRaw(plot, "price");
|
||||
if (price != null) {
|
||||
plots.add(plot);
|
||||
}
|
||||
@ -378,9 +378,9 @@ public class list extends SubCommand {
|
||||
} else {
|
||||
color = "$1";
|
||||
}
|
||||
final PlotMessage trusted = new PlotMessage().text(C.color(C.PLOT_INFO_TRUSTED.s().replaceAll("%trusted%", Info.getPlayerList(plot.getTrusted())))).color("$1");
|
||||
final PlotMessage trusted = new PlotMessage().text(C.color(C.PLOT_INFO_TRUSTED.s().replaceAll("%trusted%", MainUtil.getPlayerList(plot.getTrusted())))).color("$1");
|
||||
|
||||
final PlotMessage members = new PlotMessage().text(C.color(C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", Info.getPlayerList(plot.getMembers())))).color("$1");
|
||||
final PlotMessage members = new PlotMessage().text(C.color(C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers())))).color("$1");
|
||||
|
||||
String strFlags = StringMan.join(plot.getFlags().values(), ",");
|
||||
if (strFlags.length() == 0) {
|
||||
|
@ -451,6 +451,7 @@ public enum C {
|
||||
*/
|
||||
NONE("None", "Info"),
|
||||
UNKNOWN("Unknown", "Info"),
|
||||
EVERYONE("Everyone", "Info"),
|
||||
PLOT_UNOWNED("$2The current plot must have an owner to perform this action", "Info"),
|
||||
PLOT_INFO_UNCLAIMED("$2Plot $1%s$2 is not yet claimed", "Info"),
|
||||
PLOT_INFO_HEADER("$3&m---------&r $1INFO $3&m---------", false, "Info"),
|
||||
|
@ -1297,7 +1297,7 @@ public class SQLManager implements AbstractDB {
|
||||
if (plot.temp > 0) {
|
||||
return plot.temp;
|
||||
}
|
||||
id = 1 / 0;
|
||||
throw new SQLException("Plot does not exist in database");
|
||||
}
|
||||
plot.temp = id;
|
||||
return id;
|
||||
|
@ -20,9 +20,11 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
public class Flag {
|
||||
public class Flag implements Cloneable {
|
||||
private AbstractFlag key;
|
||||
private Object value;
|
||||
|
||||
@ -122,4 +124,24 @@ public class Flag {
|
||||
public int hashCode() {
|
||||
return key.getKey().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object clone() {
|
||||
try {
|
||||
if (value == null) {
|
||||
return super.clone();
|
||||
}
|
||||
if (value instanceof Cloneable) {
|
||||
Method method = value.getClass().getDeclaredMethod("clone");
|
||||
if (!method.isAccessible()) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
return new Flag(key, method.invoke(value));
|
||||
}
|
||||
return new Flag(key, key.parseValueRaw(value.toString()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,13 +129,13 @@ public class FlagManager {
|
||||
if (plotworld.DEFAULT_FLAGS.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return ((HashMap<String, Flag>) plotworld.DEFAULT_FLAGS.clone()).get(id);
|
||||
return plotworld.DEFAULT_FLAGS.get(id);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static boolean isBooleanFlag(final Plot plot, final String key, final boolean defaultValue) {
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, key);
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, key);
|
||||
if (flag == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
@ -153,6 +153,11 @@ public class FlagManager {
|
||||
* @return Flag
|
||||
*/
|
||||
public static Flag getPlotFlag(final Plot plot, final String flag) {
|
||||
Flag result = getPlotFlagRaw(plot, flag);
|
||||
return result == null ? null : (Flag) result.clone();
|
||||
}
|
||||
|
||||
public static Flag getPlotFlagRaw(final Plot plot, final String flag) {
|
||||
if (!plot.hasOwner()) {
|
||||
return null;
|
||||
}
|
||||
@ -163,7 +168,7 @@ public class FlagManager {
|
||||
if (plot.owner == null) {
|
||||
return false;
|
||||
}
|
||||
final Flag flag = getPlotFlag(plot, strFlag);
|
||||
final Flag flag = getPlotFlagRaw(plot, strFlag);
|
||||
return !((flag == null) || !((Boolean) flag.getValue()));
|
||||
}
|
||||
|
||||
@ -171,7 +176,7 @@ public class FlagManager {
|
||||
if (plot.owner == null) {
|
||||
return false;
|
||||
}
|
||||
final Flag flag = getPlotFlag(plot, strFlag);
|
||||
final Flag flag = getPlotFlagRaw(plot, strFlag);
|
||||
if ((flag == null) || ((Boolean) flag.getValue())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -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 remove(final Object t, final String value);
|
||||
|
@ -157,4 +157,9 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
@Override
|
||||
public void kick(final String message) {}
|
||||
|
||||
@Override
|
||||
public boolean isBanned() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
||||
/**
|
||||
* Created 2015-02-11 for PlotSquared
|
||||
*
|
||||
@ -70,6 +73,18 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
return world;
|
||||
}
|
||||
|
||||
public PlotWorld getPlotWorld() {
|
||||
return PS.get().getPlotWorld(world);
|
||||
}
|
||||
|
||||
public PlotManager getPlotManager() {
|
||||
return PS.get().getPlotManager(world);
|
||||
}
|
||||
|
||||
public Plot getPlot() {
|
||||
return MainUtil.getPlot(this);
|
||||
}
|
||||
|
||||
public void setWorld(final String world) {
|
||||
this.world = world;
|
||||
built = false;
|
||||
@ -184,7 +199,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
|
||||
private Object getBukkitWorld() {
|
||||
try {
|
||||
final Class clazz = Class.forName("org.bukkit.Bukkit");
|
||||
final Class<?> clazz = Class.forName("org.bukkit.Bukkit");
|
||||
return clazz.getMethod("getWorld", String.class).invoke(null, world);
|
||||
} catch (final Exception e) {
|
||||
return null;
|
||||
@ -196,7 +211,8 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
return o;
|
||||
}
|
||||
try {
|
||||
final Constructor constructor = Class.forName("org.bukkit.Location").getConstructor(Class.forName("org.bukkit.World"), double.class, double.class, double.class, float.class, float.class);
|
||||
final Constructor<?> constructor = Class.forName("org.bukkit.Location").getConstructor(Class.forName("org.bukkit.World"), double.class, double.class, double.class, float.class,
|
||||
float.class);
|
||||
built = true;
|
||||
return (o = constructor.newInstance(Class.forName("org.bukkit.World").cast(getBukkitWorld()), x, y, z, yaw, pitch));
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | ClassNotFoundException | NoSuchMethodException e) {
|
||||
|
@ -286,7 +286,7 @@ public class Plot {
|
||||
if (owner == null) {
|
||||
return ClusterManager.getCluster(this);
|
||||
}
|
||||
Flag flag = FlagManager.getPlotFlag(this, "cluster");
|
||||
Flag flag = FlagManager.getPlotFlagRaw(this, "cluster");
|
||||
if (flag != null) {
|
||||
PlotCluster cluster = (PlotCluster) flag.getValue();
|
||||
cluster = ClusterManager.getCluster(cluster.world, cluster.getName());
|
||||
@ -650,7 +650,7 @@ public class Plot {
|
||||
* @param flag
|
||||
*/
|
||||
public Flag getFlag(final String key) {
|
||||
return FlagManager.getPlotFlag(this, key);
|
||||
return FlagManager.getPlotFlagRaw(this, key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ public class PlotAnalysis {
|
||||
public static PlotAnalysis MODIFIERS = new PlotAnalysis();
|
||||
|
||||
public static PlotAnalysis getAnalysis(final Plot plot) {
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, "analysis");
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "analysis");
|
||||
if (flag != null) {
|
||||
final PlotAnalysis analysis = new PlotAnalysis();
|
||||
final List<Integer> values = (List<Integer>) flag.getValue();
|
||||
|
@ -6,11 +6,15 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandCaller;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
|
||||
/**
|
||||
* Created 2015-02-20 for PlotSquared
|
||||
@ -301,9 +305,35 @@ public abstract class PlotPlayer implements CommandCaller {
|
||||
*/
|
||||
public abstract void playMusic(final Location loc, final int id);
|
||||
|
||||
/**
|
||||
* Check if the player is banned
|
||||
* @return
|
||||
*/
|
||||
public abstract boolean isBanned();
|
||||
|
||||
/**
|
||||
* Kick the player from the game
|
||||
* @param message
|
||||
*/
|
||||
public abstract void kick(final String message);
|
||||
|
||||
/**
|
||||
* Called when the player quits
|
||||
*/
|
||||
public void unregister() {
|
||||
final Plot plot = getCurrentPlot();
|
||||
if (plot != null) {
|
||||
PlotListener.plotExit(this, plot);
|
||||
}
|
||||
ExpireManager.dates.put(getUUID(), System.currentTimeMillis());
|
||||
EventUtil.unregisterPlayer(this);
|
||||
if (Settings.DELETE_PLOTS_ON_BAN && isBanned()) {
|
||||
for (final Plot owned : PS.get().getPlotsInWorld(getName())) {
|
||||
owned.deletePlot(null);
|
||||
PS.debug(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), getName()));
|
||||
}
|
||||
}
|
||||
UUIDHandler.getPlayers().remove(getName());
|
||||
PS.get().IMP.unregister(this);
|
||||
}
|
||||
}
|
||||
|
@ -5,4 +5,9 @@ public abstract class RunnableVal<T> implements Runnable {
|
||||
|
||||
@Override
|
||||
public abstract void run();
|
||||
|
||||
public void run(T value) {
|
||||
this.value = value;
|
||||
run();
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,17 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
@ -103,17 +105,72 @@ public abstract class ChunkManager {
|
||||
|
||||
public abstract void unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe);
|
||||
|
||||
public abstract Set<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 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 abstract Plot hasPlot(String world, ChunkLoc chunk);
|
||||
public Plot hasPlot(String world, ChunkLoc chunk) {
|
||||
final int x1 = chunk.x << 4;
|
||||
final int z1 = chunk.z << 4;
|
||||
final int x2 = x1 + 15;
|
||||
final int z2 = z1 + 15;
|
||||
final Location bot = new Location(world, x1, 0, z1);
|
||||
Plot plot;
|
||||
plot = MainUtil.getPlotAbs(bot);
|
||||
if ((plot != null) && (plot.owner != null)) {
|
||||
return plot;
|
||||
}
|
||||
final Location top = new Location(world, x2, 0, z2);
|
||||
plot = MainUtil.getPlotAbs(top);
|
||||
if ((plot != null) && (plot.owner != null)) {
|
||||
return plot;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a region to a new location (in the same world)
|
||||
|
@ -86,14 +86,14 @@ public abstract class EventUtil {
|
||||
if (!plot.hasOwner()) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
}
|
||||
final Flag use = FlagManager.getPlotFlag(plot, "use");
|
||||
final Flag use = FlagManager.getPlotFlagRaw(plot, "use");
|
||||
if (use != null) {
|
||||
final HashSet<PlotBlock> value = (HashSet<PlotBlock>) use.getValue();
|
||||
if (value.contains(PlotBlock.EVERYTHING) || value.contains(block.getPlotBlock())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
final Flag destroy = FlagManager.getPlotFlag(plot, "break");
|
||||
final Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
|
||||
if (destroy != null) {
|
||||
final HashSet<PlotBlock> value = (HashSet<PlotBlock>) destroy.getValue();
|
||||
if (value.contains(PlotBlock.EVERYTHING) || value.contains(block.getPlotBlock())) {
|
||||
@ -142,7 +142,7 @@ public abstract class EventUtil {
|
||||
if (!plot.hasOwner()) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, "use");
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
|
||||
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
@ -156,7 +156,7 @@ public abstract class EventUtil {
|
||||
if (!plot.hasOwner()) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED.s(), notifyPerms);
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, "place");
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
|
||||
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER.s(), notifyPerms);
|
||||
@ -173,7 +173,7 @@ public abstract class EventUtil {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "device-interact")) {
|
||||
return true;
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, "use");
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
|
||||
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
@ -190,7 +190,7 @@ public abstract class EventUtil {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "hanging-interact")) {
|
||||
return true;
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, "use");
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
|
||||
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
@ -207,7 +207,7 @@ public abstract class EventUtil {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "misc-interact")) {
|
||||
return true;
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, "use");
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
|
||||
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
@ -224,7 +224,7 @@ public abstract class EventUtil {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "vehicle-use")) {
|
||||
return true;
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, "use");
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
|
||||
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
@ -242,7 +242,7 @@ public abstract class EventUtil {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "mob-place")) {
|
||||
return true;
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, "place");
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
|
||||
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
@ -278,7 +278,7 @@ public abstract class EventUtil {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "misc-place")) {
|
||||
return true;
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, "place");
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
|
||||
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
@ -296,7 +296,7 @@ public abstract class EventUtil {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "vehicle-place")) {
|
||||
return true;
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, "place");
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
|
||||
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
|
@ -223,7 +223,7 @@ public class ExpireManager {
|
||||
final Iterator<Plot> iter = plots.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final Plot plot = iter.next();
|
||||
final Flag keepFlag = FlagManager.getPlotFlag(plot, "keep");
|
||||
final Flag keepFlag = FlagManager.getPlotFlagRaw(plot, "keep");
|
||||
if ((keepFlag != null) && (Boolean) keepFlag.getValue()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -34,12 +34,14 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -269,6 +271,8 @@ public class MainUtil {
|
||||
public static String getName(final UUID owner) {
|
||||
if (owner == null) {
|
||||
return C.NONE.s();
|
||||
} else if (owner.equals(DBFunc.everyone)) {
|
||||
return C.EVERYONE.s();
|
||||
}
|
||||
final String name = UUIDHandler.getName(owner);
|
||||
if (name == null) {
|
||||
@ -518,10 +522,14 @@ public class MainUtil {
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
if (createSign) {
|
||||
plot.removeSign();
|
||||
}
|
||||
final PlotManager manager = PS.get().getPlotManager(plot.world);
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
if (createRoad) {
|
||||
manager.startPlotUnlink(plotworld, ids);
|
||||
}
|
||||
if ((plotworld.TERRAIN != 3) && createRoad) {
|
||||
for (Plot current : plots) {
|
||||
if (current.getMerged(1)) {
|
||||
@ -545,7 +553,9 @@ public class MainUtil {
|
||||
MainUtil.setSign(getName(current.owner), current);
|
||||
}
|
||||
}
|
||||
if (createRoad) {
|
||||
manager.finishPlotUnlink(plotworld, ids);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2157,8 +2167,13 @@ public class MainUtil {
|
||||
if (!tmp.getMerged(2)) {
|
||||
// invalid merge
|
||||
PS.debug("Fixing invalid merge: " + plot);
|
||||
if (tmp.hasOwner()) {
|
||||
tmp.getSettings().setMerged(2, true);
|
||||
DBFunc.setMerged(tmp, tmp.settings.getMerged());
|
||||
} else {
|
||||
plot.getSettings().setMerged(0, false);
|
||||
DBFunc.setMerged(plot, plot.settings.getMerged());
|
||||
}
|
||||
}
|
||||
queuecache.add(tmp);
|
||||
frontier.add(tmp);
|
||||
@ -2168,8 +2183,13 @@ public class MainUtil {
|
||||
if (!tmp.getMerged(3)) {
|
||||
// invalid merge
|
||||
PS.debug("Fixing invalid merge: " + plot);
|
||||
if (tmp.hasOwner()) {
|
||||
tmp.getSettings().setMerged(3, true);
|
||||
DBFunc.setMerged(tmp, tmp.settings.getMerged());
|
||||
} else {
|
||||
plot.getSettings().setMerged(1, false);
|
||||
DBFunc.setMerged(plot, plot.settings.getMerged());
|
||||
}
|
||||
}
|
||||
queuecache.add(tmp);
|
||||
frontier.add(tmp);
|
||||
@ -2179,8 +2199,13 @@ public class MainUtil {
|
||||
if (!tmp.getMerged(0)) {
|
||||
// invalid merge
|
||||
PS.debug("Fixing invalid merge: " + plot);
|
||||
if (tmp.hasOwner()) {
|
||||
tmp.getSettings().setMerged(0, true);
|
||||
DBFunc.setMerged(tmp, tmp.settings.getMerged());
|
||||
} else {
|
||||
plot.getSettings().setMerged(2, false);
|
||||
DBFunc.setMerged(plot, plot.settings.getMerged());
|
||||
}
|
||||
}
|
||||
queuecache.add(tmp);
|
||||
frontier.add(tmp);
|
||||
@ -2190,8 +2215,13 @@ public class MainUtil {
|
||||
if (!tmp.getMerged(1)) {
|
||||
// invalid merge
|
||||
PS.debug("Fixing invalid merge: " + plot);
|
||||
if (tmp.hasOwner()) {
|
||||
tmp.getSettings().setMerged(1, true);
|
||||
DBFunc.setMerged(tmp, tmp.settings.getMerged());
|
||||
} else {
|
||||
plot.getSettings().setMerged(3, false);
|
||||
DBFunc.setMerged(plot, plot.settings.getMerged());
|
||||
}
|
||||
}
|
||||
queuecache.add(tmp);
|
||||
frontier.add(tmp);
|
||||
@ -2381,4 +2411,84 @@ public class MainUtil {
|
||||
public static boolean setComponent(final Plot plot, final String component, final PlotBlock[] blocks) {
|
||||
return PS.get().getPlotManager(plot.world).setComponent(PS.get().getPlotWorld(plot.world), plot.id, component, blocks);
|
||||
}
|
||||
|
||||
public static void format(String info, final Plot plot, final PlotPlayer player, final boolean full, final RunnableVal<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();
|
||||
}
|
||||
}
|
||||
|
@ -301,9 +301,11 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
if (MainUtil.isPlotRoad(BukkitUtil.getLocation(loc))) {
|
||||
final Entity passenger = entity.getPassenger();
|
||||
if (!(passenger instanceof Player)) {
|
||||
if (entity.getMetadata("keep").size() == 0) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class ForceFieldListener implements Listener {
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) {
|
||||
if ((FlagManager.getPlotFlagRaw(plot, "forcefield") != null) && FlagManager.getPlotFlagRaw(plot, "forcefield").getValue().equals("true")) {
|
||||
if (!FlagManager.isBooleanFlag(plot, "forcefield", false)) {
|
||||
final UUID uuid = pp.getUUID();
|
||||
if (plot.isAdded(uuid)) {
|
||||
|
@ -198,7 +198,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
return;
|
||||
}
|
||||
final Flag redstone = FlagManager.getPlotFlag(plot, "redstone");
|
||||
final Flag redstone = FlagManager.getPlotFlagRaw(plot, "redstone");
|
||||
if (redstone != null) {
|
||||
if ((Boolean) redstone.getValue()) {
|
||||
return;
|
||||
@ -343,7 +343,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
|
||||
Flag flag;
|
||||
if (((flag = FlagManager.getPlotFlag(plot, "blocked-cmds")) != null) && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||
if (((flag = FlagManager.getPlotFlagRaw(plot, "blocked-cmds")) != null) && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||
final List<String> v = (List<String>) flag.getValue();
|
||||
|
||||
String msg = event.getMessage().toLowerCase().replaceFirst("/", "");
|
||||
@ -648,7 +648,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
final Flag destroy = FlagManager.getPlotFlag(plot, "break");
|
||||
final Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
|
||||
final Block block = event.getBlock();
|
||||
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
|
||||
return;
|
||||
@ -871,7 +871,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
if (!plot.isAdded(pp.getUUID())) {
|
||||
final Flag destroy = FlagManager.getPlotFlag(plot, "break");
|
||||
final Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
|
||||
final Block block = event.getBlock();
|
||||
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
|
||||
return;
|
||||
@ -1267,6 +1267,9 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
final Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
if (MainUtil.isPlotAreaAbs(loc)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (FlagManager.isPlotFlagTrue(plot, "disable-physics")) {
|
||||
@ -1299,7 +1302,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
|
||||
public boolean checkEntity(final Entity entity, final Plot plot) {
|
||||
if ((plot != null) && (plot.owner != null)) {
|
||||
final Flag entityFlag = FlagManager.getPlotFlag(plot, "entity-cap");
|
||||
final Flag entityFlag = FlagManager.getPlotFlagRaw(plot, "entity-cap");
|
||||
int[] mobs = null;
|
||||
if (entityFlag != null) {
|
||||
final int cap = ((Integer) entityFlag.getValue());
|
||||
@ -1312,7 +1315,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
}
|
||||
if (entity instanceof Creature) {
|
||||
final Flag mobFlag = FlagManager.getPlotFlag(plot, "mob-cap");
|
||||
final Flag mobFlag = FlagManager.getPlotFlagRaw(plot, "mob-cap");
|
||||
if (mobFlag != null) {
|
||||
final int cap = ((Integer) mobFlag.getValue());
|
||||
if (cap == 0) {
|
||||
@ -1326,7 +1329,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
}
|
||||
if (entity instanceof Animals) {
|
||||
final Flag animalFlag = FlagManager.getPlotFlag(plot, "animal-cap");
|
||||
final Flag animalFlag = FlagManager.getPlotFlagRaw(plot, "animal-cap");
|
||||
if (animalFlag != null) {
|
||||
final int cap = ((Integer) animalFlag.getValue());
|
||||
if (cap == 0) {
|
||||
@ -1340,7 +1343,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
}
|
||||
} else if (entity instanceof Monster) {
|
||||
final Flag monsterFlag = FlagManager.getPlotFlag(plot, "hostile-cap");
|
||||
final Flag monsterFlag = FlagManager.getPlotFlagRaw(plot, "hostile-cap");
|
||||
if (monsterFlag != null) {
|
||||
final int cap = ((Integer) monsterFlag.getValue());
|
||||
if (cap == 0) {
|
||||
@ -1355,7 +1358,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
}
|
||||
} else if (entity instanceof Vehicle) {
|
||||
final Flag vehicleFlag = FlagManager.getPlotFlag(plot, "vehicle-cap");
|
||||
final Flag vehicleFlag = FlagManager.getPlotFlagRaw(plot, "vehicle-cap");
|
||||
if (vehicleFlag != null) {
|
||||
final int cap = ((Integer) vehicleFlag.getValue());
|
||||
if (cap == 0) {
|
||||
@ -1609,7 +1612,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
|
||||
e.setCancelled(true);
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
final Flag use = FlagManager.getPlotFlag(plot, C.FLAG_USE.s());
|
||||
final Flag use = FlagManager.getPlotFlagRaw(plot, C.FLAG_USE.s());
|
||||
if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) {
|
||||
return;
|
||||
}
|
||||
@ -1655,19 +1658,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onLeave(final PlayerQuitEvent event) {
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
||||
final Plot plot = pp.getCurrentPlot();
|
||||
if (plot != null) {
|
||||
plotExit(pp, plot);
|
||||
}
|
||||
ExpireManager.dates.put(pp.getUUID(), System.currentTimeMillis());
|
||||
EventUtil.unregisterPlayer(pp);
|
||||
if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) {
|
||||
for (final Plot owned : PS.get().getPlotsInWorld(pp.getName())) {
|
||||
owned.deletePlot(null);
|
||||
PS.debug(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
BukkitUtil.removePlayer(pp.getName());
|
||||
pp.unregister();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@ -1694,7 +1685,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
|
||||
e.setCancelled(true);
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
final Flag use = FlagManager.getPlotFlag(plot, C.FLAG_USE.s());
|
||||
final Flag use = FlagManager.getPlotFlagRaw(plot, C.FLAG_USE.s());
|
||||
final Block block = e.getBlockClicked();
|
||||
if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
|
||||
return;
|
||||
@ -1983,16 +1974,16 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if ((plot != null) && ((FlagManager.isPlotFlagTrue(plot, "hanging-break") || plot.isAdded(pp.getUUID())))) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.break." + stub)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.break." + stub);
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
|
||||
return false;
|
||||
}
|
||||
} else if (victim.getEntityId() == 30) {
|
||||
if ((plot != null) && ((FlagManager.isPlotFlagTrue(plot, "misc-break") || plot.isAdded(pp.getUUID())))) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.break." + stub)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.break." + stub);
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
|
||||
return false;
|
||||
}
|
||||
} else if ((victim instanceof Monster) || (victim instanceof EnderDragon)) { // victim is monster
|
||||
@ -2013,7 +2004,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
} else if (victim instanceof Player) {
|
||||
if (plot != null) {
|
||||
final Flag pvp = FlagManager.getPlotFlag(plot, C.FLAG_PVP.s());
|
||||
final Flag pvp = FlagManager.getPlotFlagRaw(plot, C.FLAG_PVP.s());
|
||||
if (pvp == null) {
|
||||
return true;
|
||||
} else {
|
||||
@ -2108,7 +2099,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
return;
|
||||
}
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
final Flag place = FlagManager.getPlotFlag(plot, C.FLAG_PLACE.s());
|
||||
final Flag place = FlagManager.getPlotFlagRaw(plot, C.FLAG_PLACE.s());
|
||||
final Block block = event.getBlock();
|
||||
if (((place == null) || !((HashSet<PlotBlock>) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData())))
|
||||
&& !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
|
@ -165,12 +165,12 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
public void onPlotEnter(final PlayerEnterPlotEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final Plot plot = event.getPlot();
|
||||
final Flag feed = FlagManager.getPlotFlag(plot, "feed");
|
||||
final Flag feed = FlagManager.getPlotFlagRaw(plot, "feed");
|
||||
if (feed != null) {
|
||||
final Integer[] value = (Integer[]) feed.getValue();
|
||||
feedRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
|
||||
}
|
||||
final Flag heal = FlagManager.getPlotFlag(plot, "heal");
|
||||
final Flag heal = FlagManager.getPlotFlagRaw(plot, "heal");
|
||||
if (heal != null) {
|
||||
final Integer[] value = (Integer[]) heal.getValue();
|
||||
healRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
|
||||
|
@ -279,4 +279,9 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
public void kick(final String message) {
|
||||
player.kickPlayer(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned() {
|
||||
return player.isBanned();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -69,25 +68,7 @@ import com.plotsquared.bukkit.object.entity.EntityWrapper;
|
||||
public class BukkitChunkManager extends ChunkManager {
|
||||
@Override
|
||||
public Set<ChunkLoc> getChunkChunks(final String world) {
|
||||
final String directory = Bukkit.getWorldContainer() + File.separator + world + File.separator + "region";
|
||||
final File folder = new File(directory);
|
||||
final File[] regionFiles = folder.listFiles();
|
||||
final HashSet<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) {}
|
||||
}
|
||||
}
|
||||
Set<ChunkLoc> chunks = super.getChunkChunks(world);
|
||||
for (final Chunk chunk : Bukkit.getWorld(world).getLoadedChunks()) {
|
||||
final ChunkLoc loc = new ChunkLoc(chunk.getX() >> 5, chunk.getZ() >> 5);
|
||||
if (!chunks.contains(loc)) {
|
||||
@ -117,69 +98,6 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRegionFile(final String world, final ChunkLoc loc) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
|
||||
final File file = new File(PS.get().IMP.getWorldContainer(), directory);
|
||||
PS.log("&6 - Deleting region: " + file.getName() + " (approx 1024 chunks)");
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (final InterruptedException e) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRegionFiles(String world, List<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[]> furnaceContents;
|
||||
private static HashMap<BlockLoc, ItemStack[]> dispenserContents;
|
||||
|
@ -44,7 +44,6 @@ public class BukkitUtil extends BlockManager {
|
||||
public static void removePlayer(final String plr) {
|
||||
lastPlayer = null;
|
||||
lastPlotPlayer = null;
|
||||
UUIDHandler.getPlayers().remove(plr);
|
||||
}
|
||||
|
||||
// These weren't being used, but they might be useful later, so I'm just commenting them out
|
||||
|
@ -261,7 +261,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
|
||||
if (block.getData() == data) {
|
||||
return;
|
||||
}
|
||||
block.setData(data);
|
||||
block.setData(data, false);
|
||||
return;
|
||||
}
|
||||
// blockstate
|
||||
|
@ -25,8 +25,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -37,6 +35,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotHandler;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.CommentManager;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
@ -76,7 +75,12 @@ public class PlotListener {
|
||||
final Flag greetingFlag = flags.get("greeting");
|
||||
if (greetingFlag != null) {
|
||||
greeting = (String) greetingFlag.getValue();
|
||||
pp.sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + greeting));
|
||||
MainUtil.format(C.PREFIX_GREETING.s() + greeting, plot, pp, false, new RunnableVal<String>() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(pp, value);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
greeting = "";
|
||||
}
|
||||
@ -189,7 +193,7 @@ public class PlotListener {
|
||||
if (pw == null) {
|
||||
return true;
|
||||
}
|
||||
if (FlagManager.getPlotFlag(plot, "gamemode") != null) {
|
||||
if (FlagManager.getPlotFlagRaw(plot, "gamemode") != null) {
|
||||
if (pp.getGamemode() != pw.GAMEMODE) {
|
||||
if (!Permissions.hasPermission(pp, "plots.gamemode.bypass")) {
|
||||
pp.setGamemode(pw.GAMEMODE);
|
||||
@ -198,11 +202,16 @@ public class PlotListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
final Flag farewell = FlagManager.getPlotFlag(plot, "farewell");
|
||||
final Flag farewell = FlagManager.getPlotFlagRaw(plot, "farewell");
|
||||
if (farewell != null) {
|
||||
pp.sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + farewell.getValueString()));
|
||||
MainUtil.format(C.PREFIX_FAREWELL.s() + farewell.getValueString(), plot, pp, false, new RunnableVal<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 (!Permissions.hasPermission(pp, "plots.flag.notify-enter.bypass")) {
|
||||
for (final UUID uuid : PlotHandler.getOwners(plot)) {
|
||||
@ -213,16 +222,16 @@ public class PlotListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (FlagManager.getPlotFlag(plot, "fly") != null) {
|
||||
if (FlagManager.getPlotFlagRaw(plot, "fly") != null) {
|
||||
final PlotGamemode gamemode = pp.getGamemode();
|
||||
if ((gamemode == PlotGamemode.SURVIVAL) || (gamemode == PlotGamemode.ADVENTURE)) {
|
||||
pp.setFlight(false);
|
||||
}
|
||||
}
|
||||
if (FlagManager.getPlotFlag(plot, "time") != null) {
|
||||
if (FlagManager.getPlotFlagRaw(plot, "time") != null) {
|
||||
pp.setTime(Long.MAX_VALUE);
|
||||
}
|
||||
if (FlagManager.getPlotFlag(plot, "weather") != null) {
|
||||
if (FlagManager.getPlotFlagRaw(plot, "weather") != null) {
|
||||
pp.setWeather(PlotWeather.RESET);
|
||||
}
|
||||
final Location lastLoc = (Location) pp.getMeta("music");
|
||||
|
@ -43,7 +43,7 @@ public class WEManager {
|
||||
return regions;
|
||||
}
|
||||
for (final Plot plot : PS.get().getPlotsInWorld(player.getLocation().getWorld())) {
|
||||
if (!plot.isBasePlot() || (Settings.DONE_RESTRICTS_BUILDING && (FlagManager.getPlotFlag(plot, "done") != null))) {
|
||||
if (!plot.isBasePlot() || (Settings.DONE_RESTRICTS_BUILDING && (FlagManager.getPlotFlagRaw(plot, "done") != null))) {
|
||||
continue;
|
||||
}
|
||||
if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) {
|
||||
|
@ -49,7 +49,7 @@ public class StateWrapper {
|
||||
short id = itemComp.getShort("id");
|
||||
String idStr = itemComp.getString("id");
|
||||
if ((idStr != null) && !MathMan.isInteger(idStr)) {
|
||||
idStr = idStr.split(":")[1].toLowerCase();
|
||||
idStr = idStr.split(":")[0].toLowerCase();
|
||||
id = (short) ItemType.getId(idStr);
|
||||
}
|
||||
ids[i] = id;
|
||||
|
@ -6,23 +6,14 @@ import org.spongepowered.api.world.World;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.plotsquared.sponge.util.SpongeUtil;
|
||||
|
||||
public class SpongeHybridUtils extends HybridUtils {
|
||||
|
||||
@Override
|
||||
public void analyzePlot(final Plot plot, final RunnableVal<PlotAnalysis> whenDone) {
|
||||
// TODO Auto-generated method stub
|
||||
PS.debug("analyzePlot is not implemented");
|
||||
if (whenDone != null) {
|
||||
whenDone.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkModified(final String worldname, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) {
|
||||
PS.debug("checkModified is not implemented");
|
||||
@ -68,4 +59,10 @@ public class SpongeHybridUtils extends HybridUtils {
|
||||
return ey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyzeRegion(String world, RegionWrapper region, RunnableVal<PlotAnalysis> whenDone) {
|
||||
// TODO Auto-generated method stub
|
||||
whenDone.run();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@ -20,12 +21,11 @@ import org.spongepowered.api.Server;
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.block.BlockType;
|
||||
import org.spongepowered.api.block.BlockTypes;
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.event.Subscribe;
|
||||
import org.spongepowered.api.event.entity.player.PlayerChatEvent;
|
||||
import org.spongepowered.api.event.state.InitializationEvent;
|
||||
import org.spongepowered.api.event.state.PreInitializationEvent;
|
||||
import org.spongepowered.api.event.state.ServerAboutToStartEvent;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
|
||||
import org.spongepowered.api.event.game.state.GameInitializationEvent;
|
||||
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
|
||||
import org.spongepowered.api.plugin.Plugin;
|
||||
import org.spongepowered.api.plugin.PluginContainer;
|
||||
import org.spongepowered.api.service.profile.GameProfileResolver;
|
||||
@ -37,7 +37,6 @@ import org.spongepowered.api.world.DimensionTypes;
|
||||
import org.spongepowered.api.world.GeneratorTypes;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.inject.Inject;
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.plot.IPlotMain;
|
||||
@ -71,6 +70,7 @@ import com.plotsquared.sponge.util.SpongeBlockManager;
|
||||
import com.plotsquared.sponge.util.SpongeChatManager;
|
||||
import com.plotsquared.sponge.util.SpongeChunkManager;
|
||||
import com.plotsquared.sponge.util.SpongeCommand;
|
||||
import com.plotsquared.sponge.util.SpongeEconHandler;
|
||||
import com.plotsquared.sponge.util.SpongeEventUtil;
|
||||
import com.plotsquared.sponge.util.SpongeInventoryUtil;
|
||||
import com.plotsquared.sponge.util.SpongeMetrics;
|
||||
@ -215,19 +215,19 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////// ON ENABLE /////////////////////
|
||||
@Subscribe
|
||||
public void init(final InitializationEvent event) {
|
||||
log("INIT");
|
||||
@Listener
|
||||
public void init(final GameInitializationEvent event) {
|
||||
log("P^2 INIT");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onInit(final PreInitializationEvent event) {
|
||||
log("PRE INIT");
|
||||
@Listener
|
||||
public void onInit(final GamePreInitializationEvent event) {
|
||||
log("P^2 PRE INIT");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onServerAboutToStart(final ServerAboutToStartEvent event) {
|
||||
log("ABOUT START");
|
||||
@Listener
|
||||
public void onServerAboutToStart(final GameAboutToStartServerEvent event) {
|
||||
log("P^2 ABOUT START");
|
||||
THIS = this;
|
||||
|
||||
//
|
||||
@ -381,13 +381,6 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerChat(final PlayerChatEvent event) {
|
||||
// This is how events sort of work?
|
||||
final Player player = event.getUser();
|
||||
log(player.getWorld().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
message = C.format(message, C.replacements);
|
||||
@ -455,8 +448,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
public EconHandler getEconomyHandler() {
|
||||
// TODO Auto-generated method stub
|
||||
// Nothing like Vault exists yet
|
||||
PS.log("getEconomyHandler NOT IMPLEMENTED YET");
|
||||
return null;
|
||||
return new SpongeEconHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -506,7 +498,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
|
||||
@Override
|
||||
public void registerPlayerEvents() {
|
||||
game.getEventManager().register(this, new MainListener());
|
||||
game.getEventManager().registerListeners(this, new MainListener());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.plotsquared.sponge;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.world.World;
|
||||
@ -17,7 +19,9 @@ import com.intellectualcrafters.jnbt.Tag;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.sponge.util.SpongeUtil;
|
||||
@ -25,32 +29,21 @@ import com.plotsquared.sponge.util.SpongeUtil;
|
||||
public class SpongeSchematicHandler extends SchematicHandler {
|
||||
|
||||
@Override
|
||||
public void getCompoundTag(final String world, final Location pos1, final Location pos2, final RunnableVal<CompoundTag> whenDone) {
|
||||
|
||||
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
|
||||
// async
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Main positions
|
||||
final int p1x = pos1.getX();
|
||||
final int p1z = pos1.getZ();
|
||||
final int p2x = pos2.getX();
|
||||
final int p2z = pos2.getZ();
|
||||
final int bcx = p1x >> 4;
|
||||
final int bcz = p1z >> 4;
|
||||
final int tcx = p2x >> 4;
|
||||
final int tcz = p2z >> 4;
|
||||
final int sy = pos1.getY();
|
||||
final int ey = pos2.getY();
|
||||
|
||||
final int width = (pos2.getX() - pos1.getX()) + 1;
|
||||
final int height = (pos2.getY() - pos1.getY()) + 1;
|
||||
final int length = (pos2.getZ() - pos1.getZ()) + 1;
|
||||
Location[] corners = MainUtil.getCorners(world, regions);
|
||||
final Location bot = corners[0];
|
||||
final Location top = corners[1];
|
||||
|
||||
final int width = (top.getX() - bot.getX()) + 1;
|
||||
final int height = (top.getY() - bot.getY()) + 1;
|
||||
final int length = (top.getZ() - bot.getZ()) + 1;
|
||||
// Main Schematic tag
|
||||
final HashMap<String, Tag> schematic = new HashMap<>();
|
||||
|
||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||
schematic.put("Length", new ShortTag("Length", (short) length));
|
||||
schematic.put("Height", new ShortTag("Height", (short) height));
|
||||
@ -61,12 +54,47 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
||||
schematic.put("WEOffsetX", new IntTag("WEOffsetX", 0));
|
||||
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
|
||||
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
|
||||
|
||||
// Arrays of data types
|
||||
final List<Tag> tileEntities = new ArrayList<Tag>();
|
||||
final byte[] blocks = new byte[width * height * length];
|
||||
final byte[] blockData = new byte[width * height * length];
|
||||
|
||||
// Queue
|
||||
final ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions);
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (queue.size() == 0) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
||||
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
|
||||
whenDone.value = new CompoundTag("Schematic", schematic);
|
||||
TaskManager.runTask(whenDone);
|
||||
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++) {
|
||||
@ -74,7 +102,6 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
||||
chunks.add(new ChunkLoc(x, z));
|
||||
}
|
||||
}
|
||||
|
||||
final World worldObj = SpongeUtil.getWorld(world);
|
||||
// Main thread
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@ -84,17 +111,14 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
||||
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;
|
||||
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;
|
||||
|
||||
@ -246,26 +270,15 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (chunks.size() != 0) {
|
||||
TaskManager.runTaskLater(this, 1);
|
||||
} else {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
||||
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
|
||||
whenDone.value = new CompoundTag("Schematic", schematic);
|
||||
TaskManager.runTask(whenDone);
|
||||
System.gc();
|
||||
System.gc();
|
||||
regionTask.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import org.spongepowered.api.event.AbstractEvent;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.event.AbstractEvent;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
|
||||
public abstract class PlayerEvent extends AbstractEvent {
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import org.spongepowered.api.event.AbstractEvent;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import org.spongepowered.api.event.AbstractEvent;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import org.spongepowered.api.event.AbstractEvent;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.spongepowered.api.event.AbstractEvent;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.spongepowered.api.event.AbstractEvent;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,9 +7,11 @@ import java.util.UUID;
|
||||
import org.spongepowered.api.data.key.Keys;
|
||||
import org.spongepowered.api.data.manipulator.mutable.TargetedLocationData;
|
||||
import org.spongepowered.api.data.value.mutable.Value;
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.player.gamemode.GameMode;
|
||||
import org.spongepowered.api.entity.player.gamemode.GameModes;
|
||||
import org.spongepowered.api.effect.sound.SoundTypes;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.entity.living.player.gamemode.GameMode;
|
||||
import org.spongepowered.api.entity.living.player.gamemode.GameModes;
|
||||
import org.spongepowered.api.service.ban.BanService;
|
||||
import org.spongepowered.api.text.Texts;
|
||||
import org.spongepowered.api.text.chat.ChatTypes;
|
||||
|
||||
@ -19,6 +21,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
@ -152,21 +155,27 @@ public class SpongePlayer extends PlotPlayer {
|
||||
@Override
|
||||
public void setAttribute(String key) {
|
||||
key = "plotsquared_user_attributes." + key;
|
||||
// EconHandler.manager.setPermission(getName(), key, true);
|
||||
if ((EconHandler.manager == null) || player.hasPermission("plotsquared_user_attributes.*")) {
|
||||
setMeta(key, true);
|
||||
return;
|
||||
}
|
||||
EconHandler.manager.setPermission(getName(), key, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAttribute(String key) {
|
||||
key = "plotsquared_user_attributes." + key;
|
||||
return getMeta(key) != null;
|
||||
// TODO register attributes
|
||||
if ((EconHandler.manager == null) || player.hasPermission("plotsquared_user_attributes.*")) {
|
||||
final Object v = getMeta(key);
|
||||
return v == null ? false : (Boolean) v;
|
||||
}
|
||||
return player.hasPermission(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String key) {
|
||||
key = "plotsquared_user_attributes." + key;
|
||||
// EconHandler.manager.setPermission(getName(), key, false);
|
||||
EconHandler.manager.setPermission(getName(), key, false);
|
||||
deleteMeta(key);
|
||||
}
|
||||
|
||||
@ -197,20 +206,20 @@ public class SpongePlayer extends PlotPlayer {
|
||||
@Override
|
||||
public void setGamemode(final PlotGamemode gamemode) {
|
||||
// TODO Auto-generated method stub
|
||||
// switch (gamemode) {
|
||||
// case ADVENTURE:
|
||||
// player.offer(Keys.GAME_MODE, GameModes.ADVENTURE);
|
||||
// return;
|
||||
// case CREATIVE:
|
||||
// player.offer(Keys.GAME_MODE, GameModes.CREATIVE);
|
||||
// return;
|
||||
// case SPECTATOR:
|
||||
// player.offer(Keys.GAME_MODE, GameModes.SPECTATOR);
|
||||
// return;
|
||||
// case SURVIVAL:
|
||||
// player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
|
||||
// return;
|
||||
// }
|
||||
switch (gamemode) {
|
||||
case ADVENTURE:
|
||||
player.offer(Keys.GAME_MODE, GameModes.ADVENTURE);
|
||||
return;
|
||||
case CREATIVE:
|
||||
player.offer(Keys.GAME_MODE, GameModes.CREATIVE);
|
||||
return;
|
||||
case SPECTATOR:
|
||||
player.offer(Keys.GAME_MODE, GameModes.SPECTATOR);
|
||||
return;
|
||||
case SURVIVAL:
|
||||
player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -221,18 +230,63 @@ public class SpongePlayer extends PlotPlayer {
|
||||
|
||||
@Override
|
||||
public void setFlight(final boolean fly) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
player.offer(Keys.IS_FLYING, fly);
|
||||
player.offer(Keys.CAN_FLY, fly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playMusic(final Location loc, final int id) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
switch (id) {
|
||||
case 0:
|
||||
player.playSound(null, SpongeUtil.getLocation(loc).getPosition(), 1);
|
||||
break;
|
||||
case 2256:
|
||||
player.playSound(SoundTypes.RECORDS_11, SpongeUtil.getLocation(loc).getPosition(), 1);
|
||||
break;
|
||||
case 2257:
|
||||
player.playSound(SoundTypes.RECORDS_13, SpongeUtil.getLocation(loc).getPosition(), 1);
|
||||
break;
|
||||
case 2258:
|
||||
player.playSound(SoundTypes.RECORDS_BLOCKS, SpongeUtil.getLocation(loc).getPosition(), 1);
|
||||
break;
|
||||
case 2259:
|
||||
player.playSound(SoundTypes.RECORDS_CAT, SpongeUtil.getLocation(loc).getPosition(), 1);
|
||||
break;
|
||||
case 2260:
|
||||
player.playSound(SoundTypes.RECORDS_CHIRP, SpongeUtil.getLocation(loc).getPosition(), 1);
|
||||
break;
|
||||
case 2261:
|
||||
player.playSound(SoundTypes.RECORDS_FAR, SpongeUtil.getLocation(loc).getPosition(), 1);
|
||||
break;
|
||||
case 2262:
|
||||
player.playSound(SoundTypes.RECORDS_MALL, SpongeUtil.getLocation(loc).getPosition(), 1);
|
||||
break;
|
||||
case 2263:
|
||||
player.playSound(SoundTypes.RECORDS_MELLOHI, SpongeUtil.getLocation(loc).getPosition(), 1);
|
||||
break;
|
||||
case 2264:
|
||||
player.playSound(SoundTypes.RECORDS_STAL, SpongeUtil.getLocation(loc).getPosition(), 1);
|
||||
break;
|
||||
case 2265:
|
||||
player.playSound(SoundTypes.RECORDS_STRAD, SpongeUtil.getLocation(loc).getPosition(), 1);
|
||||
break;
|
||||
case 2266:
|
||||
player.playSound(SoundTypes.RECORDS_WAIT, SpongeUtil.getLocation(loc).getPosition(), 1);
|
||||
break;
|
||||
case 2267:
|
||||
player.playSound(SoundTypes.RECORDS_WARD, SpongeUtil.getLocation(loc).getPosition(), 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kick(final String message) {
|
||||
player.kick(SpongeMain.THIS.getText(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned() {
|
||||
BanService service = SpongeMain.THIS.getGame().getServiceManager().provide(BanService.class).get();
|
||||
return service.isBanned(player);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.plotsquared.sponge.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.block.BlockType;
|
||||
@ -15,7 +16,6 @@ import org.spongepowered.api.world.World;
|
||||
import org.spongepowered.api.world.biome.BiomeType;
|
||||
import org.spongepowered.api.world.biome.BiomeTypes;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
@ -30,7 +30,8 @@ public class SpongeBlockManager extends BlockManager {
|
||||
public boolean isBlockSolid(final PlotBlock block) {
|
||||
final BlockState state = SpongeMain.THIS.getBlockState(block);
|
||||
final BlockType type = state.getType();
|
||||
return type.isSolidCube() && !type.isAffectedByGravity();
|
||||
// TODO check if solid;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -220,7 +221,6 @@ public class SpongeBlockManager extends BlockManager {
|
||||
if (block != state) {
|
||||
world.setBlock(x, y, z, state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,9 +1,8 @@
|
||||
package com.plotsquared.sponge.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.spongepowered.api.entity.Entity;
|
||||
import org.spongepowered.api.entity.living.Living;
|
||||
@ -11,15 +10,11 @@ import org.spongepowered.api.entity.living.animal.Animal;
|
||||
import org.spongepowered.api.entity.living.monster.Monster;
|
||||
import org.spongepowered.api.world.Chunk;
|
||||
import org.spongepowered.api.world.World;
|
||||
import org.spongepowered.api.world.storage.ChunkDataStream;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
@ -29,7 +24,6 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
@Override
|
||||
public void setChunk(final ChunkWrapper loc, final PlotBlock[][] result) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,7 +40,7 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
final int[] count = new int[5];
|
||||
world.getEntities(new Predicate<Entity>() {
|
||||
@Override
|
||||
public boolean apply(final Entity entity) {
|
||||
public boolean test(final Entity entity) {
|
||||
final org.spongepowered.api.world.Location loc = entity.getLocation();
|
||||
final int x = loc.getBlockX();
|
||||
if ((x >= bx) && (x <= tx)) {
|
||||
@ -78,27 +72,10 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
return worldObj.loadChunk(loc.x << 4, 0, loc.z << 4, force).isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe) {
|
||||
final World worldObj = SpongeUtil.getWorld(world);
|
||||
final Optional<Chunk> chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4);
|
||||
if (chunk.isPresent()) {
|
||||
return worldObj.unloadChunk(chunk.get());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ChunkLoc> getChunkChunks(final String world) {
|
||||
final HashSet<ChunkLoc> chunks = new HashSet<ChunkLoc>();
|
||||
final World worldObj = SpongeUtil.getWorld(world);
|
||||
final ChunkDataStream storage = worldObj.getWorldStorage().getGeneratedChunks();
|
||||
while (storage.hasNext()) {
|
||||
storage.next();
|
||||
|
||||
// TODO get chunk from DataContainer
|
||||
}
|
||||
return chunks;
|
||||
// TODO save world;
|
||||
return super.getChunkChunks(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,55 +87,19 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRegionFile(final String world, final ChunkLoc loc) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRegionFiles(final String world, final List<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
|
||||
public boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone) {
|
||||
// TODO Auto-generated method stub
|
||||
// TODO copy a region
|
||||
TaskManager.runTask(whenDone);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone) {
|
||||
// TODO Auto-generated method stub
|
||||
TaskManager.runTask(whenDone);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swap(final String world, final PlotId id, final PlotId plotid) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swap(final String worldname, final Location bot1, final Location top1, final Location bot2, final Location top2) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllEntities(final Location pos1, final Location pos2) {
|
||||
final String worldname = pos1.getWorld();
|
||||
@ -169,7 +110,7 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
final int tz = pos2.getZ();
|
||||
world.getEntities(new Predicate<Entity>() {
|
||||
@Override
|
||||
public boolean apply(final Entity entity) {
|
||||
public boolean test(final Entity entity) {
|
||||
final org.spongepowered.api.world.Location loc = entity.getLocation();
|
||||
final int x = loc.getBlockX();
|
||||
if ((x >= bx) && (x <= tx)) {
|
||||
@ -183,4 +124,19 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swap(Location bot1, Location top1, Location bot2, Location top2, Runnable whenDone) {
|
||||
// TODO swap region
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unloadChunk(String world, ChunkLoc loc, boolean save, boolean safe) {
|
||||
final World worldObj = SpongeUtil.getWorld(world);
|
||||
final Optional<Chunk> chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4);
|
||||
if (chunk.isPresent()) {
|
||||
worldObj.unloadChunk(chunk.get());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.text.Texts;
|
||||
import org.spongepowered.api.util.command.CommandCallable;
|
||||
@ -13,7 +13,7 @@ import org.spongepowered.api.util.command.CommandException;
|
||||
import org.spongepowered.api.util.command.CommandResult;
|
||||
import org.spongepowered.api.util.command.CommandSource;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -3,7 +3,6 @@ package com.plotsquared.sponge.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
import org.spongepowered.api.event.Event;
|
||||
import org.spongepowered.api.service.event.EventManager;
|
||||
|
||||
@ -41,11 +40,7 @@ public class SpongeEventUtil extends EventUtil {
|
||||
}
|
||||
|
||||
public boolean callEvent(final Event event) {
|
||||
events.post(event);
|
||||
if (event instanceof Cancellable) {
|
||||
return !((Cancellable) event).isCancelled();
|
||||
}
|
||||
return true;
|
||||
return !events.post(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,7 +3,7 @@ package com.plotsquared.sponge.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.item.ItemType;
|
||||
import org.spongepowered.api.item.ItemTypes;
|
||||
import org.spongepowered.api.item.inventory.Carrier;
|
||||
|
@ -1,13 +1,14 @@
|
||||
package com.plotsquared.sponge.util;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.spongepowered.api.entity.Entity;
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.world.World;
|
||||
import org.spongepowered.api.world.extent.Extent;
|
||||
|
||||
import com.flowpowered.math.vector.Vector3d;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
import com.google.common.base.Optional;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
@ -24,12 +25,8 @@ public class SpongeUtil {
|
||||
return new Location(world, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
public static Location getLocation(final org.spongepowered.api.world.Location block) {
|
||||
final Extent extent = block.getExtent();
|
||||
if (extent instanceof World) {
|
||||
return getLocation(((World) extent).getName(), block);
|
||||
}
|
||||
return null;
|
||||
public static Location getLocation(final org.spongepowered.api.world.Location<World> block) {
|
||||
return getLocation(block.getExtent().getName(), block);
|
||||
}
|
||||
|
||||
public static Location getLocationFull(final Entity player) {
|
||||
@ -83,7 +80,6 @@ public class SpongeUtil {
|
||||
public static void removePlayer(final String player) {
|
||||
lastPlayer = null;
|
||||
lastPlotPlayer = null;
|
||||
UUIDHandler.getPlayers().remove(player);
|
||||
}
|
||||
|
||||
public static Location getLocation(final String world, final org.spongepowered.api.world.Location spawn) {
|
||||
@ -110,4 +106,12 @@ public class SpongeUtil {
|
||||
}
|
||||
return new org.spongepowered.api.world.Location(world.get(), loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
public static Location getLocation(String world, Vector3i position) {
|
||||
return new Location(world, position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
public static Location getLocation(String world, Vector3d position) {
|
||||
return new Location(world, MathMan.roundInt(position.getX()), MathMan.roundInt(position.getY()), MathMan.roundInt(position.getZ()));
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.plotsquared.sponge.uuid;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.GameProfile;
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
|
@ -85,6 +85,15 @@ permissions:
|
||||
plots.inbox.read.owner: true
|
||||
plots.comment: true
|
||||
plots.inbox: true
|
||||
plots.permpack.wilderness:
|
||||
default: op
|
||||
children:
|
||||
plots.admin.interact.unowned: true
|
||||
plots.admin.destroy.unowned: true
|
||||
plots.admin.build.unowned: true
|
||||
plots.projectile.unowned: true
|
||||
plots.admin.vehicle.break.unowned: true
|
||||
plots.admin.pve.unowned: true
|
||||
plots.permpack.basic:
|
||||
default: op
|
||||
children:
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user