From 74399248f346ccc7c01a0e593d1db5433cfb2a91 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Wed, 28 Nov 2018 13:58:56 +0100 Subject: [PATCH] Use generics in the getFlag method --- api/pom.xml | 2 +- .../implementation/IWorldGuardImplementation.java | 3 ++- implementation/pom.xml | 2 +- implementation/v6/pom.xml | 4 ++-- .../implementation/v6/WorldGuardImplementation.java | 6 ++++-- implementation/v7/pom.xml | 4 ++-- .../implementation/v7/WorldGuardImplementation.java | 5 +++-- library/pom.xml | 8 ++++---- pom.xml | 2 +- 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index e16bd4b..6bb8969 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -7,7 +7,7 @@ org.codemc.worldguardwrapper worldguardwrapper-parent - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT worldguardwrapper-api diff --git a/api/src/main/java/org/codemc/worldguardwrapper/implementation/IWorldGuardImplementation.java b/api/src/main/java/org/codemc/worldguardwrapper/implementation/IWorldGuardImplementation.java index 631cd86..3c5fe52 100644 --- a/api/src/main/java/org/codemc/worldguardwrapper/implementation/IWorldGuardImplementation.java +++ b/api/src/main/java/org/codemc/worldguardwrapper/implementation/IWorldGuardImplementation.java @@ -40,9 +40,10 @@ public interface IWorldGuardImplementation { * Returns the flag with the given name. * * @param name The flag name + * @param type The flag type * @return The flag, empty if it doesn't exists */ - Optional> getFlag(@NonNull String name); + Optional> getFlag(String name, Class type); /** * Registers a flag to WorldGuard's flag registry. diff --git a/implementation/pom.xml b/implementation/pom.xml index 225c932..46d1d76 100644 --- a/implementation/pom.xml +++ b/implementation/pom.xml @@ -7,7 +7,7 @@ org.codemc.worldguardwrapper worldguardwrapper-parent - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT worldguardwrapper-implementation diff --git a/implementation/v6/pom.xml b/implementation/v6/pom.xml index a7b8917..e13e992 100644 --- a/implementation/v6/pom.xml +++ b/implementation/v6/pom.xml @@ -7,7 +7,7 @@ org.codemc.worldguardwrapper worldguardwrapper-implementation - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT worldguardwrapper-implementation-v6 @@ -18,7 +18,7 @@ ${project.groupId} worldguardwrapper-api - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT provided 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 ee659b0..f11ddb4 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 @@ -72,10 +72,12 @@ public class WorldGuardImplementation implements IWorldGuardImplementation { return queryValue(player, location, wrappedFlag); } + + @SuppressWarnings("unchecked") @Override - public Optional> getFlag(String name) { + public Optional> getFlag(String name, Class type) { return Optional.ofNullable(flagRegistry.get(name)) - .map(WrappedFlag::new); + .map(flag -> (IWrappedFlag) new WrappedFlag(flag)); } @SuppressWarnings("unchecked") diff --git a/implementation/v7/pom.xml b/implementation/v7/pom.xml index e0daafc..d76dad5 100644 --- a/implementation/v7/pom.xml +++ b/implementation/v7/pom.xml @@ -7,7 +7,7 @@ org.codemc.worldguardwrapper worldguardwrapper-implementation - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT worldguardwrapper-implementation-v7 @@ -18,7 +18,7 @@ ${project.groupId} worldguardwrapper-api - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT provided 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 a5ee466..b42075c 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 @@ -76,10 +76,11 @@ public class WorldGuardImplementation implements IWorldGuardImplementation { return queryValue(player, location, wrappedFlag); } + @SuppressWarnings("unchecked") @Override - public Optional> getFlag(String name) { + public Optional> getFlag(String name, Class type) { return Optional.ofNullable(flagRegistry.get(name)) - .map(WrappedFlag::new); + .map(flag -> (IWrappedFlag) new WrappedFlag(flag)); } @SuppressWarnings("unchecked") diff --git a/library/pom.xml b/library/pom.xml index 5c61084..7062e6b 100644 --- a/library/pom.xml +++ b/library/pom.xml @@ -7,7 +7,7 @@ org.codemc.worldguardwrapper worldguardwrapper-parent - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT worldguardwrapper @@ -18,18 +18,18 @@ ${project.groupId} worldguardwrapper-api - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT ${project.groupId} worldguardwrapper-implementation-v6 - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT runtime ${project.groupId} worldguardwrapper-implementation-v7 - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT runtime diff --git a/pom.xml b/pom.xml index 3971348..f5de583 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.codemc.worldguardwrapper worldguardwrapper-parent - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom