Merge remote-tracking branch 'origin/master'

# Conflicts:
#	Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java
This commit is contained in:
Jesse Boyd 2016-09-17 16:03:57 +10:00
commit d89274ce09
22 changed files with 1139 additions and 1305 deletions

View File

@ -57,6 +57,7 @@ import com.plotsquared.bukkit.util.BukkitSchematicHandler;
import com.plotsquared.bukkit.util.BukkitSetupUtils;
import com.plotsquared.bukkit.util.BukkitTaskManager;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.BukkitVersion;
import com.plotsquared.bukkit.util.Metrics;
import com.plotsquared.bukkit.util.SendChunk;
import com.plotsquared.bukkit.util.SetGenCB;
@ -374,21 +375,21 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
} catch (NoSuchMethodException ignored) {
PS.debug("Not running Spigot. Skipping EntitySpawnListener event.");
}
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_0)) {
try {
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this);
} catch (Throwable e) {
e.printStackTrace();
}
}
if (PS.get().checkVersion(getServerVersion(), 1, 8, 3)) {
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_3)) {
try {
getServer().getPluginManager().registerEvents(new PlayerEvents183(), this);
} catch (Throwable e) {
e.printStackTrace();
}
}
if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) {
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_9_0)) {
try {
getServer().getPluginManager().registerEvents(new PlayerEvents_1_9(main), this);
} catch (Throwable e) {
@ -443,13 +444,13 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
PS.debug(SendChunk.class + " does not support " + StringMan.getString(getServerVersion()));
MainUtil.canSendChunk = false;
}
if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) {
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_9_0)) {
return QueueProvider.of(BukkitLocalQueue_1_9.class, BukkitLocalQueue.class);
}
if (PS.get().checkVersion(getServerVersion(), 1, 8, 3)) {
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_3)) {
return QueueProvider.of(BukkitLocalQueue_1_8_3.class, BukkitLocalQueue.class);
}
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_0)) {
return QueueProvider.of(BukkitLocalQueue_1_8.class, BukkitLocalQueue.class);
}
return QueueProvider.of(BukkitLocalQueue_1_7.class, BukkitLocalQueue.class);
@ -505,7 +506,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
@Override
public UUIDHandlerImplementation initUUIDHandler() {
boolean checkVersion = PS.get().checkVersion(getServerVersion(), 1, 7, 6);
boolean checkVersion = PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_7_6);
UUIDWrapper wrapper;
if (Settings.UUID.OFFLINE) {
if (Settings.UUID.FORCE_LOWERCASE) {

View File

@ -78,12 +78,11 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
this(rawText(firstPartText));
}
public FancyMessage(final TextualComponent firstPartText) {
private FancyMessage(final TextualComponent firstPartText) {
messageParts = new ArrayList<>();
messageParts.add(new MessagePart(firstPartText));
jsonString = null;
dirty = false;
if (nmsPacketPlayOutChatConstructor == null) {
try {
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat").getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent"));

View File

@ -1,12 +1,12 @@
package com.plotsquared.bukkit.chat;
import com.google.gson.stream.JsonWriter;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.stream.JsonWriter;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
/**
* Represents a JSON string value.
* Writes by this object will not write name values nor begin/end objects in the JSON stream.

View File

@ -1,6 +1,7 @@
package com.plotsquared.bukkit.object.entity;
import com.intellectualcrafters.plot.PS;
import com.plotsquared.bukkit.util.BukkitVersion;
import org.bukkit.Art;
import org.bukkit.DyeColor;
import org.bukkit.Location;
@ -86,7 +87,7 @@ public class EntityWrapper {
if (depth == 1) {
return;
}
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 10, 0) || entity instanceof ArmorStand) {
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_10_0) || entity instanceof ArmorStand) {
if (!entity.hasGravity()) {
this.noGravity = true;
}
@ -94,7 +95,7 @@ public class EntityWrapper {
switch (entity.getType()) {
case ARROW:
case BOAT:
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) {
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_0)) {
Boat boat = (Boat) entity;
this.dataByte = getOrdinal(TreeSpecies.values(), boat.getWoodType());
}
@ -353,7 +354,7 @@ public class EntityWrapper {
void restoreEquipment(LivingEntity entity) {
EntityEquipment equipment = entity.getEquipment();
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) {
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_0)) {
equipment.setItemInMainHand(this.lived.mainHand);
equipment.setItemInOffHand(this.lived.offHand);
} else {
@ -397,7 +398,7 @@ public class EntityWrapper {
}
void storeEquipment(EntityEquipment equipment) {
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) {
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_0)) {
this.lived.mainHand = equipment.getItemInMainHand().clone();
this.lived.offHand = equipment.getItemInOffHand().clone();
} else {
@ -487,7 +488,7 @@ public class EntityWrapper {
if (this.depth == 1) {
return entity;
}
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 10, 0) || entity instanceof ArmorStand) {
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_10_0) || entity instanceof ArmorStand) {
if (this.noGravity) {
entity.setGravity(false);
}
@ -495,7 +496,7 @@ public class EntityWrapper {
switch (entity.getType()) {
case ARROW:
case BOAT:
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) {
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_0)) {
Boat boat = (Boat) entity;
boat.setWoodType(TreeSpecies.values()[dataByte]);
}

View File

@ -12,8 +12,6 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
import java.util.HashSet;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
@ -23,6 +21,9 @@ import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.material.Directional;
import org.bukkit.material.MaterialData;
import java.util.HashSet;
import java.util.Random;
public class BukkitHybridUtils extends HybridUtils {
@Override
@ -50,7 +51,8 @@ public class BukkitHybridUtils extends HybridUtils {
}
final BiomeGrid nullBiomeGrid = new BiomeGrid() {
@Override
public void setBiome(int a, int b, Biome c) {}
public void setBiome(int a, int b, Biome c) {
}
@Override
public Biome getBiome(int a, int b) {

View File

@ -0,0 +1,13 @@
package com.plotsquared.bukkit.util;
public class BukkitVersion {
public static int[] v1_10_2 = {1, 10, 2};
public static int[] v1_10_0 = {1, 10, 0};
public static int[] v1_9_4 = {1, 9, 4};
public static int[] v1_9_0 = {1, 9, 0};
public static int[] v1_8_3 = {1, 8, 3};
public static int[] v1_8_0 = {1, 8, 0};
public static int[] v1_7_6 = {1, 7, 6};
public static int[] v1_7_0 = {1, 7, 0};
public static int[] v1_6_0 = {1, 6, 0};
}

View File

@ -8,7 +8,6 @@ import com.google.common.collect.MapMaker;
import com.google.common.io.ByteSink;
import com.google.common.io.ByteSource;
import com.google.common.io.Closeables;
import com.google.common.io.Files;
import com.google.common.primitives.Primitives;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -20,7 +19,6 @@ import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -161,7 +159,6 @@ public class NbtFactory {
/**
* Load the content of a file from a stream.
*
* Use {@link Files#newInputStreamSupplier(File)} to provide a stream from a file.
* @param stream - the stream supplier.
* @param option - whether or not to decompress the input stream.
* @return The decoded NBT compound.
@ -196,7 +193,6 @@ public class NbtFactory {
/**
* Save the content of a NBT compound to a stream.
*
* Use {@link Files#newOutputStreamSupplier(File)} to provide a stream supplier to a file.
* @param source - the NBT compound to save.
* @param stream - the stream.
* @param option - whether or not to compress the output.
@ -445,8 +441,7 @@ public class NbtFactory {
/**
* Convert a given NBT element to a primitive wrapper or List/Map equivalent.
* <p>
* All changes to any mutable objects will be reflected in the underlying NBT element(s).
* <p> All changes to any mutable objects will be reflected in the underlying NBT element(s).
* @param nms - the NBT element.
* @return The wrapper equivalent.
*/
@ -605,7 +600,7 @@ public class NbtFactory {
*/
private static class LoadMethodWorldUpdate extends LoadCompoundMethod {
public LoadMethodWorldUpdate(Class<?> streamClass) {
LoadMethodWorldUpdate(Class<?> streamClass) {
setMethod(getMethod(Modifier.STATIC, 0, streamClass, null, DataInput.class));
}
@ -622,7 +617,7 @@ public class NbtFactory {
private Object readLimiter;
public LoadMethodSkinUpdate(Class<?> streamClass, Class<?> readLimiterClass) {
LoadMethodSkinUpdate(Class<?> streamClass, Class<?> readLimiterClass) {
setMethod(getMethod(Modifier.STATIC, 0, streamClass, null, DataInput.class, readLimiterClass));
// Find the unlimited read limiter
@ -645,8 +640,7 @@ public class NbtFactory {
/**
* Represents a root NBT compound.
* <p>
* All changes to this map will be reflected in the underlying NBT compound. Values may only be one of the following:
* <p> All changes to this map will be reflected in the underlying NBT compound. Values may only be one of the following:
* <ul>
* <li>Primitive types</li>
* <li>{@link String String}</li>
@ -769,8 +763,6 @@ public class NbtFactory {
/**
* Save the content of a NBT compound to a stream.
* <p>
* Use {@link Files#newOutputStreamSupplier(File)} to provide a stream supplier to a file.
* @param stream - the output stream.
* @param option - whether or not to compress the output.
* @throws IOException If anything went wrong.

View File

@ -50,7 +50,7 @@ public class SendChunk {
RefClass classChunk = getRefClass("{nms}.Chunk");
this.methodInitLighting = classChunk.getMethod("initLighting");
RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 4)) {
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_4)) {
//this works for 1.9.4 and 1.10
tempMapChunk = classMapChunk.getConstructor(classChunk.getRealClass(),int.class);
} else {
@ -116,7 +116,7 @@ public class SendChunk {
chunks.remove(chunk);
Object con = this.connection.of(entity).get();
Object packet = null;
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 4)) {
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_4)) {
try {
packet = this.mapChunk.create(c,65535);
} catch (Exception ignored) {}

View File

@ -1,5 +1,7 @@
package com.plotsquared.bukkit.util.block;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.ChunkWrapper;
import com.intellectualcrafters.plot.object.PseudoRandom;
@ -9,6 +11,11 @@ import com.intellectualcrafters.plot.util.ReflectionUtils;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.block.BasicLocalBlockQueue;
import com.plotsquared.bukkit.util.SendChunk;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
@ -18,13 +25,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
public class BukkitLocalQueue_1_8_3 extends BukkitLocalQueue<char[]> {

View File

@ -29,9 +29,6 @@ public class MemoryConfiguration extends MemorySection implements Configuration
@Override
public void addDefault(String path, Object value) {
if (path == null) {
throw new NullPointerException("Path may not be null");
}
if (this.defaults == null) {
this.defaults = new MemoryConfiguration();
}
@ -41,10 +38,6 @@ public class MemoryConfiguration extends MemorySection implements Configuration
@Override
public void addDefaults(Map<String, Object> defaults) {
if (defaults == null) {
throw new NullPointerException("Defaults may not be null");
}
for (Map.Entry<String, Object> entry : defaults.entrySet()) {
addDefault(entry.getKey(), entry.getValue());
}
@ -52,10 +45,6 @@ public class MemoryConfiguration extends MemorySection implements Configuration
@Override
public void addDefaults(Configuration defaults) {
if (defaults == null) {
throw new NullPointerException("Defaults may not be null");
}
addDefaults(defaults.getValues(true));
}

View File

@ -49,13 +49,6 @@ public class MemorySection implements ConfigurationSection {
* if parent contains no root Configuration.
*/
protected MemorySection(ConfigurationSection parent, String path) {
if (parent == null) {
throw new NullPointerException("Parent may not be null");
}
if (path == null) {
throw new NullPointerException("Path may not be null");
}
this.path = path;
this.parent = parent;
this.root = parent.getRoot();
@ -133,7 +126,7 @@ public class MemorySection implements ConfigurationSection {
* @return Full path of the section from its root.
*/
public static String createPath(ConfigurationSection section, String key) {
return createPath(section, key, (section == null) ? null : section.getRoot());
return createPath(section, key, section.getRoot());
}
/**
@ -149,9 +142,6 @@ public class MemorySection implements ConfigurationSection {
* @return Full path of the section from its root.
*/
public static String createPath(ConfigurationSection section, String key, ConfigurationSection relativeTo) {
if (section == null) {
throw new NullPointerException("Cannot create path without a section");
}
Configuration root = section.getRoot();
if (root == null) {
throw new IllegalStateException("Cannot create path without a root");
@ -253,10 +243,6 @@ public class MemorySection implements ConfigurationSection {
@Override
public void addDefault(String path, Object value) {
if (path == null) {
throw new NullPointerException("Path cannot be null");
}
Configuration root = getRoot();
if (root == null) {
throw new IllegalStateException("Cannot add default without root");
@ -283,10 +269,6 @@ public class MemorySection implements ConfigurationSection {
@Override
public void set(String path, Object value) {
if (path == null) {
throw new NullPointerException("Cannot set to an empty path");
}
Configuration root = getRoot();
if (root == null) {
throw new IllegalStateException("Cannot use section without a root");
@ -367,9 +349,6 @@ public class MemorySection implements ConfigurationSection {
@Override
public ConfigurationSection createSection(String path) {
if (path == null) {
throw new NullPointerException("Cannot create section at empty path");
}
Configuration root = getRoot();
if (root == null) {
throw new IllegalStateException("Cannot create section without a root");
@ -787,10 +766,6 @@ public class MemorySection implements ConfigurationSection {
}
protected Object getDefault(String path) {
if (path == null) {
throw new NullPointerException("Path may not be null");
}
Configuration root = getRoot();
Configuration defaults = root == null ? null : root.getDefaults();
return (defaults == null) ? null : defaults.get(createPath(this, path));

View File

@ -87,9 +87,6 @@ public abstract class FileConfiguration extends MemoryConfiguration {
* @throws IllegalArgumentException Thrown when file is null.
*/
public void load(File file) throws IOException, InvalidConfigurationException {
if (file == null) {
throw new NullPointerException("File cannot be null");
}
FileInputStream stream = new FileInputStream(file);
@ -124,32 +121,6 @@ public abstract class FileConfiguration extends MemoryConfiguration {
loadFromString(builder.toString());
}
/**
* Loads this {@link FileConfiguration} from the specified location.
*
* <p>All the values contained within this configuration will be removed,
* leaving only settings and defaults, and the new values will be loaded
* from the given file.
*
* <p>If the file cannot be loaded for any reason, an exception will be
* thrown.
*
* @param file File to load from.
* @throws FileNotFoundException Thrown when the given file cannot be
* opened.
* @throws IOException Thrown when the given file cannot be read.
* @throws InvalidConfigurationException Thrown when the given file is not
* a valid Configuration.
* @throws IllegalArgumentException Thrown when file is null.
*/
public void load(String file) throws IOException, InvalidConfigurationException {
if (file == null) {
throw new NullPointerException("File cannot be null");
}
load(new File(file));
}
/**
* Loads this {@link FileConfiguration} from the specified string, as
* opposed to from file.

View File

@ -11,7 +11,6 @@ import org.yaml.snakeyaml.representer.Representer;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Map;
@ -38,13 +37,8 @@ public class YamlConfiguration extends FileConfiguration {
*
* @param file Input file
* @return Resulting configuration
* @throws IllegalArgumentException Thrown if file is null
*/
public static YamlConfiguration loadConfiguration(File file) {
if (file == null) {
throw new NullPointerException("File cannot be null");
}
YamlConfiguration config = new YamlConfiguration();
try {
@ -70,34 +64,6 @@ public class YamlConfiguration extends FileConfiguration {
return config;
}
/**
* Creates a new {@link YamlConfiguration}, loading from the given reader.
*
* <p>Any errors loading the Configuration will be logged and then ignored.
* If the specified input is not a valid config, a blank config will be
* returned.
*
* @param reader input
* @return resulting configuration
* @throws IllegalArgumentException Thrown if stream is null
*/
public static YamlConfiguration loadConfiguration(Reader reader) {
if (reader == null) {
throw new NullPointerException("Reader cannot be null");
}
YamlConfiguration config = new YamlConfiguration();
try {
config.load(reader);
} catch (IOException | InvalidConfigurationException ex) {
PS.debug("Cannot load configuration from stream");
ex.printStackTrace();
}
return config;
}
@Override
public String saveToString() {
yamlOptions.setIndent(options().indent());
@ -116,9 +82,6 @@ public class YamlConfiguration extends FileConfiguration {
@Override
public void loadFromString(String contents) throws InvalidConfigurationException {
if (contents == null) {
throw new NullPointerException("Contents cannot be null");
}
Map<?, ?> input;
try {

View File

@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.Permissions;
import java.util.List;
@ -12,11 +13,31 @@ public abstract class CommentInbox {
@Override
public abstract String toString();
public abstract boolean canRead(Plot plot, PlotPlayer player);
public boolean canRead(Plot plot, PlotPlayer player) {
if (Permissions.hasPermission(player, "plots.inbox.read." + toString())) {
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.read." + toString() + ".other")) {
return true;
}
}
return false;
}
public abstract boolean canWrite(Plot plot, PlotPlayer player);
public boolean canWrite(Plot plot, PlotPlayer player) {
if (plot == null) {
return Permissions.hasPermission(player, "plots.inbox.write." + toString());
}
return Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.inbox.write." + toString() + ".other"));
}
public abstract boolean canModify(Plot plot, PlotPlayer player);
public boolean canModify(Plot plot, PlotPlayer player) {
if (Permissions.hasPermission(player, "plots.inbox.modify." + toString())) {
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + toString() + ".other")) {
return true;
}
}
return false;
}
/**
*

View File

@ -3,9 +3,7 @@ package com.intellectualcrafters.plot.object.comment;
import com.google.common.base.Optional;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.TaskManager;
import java.util.ArrayList;
@ -13,35 +11,6 @@ import java.util.List;
public class InboxOwner extends CommentInbox {
@Override
public boolean canRead(Plot plot, PlotPlayer player) {
if (Permissions.hasPermission(player, "plots.inbox.read." + toString())) {
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.read." + toString() + ".other")) {
return true;
}
}
return false;
}
@Override
public boolean canWrite(Plot plot, PlotPlayer player) {
if (plot == null) {
return Permissions.hasPermission(player, "plots.inbox.write." + toString());
}
return Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.inbox.write." + toString() + ".other"));
}
@Override
public boolean canModify(Plot plot, PlotPlayer player) {
if (Permissions.hasPermission(player, "plots.inbox.modify." + toString())) {
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + toString() + ".other")) {
return true;
}
}
return false;
}
@Override
public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());

View File

@ -3,9 +3,7 @@ package com.intellectualcrafters.plot.object.comment;
import com.google.common.base.Optional;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.TaskManager;
import java.util.ArrayList;
@ -13,35 +11,6 @@ import java.util.List;
public class InboxPublic extends CommentInbox {
@Override
public boolean canRead(Plot plot, PlotPlayer player) {
if (Permissions.hasPermission(player, "plots.inbox.read." + toString())) {
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.read." + toString() + ".other")) {
return true;
}
}
return false;
}
@Override
public boolean canWrite(Plot plot, PlotPlayer player) {
if (plot == null) {
return Permissions.hasPermission(player, "plots.inbox.write." + toString());
}
return Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.inbox.write." + toString() + ".other"));
}
@Override
public boolean canModify(Plot plot, PlotPlayer player) {
if (Permissions.hasPermission(player, "plots.inbox.modify." + toString())) {
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + toString() + ".other")) {
return true;
}
}
return false;
}
@Override
public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());

View File

@ -2,45 +2,13 @@ package com.intellectualcrafters.plot.object.comment;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.TaskManager;
import java.util.List;
public class InboxReport extends CommentInbox {
@Override
public boolean canRead(Plot plot, PlotPlayer player) {
if (Permissions.hasPermission(player, "plots.inbox.read." + toString())) {
if (plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.inbox.read." + toString() + ".other")) {
return true;
}
}
return false;
}
@Override
public boolean canWrite(Plot plot, PlotPlayer player) {
if (plot == null) {
return Permissions.hasPermission(player, "plots.inbox.write." + toString());
}
return Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.inbox.write." + toString() + ".other"));
}
@Override
public boolean canModify(Plot plot, PlotPlayer player) {
if (Permissions.hasPermission(player, "plots.inbox.modify." + toString())) {
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + toString() + ".other")) {
return true;
}
}
return false;
}
@Override
public boolean getComments(Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
DBFunc.getComments(null, toString(), new RunnableVal<List<PlotComment>>() {

View File

@ -376,7 +376,7 @@ public class MainListener {
}
Optional<Explosive> source = event.getExplosion().getSourceExplosive();
if (!source.isPresent()) {
event.filterAll();
event.setCancelled(true);
return;
}
Explosive tnt = source.get();
@ -385,21 +385,22 @@ public class MainListener {
Plot currentPlot = current.getPlot();
if (currentPlot == null) {
if (current.isPlotArea()) {
event.filterAll();
event.setCancelled(true);
}
return;
}
if (creator != null) {
if (!currentPlot.isAdded(creator)) {
event.filterAll();
event.setCancelled(true);
return;
}
}
if (!currentPlot.getFlag(Flags.EXPLOSION).or(false)) {
event.filterAll();
event.setCancelled(true);
return;
}
event.filter(loc -> currentPlot.equals(SpongeUtil.getLocation(loc.getExtent().getName(), loc).getPlot()));
event.getAffectedLocations().removeIf(worldLocation -> currentPlot.equals(SpongeUtil.getLocation(worldLocation.getExtent().getName(), worldLocation).getPlot()));
event.filterEntities(entity -> currentPlot.equals(SpongeUtil.getLocation(entity).getPlot()));
}
}