mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-10-31 09:33:43 +01:00 
			
		
		
		
	Merge remote-tracking branch 'origin/master'
# Conflicts: # Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java
This commit is contained in:
		| @@ -57,6 +57,7 @@ import com.plotsquared.bukkit.util.BukkitSchematicHandler; | |||||||
| import com.plotsquared.bukkit.util.BukkitSetupUtils; | import com.plotsquared.bukkit.util.BukkitSetupUtils; | ||||||
| import com.plotsquared.bukkit.util.BukkitTaskManager; | import com.plotsquared.bukkit.util.BukkitTaskManager; | ||||||
| import com.plotsquared.bukkit.util.BukkitUtil; | import com.plotsquared.bukkit.util.BukkitUtil; | ||||||
|  | import com.plotsquared.bukkit.util.BukkitVersion; | ||||||
| import com.plotsquared.bukkit.util.Metrics; | import com.plotsquared.bukkit.util.Metrics; | ||||||
| import com.plotsquared.bukkit.util.SendChunk; | import com.plotsquared.bukkit.util.SendChunk; | ||||||
| import com.plotsquared.bukkit.util.SetGenCB; | import com.plotsquared.bukkit.util.SetGenCB; | ||||||
| @@ -374,21 +375,21 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain | |||||||
|         } catch (NoSuchMethodException ignored) { |         } catch (NoSuchMethodException ignored) { | ||||||
|             PS.debug("Not running Spigot. Skipping EntitySpawnListener event."); |             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 { |             try { | ||||||
|                 getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this); |                 getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this); | ||||||
|             } catch (Throwable e) { |             } catch (Throwable e) { | ||||||
|                 e.printStackTrace(); |                 e.printStackTrace(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         if (PS.get().checkVersion(getServerVersion(), 1, 8, 3)) { |         if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_3)) { | ||||||
|             try { |             try { | ||||||
|                 getServer().getPluginManager().registerEvents(new PlayerEvents183(), this); |                 getServer().getPluginManager().registerEvents(new PlayerEvents183(), this); | ||||||
|             } catch (Throwable e) { |             } catch (Throwable e) { | ||||||
|                 e.printStackTrace(); |                 e.printStackTrace(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) { |         if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_9_0)) { | ||||||
|             try { |             try { | ||||||
|                 getServer().getPluginManager().registerEvents(new PlayerEvents_1_9(main), this); |                 getServer().getPluginManager().registerEvents(new PlayerEvents_1_9(main), this); | ||||||
|             } catch (Throwable e) { |             } 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())); |             PS.debug(SendChunk.class + " does not support " + StringMan.getString(getServerVersion())); | ||||||
|             MainUtil.canSendChunk = false; |             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); |             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); |             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_8.class, BukkitLocalQueue.class); | ||||||
|         } |         } | ||||||
|         return QueueProvider.of(BukkitLocalQueue_1_7.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 |     @Override | ||||||
|     public UUIDHandlerImplementation initUUIDHandler() { |     public UUIDHandlerImplementation initUUIDHandler() { | ||||||
|         boolean checkVersion = PS.get().checkVersion(getServerVersion(), 1, 7, 6); |         boolean checkVersion = PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_7_6); | ||||||
|         UUIDWrapper wrapper; |         UUIDWrapper wrapper; | ||||||
|         if (Settings.UUID.OFFLINE) { |         if (Settings.UUID.OFFLINE) { | ||||||
|             if (Settings.UUID.FORCE_LOWERCASE) { |             if (Settings.UUID.FORCE_LOWERCASE) { | ||||||
|   | |||||||
| @@ -78,12 +78,11 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< | |||||||
|         this(rawText(firstPartText)); |         this(rawText(firstPartText)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| 	public FancyMessage(final TextualComponent firstPartText) { |     private FancyMessage(final TextualComponent firstPartText) { | ||||||
|         messageParts = new ArrayList<>(); |         messageParts = new ArrayList<>(); | ||||||
|         messageParts.add(new MessagePart(firstPartText)); |         messageParts.add(new MessagePart(firstPartText)); | ||||||
|         jsonString = null; |         jsonString = null; | ||||||
|         dirty = false; |         dirty = false; | ||||||
|  |  | ||||||
|         if (nmsPacketPlayOutChatConstructor == null) { |         if (nmsPacketPlayOutChatConstructor == null) { | ||||||
|             try { |             try { | ||||||
|                 nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat").getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent")); |                 nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat").getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent")); | ||||||
|   | |||||||
| @@ -1,12 +1,12 @@ | |||||||
| package com.plotsquared.bukkit.chat; | package com.plotsquared.bukkit.chat; | ||||||
|  |  | ||||||
|  | import com.google.gson.stream.JsonWriter; | ||||||
|  | import org.bukkit.configuration.serialization.ConfigurationSerializable; | ||||||
|  |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| import com.google.gson.stream.JsonWriter; |  | ||||||
| import org.bukkit.configuration.serialization.ConfigurationSerializable; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Represents a JSON string value. |  * Represents a JSON string value. | ||||||
|  * Writes by this object will not write name values nor begin/end objects in the JSON stream. |  * Writes by this object will not write name values nor begin/end objects in the JSON stream. | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package com.plotsquared.bukkit.object.entity; | package com.plotsquared.bukkit.object.entity; | ||||||
|  |  | ||||||
| import com.intellectualcrafters.plot.PS; | import com.intellectualcrafters.plot.PS; | ||||||
|  | import com.plotsquared.bukkit.util.BukkitVersion; | ||||||
| import org.bukkit.Art; | import org.bukkit.Art; | ||||||
| import org.bukkit.DyeColor; | import org.bukkit.DyeColor; | ||||||
| import org.bukkit.Location; | import org.bukkit.Location; | ||||||
| @@ -86,7 +87,7 @@ public class EntityWrapper { | |||||||
|         if (depth == 1) { |         if (depth == 1) { | ||||||
|             return; |             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()) { |             if (!entity.hasGravity()) { | ||||||
|                 this.noGravity = true; |                 this.noGravity = true; | ||||||
|             } |             } | ||||||
| @@ -94,7 +95,7 @@ public class EntityWrapper { | |||||||
|         switch (entity.getType()) { |         switch (entity.getType()) { | ||||||
|             case ARROW: |             case ARROW: | ||||||
|             case BOAT: |             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 boat = (Boat) entity; | ||||||
|                     this.dataByte = getOrdinal(TreeSpecies.values(), boat.getWoodType()); |                     this.dataByte = getOrdinal(TreeSpecies.values(), boat.getWoodType()); | ||||||
|                 } |                 } | ||||||
| @@ -353,7 +354,7 @@ public class EntityWrapper { | |||||||
|  |  | ||||||
|     void restoreEquipment(LivingEntity entity) { |     void restoreEquipment(LivingEntity entity) { | ||||||
|         EntityEquipment equipment = entity.getEquipment(); |         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.setItemInMainHand(this.lived.mainHand); | ||||||
|             equipment.setItemInOffHand(this.lived.offHand); |             equipment.setItemInOffHand(this.lived.offHand); | ||||||
|         } else { |         } else { | ||||||
| @@ -397,7 +398,7 @@ public class EntityWrapper { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     void storeEquipment(EntityEquipment equipment) { |     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.mainHand = equipment.getItemInMainHand().clone(); | ||||||
|             this.lived.offHand = equipment.getItemInOffHand().clone(); |             this.lived.offHand = equipment.getItemInOffHand().clone(); | ||||||
|         } else { |         } else { | ||||||
| @@ -487,7 +488,7 @@ public class EntityWrapper { | |||||||
|         if (this.depth == 1) { |         if (this.depth == 1) { | ||||||
|             return entity; |             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) { |             if (this.noGravity) { | ||||||
|                 entity.setGravity(false); |                 entity.setGravity(false); | ||||||
|             } |             } | ||||||
| @@ -495,7 +496,7 @@ public class EntityWrapper { | |||||||
|         switch (entity.getType()) { |         switch (entity.getType()) { | ||||||
|             case ARROW: |             case ARROW: | ||||||
|             case BOAT: |             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 boat = (Boat) entity; | ||||||
|                     boat.setWoodType(TreeSpecies.values()[dataByte]); |                     boat.setWoodType(TreeSpecies.values()[dataByte]); | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -12,8 +12,6 @@ import com.intellectualcrafters.plot.util.TaskManager; | |||||||
| import com.intellectualcrafters.plot.util.block.GlobalBlockQueue; | import com.intellectualcrafters.plot.util.block.GlobalBlockQueue; | ||||||
| import com.intellectualcrafters.plot.util.block.LocalBlockQueue; | import com.intellectualcrafters.plot.util.block.LocalBlockQueue; | ||||||
| import com.intellectualcrafters.plot.util.expiry.PlotAnalysis; | import com.intellectualcrafters.plot.util.expiry.PlotAnalysis; | ||||||
| import java.util.HashSet; |  | ||||||
| import java.util.Random; |  | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| import org.bukkit.Material; | import org.bukkit.Material; | ||||||
| import org.bukkit.World; | import org.bukkit.World; | ||||||
| @@ -23,6 +21,9 @@ import org.bukkit.generator.ChunkGenerator.BiomeGrid; | |||||||
| import org.bukkit.material.Directional; | import org.bukkit.material.Directional; | ||||||
| import org.bukkit.material.MaterialData; | import org.bukkit.material.MaterialData; | ||||||
|  |  | ||||||
|  | import java.util.HashSet; | ||||||
|  | import java.util.Random; | ||||||
|  |  | ||||||
| public class BukkitHybridUtils extends HybridUtils { | public class BukkitHybridUtils extends HybridUtils { | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -50,7 +51,8 @@ public class BukkitHybridUtils extends HybridUtils { | |||||||
|                 } |                 } | ||||||
|                 final BiomeGrid nullBiomeGrid = new BiomeGrid() { |                 final BiomeGrid nullBiomeGrid = new BiomeGrid() { | ||||||
|                     @Override |                     @Override | ||||||
|                     public void setBiome(int a, int b, Biome c) {} |                     public void setBiome(int a, int b, Biome c) { | ||||||
|  |                     } | ||||||
|  |  | ||||||
|                     @Override |                     @Override | ||||||
|                     public Biome getBiome(int a, int b) { |                     public Biome getBiome(int a, int b) { | ||||||
|   | |||||||
| @@ -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}; | ||||||
|  | } | ||||||
| @@ -8,7 +8,6 @@ import com.google.common.collect.MapMaker; | |||||||
| import com.google.common.io.ByteSink; | import com.google.common.io.ByteSink; | ||||||
| import com.google.common.io.ByteSource; | import com.google.common.io.ByteSource; | ||||||
| import com.google.common.io.Closeables; | import com.google.common.io.Closeables; | ||||||
| import com.google.common.io.Files; |  | ||||||
| import com.google.common.primitives.Primitives; | import com.google.common.primitives.Primitives; | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| import org.bukkit.Material; | import org.bukkit.Material; | ||||||
| @@ -20,7 +19,6 @@ import java.io.DataInput; | |||||||
| import java.io.DataInputStream; | import java.io.DataInputStream; | ||||||
| import java.io.DataOutput; | import java.io.DataOutput; | ||||||
| import java.io.DataOutputStream; | import java.io.DataOutputStream; | ||||||
| import java.io.File; |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.InputStream; | import java.io.InputStream; | ||||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||||
| @@ -161,7 +159,6 @@ public class NbtFactory { | |||||||
|     /** |     /** | ||||||
|      * Load the content of a file from a stream. |      * 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 stream - the stream supplier. | ||||||
|      * @param option - whether or not to decompress the input stream. |      * @param option - whether or not to decompress the input stream. | ||||||
|      * @return The decoded NBT compound. |      * @return The decoded NBT compound. | ||||||
| @@ -196,7 +193,6 @@ public class NbtFactory { | |||||||
|     /** |     /** | ||||||
|      * Save the content of a NBT compound to a stream. |      * 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 source - the NBT compound to save. | ||||||
|      * @param stream - the stream. |      * @param stream - the stream. | ||||||
|      * @param option - whether or not to compress the output. |      * @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. |      * Convert a given NBT element to a primitive wrapper or List/Map equivalent. | ||||||
|      * <p> |      * <p> All changes to any mutable objects will be reflected in the underlying NBT element(s). | ||||||
|      * All changes to any mutable objects will be reflected in the underlying NBT element(s). |  | ||||||
|      * @param nms - the NBT element. |      * @param nms - the NBT element. | ||||||
|      * @return The wrapper equivalent. |      * @return The wrapper equivalent. | ||||||
|      */ |      */ | ||||||
| @@ -605,7 +600,7 @@ public class NbtFactory { | |||||||
|      */ |      */ | ||||||
|     private static class LoadMethodWorldUpdate extends LoadCompoundMethod { |     private static class LoadMethodWorldUpdate extends LoadCompoundMethod { | ||||||
|  |  | ||||||
|         public LoadMethodWorldUpdate(Class<?> streamClass) { |         LoadMethodWorldUpdate(Class<?> streamClass) { | ||||||
|             setMethod(getMethod(Modifier.STATIC, 0, streamClass, null, DataInput.class)); |             setMethod(getMethod(Modifier.STATIC, 0, streamClass, null, DataInput.class)); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -622,7 +617,7 @@ public class NbtFactory { | |||||||
|  |  | ||||||
|         private Object readLimiter; |         private Object readLimiter; | ||||||
|  |  | ||||||
|         public LoadMethodSkinUpdate(Class<?> streamClass, Class<?> readLimiterClass) { |         LoadMethodSkinUpdate(Class<?> streamClass, Class<?> readLimiterClass) { | ||||||
|             setMethod(getMethod(Modifier.STATIC, 0, streamClass, null, DataInput.class, readLimiterClass)); |             setMethod(getMethod(Modifier.STATIC, 0, streamClass, null, DataInput.class, readLimiterClass)); | ||||||
|  |  | ||||||
|             // Find the unlimited read limiter |             // Find the unlimited read limiter | ||||||
| @@ -645,8 +640,7 @@ public class NbtFactory { | |||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Represents a root NBT compound. |      * Represents a root NBT compound. | ||||||
|      * <p> |      * <p> All changes to this map will be reflected in the underlying NBT compound. Values may only be one of the following: | ||||||
|      * All changes to this map will be reflected in the underlying NBT compound. Values may only be one of the following: |  | ||||||
|      * <ul> |      * <ul> | ||||||
|      *   <li>Primitive types</li> |      *   <li>Primitive types</li> | ||||||
|      *   <li>{@link String String}</li> |      *   <li>{@link String String}</li> | ||||||
| @@ -769,8 +763,6 @@ public class NbtFactory { | |||||||
|  |  | ||||||
|         /** |         /** | ||||||
|          * Save the content of a NBT compound to a stream. |          * 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 stream - the output stream. | ||||||
|          * @param option - whether or not to compress the output. |          * @param option - whether or not to compress the output. | ||||||
|          * @throws IOException If anything went wrong. |          * @throws IOException If anything went wrong. | ||||||
|   | |||||||
| @@ -50,7 +50,7 @@ public class SendChunk { | |||||||
|         RefClass classChunk = getRefClass("{nms}.Chunk"); |         RefClass classChunk = getRefClass("{nms}.Chunk"); | ||||||
|         this.methodInitLighting = classChunk.getMethod("initLighting"); |         this.methodInitLighting = classChunk.getMethod("initLighting"); | ||||||
|         RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk"); |         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 |             //this works for 1.9.4 and 1.10 | ||||||
|             tempMapChunk = classMapChunk.getConstructor(classChunk.getRealClass(),int.class); |             tempMapChunk = classMapChunk.getConstructor(classChunk.getRealClass(),int.class); | ||||||
|         } else { |         } else { | ||||||
| @@ -116,7 +116,7 @@ public class SendChunk { | |||||||
|                 chunks.remove(chunk); |                 chunks.remove(chunk); | ||||||
|                 Object con = this.connection.of(entity).get(); |                 Object con = this.connection.of(entity).get(); | ||||||
|                 Object packet = null; |                 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 { |                     try { | ||||||
|                         packet = this.mapChunk.create(c,65535); |                         packet = this.mapChunk.create(c,65535); | ||||||
|                     } catch (Exception ignored) {} |                     } catch (Exception ignored) {} | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| package com.plotsquared.bukkit.util.block; | 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.ChunkLoc; | ||||||
| import com.intellectualcrafters.plot.object.ChunkWrapper; | import com.intellectualcrafters.plot.object.ChunkWrapper; | ||||||
| import com.intellectualcrafters.plot.object.PseudoRandom; | 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.TaskManager; | ||||||
| import com.intellectualcrafters.plot.util.block.BasicLocalBlockQueue; | import com.intellectualcrafters.plot.util.block.BasicLocalBlockQueue; | ||||||
| import com.plotsquared.bukkit.util.SendChunk; | 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.Field; | ||||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| @@ -18,13 +25,6 @@ import java.util.HashMap; | |||||||
| import java.util.Iterator; | import java.util.Iterator; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| import java.util.Set; | 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[]> { | public class BukkitLocalQueue_1_8_3 extends BukkitLocalQueue<char[]> { | ||||||
|  |  | ||||||
| @@ -403,11 +403,11 @@ public class BukkitLocalQueue_1_8_3 extends BukkitLocalQueue<char[]> { | |||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
| /* |             /* | ||||||
|                 if (!(boolean) methodAreNeighborsLoaded.of(c).call(1)) { |                 if (!(boolean) methodAreNeighborsLoaded.of(c).call(1)) { | ||||||
|                     return false; |                     return false; | ||||||
|                 } |                 } | ||||||
| */ |             */ | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             this.methodInitLighting.of(c).call(); |             this.methodInitLighting.of(c).call(); | ||||||
|   | |||||||
| @@ -29,9 +29,6 @@ public class MemoryConfiguration extends MemorySection implements Configuration | |||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     public void addDefault(String path, Object value) { |     public void addDefault(String path, Object value) { | ||||||
|         if (path == null) { |  | ||||||
|             throw new NullPointerException("Path may not be null"); |  | ||||||
|         } |  | ||||||
|         if (this.defaults == null) { |         if (this.defaults == null) { | ||||||
|             this.defaults = new MemoryConfiguration(); |             this.defaults = new MemoryConfiguration(); | ||||||
|         } |         } | ||||||
| @@ -41,10 +38,6 @@ public class MemoryConfiguration extends MemorySection implements Configuration | |||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     public void addDefaults(Map<String, Object> defaults) { |     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()) { |         for (Map.Entry<String, Object> entry : defaults.entrySet()) { | ||||||
|             addDefault(entry.getKey(), entry.getValue()); |             addDefault(entry.getKey(), entry.getValue()); | ||||||
|         } |         } | ||||||
| @@ -52,10 +45,6 @@ public class MemoryConfiguration extends MemorySection implements Configuration | |||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     public void addDefaults(Configuration defaults) { |     public void addDefaults(Configuration defaults) { | ||||||
|         if (defaults == null) { |  | ||||||
|             throw new NullPointerException("Defaults may not be null"); |  | ||||||
|         } |  | ||||||
|          |  | ||||||
|         addDefaults(defaults.getValues(true)); |         addDefaults(defaults.getValues(true)); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|   | |||||||
| @@ -49,13 +49,6 @@ public class MemorySection implements ConfigurationSection { | |||||||
|      *     if parent contains no root Configuration. |      *     if parent contains no root Configuration. | ||||||
|      */ |      */ | ||||||
|     protected MemorySection(ConfigurationSection parent, String path) { |     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.path = path; | ||||||
|         this.parent = parent; |         this.parent = parent; | ||||||
|         this.root = parent.getRoot(); |         this.root = parent.getRoot(); | ||||||
| @@ -133,7 +126,7 @@ public class MemorySection implements ConfigurationSection { | |||||||
|      * @return Full path of the section from its root. |      * @return Full path of the section from its root. | ||||||
|      */ |      */ | ||||||
|     public static String createPath(ConfigurationSection section, String key) { |     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. |      * @return Full path of the section from its root. | ||||||
|      */ |      */ | ||||||
|     public static String createPath(ConfigurationSection section, String key, ConfigurationSection relativeTo) { |     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(); |         Configuration root = section.getRoot(); | ||||||
|         if (root == null) { |         if (root == null) { | ||||||
|             throw new IllegalStateException("Cannot create path without a root"); |             throw new IllegalStateException("Cannot create path without a root"); | ||||||
| @@ -253,10 +243,6 @@ public class MemorySection implements ConfigurationSection { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void addDefault(String path, Object value) { |     public void addDefault(String path, Object value) { | ||||||
|         if (path == null) { |  | ||||||
|             throw new NullPointerException("Path cannot be null"); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         Configuration root = getRoot(); |         Configuration root = getRoot(); | ||||||
|         if (root == null) { |         if (root == null) { | ||||||
|             throw new IllegalStateException("Cannot add default without root"); |             throw new IllegalStateException("Cannot add default without root"); | ||||||
| @@ -283,10 +269,6 @@ public class MemorySection implements ConfigurationSection { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void set(String path, Object value) { |     public void set(String path, Object value) { | ||||||
|         if (path == null) { |  | ||||||
|             throw new NullPointerException("Cannot set to an empty path"); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         Configuration root = getRoot(); |         Configuration root = getRoot(); | ||||||
|         if (root == null) { |         if (root == null) { | ||||||
|             throw new IllegalStateException("Cannot use section without a root"); |             throw new IllegalStateException("Cannot use section without a root"); | ||||||
| @@ -367,9 +349,6 @@ public class MemorySection implements ConfigurationSection { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public ConfigurationSection createSection(String path) { |     public ConfigurationSection createSection(String path) { | ||||||
|         if (path == null) { |  | ||||||
|             throw new NullPointerException("Cannot create section at empty path"); |  | ||||||
|         } |  | ||||||
|         Configuration root = getRoot(); |         Configuration root = getRoot(); | ||||||
|         if (root == null) { |         if (root == null) { | ||||||
|             throw new IllegalStateException("Cannot create section without a root"); |             throw new IllegalStateException("Cannot create section without a root"); | ||||||
| @@ -787,10 +766,6 @@ public class MemorySection implements ConfigurationSection { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected Object getDefault(String path) { |     protected Object getDefault(String path) { | ||||||
|         if (path == null) { |  | ||||||
|             throw new NullPointerException("Path may not be null"); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         Configuration root = getRoot(); |         Configuration root = getRoot(); | ||||||
|         Configuration defaults = root == null ? null : root.getDefaults(); |         Configuration defaults = root == null ? null : root.getDefaults(); | ||||||
|         return (defaults == null) ? null : defaults.get(createPath(this, path)); |         return (defaults == null) ? null : defaults.get(createPath(this, path)); | ||||||
|   | |||||||
| @@ -87,9 +87,6 @@ public abstract class FileConfiguration extends MemoryConfiguration { | |||||||
|      * @throws IllegalArgumentException Thrown when file is null. |      * @throws IllegalArgumentException Thrown when file is null. | ||||||
|      */ |      */ | ||||||
|     public void load(File file) throws IOException, InvalidConfigurationException { |     public void load(File file) throws IOException, InvalidConfigurationException { | ||||||
|         if (file == null) { |  | ||||||
|             throw new NullPointerException("File cannot be null"); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         FileInputStream stream = new FileInputStream(file); |         FileInputStream stream = new FileInputStream(file); | ||||||
|          |          | ||||||
| @@ -124,32 +121,6 @@ public abstract class FileConfiguration extends MemoryConfiguration { | |||||||
|         loadFromString(builder.toString()); |         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 |      * Loads this {@link FileConfiguration} from the specified string, as | ||||||
|      * opposed to from file. |      * opposed to from file. | ||||||
|   | |||||||
| @@ -11,7 +11,6 @@ import org.yaml.snakeyaml.representer.Representer; | |||||||
|  |  | ||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.Reader; |  | ||||||
| import java.nio.file.Files; | import java.nio.file.Files; | ||||||
| import java.nio.file.StandardCopyOption; | import java.nio.file.StandardCopyOption; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| @@ -38,13 +37,8 @@ public class YamlConfiguration extends FileConfiguration { | |||||||
|      * |      * | ||||||
|      * @param file Input file |      * @param file Input file | ||||||
|      * @return Resulting configuration |      * @return Resulting configuration | ||||||
|      * @throws IllegalArgumentException Thrown if file is null |  | ||||||
|      */ |      */ | ||||||
|     public static YamlConfiguration loadConfiguration(File file) { |     public static YamlConfiguration loadConfiguration(File file) { | ||||||
|         if (file == null) { |  | ||||||
|             throw new NullPointerException("File cannot be null"); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         YamlConfiguration config = new YamlConfiguration(); |         YamlConfiguration config = new YamlConfiguration(); | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
| @@ -70,34 +64,6 @@ public class YamlConfiguration extends FileConfiguration { | |||||||
|         return config; |         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 |     @Override | ||||||
|     public String saveToString() { |     public String saveToString() { | ||||||
|         yamlOptions.setIndent(options().indent()); |         yamlOptions.setIndent(options().indent()); | ||||||
| @@ -116,9 +82,6 @@ public class YamlConfiguration extends FileConfiguration { | |||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     public void loadFromString(String contents) throws InvalidConfigurationException { |     public void loadFromString(String contents) throws InvalidConfigurationException { | ||||||
|         if (contents == null) { |  | ||||||
|             throw new NullPointerException("Contents cannot be null"); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         Map<?, ?> input; |         Map<?, ?> input; | ||||||
|         try { |         try { | ||||||
|   | |||||||
| @@ -19,16 +19,16 @@ public class TeleportDenyFlag extends EnumFlag { | |||||||
|                 result = !plot.getTrusted().contains(player.getUUID()); |                 result = !plot.getTrusted().contains(player.getUUID()); | ||||||
|                 break; |                 break; | ||||||
|             case "members": |             case "members": | ||||||
|                 result =!plot.getMembers().contains(player.getUUID()); |                 result = !plot.getMembers().contains(player.getUUID()); | ||||||
|                 break; |                 break; | ||||||
|             case "nonmembers": |             case "nonmembers": | ||||||
|                 result =!plot.isAdded(player.getUUID()); |                 result = !plot.isAdded(player.getUUID()); | ||||||
|                 break; |                 break; | ||||||
|             case "nontrusted": |             case "nontrusted": | ||||||
|                 result =!plot.getTrusted().contains(player.getUUID()) && !plot.isOwner(player.getUUID()); |                 result = !plot.getTrusted().contains(player.getUUID()) && !plot.isOwner(player.getUUID()); | ||||||
|                 break; |                 break; | ||||||
|             case "nonowners": |             case "nonowners": | ||||||
|                 result =!plot.isOwner(player.getUUID()); |                 result = !plot.isOwner(player.getUUID()); | ||||||
|                 break; |                 break; | ||||||
|             default: |             default: | ||||||
|                 return true; |                 return true; | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.database.DBFunc; | |||||||
| import com.intellectualcrafters.plot.object.Plot; | import com.intellectualcrafters.plot.object.Plot; | ||||||
| import com.intellectualcrafters.plot.object.PlotPlayer; | import com.intellectualcrafters.plot.object.PlotPlayer; | ||||||
| import com.intellectualcrafters.plot.object.RunnableVal; | import com.intellectualcrafters.plot.object.RunnableVal; | ||||||
|  | import com.intellectualcrafters.plot.util.Permissions; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| @@ -12,11 +13,31 @@ public abstract class CommentInbox { | |||||||
|     @Override |     @Override | ||||||
|     public abstract String toString(); |     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; | ||||||
|  |     } | ||||||
|      |      | ||||||
|     /** |     /** | ||||||
|      * |      * | ||||||
|   | |||||||
| @@ -3,9 +3,7 @@ package com.intellectualcrafters.plot.object.comment; | |||||||
| import com.google.common.base.Optional; | import com.google.common.base.Optional; | ||||||
| import com.intellectualcrafters.plot.database.DBFunc; | import com.intellectualcrafters.plot.database.DBFunc; | ||||||
| import com.intellectualcrafters.plot.object.Plot; | import com.intellectualcrafters.plot.object.Plot; | ||||||
| import com.intellectualcrafters.plot.object.PlotPlayer; |  | ||||||
| import com.intellectualcrafters.plot.object.RunnableVal; | import com.intellectualcrafters.plot.object.RunnableVal; | ||||||
| import com.intellectualcrafters.plot.util.Permissions; |  | ||||||
| import com.intellectualcrafters.plot.util.TaskManager; | import com.intellectualcrafters.plot.util.TaskManager; | ||||||
|  |  | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| @@ -13,35 +11,6 @@ import java.util.List; | |||||||
|  |  | ||||||
| public class InboxOwner extends CommentInbox { | 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 |     @Override | ||||||
|     public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) { |     public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) { | ||||||
|         Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString()); |         Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString()); | ||||||
|   | |||||||
| @@ -3,9 +3,7 @@ package com.intellectualcrafters.plot.object.comment; | |||||||
| import com.google.common.base.Optional; | import com.google.common.base.Optional; | ||||||
| import com.intellectualcrafters.plot.database.DBFunc; | import com.intellectualcrafters.plot.database.DBFunc; | ||||||
| import com.intellectualcrafters.plot.object.Plot; | import com.intellectualcrafters.plot.object.Plot; | ||||||
| import com.intellectualcrafters.plot.object.PlotPlayer; |  | ||||||
| import com.intellectualcrafters.plot.object.RunnableVal; | import com.intellectualcrafters.plot.object.RunnableVal; | ||||||
| import com.intellectualcrafters.plot.util.Permissions; |  | ||||||
| import com.intellectualcrafters.plot.util.TaskManager; | import com.intellectualcrafters.plot.util.TaskManager; | ||||||
|  |  | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| @@ -13,35 +11,6 @@ import java.util.List; | |||||||
|  |  | ||||||
| public class InboxPublic extends CommentInbox { | 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 |     @Override | ||||||
|     public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) { |     public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) { | ||||||
|         Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString()); |         Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString()); | ||||||
|   | |||||||
| @@ -2,45 +2,13 @@ package com.intellectualcrafters.plot.object.comment; | |||||||
|  |  | ||||||
| import com.intellectualcrafters.plot.database.DBFunc; | import com.intellectualcrafters.plot.database.DBFunc; | ||||||
| import com.intellectualcrafters.plot.object.Plot; | import com.intellectualcrafters.plot.object.Plot; | ||||||
| import com.intellectualcrafters.plot.object.PlotPlayer; |  | ||||||
| import com.intellectualcrafters.plot.object.RunnableVal; | import com.intellectualcrafters.plot.object.RunnableVal; | ||||||
| import com.intellectualcrafters.plot.util.Permissions; |  | ||||||
| import com.intellectualcrafters.plot.util.TaskManager; | import com.intellectualcrafters.plot.util.TaskManager; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class InboxReport extends CommentInbox { | 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 |     @Override | ||||||
|     public boolean getComments(Plot plot, final RunnableVal<List<PlotComment>> whenDone) { |     public boolean getComments(Plot plot, final RunnableVal<List<PlotComment>> whenDone) { | ||||||
|         DBFunc.getComments(null, toString(), new RunnableVal<List<PlotComment>>() { |         DBFunc.getComments(null, toString(), new RunnableVal<List<PlotComment>>() { | ||||||
|   | |||||||
| @@ -376,7 +376,7 @@ public class MainListener { | |||||||
|             } |             } | ||||||
|             Optional<Explosive> source = event.getExplosion().getSourceExplosive(); |             Optional<Explosive> source = event.getExplosion().getSourceExplosive(); | ||||||
|             if (!source.isPresent()) { |             if (!source.isPresent()) { | ||||||
|                 event.filterAll(); |                 event.setCancelled(true); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|             Explosive tnt = source.get(); |             Explosive tnt = source.get(); | ||||||
| @@ -385,21 +385,22 @@ public class MainListener { | |||||||
|             Plot currentPlot = current.getPlot(); |             Plot currentPlot = current.getPlot(); | ||||||
|             if (currentPlot == null) { |             if (currentPlot == null) { | ||||||
|                 if (current.isPlotArea()) { |                 if (current.isPlotArea()) { | ||||||
|                     event.filterAll(); |                     event.setCancelled(true); | ||||||
|                 } |                 } | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|             if (creator != null) { |             if (creator != null) { | ||||||
|                 if (!currentPlot.isAdded(creator)) { |                 if (!currentPlot.isAdded(creator)) { | ||||||
|                     event.filterAll(); |                     event.setCancelled(true); | ||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             if (!currentPlot.getFlag(Flags.EXPLOSION).or(false)) { |             if (!currentPlot.getFlag(Flags.EXPLOSION).or(false)) { | ||||||
|                 event.filterAll(); |                 event.setCancelled(true); | ||||||
|                 return; |                 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())); |             event.filterEntities(entity -> currentPlot.equals(SpongeUtil.getLocation(entity).getPlot())); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jesse Boyd
					Jesse Boyd