From b54027de6d6cb510ef43b8f64f1fc2af5694cff6 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Tue, 27 Nov 2018 08:49:46 +0100 Subject: [PATCH] New flag system, bump version --- api/pom.xml | 2 +- .../flag/AbstractWrappedFlag.java | 17 - .../worldguardwrapper/flag/IWrappedFlag.java | 11 + .../flag/WrappedBooleanFlag.java | 11 - .../flag/WrappedDoubleFlag.java | 11 - .../flag/WrappedEnumFlag.java | 15 - .../flag/WrappedIntegerFlag.java | 15 - .../flag/WrappedLocationFlag.java | 17 - .../flag/WrappedSetFlag.java | 31 -- .../worldguardwrapper/flag/WrappedState.java | 9 + .../flag/WrappedStringFlag.java | 15 - .../IWorldGuardImplementation.java | 62 ++-- ...WrappedDomain.java => IWrappedDomain.java} | 2 +- .../region/IWrappedRegion.java | 30 ++ .../region/WrappedRegion.java | 30 -- ...idSelection.java => ICuboidSelection.java} | 2 +- ...election.java => IPolygonalSelection.java} | 2 +- .../{Selection.java => ISelection.java} | 2 +- implementation/interface/pom.xml | 24 -- .../wrapper/WrapperAdapter.java | 25 -- .../wrapper/WrapperAdapterRegister.java | 34 -- implementation/pom.xml | 3 +- implementation/v6/pom.xml | 7 +- .../v6/WorldGuardImplementation.java | 290 ++++-------------- .../v6/{ => event}/EventListener.java | 2 +- .../implementation/v6/flag/WrappedFlag.java | 27 ++ .../v6/region/WrappedRegion.java | 175 +++++++++++ .../v6/utility/WorldGuardVectorUtilities.java | 26 ++ implementation/v7/pom.xml | 125 +------- .../v7/WorldGuardImplementation.java | 282 ++++------------- .../v7/{ => event}/EventListener.java | 2 +- .../implementation/v7/flag/WrappedFlag.java | 26 ++ .../v7/region/WrappedRegion.java | 174 +++++++++++ library/pom.xml | 15 +- .../worldguardwrapper/WorldGuardWrapper.java | 15 +- pom.xml | 2 +- 36 files changed, 677 insertions(+), 861 deletions(-) delete mode 100644 api/src/main/java/org/codemc/worldguardwrapper/flag/AbstractWrappedFlag.java create mode 100644 api/src/main/java/org/codemc/worldguardwrapper/flag/IWrappedFlag.java delete mode 100644 api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedBooleanFlag.java delete mode 100644 api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedDoubleFlag.java delete mode 100644 api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedEnumFlag.java delete mode 100644 api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedIntegerFlag.java delete mode 100644 api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedLocationFlag.java delete mode 100644 api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedSetFlag.java create mode 100644 api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedState.java delete mode 100644 api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedStringFlag.java rename {implementation/interface => api}/src/main/java/org/codemc/worldguardwrapper/implementation/IWorldGuardImplementation.java (60%) rename api/src/main/java/org/codemc/worldguardwrapper/region/{WrappedDomain.java => IWrappedDomain.java} (89%) create mode 100644 api/src/main/java/org/codemc/worldguardwrapper/region/IWrappedRegion.java delete mode 100644 api/src/main/java/org/codemc/worldguardwrapper/region/WrappedRegion.java rename api/src/main/java/org/codemc/worldguardwrapper/selection/{CuboidSelection.java => ICuboidSelection.java} (72%) rename api/src/main/java/org/codemc/worldguardwrapper/selection/{PolygonalSelection.java => IPolygonalSelection.java} (76%) rename api/src/main/java/org/codemc/worldguardwrapper/selection/{Selection.java => ISelection.java} (62%) delete mode 100644 implementation/interface/pom.xml delete mode 100644 implementation/interface/src/main/java/org/codemc/worldguardwrapper/implementation/wrapper/WrapperAdapter.java delete mode 100644 implementation/interface/src/main/java/org/codemc/worldguardwrapper/implementation/wrapper/WrapperAdapterRegister.java rename implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/{ => event}/EventListener.java (98%) create mode 100644 implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/flag/WrappedFlag.java create mode 100644 implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/region/WrappedRegion.java create mode 100644 implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/utility/WorldGuardVectorUtilities.java rename implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/{ => event}/EventListener.java (98%) create mode 100644 implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/flag/WrappedFlag.java create mode 100644 implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/region/WrappedRegion.java diff --git a/api/pom.xml b/api/pom.xml index 629598e..e16bd4b 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -7,7 +7,7 @@ org.codemc.worldguardwrapper worldguardwrapper-parent - 1.0.4-SNAPSHOT + 1.1.0-SNAPSHOT worldguardwrapper-api diff --git a/api/src/main/java/org/codemc/worldguardwrapper/flag/AbstractWrappedFlag.java b/api/src/main/java/org/codemc/worldguardwrapper/flag/AbstractWrappedFlag.java deleted file mode 100644 index eb2b910..0000000 --- a/api/src/main/java/org/codemc/worldguardwrapper/flag/AbstractWrappedFlag.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.codemc.worldguardwrapper.flag; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - -@AllArgsConstructor -@RequiredArgsConstructor -@Getter -public abstract class AbstractWrappedFlag { - @NonNull - private String name; - @NonNull - private Class type; - private T defaultValue; -} diff --git a/api/src/main/java/org/codemc/worldguardwrapper/flag/IWrappedFlag.java b/api/src/main/java/org/codemc/worldguardwrapper/flag/IWrappedFlag.java new file mode 100644 index 0000000..f2f45f2 --- /dev/null +++ b/api/src/main/java/org/codemc/worldguardwrapper/flag/IWrappedFlag.java @@ -0,0 +1,11 @@ +package org.codemc.worldguardwrapper.flag; + +import java.util.Optional; + +public interface IWrappedFlag { + + String getName(); + + Optional getDefaultValue(); + +} diff --git a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedBooleanFlag.java b/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedBooleanFlag.java deleted file mode 100644 index f4bc53f..0000000 --- a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedBooleanFlag.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.codemc.worldguardwrapper.flag; - -/** - * A flag that stores a boolean. - */ -public class WrappedBooleanFlag extends AbstractWrappedFlag { - - public WrappedBooleanFlag(String name) { - super(name, boolean.class, null); - } -} diff --git a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedDoubleFlag.java b/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedDoubleFlag.java deleted file mode 100644 index a307477..0000000 --- a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedDoubleFlag.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.codemc.worldguardwrapper.flag; - -/** - * A flag that stores a double. - */ -public class WrappedDoubleFlag extends AbstractWrappedFlag { - - public WrappedDoubleFlag(String name) { - super(name, double.class, null); - } -} diff --git a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedEnumFlag.java b/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedEnumFlag.java deleted file mode 100644 index 2c8d99a..0000000 --- a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedEnumFlag.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.codemc.worldguardwrapper.flag; - -/** - * A flag that stores an enum value. - */ -public class WrappedEnumFlag> extends AbstractWrappedFlag { - - public WrappedEnumFlag(String name, Class enumClass) { - this(name, enumClass, null); - } - - public WrappedEnumFlag(String name, Class enumClass, T defaultValue) { - super(name, enumClass, defaultValue); - } -} diff --git a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedIntegerFlag.java b/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedIntegerFlag.java deleted file mode 100644 index 4851e4c..0000000 --- a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedIntegerFlag.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.codemc.worldguardwrapper.flag; - -/** - * A flag that stores an integer. - */ -public class WrappedIntegerFlag extends AbstractWrappedFlag { - - public WrappedIntegerFlag(String name) { - this(name, 0); - } - - public WrappedIntegerFlag(String name, int defaultValue) { - super(name, int.class, defaultValue); - } -} diff --git a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedLocationFlag.java b/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedLocationFlag.java deleted file mode 100644 index 0068503..0000000 --- a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedLocationFlag.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.codemc.worldguardwrapper.flag; - -import org.bukkit.Location; - -/** - * A flag that stores a bukkit location. - */ -public class WrappedLocationFlag extends AbstractWrappedFlag { - - public WrappedLocationFlag(String name) { - this(name, null); - } - - public WrappedLocationFlag(String name, Location defaultValue) { - super(name, Location.class, defaultValue); - } -} diff --git a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedSetFlag.java b/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedSetFlag.java deleted file mode 100644 index da6fd99..0000000 --- a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedSetFlag.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.codemc.worldguardwrapper.flag; - -import java.util.HashSet; -import java.util.Set; - -/** - * A flag that stores a set of values of the sub flag's type. - */ -public class WrappedSetFlag extends AbstractWrappedFlag> { - - private AbstractWrappedFlag subFlag; - - public WrappedSetFlag(String name, AbstractWrappedFlag subFlag) { - this(name, new HashSet<>(), subFlag); - } - - @SuppressWarnings("unchecked") - public WrappedSetFlag(String name, Set defaultValue, AbstractWrappedFlag subFlag) { - super(name, (Class>) defaultValue.getClass(), defaultValue); - this.subFlag = subFlag; - } - - /** - * Get the type of values stored in this flag. - * - * @return The stored flag type. - */ - public AbstractWrappedFlag getSubFlag() { - return subFlag; - } -} diff --git a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedState.java b/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedState.java new file mode 100644 index 0000000..0901810 --- /dev/null +++ b/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedState.java @@ -0,0 +1,9 @@ +package org.codemc.worldguardwrapper.flag; + +public enum WrappedState { + ALLOW, + DENY; + + WrappedState() { + } +} diff --git a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedStringFlag.java b/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedStringFlag.java deleted file mode 100644 index a9b296f..0000000 --- a/api/src/main/java/org/codemc/worldguardwrapper/flag/WrappedStringFlag.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.codemc.worldguardwrapper.flag; - -/** - * A flag that stores a string. - */ -public class WrappedStringFlag extends AbstractWrappedFlag { - - public WrappedStringFlag(String name) { - this(name, ""); - } - - public WrappedStringFlag(String name, String defaultValue) { - super(name, String.class, defaultValue); - } -} diff --git a/implementation/interface/src/main/java/org/codemc/worldguardwrapper/implementation/IWorldGuardImplementation.java b/api/src/main/java/org/codemc/worldguardwrapper/implementation/IWorldGuardImplementation.java similarity index 60% rename from implementation/interface/src/main/java/org/codemc/worldguardwrapper/implementation/IWorldGuardImplementation.java rename to api/src/main/java/org/codemc/worldguardwrapper/implementation/IWorldGuardImplementation.java index 8939f4f..631cd86 100644 --- a/implementation/interface/src/main/java/org/codemc/worldguardwrapper/implementation/IWorldGuardImplementation.java +++ b/api/src/main/java/org/codemc/worldguardwrapper/implementation/IWorldGuardImplementation.java @@ -5,8 +5,8 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; -import org.codemc.worldguardwrapper.flag.AbstractWrappedFlag; -import org.codemc.worldguardwrapper.region.WrappedRegion; +import org.codemc.worldguardwrapper.flag.IWrappedFlag; +import org.codemc.worldguardwrapper.region.IWrappedRegion; import java.util.*; @@ -26,17 +26,6 @@ public interface IWorldGuardImplementation { */ int getApiVersion(); - /** - * Query a flag's value for a given player at a given location. - * - * @param player The player - * @param location The location - * @param flagName The name of the flag - * @param type The type of the flag's value - * @return The flag's value - */ - Optional queryFlag(Player player, @NonNull Location location, @NonNull String flagName, Class type); - /** * Query a flag's value for a given player at a given location. * @@ -45,17 +34,36 @@ public interface IWorldGuardImplementation { * @param flag The flag * @return The flag's value */ - default Optional queryFlag(Player player, @NonNull Location location, @NonNull AbstractWrappedFlag flag) { - return queryFlag(player, location, flag.getName(), flag.getType()); - } + Optional queryFlag(Player player, @NonNull Location location, @NonNull IWrappedFlag flag); /** - * Register a flag to WorldGuard's flag registry. + * Returns the flag with the given name. * - * @param flag The flag to register - * @return Whether the flag has been registered + * @param name The flag name + * @return The flag, empty if it doesn't exists */ - boolean registerFlag(@NonNull AbstractWrappedFlag flag); + Optional> getFlag(@NonNull String name); + + /** + * Registers a flag to WorldGuard's flag registry. + * + * @param name The flag name + * @param type The flag type + * @param defaultValue the flag default value (if supported by the type), can be null + * @return The created flag, empty if a name conflict occurred + */ + Optional> registerFlag(@NonNull String name, @NonNull Class type, T defaultValue); + + /** + * Registers a flag to WorldGuard's flag registry. + * + * @param name The flag name + * @param type The flag type + * @return The created flag, empty if a name conflict occurred + */ + default Optional> registerFlag(@NonNull String name, @NonNull Class type) { + return registerFlag(name, type, null); + } /** * Get a region by its ID. @@ -64,7 +72,7 @@ public interface IWorldGuardImplementation { * @param id ID of the region * @return The region */ - Optional getRegion(@NonNull World world, @NonNull String id); + Optional getRegion(@NonNull World world, @NonNull String id); /** * Get an unmodifiable map of regions containing the state of the @@ -76,7 +84,7 @@ public interface IWorldGuardImplementation { * @param world The world * @return A map of regions */ - Map getRegions(@NonNull World world); + Map getRegions(@NonNull World world); /** * Get a set of regions at the given location. @@ -84,7 +92,7 @@ public interface IWorldGuardImplementation { * @param location The location * @return A set of regions */ - Set getRegions(@NonNull Location location); + Set getRegions(@NonNull Location location); /** @@ -94,7 +102,7 @@ public interface IWorldGuardImplementation { * @param maximum The maximum location of the area * @return A set of regions */ - Set getRegions(@NonNull Location minimum, @NonNull Location maximum); + Set getRegions(@NonNull Location minimum, @NonNull Location maximum); /** * Add a region. If only two points are given, a cuboid region will be created. @@ -105,7 +113,7 @@ public interface IWorldGuardImplementation { * @param maxY The maximum y coordinate * @return The added region */ - Optional addRegion(@NonNull String id, @NonNull List points, int minY, int maxY); + Optional addRegion(@NonNull String id, @NonNull List points, int minY, int maxY); /** * Add a cuboid region. @@ -115,7 +123,7 @@ public interface IWorldGuardImplementation { * @param point2 The second point of the region * @return The added region */ - default Optional addCuboidRegion(@NonNull String id, @NonNull Location point1, @NonNull Location point2) { + default Optional addCuboidRegion(@NonNull String id, @NonNull Location point1, @NonNull Location point2) { return addRegion(id, Arrays.asList(point1, point2), 0, 0); } @@ -126,6 +134,6 @@ public interface IWorldGuardImplementation { * @param id The region ID * @return A list of removed regions where the first entry is the region specified by {@code id} */ - Optional> removeRegion(@NonNull World world, @NonNull String id); + Optional> removeRegion(@NonNull World world, @NonNull String id); } diff --git a/api/src/main/java/org/codemc/worldguardwrapper/region/WrappedDomain.java b/api/src/main/java/org/codemc/worldguardwrapper/region/IWrappedDomain.java similarity index 89% rename from api/src/main/java/org/codemc/worldguardwrapper/region/WrappedDomain.java rename to api/src/main/java/org/codemc/worldguardwrapper/region/IWrappedDomain.java index b878f87..2a877b2 100644 --- a/api/src/main/java/org/codemc/worldguardwrapper/region/WrappedDomain.java +++ b/api/src/main/java/org/codemc/worldguardwrapper/region/IWrappedDomain.java @@ -3,7 +3,7 @@ package org.codemc.worldguardwrapper.region; import java.util.Set; import java.util.UUID; -public interface WrappedDomain { +public interface IWrappedDomain { Set getPlayers(); diff --git a/api/src/main/java/org/codemc/worldguardwrapper/region/IWrappedRegion.java b/api/src/main/java/org/codemc/worldguardwrapper/region/IWrappedRegion.java new file mode 100644 index 0000000..d1e937d --- /dev/null +++ b/api/src/main/java/org/codemc/worldguardwrapper/region/IWrappedRegion.java @@ -0,0 +1,30 @@ +package org.codemc.worldguardwrapper.region; + +import org.bukkit.Location; +import org.codemc.worldguardwrapper.flag.IWrappedFlag; +import org.codemc.worldguardwrapper.selection.ISelection; + +import java.util.Map; +import java.util.Optional; + +public interface IWrappedRegion { + + ISelection getSelection(); + + String getId(); + + Optional getFlag(IWrappedFlag flag); + + void setFlag(IWrappedFlag flag, T value); + + Map, Object> getFlags(); + + int getPriority(); + + IWrappedDomain getOwners(); + + IWrappedDomain getMembers(); + + boolean contains(Location location); + +} diff --git a/api/src/main/java/org/codemc/worldguardwrapper/region/WrappedRegion.java b/api/src/main/java/org/codemc/worldguardwrapper/region/WrappedRegion.java deleted file mode 100644 index 041515d..0000000 --- a/api/src/main/java/org/codemc/worldguardwrapper/region/WrappedRegion.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.codemc.worldguardwrapper.region; - -import org.bukkit.Location; -import org.codemc.worldguardwrapper.flag.AbstractWrappedFlag; -import org.codemc.worldguardwrapper.selection.Selection; - -import java.util.Map; -import java.util.Optional; - -public interface WrappedRegion { - - Selection getSelection(); - - String getId(); - - Optional getFlag(String name); - - Map getFlags(); - - Map, Object> getWrappedFlags(); - - int getPriority(); - - WrappedDomain getOwners(); - - WrappedDomain getMembers(); - - boolean contains(Location location); - -} diff --git a/api/src/main/java/org/codemc/worldguardwrapper/selection/CuboidSelection.java b/api/src/main/java/org/codemc/worldguardwrapper/selection/ICuboidSelection.java similarity index 72% rename from api/src/main/java/org/codemc/worldguardwrapper/selection/CuboidSelection.java rename to api/src/main/java/org/codemc/worldguardwrapper/selection/ICuboidSelection.java index 384af0c..433cae4 100644 --- a/api/src/main/java/org/codemc/worldguardwrapper/selection/CuboidSelection.java +++ b/api/src/main/java/org/codemc/worldguardwrapper/selection/ICuboidSelection.java @@ -2,7 +2,7 @@ package org.codemc.worldguardwrapper.selection; import org.bukkit.Location; -public interface CuboidSelection extends Selection { +public interface ICuboidSelection extends ISelection { Location getMinimumPoint(); diff --git a/api/src/main/java/org/codemc/worldguardwrapper/selection/PolygonalSelection.java b/api/src/main/java/org/codemc/worldguardwrapper/selection/IPolygonalSelection.java similarity index 76% rename from api/src/main/java/org/codemc/worldguardwrapper/selection/PolygonalSelection.java rename to api/src/main/java/org/codemc/worldguardwrapper/selection/IPolygonalSelection.java index 29a2192..f115381 100644 --- a/api/src/main/java/org/codemc/worldguardwrapper/selection/PolygonalSelection.java +++ b/api/src/main/java/org/codemc/worldguardwrapper/selection/IPolygonalSelection.java @@ -4,7 +4,7 @@ import org.bukkit.Location; import java.util.Set; -public interface PolygonalSelection extends Selection { +public interface IPolygonalSelection extends ISelection { Set getPoints(); diff --git a/api/src/main/java/org/codemc/worldguardwrapper/selection/Selection.java b/api/src/main/java/org/codemc/worldguardwrapper/selection/ISelection.java similarity index 62% rename from api/src/main/java/org/codemc/worldguardwrapper/selection/Selection.java rename to api/src/main/java/org/codemc/worldguardwrapper/selection/ISelection.java index fc7b2f0..0f10b71 100644 --- a/api/src/main/java/org/codemc/worldguardwrapper/selection/Selection.java +++ b/api/src/main/java/org/codemc/worldguardwrapper/selection/ISelection.java @@ -1,4 +1,4 @@ package org.codemc.worldguardwrapper.selection; -public interface Selection { +public interface ISelection { } diff --git a/implementation/interface/pom.xml b/implementation/interface/pom.xml deleted file mode 100644 index 79e9ab0..0000000 --- a/implementation/interface/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - 4.0.0 - - - org.codemc.worldguardwrapper - worldguardwrapper-implementation - 1.0.4-SNAPSHOT - - - worldguardwrapper-implementation-interface - - WorldGuardWrapper-Implementation-Interface - - - - ${project.groupId} - worldguardwrapper-api - 1.0.4-SNAPSHOT - - - diff --git a/implementation/interface/src/main/java/org/codemc/worldguardwrapper/implementation/wrapper/WrapperAdapter.java b/implementation/interface/src/main/java/org/codemc/worldguardwrapper/implementation/wrapper/WrapperAdapter.java deleted file mode 100644 index b1af2b6..0000000 --- a/implementation/interface/src/main/java/org/codemc/worldguardwrapper/implementation/wrapper/WrapperAdapter.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codemc.worldguardwrapper.implementation.wrapper; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.function.Function; - -@AllArgsConstructor -public class WrapperAdapter { - - @Getter - private Class wrappedFlag; - @Getter - private Class unwrappedFlag; - private Function wrapper; - private Function unwrapper; - - public W wrap(U flag) { - return wrapper.apply(flag); - } - - public U unwrap(W flag) { - return unwrapper.apply(flag); - } -} diff --git a/implementation/interface/src/main/java/org/codemc/worldguardwrapper/implementation/wrapper/WrapperAdapterRegister.java b/implementation/interface/src/main/java/org/codemc/worldguardwrapper/implementation/wrapper/WrapperAdapterRegister.java deleted file mode 100644 index f722836..0000000 --- a/implementation/interface/src/main/java/org/codemc/worldguardwrapper/implementation/wrapper/WrapperAdapterRegister.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.codemc.worldguardwrapper.implementation.wrapper; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -public class WrapperAdapterRegister { - - private Map, WrapperAdapter> wrappedToAdapter = new HashMap<>(); - private Map, WrapperAdapter> unwrappedToAdapter = new HashMap<>(); - - public void register(WrapperAdapter adapter) { - wrappedToAdapter.put(adapter.getWrappedFlag(), adapter); - unwrappedToAdapter.put(adapter.getUnwrappedFlag(), adapter); - } - - @SuppressWarnings("unchecked") - public Optional> fromWrapped(W wrapped) { - return Optional.ofNullable(wrappedToAdapter.get(wrapped.getClass())); - } - - @SuppressWarnings("unchecked") - public Optional> fromUnwrapped(U unwrapped) { - return Optional.ofNullable(unwrappedToAdapter.get(unwrapped.getClass())); - } - - public Optional unwrap(W wrapped) { - return fromWrapped(wrapped).map(adapter -> adapter.unwrap(wrapped)); - } - - public Optional wrap(U unwrapped) { - return fromUnwrapped(unwrapped).map(adapter -> adapter.wrap(unwrapped)); - } -} diff --git a/implementation/pom.xml b/implementation/pom.xml index 470b738..3c1637c 100644 --- a/implementation/pom.xml +++ b/implementation/pom.xml @@ -7,14 +7,13 @@ org.codemc.worldguardwrapper worldguardwrapper-parent - 1.0.4-SNAPSHOT + 1.1.0-SNAPSHOT worldguardwrapper-implementation pom - interface v6 v7 diff --git a/implementation/v6/pom.xml b/implementation/v6/pom.xml index 8351242..75f2f13 100644 --- a/implementation/v6/pom.xml +++ b/implementation/v6/pom.xml @@ -7,7 +7,7 @@ org.codemc.worldguardwrapper worldguardwrapper-implementation - 1.0.4-SNAPSHOT + 1.1.0-SNAPSHOT worldguardwrapper-implementation-v6 @@ -17,8 +17,9 @@ ${project.groupId} - worldguardwrapper-implementation-interface - 1.0.4-SNAPSHOT + worldguardwrapper-api + 1.1.0-SNAPSHOT + provided com.sk89q.worldguard diff --git a/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/WorldGuardImplementation.java b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/WorldGuardImplementation.java index 5472d71..ee659b0 100644 --- a/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/WorldGuardImplementation.java +++ b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/WorldGuardImplementation.java @@ -1,52 +1,39 @@ package org.codemc.worldguardwrapper.implementation.v6; -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.protection.ApplicableRegionSet; -import com.sk89q.worldguard.protection.flags.BooleanFlag; -import com.sk89q.worldguard.protection.flags.Flag; -import com.sk89q.worldguard.protection.flags.StateFlag; +import com.sk89q.worldguard.protection.flags.*; import com.sk89q.worldguard.protection.flags.registry.FlagConflictException; import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion; +import lombok.NoArgsConstructor; import lombok.NonNull; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; -import org.codemc.worldguardwrapper.flag.AbstractWrappedFlag; -import org.codemc.worldguardwrapper.flag.WrappedBooleanFlag; +import org.bukkit.util.Vector; +import org.codemc.worldguardwrapper.flag.IWrappedFlag; +import org.codemc.worldguardwrapper.flag.WrappedState; import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation; -import org.codemc.worldguardwrapper.implementation.wrapper.WrapperAdapter; -import org.codemc.worldguardwrapper.implementation.wrapper.WrapperAdapterRegister; -import org.codemc.worldguardwrapper.region.WrappedDomain; -import org.codemc.worldguardwrapper.region.WrappedRegion; -import org.codemc.worldguardwrapper.selection.CuboidSelection; -import org.codemc.worldguardwrapper.selection.PolygonalSelection; -import org.codemc.worldguardwrapper.selection.Selection; +import org.codemc.worldguardwrapper.implementation.v6.flag.WrappedFlag; +import org.codemc.worldguardwrapper.implementation.v6.region.WrappedRegion; +import org.codemc.worldguardwrapper.implementation.v6.utility.WorldGuardVectorUtilities; +import org.codemc.worldguardwrapper.region.IWrappedRegion; import java.util.*; import java.util.stream.Collectors; +@NoArgsConstructor public class WorldGuardImplementation implements IWorldGuardImplementation { private final WorldGuardPlugin plugin = WorldGuardPlugin.inst(); private final FlagRegistry flagRegistry = plugin.getFlagRegistry(); - private final WrapperAdapterRegister, Flag> flagAdapter = new WrapperAdapterRegister<>(); - - @SuppressWarnings("unchecked") - public WorldGuardImplementation() { - // Register the flag adapters - flagAdapter.register(new WrapperAdapter<>(WrappedBooleanFlag.class, BooleanFlag.class, - flag -> new WrappedBooleanFlag(flag.getName()), flag -> new BooleanFlag(flag.getName()))); - } - private Optional wrapPlayer(Player player) { return Optional.ofNullable(player).map(bukkitPlayer -> plugin.wrapPlayer(player)); } @@ -61,7 +48,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation { private Optional getApplicableRegions(@NonNull Location minimum, @NonNull Location maximum) { return getWorldManager(minimum.getWorld()).map(manager -> manager.getApplicableRegions( - new ProtectedCuboidRegion("temp", toBlockVector(minimum), toBlockVector(maximum)))); + new ProtectedCuboidRegion("temp", WorldGuardVectorUtilities.toBlockVector(minimum), WorldGuardVectorUtilities.toBlockVector(maximum)))); } private Optional queryValue(Player player, @NonNull Location location, @NonNull Flag flag) { @@ -69,172 +56,6 @@ public class WorldGuardImplementation implements IWorldGuardImplementation { .orElse(null), flag)); } - private Optional queryState(Player player, @NonNull Location location, @NonNull StateFlag... stateFlags) { - return getApplicableRegions(location).map(applicableRegions -> applicableRegions.queryState(wrapPlayer(player) - .orElse(null), stateFlags)); - } - - private BlockVector toBlockVector(Location location) { - return new BlockVector(location.getX(), location.getY(), location.getZ()); - } - - private Location fromBlockVector(World world, BlockVector vector) { - return new Location(world, vector.getX(), vector.getY(), vector.getZ()); - } - - private List toBlockVector2DList(List locations) { - return locations.stream().map(location -> new BlockVector2D(location.getX(), location.getZ())).collect(Collectors.toList()); - } - - private WrappedRegion toRegion(World world, ProtectedRegion region) { - return new WrappedRegion() { - - @Override - public Selection getSelection() { - if (region instanceof PolygonalSelection) { - return new PolygonalSelection() { - - @Override - public Set getPoints() { - return region.getPoints().stream() - .map(vector -> new BlockVector(vector.toVector())) - .map(vector -> fromBlockVector(world, vector)) - .collect(Collectors.toSet()); - } - - @Override - public int getMinimumY() { - return ((PolygonalSelection) region).getMinimumY(); - } - - @Override - public int getMaximumY() { - return ((PolygonalSelection) region).getMaximumY(); - } - }; - } - return new CuboidSelection() { - - @Override - public Location getMinimumPoint() { - return fromBlockVector(world, region.getMinimumPoint()); - } - - @Override - public Location getMaximumPoint() { - return fromBlockVector(world, region.getMaximumPoint()); - } - }; - } - - @Override - public String getId() { - return region.getId(); - } - - @Override - public Map getFlags() { - Map map = new HashMap<>(); - region.getFlags().forEach((flag, value) -> map.put(flag.getName(), value)); - return map; - } - - @Override - public Map, Object> getWrappedFlags() { - Map, Object> map = new HashMap<>(); - region.getFlags().forEach((flag, value) -> - flagAdapter.wrap(flag).ifPresent(wrapped -> map.put(wrapped, value))); - return map; - } - - @Override - public Optional getFlag(String name) { - return Optional.ofNullable(flagRegistry.get(name)) - .map(region::getFlag); - } - - @Override - public int getPriority() { - return region.getPriority(); - } - - @Override - public WrappedDomain getOwners() { - return new WrappedDomain() { - @Override - public Set getPlayers() { - return region.getOwners().getUniqueIds(); - } - - @Override - public void addPlayer(UUID uuid) { - region.getOwners().addPlayer(uuid); - } - - @Override - public void removePlayer(UUID uuid) { - region.getOwners().removePlayer(uuid); - } - - @Override - public Set getGroups() { - return region.getOwners().getGroups(); - } - - @Override - public void addGroup(String name) { - region.getOwners().addGroup(name); - } - - @Override - public void removeGroup(String name) { - region.getOwners().removeGroup(name); - } - }; - } - - @Override - public WrappedDomain getMembers() { - return new WrappedDomain() { - @Override - public Set getPlayers() { - return region.getMembers().getUniqueIds(); - } - - @Override - public void addPlayer(UUID uuid) { - region.getMembers().addPlayer(uuid); - } - - @Override - public void removePlayer(UUID uuid) { - region.getMembers().removePlayer(uuid); - } - - @Override - public Set getGroups() { - return region.getMembers().getGroups(); - } - - @Override - public void addGroup(String name) { - region.getMembers().addGroup(name); - } - - @Override - public void removeGroup(String name) { - region.getMembers().removeGroup(name); - } - }; - } - - @Override - public boolean contains(Location location) { - return region.contains(toBlockVector(location)); - } - }; - } - @Override public JavaPlugin getWorldGuardPlugin() { return WorldGuardPlugin.inst(); @@ -246,94 +67,113 @@ public class WorldGuardImplementation implements IWorldGuardImplementation { } @Override + public Optional queryFlag(Player player, Location location, IWrappedFlag flag) { + Flag wrappedFlag = ((WrappedFlag) flag).getHandle(); + return queryValue(player, location, wrappedFlag); + } + + @Override + public Optional> getFlag(String name) { + return Optional.ofNullable(flagRegistry.get(name)) + .map(WrappedFlag::new); + } + @SuppressWarnings("unchecked") - public Optional queryFlag(Player player, Location location, String flagName, Class type) { - Flag flag = flagRegistry.get(flagName); - Object value = queryValue(player, location, flag).orElse(null); - if (type.isInstance(value)) { - return Optional.of((T) value); + @Override + public Optional> registerFlag(String name, Class type, T defaultValue) { + final Flag wrappedFlag; + if (type.equals(Boolean.class) || type.equals(boolean.class)) { + wrappedFlag = (Flag) new BooleanFlag(name); + } else if (type.equals(Double.class) || type.equals(double.class)) { + wrappedFlag = (Flag) new DoubleFlag(name); + } else if (type.equals(Enum.class)) { + wrappedFlag = new EnumFlag(name, type); + } else if (type.equals(Integer.class) || type.equals(int.class)) { + wrappedFlag = (Flag) new IntegerFlag(name); + } else if (type.equals(Location.class)) { + wrappedFlag = (Flag) new LocationFlag(name); + } else if (type.equals(WrappedState.class)) { + wrappedFlag = (Flag) new StateFlag(name, defaultValue == WrappedState.ALLOW); + } else if (type.equals(String.class)) { + wrappedFlag = (Flag) new StringFlag(name, (String) defaultValue); + } else if (type.equals(Vector.class)) { + wrappedFlag = (Flag) new VectorFlag(name); + } else { + throw new IllegalArgumentException("Unsupported flag type " + type.getName()); + } + try { + flagRegistry.register(wrappedFlag); + return Optional.of(new WrappedFlag<>(wrappedFlag)); + } catch (FlagConflictException ignored) { } return Optional.empty(); } @Override - public boolean registerFlag(AbstractWrappedFlag flag) { - Optional> unwrapped = flagAdapter.unwrap(flag); - if (unwrapped.isPresent()) { - try { - flagRegistry.register(unwrapped.get()); - return true; - } catch (FlagConflictException ignored) { - } - } - return false; + public Optional getRegion(World world, String id) { + return getWorldManager(world).map(regionManager -> new WrappedRegion(world, regionManager.getRegion(id))); } @Override - public Optional getRegion(World world, String id) { - return getWorldManager(world).map(regionManager -> toRegion(world, regionManager.getRegion(id))); - } - - @Override - public Map getRegions(World world) { + public Map getRegions(World world) { RegionManager regionManager = plugin.getRegionManager(world); Map regions = regionManager.getRegions(); - Map map = new HashMap<>(); - regions.forEach((name, region) -> map.put(name, toRegion(world, region))); + Map map = new HashMap<>(); + regions.forEach((name, region) -> map.put(name, new WrappedRegion(world, region))); return map; } @Override - public Set getRegions(Location location) { + public Set getRegions(Location location) { ApplicableRegionSet regionSet = getApplicableRegions(location).orElse(null); - Set set = new HashSet<>(); + Set set = new HashSet<>(); if (regionSet == null) { return set; } - regionSet.forEach(region -> set.add(toRegion(location.getWorld(), region))); + regionSet.forEach(region -> set.add(new WrappedRegion(location.getWorld(), region))); return set; } @Override - public Set getRegions(Location minimum, Location maximum) { + public Set getRegions(Location minimum, Location maximum) { ApplicableRegionSet regionSet = getApplicableRegions(minimum, maximum).orElse(null); - Set set = new HashSet<>(); + Set set = new HashSet<>(); if (regionSet == null) { return set; } - regionSet.forEach(region -> set.add(toRegion(minimum.getWorld(), region))); + regionSet.forEach(region -> set.add(new WrappedRegion(minimum.getWorld(), region))); return set; } @Override - public Optional addRegion(String id, List points, int minY, int maxY) { + public Optional addRegion(String id, List points, int minY, int maxY) { ProtectedRegion region; World world = points.get(0).getWorld(); if (points.size() == 2) { - region = new ProtectedCuboidRegion(id, toBlockVector(points.get(0)), toBlockVector(points.get(1))); + region = new ProtectedCuboidRegion(id, WorldGuardVectorUtilities.toBlockVector(points.get(0)), WorldGuardVectorUtilities.toBlockVector(points.get(1))); } else { - region = new ProtectedPolygonalRegion(id, toBlockVector2DList(points), minY, maxY); + region = new ProtectedPolygonalRegion(id, WorldGuardVectorUtilities.toBlockVector2DList(points), minY, maxY); } Optional manager = getWorldManager(world); if (manager.isPresent()) { manager.get().addRegion(region); - return Optional.of(toRegion(world, region)); + return Optional.of(new WrappedRegion(world, region)); } else { return Optional.empty(); } } @Override - public Optional> removeRegion(World world, String id) { + public Optional> removeRegion(World world, String id) { Optional> set = getWorldManager(world).map(manager -> manager.removeRegion(id)); - return set.map(protectedRegions -> protectedRegions.stream().map(region -> toRegion(world, region)) + return set.map(protectedRegions -> protectedRegions.stream().map(region -> new WrappedRegion(world, region)) .collect(Collectors.toSet())); } diff --git a/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/EventListener.java b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/event/EventListener.java similarity index 98% rename from implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/EventListener.java rename to implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/event/EventListener.java index 9f668b9..05a80c6 100644 --- a/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/EventListener.java +++ b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/event/EventListener.java @@ -1,4 +1,4 @@ -package org.codemc.worldguardwrapper.implementation.v6; +package org.codemc.worldguardwrapper.implementation.v6.event; import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent; import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent; diff --git a/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/flag/WrappedFlag.java b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/flag/WrappedFlag.java new file mode 100644 index 0000000..b5318d7 --- /dev/null +++ b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/flag/WrappedFlag.java @@ -0,0 +1,27 @@ +package org.codemc.worldguardwrapper.implementation.v6.flag; + +import com.sk89q.worldguard.protection.flags.Flag; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.codemc.worldguardwrapper.flag.IWrappedFlag; + +import java.util.Optional; + +@AllArgsConstructor +@Getter +public class WrappedFlag implements IWrappedFlag { + + private final Flag handle; + + @Override + public String getName() { + return handle.getName(); + } + + @Override + public Optional getDefaultValue() { + return Optional.ofNullable(handle.getDefault()); + } + +} diff --git a/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/region/WrappedRegion.java b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/region/WrappedRegion.java new file mode 100644 index 0000000..b58ffac --- /dev/null +++ b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/region/WrappedRegion.java @@ -0,0 +1,175 @@ +package org.codemc.worldguardwrapper.implementation.v6.region; + +import com.sk89q.worldedit.BlockVector; +import com.sk89q.worldguard.protection.flags.Flag; +import com.sk89q.worldguard.protection.regions.ProtectedRegion; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.bukkit.Location; +import org.bukkit.World; +import org.codemc.worldguardwrapper.flag.IWrappedFlag; +import org.codemc.worldguardwrapper.implementation.v6.flag.WrappedFlag; +import org.codemc.worldguardwrapper.implementation.v6.utility.WorldGuardVectorUtilities; +import org.codemc.worldguardwrapper.region.IWrappedDomain; +import org.codemc.worldguardwrapper.region.IWrappedRegion; +import org.codemc.worldguardwrapper.selection.ICuboidSelection; +import org.codemc.worldguardwrapper.selection.IPolygonalSelection; +import org.codemc.worldguardwrapper.selection.ISelection; + +import java.util.*; +import java.util.stream.Collectors; + +@AllArgsConstructor +@Getter +public class WrappedRegion implements IWrappedRegion { + + private final World world; + private final ProtectedRegion handle; + + @Override + public ISelection getSelection() { + if (handle instanceof IPolygonalSelection) { + return new IPolygonalSelection() { + + @Override + public Set getPoints() { + return handle.getPoints().stream() + .map(vector -> new BlockVector(vector.toVector())) + .map(vector -> WorldGuardVectorUtilities.fromBlockVector(world, vector)) + .collect(Collectors.toSet()); + } + + @Override + public int getMinimumY() { + return ((IPolygonalSelection) handle).getMinimumY(); + } + + @Override + public int getMaximumY() { + return ((IPolygonalSelection) handle).getMaximumY(); + } + }; + } + return new ICuboidSelection() { + + @Override + public Location getMinimumPoint() { + return WorldGuardVectorUtilities.fromBlockVector(world, handle.getMinimumPoint()); + } + + @Override + public Location getMaximumPoint() { + return WorldGuardVectorUtilities.fromBlockVector(world, handle.getMaximumPoint()); + } + }; + } + + @Override + public String getId() { + return handle.getId(); + } + + @SuppressWarnings("unchecked") + @Override + public Optional getFlag(IWrappedFlag flag) { + Flag wrappedFlag = ((WrappedFlag) flag).getHandle(); + return Optional.ofNullable(handle.getFlag(wrappedFlag)) + .map(value -> (T) value); + } + + @SuppressWarnings("unchecked") + @Override + public void setFlag(IWrappedFlag flag, T value) { + Flag wrappedFlag = ((WrappedFlag) flag).getHandle(); + handle.setFlag(wrappedFlag, value); + } + + @Override + public Map, Object> getFlags() { + Map, Object> map = new HashMap<>(); + handle.getFlags().forEach((flag, value) -> map.put(new WrappedFlag<>(flag), value)); + return map; + } + + @Override + public int getPriority() { + return handle.getPriority(); + } + + @Override + public IWrappedDomain getOwners() { + return new IWrappedDomain() { + @Override + public Set getPlayers() { + return handle.getOwners().getUniqueIds(); + } + + @Override + public void addPlayer(UUID uuid) { + handle.getOwners().addPlayer(uuid); + } + + @Override + public void removePlayer(UUID uuid) { + handle.getOwners().removePlayer(uuid); + } + + @Override + public Set getGroups() { + return handle.getOwners().getGroups(); + } + + @Override + public void addGroup(String name) { + handle.getOwners().addGroup(name); + } + + @Override + public void removeGroup(String name) { + handle.getOwners().removeGroup(name); + } + }; + } + + @Override + public IWrappedDomain getMembers() { + return new IWrappedDomain() { + @Override + public Set getPlayers() { + return handle.getMembers().getUniqueIds(); + } + + @Override + public void addPlayer(UUID uuid) { + handle.getMembers().addPlayer(uuid); + } + + @Override + public void removePlayer(UUID uuid) { + handle.getMembers().removePlayer(uuid); + } + + @Override + public Set getGroups() { + return handle.getMembers().getGroups(); + } + + @Override + public void addGroup(String name) { + handle.getMembers().addGroup(name); + } + + @Override + public void removeGroup(String name) { + handle.getMembers().removeGroup(name); + } + }; + } + + @Override + public boolean contains(Location location) { + return handle.contains(WorldGuardVectorUtilities.toBlockVector(location)); + } + +} diff --git a/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/utility/WorldGuardVectorUtilities.java b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/utility/WorldGuardVectorUtilities.java new file mode 100644 index 0000000..988fb8c --- /dev/null +++ b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/utility/WorldGuardVectorUtilities.java @@ -0,0 +1,26 @@ +package org.codemc.worldguardwrapper.implementation.v6.utility; + +import com.sk89q.worldedit.BlockVector; +import com.sk89q.worldedit.BlockVector2D; +import lombok.experimental.UtilityClass; +import org.bukkit.Location; +import org.bukkit.World; + +import java.util.List; +import java.util.stream.Collectors; + +@UtilityClass +public class WorldGuardVectorUtilities { + + public BlockVector toBlockVector(Location location) { + return new BlockVector(location.getX(), location.getY(), location.getZ()); + } + + public Location fromBlockVector(World world, BlockVector vector) { + return new Location(world, vector.getX(), vector.getY(), vector.getZ()); + } + + public List toBlockVector2DList(List locations) { + return locations.stream().map(location -> new BlockVector2D(location.getX(), location.getZ())).collect(Collectors.toList()); + } +} diff --git a/implementation/v7/pom.xml b/implementation/v7/pom.xml index fcf4d49..051945d 100644 --- a/implementation/v7/pom.xml +++ b/implementation/v7/pom.xml @@ -7,7 +7,7 @@ org.codemc.worldguardwrapper worldguardwrapper-implementation - 1.0.4-SNAPSHOT + 1.1.0-SNAPSHOT worldguardwrapper-implementation-v7 @@ -17,13 +17,14 @@ ${project.groupId} - worldguardwrapper-implementation-interface - 1.0.4-SNAPSHOT + worldguardwrapper-api + 1.1.0-SNAPSHOT + provided com.sk89q.worldguard worldguard-legacy - 7.0.0-20181117.063337-9 + 7.0.0-SNAPSHOT provided @@ -36,121 +37,5 @@ - - com.sk89q.worldguard - worldguard-core - 7.0.0-20181117.063337-9 - provided - - - com.sk89q.intake - intake - - - com.sk89q - squirrelid - - - org.flywaydb - flyway-core - - - org.khelekore - prtree - - - net.sf.opencsv - opencsv - - - com.googlecode.json-simple - json-simple - - - com.google.code.findbugs - jsr305 - - - - - com.sk89q.worldedit - worldedit-bukkit - 7.0.0-20181118.055910-28 - provided - - - com.sk89q - dummypermscompat - - - org.bukkit - bukkit - - - org.bstats - bstats-bukkit - - - io.papermc - paperlib - - - net.milkbowl.vault - VaultAPI - - - org.mockito - mockito-core - - - - - com.sk89q.worldedit - worldedit-core - 7.0.0-20181118.055910-28 - provided - - - de.schlichtherle - truezip - - - rhino - js - - - org.yaml - snakeyaml - - - com.google.guava - guava - - - com.sk89q - jchronic - - - com.google.code.findbugs - jsr305 - - - com.thoughtworks.paranamer - paranamer - - - com.google.code.gson - gson - - - com.sk89q.lib - jlibnoise - - - org.mockito - mockito-core - - - diff --git a/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/WorldGuardImplementation.java b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/WorldGuardImplementation.java index 228e891..8324e34 100644 --- a/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/WorldGuardImplementation.java +++ b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/WorldGuardImplementation.java @@ -1,16 +1,14 @@ package org.codemc.worldguardwrapper.implementation.v7; +import com.sk89q.worldedit.BlockVector; +import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitWorld; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.protection.ApplicableRegionSet; -import com.sk89q.worldguard.protection.flags.Flag; -import com.sk89q.worldguard.protection.flags.FlagContext; -import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; -import com.sk89q.worldguard.protection.flags.StateFlag; +import com.sk89q.worldguard.protection.flags.*; import com.sk89q.worldguard.protection.flags.registry.FlagConflictException; import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; import com.sk89q.worldguard.protection.managers.RegionManager; @@ -23,13 +21,13 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; -import org.codemc.worldguardwrapper.flag.AbstractWrappedFlag; +import org.bukkit.util.Vector; +import org.codemc.worldguardwrapper.flag.IWrappedFlag; +import org.codemc.worldguardwrapper.flag.WrappedState; import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation; -import org.codemc.worldguardwrapper.region.WrappedDomain; -import org.codemc.worldguardwrapper.region.WrappedRegion; -import org.codemc.worldguardwrapper.selection.CuboidSelection; -import org.codemc.worldguardwrapper.selection.PolygonalSelection; -import org.codemc.worldguardwrapper.selection.Selection; +import org.codemc.worldguardwrapper.implementation.v7.flag.WrappedFlag; +import org.codemc.worldguardwrapper.implementation.v7.region.WrappedRegion; +import org.codemc.worldguardwrapper.region.IWrappedRegion; import java.util.*; import java.util.stream.Collectors; @@ -59,12 +57,12 @@ public class WorldGuardImplementation implements IWorldGuardImplementation { } private Optional getApplicableRegions(@NonNull Location location) { - return getWorldManager(location.getWorld()).map(manager -> manager.getApplicableRegions(BukkitAdapter.asBlockVector(location))); + return getWorldManager(location.getWorld()).map(manager -> manager.getApplicableRegions(BukkitAdapter.asVector(location))); } private Optional getApplicableRegions(@NonNull Location minimum, @NonNull Location maximum) { return getWorldManager(minimum.getWorld()).map(manager -> manager.getApplicableRegions( - new ProtectedCuboidRegion("temp", BukkitAdapter.asBlockVector(minimum), BukkitAdapter.asBlockVector(maximum)))); + new ProtectedCuboidRegion("temp", new BlockVector(BukkitAdapter.asVector(minimum)), new BlockVector(BukkitAdapter.asVector(maximum))))); } private Optional queryValue(Player player, @NonNull Location location, @NonNull Flag flag) { @@ -77,147 +75,6 @@ public class WorldGuardImplementation implements IWorldGuardImplementation { .orElse(null), stateFlags)); } - private WrappedRegion toRegion(World world, ProtectedRegion region) { - return new WrappedRegion() { - - @Override - public Selection getSelection() { - if (region instanceof PolygonalSelection) { - return new PolygonalSelection() { - - @Override - public Set getPoints() { - return region.getPoints().stream() - .map(BlockVector2::toBlockVector3) - .map(vector -> BukkitAdapter.adapt(world, vector)) - .collect(Collectors.toSet()); - } - - @Override - public int getMinimumY() { - return ((PolygonalSelection) region).getMinimumY(); - } - - @Override - public int getMaximumY() { - return ((PolygonalSelection) region).getMaximumY(); - } - }; - } - return new CuboidSelection() { - - @Override - public Location getMinimumPoint() { - return BukkitAdapter.adapt(world, region.getMinimumPoint()); - } - - @Override - public Location getMaximumPoint() { - return BukkitAdapter.adapt(world, region.getMaximumPoint()); - } - }; - } - - @Override - public String getId() { - return region.getId(); - } - - @Override - public Map getFlags() { - Map map = new HashMap<>(); - region.getFlags().forEach((flag, value) -> map.put(flag.getName(), value)); - return map; - } - - @Override - public Optional getFlag(String name) { - return Optional.ofNullable(flagRegistry.get(name)) - .map(region::getFlag); - } - - @Override - public int getPriority() { - return region.getPriority(); - } - - @Override - public WrappedDomain getOwners() { - return new WrappedDomain() { - @Override - public Set getPlayers() { - return region.getOwners().getUniqueIds(); - } - - @Override - public void addPlayer(UUID uuid) { - region.getOwners().addPlayer(uuid); - } - - @Override - public void removePlayer(UUID uuid) { - region.getOwners().removePlayer(uuid); - } - - @Override - public Set getGroups() { - return region.getOwners().getGroups(); - } - - @Override - public void addGroup(String name) { - region.getOwners().addGroup(name); - } - - @Override - public void removeGroup(String name) { - region.getOwners().removeGroup(name); - } - }; - } - - @Override - public WrappedDomain getMembers() { - return new WrappedDomain() { - @Override - public Set getPlayers() { - return region.getMembers().getUniqueIds(); - } - - @Override - public void addPlayer(UUID uuid) { - region.getMembers().addPlayer(uuid); - } - - @Override - public void removePlayer(UUID uuid) { - region.getMembers().removePlayer(uuid); - } - - @Override - public Set getGroups() { - return region.getMembers().getGroups(); - } - - @Override - public void addGroup(String name) { - region.getMembers().addGroup(name); - } - - @Override - public void removeGroup(String name) { - region.getMembers().removeGroup(name); - } - }; - } - - @Override - public boolean contains(Location location) { - return region.contains(BukkitAdapter.asBlockVector(location)); - } - }; - } - @Override public JavaPlugin getWorldGuardPlugin() { return WorldGuardPlugin.inst(); @@ -229,121 +86,102 @@ public class WorldGuardImplementation implements IWorldGuardImplementation { } @Override - public Optional queryStateFlag(Player player, @NonNull Location location, @NonNull String flagId) { - Flag flag = flagRegistry.get(flagId); - if (!(flag instanceof StateFlag)) { - return Optional.empty(); - } - return queryState(player, location, (StateFlag) flag).map(state -> state == StateFlag.State.ALLOW); + public Optional queryFlag(Player player, Location location, IWrappedFlag flag) { + Flag wrappedFlag = ((WrappedFlag) flag).getHandle(); + return queryValue(player, location, wrappedFlag); } @Override - public boolean registerStateFlag(@NonNull String flagId, @NonNull Boolean defaultValue) { - try { - flagRegistry.register(new StateFlag(flagId, defaultValue)); - return true; - } catch (FlagConflictException ignored) { - } - return false; + public Optional> getFlag(String name) { + return Optional.ofNullable(flagRegistry.get(name)) + .map(WrappedFlag::new); } - @Override @SuppressWarnings("unchecked") - public Optional queryFlag(Player player, Location location, String flagName, Class type) { - Flag flag = flagRegistry.get(flagName); - Object value = queryValue(player, location, flag).orElse(null); - if (type.isInstance(value)) { - return Optional.of((T) value); + @Override + public Optional> registerFlag(String name, Class type, T defaultValue) { + final Flag wrappedFlag; + if (type.equals(Boolean.class) || type.equals(boolean.class)) { + wrappedFlag = (Flag) new BooleanFlag(name); + } else if (type.equals(Double.class) || type.equals(double.class)) { + wrappedFlag = (Flag) new DoubleFlag(name); + } else if (type.equals(Enum.class)) { + wrappedFlag = new EnumFlag(name, type); + } else if (type.equals(Integer.class) || type.equals(int.class)) { + wrappedFlag = (Flag) new IntegerFlag(name); + } else if (type.equals(Location.class)) { + wrappedFlag = (Flag) new LocationFlag(name); + } else if (type.equals(WrappedState.class)) { + wrappedFlag = (Flag) new StateFlag(name, defaultValue == WrappedState.ALLOW); + } else if (type.equals(String.class)) { + wrappedFlag = (Flag) new StringFlag(name, (String) defaultValue); + } else if (type.equals(Vector.class)) { + wrappedFlag = (Flag) new VectorFlag(name); + } else { + throw new IllegalArgumentException("Unsupported flag type " + type.getName()); + } + try { + flagRegistry.register(wrappedFlag); + return Optional.of(new WrappedFlag<>(wrappedFlag)); + } catch (FlagConflictException ignored) { } return Optional.empty(); } @Override - public boolean registerFlag(AbstractWrappedFlag flag) { - Flag wgFlag = new Flag(flag.getName()) { - @Override - public T getDefault() { - return flag.getDefaultValue(); - } - - @Override - public Object marshal(T o) { - return flag.serialize(o); - } - - @Override - public T unmarshal(Object o) { - return flag.deserialize(o); - } - - @Override - public T parseInput(FlagContext context) throws InvalidFlagFormat { - return flag.parse(getPlayer(context.getPlayerSender()).orElse(null), context.getUserInput()); - } - }; - - try { - flagRegistry.register(wgFlag); - return true; - } catch (FlagConflictException ignored) { - } - return false; - } - - @Override - public Optional getRegion(World world, String id) { + public Optional getRegion(World world, String id) { return getWorldManager(world) .map(regionManager -> regionManager.getRegion(id)) - .map(region -> toRegion(world, region)); + .map(region -> new WrappedRegion(world, region)); } @Override - public Map getRegions(World world) { + public Map getRegions(World world) { RegionManager regionManager = core.getPlatform().getRegionContainer().get(new BukkitWorld(world)); if (regionManager == null) { return Collections.emptyMap(); } Map regions = regionManager.getRegions(); - Map map = new HashMap<>(); - regions.forEach((name, region) -> map.put(name, toRegion(world, region))); + Map map = new HashMap<>(); + regions.forEach((name, region) -> map.put(name, new WrappedRegion(world, region))); return map; } @Override - public Set getRegions(Location location) { + public Set getRegions(Location location) { ApplicableRegionSet regionSet = getApplicableRegions(location).orElse(null); if (regionSet == null) { return Collections.emptySet(); } return regionSet.getRegions().stream() - .map(region -> toRegion(location.getWorld(), region)) + .map(region -> new WrappedRegion(location.getWorld(), region)) .collect(Collectors.toSet()); } @Override - public Set getRegions(Location minimum, Location maximum) { + public Set getRegions(Location minimum, Location maximum) { ApplicableRegionSet regionSet = getApplicableRegions(minimum, maximum).orElse(null); if (regionSet == null) { return Collections.emptySet(); } return regionSet.getRegions().stream() - .map(region -> toRegion(minimum.getWorld(), region)) + .map(region -> new WrappedRegion(minimum.getWorld(), region)) .collect(Collectors.toSet()); } @Override - public Optional addRegion(String id, List points, int minY, int maxY) { + public Optional addRegion(String id, List points, int minY, int maxY) { ProtectedRegion region; World world = points.get(0).getWorld(); if (points.size() == 2) { - region = new ProtectedCuboidRegion(id, BukkitAdapter.asBlockVector(points.get(0)), - BukkitAdapter.asBlockVector(points.get(1))); + region = new ProtectedCuboidRegion(id, new BlockVector(BukkitAdapter.asVector(points.get(0))), + new BlockVector(BukkitAdapter.asVector(points.get(1)))); } else { - List vectorPoints = points.stream() - .map(location -> BukkitAdapter.asBlockVector(location).toBlockVector2()) + List vectorPoints = points.stream() + .map(location -> new BlockVector2D(BukkitAdapter.asVector(location).toVector2D())) .collect(Collectors.toList()); region = new ProtectedPolygonalRegion(id, vectorPoints, minY, maxY); @@ -352,16 +190,16 @@ public class WorldGuardImplementation implements IWorldGuardImplementation { Optional manager = getWorldManager(world); if (manager.isPresent()) { manager.get().addRegion(region); - return Optional.of(toRegion(world, region)); + return Optional.of(new WrappedRegion(world, region)); } else { return Optional.empty(); } } @Override - public Optional> removeRegion(World world, String id) { + public Optional> removeRegion(World world, String id) { Optional> set = getWorldManager(world).map(manager -> manager.removeRegion(id)); return set.map(protectedRegions -> protectedRegions.stream() - .map(region -> toRegion(world, region)).collect(Collectors.toSet())); + .map(region -> new WrappedRegion(world, region)).collect(Collectors.toSet())); } } diff --git a/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/EventListener.java b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/event/EventListener.java similarity index 98% rename from implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/EventListener.java rename to implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/event/EventListener.java index 6fa0b45..c551607 100644 --- a/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/EventListener.java +++ b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/event/EventListener.java @@ -1,4 +1,4 @@ -package org.codemc.worldguardwrapper.implementation.v7; +package org.codemc.worldguardwrapper.implementation.v7.event; import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent; import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent; diff --git a/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/flag/WrappedFlag.java b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/flag/WrappedFlag.java new file mode 100644 index 0000000..9aaab3f --- /dev/null +++ b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/flag/WrappedFlag.java @@ -0,0 +1,26 @@ +package org.codemc.worldguardwrapper.implementation.v7.flag; + +import com.sk89q.worldguard.protection.flags.Flag; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.codemc.worldguardwrapper.flag.IWrappedFlag; + +import java.util.Optional; + +@AllArgsConstructor +@Getter +public class WrappedFlag implements IWrappedFlag { + + private final Flag handle; + + @Override + public String getName() { + return handle.getName(); + } + + @Override + public Optional getDefaultValue() { + return Optional.ofNullable(handle.getDefault()); + } + +} diff --git a/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/region/WrappedRegion.java b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/region/WrappedRegion.java new file mode 100644 index 0000000..86695c3 --- /dev/null +++ b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/region/WrappedRegion.java @@ -0,0 +1,174 @@ +package org.codemc.worldguardwrapper.implementation.v7.region; + +import com.sk89q.worldedit.BlockVector2D; +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldguard.protection.flags.Flag; +import com.sk89q.worldguard.protection.regions.ProtectedRegion; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.bukkit.Location; +import org.bukkit.World; +import org.codemc.worldguardwrapper.flag.IWrappedFlag; +import org.codemc.worldguardwrapper.implementation.v7.flag.WrappedFlag; +import org.codemc.worldguardwrapper.region.IWrappedDomain; +import org.codemc.worldguardwrapper.region.IWrappedRegion; +import org.codemc.worldguardwrapper.selection.ICuboidSelection; +import org.codemc.worldguardwrapper.selection.IPolygonalSelection; +import org.codemc.worldguardwrapper.selection.ISelection; + +import java.util.*; +import java.util.stream.Collectors; + +@AllArgsConstructor +@Getter +public class WrappedRegion implements IWrappedRegion { + + private final World world; + private final ProtectedRegion handle; + + @Override + public ISelection getSelection() { + if (handle instanceof IPolygonalSelection) { + return new IPolygonalSelection() { + + @Override + public Set getPoints() { + return handle.getPoints().stream() + .map(BlockVector2D::toVector) + .map(vector -> BukkitAdapter.adapt(world, vector)) + .collect(Collectors.toSet()); + } + + @Override + public int getMinimumY() { + return ((IPolygonalSelection) handle).getMinimumY(); + } + + @Override + public int getMaximumY() { + return ((IPolygonalSelection) handle).getMaximumY(); + } + }; + } + return new ICuboidSelection() { + + @Override + public Location getMinimumPoint() { + return BukkitAdapter.adapt(world, handle.getMinimumPoint()); + } + + @Override + public Location getMaximumPoint() { + return BukkitAdapter.adapt(world, handle.getMaximumPoint()); + } + }; + } + + @Override + public String getId() { + return handle.getId(); + } + + @SuppressWarnings("unchecked") + @Override + public Optional getFlag(IWrappedFlag flag) { + Flag wrappedFlag = ((WrappedFlag) flag).getHandle(); + return Optional.ofNullable(handle.getFlag(wrappedFlag)) + .map(value -> (T) value); + } + + @SuppressWarnings("unchecked") + @Override + public void setFlag(IWrappedFlag flag, T value) { + Flag wrappedFlag = ((WrappedFlag) flag).getHandle(); + handle.setFlag(wrappedFlag, value); + } + + @Override + public Map, Object> getFlags() { + Map, Object> map = new HashMap<>(); + handle.getFlags().forEach((flag, value) -> map.put(new WrappedFlag<>(flag), value)); + return map; + } + + @Override + public int getPriority() { + return handle.getPriority(); + } + + @Override + public IWrappedDomain getOwners() { + return new IWrappedDomain() { + @Override + public Set getPlayers() { + return handle.getOwners().getUniqueIds(); + } + + @Override + public void addPlayer(UUID uuid) { + handle.getOwners().addPlayer(uuid); + } + + @Override + public void removePlayer(UUID uuid) { + handle.getOwners().removePlayer(uuid); + } + + @Override + public Set getGroups() { + return handle.getOwners().getGroups(); + } + + @Override + public void addGroup(String name) { + handle.getOwners().addGroup(name); + } + + @Override + public void removeGroup(String name) { + handle.getOwners().removeGroup(name); + } + }; + } + + @Override + public IWrappedDomain getMembers() { + return new IWrappedDomain() { + @Override + public Set getPlayers() { + return handle.getMembers().getUniqueIds(); + } + + @Override + public void addPlayer(UUID uuid) { + handle.getMembers().addPlayer(uuid); + } + + @Override + public void removePlayer(UUID uuid) { + handle.getMembers().removePlayer(uuid); + } + + @Override + public Set getGroups() { + return handle.getMembers().getGroups(); + } + + @Override + public void addGroup(String name) { + handle.getMembers().addGroup(name); + } + + @Override + public void removeGroup(String name) { + handle.getMembers().removeGroup(name); + } + }; + } + + @Override + public boolean contains(Location location) { + return handle.contains(BukkitAdapter.asVector(location)); + } + +} diff --git a/library/pom.xml b/library/pom.xml index d22b693..5c61084 100644 --- a/library/pom.xml +++ b/library/pom.xml @@ -7,7 +7,7 @@ org.codemc.worldguardwrapper worldguardwrapper-parent - 1.0.4-SNAPSHOT + 1.1.0-SNAPSHOT worldguardwrapper @@ -15,17 +15,22 @@ WorldGuardWrapper-Library + + ${project.groupId} + worldguardwrapper-api + 1.1.0-SNAPSHOT + ${project.groupId} worldguardwrapper-implementation-v6 - 1.0.4-SNAPSHOT - true + 1.1.0-SNAPSHOT + runtime ${project.groupId} worldguardwrapper-implementation-v7 - 1.0.4-SNAPSHOT - true + 1.1.0-SNAPSHOT + runtime diff --git a/library/src/main/java/org/codemc/worldguardwrapper/WorldGuardWrapper.java b/library/src/main/java/org/codemc/worldguardwrapper/WorldGuardWrapper.java index c96e832..42fe80d 100644 --- a/library/src/main/java/org/codemc/worldguardwrapper/WorldGuardWrapper.java +++ b/library/src/main/java/org/codemc/worldguardwrapper/WorldGuardWrapper.java @@ -27,13 +27,20 @@ public class WorldGuardWrapper implements IWorldGuardImplementation { private Listener eventListener; private WorldGuardWrapper() { + String version; try { Class.forName("com.sk89q.worldguard.WorldGuard"); - delegate = new org.codemc.worldguardwrapper.implementation.v7.WorldGuardImplementation(); - eventListener = new org.codemc.worldguardwrapper.implementation.v7.EventListener(); + version = "v7"; } catch (ClassNotFoundException e) { - delegate = new org.codemc.worldguardwrapper.implementation.v6.WorldGuardImplementation(); - eventListener = new org.codemc.worldguardwrapper.implementation.v6.EventListener(); + version = "v6"; + } + try { + delegate = (IWorldGuardImplementation) Class.forName("org.codemc.worldguardwrapper.implementation." + + version + ".WorldGuardImplementation").newInstance(); + eventListener = (Listener) Class.forName("new org.codemc.worldguardwrapper.implementation." + + version + ".event.EventListener").newInstance(); + } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { + throw new RuntimeException("Unable to initialize WorldGuard implementation " + version, e); } } diff --git a/pom.xml b/pom.xml index 0630e94..4654194 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.codemc.worldguardwrapper worldguardwrapper-parent - 1.0.4-SNAPSHOT + 1.1.0-SNAPSHOT pom