forked from clone/WorldGuardWrapper
Use generics in the getFlag method
This commit is contained in:
parent
06eb96b230
commit
74399248f3
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper-parent</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.1.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>worldguardwrapper-api</artifactId>
|
||||
|
|
|
@ -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<IWrappedFlag<?>> getFlag(@NonNull String name);
|
||||
<T> Optional<IWrappedFlag<T>> getFlag(String name, Class<T> type);
|
||||
|
||||
/**
|
||||
* Registers a flag to WorldGuard's flag registry.
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper-parent</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.1.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>worldguardwrapper-implementation</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper-implementation</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.1.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>worldguardwrapper-implementation-v6</artifactId>
|
||||
|
@ -18,7 +18,7 @@
|
|||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>worldguardwrapper-api</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.1.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -72,10 +72,12 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
return queryValue(player, location, wrappedFlag);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Optional<IWrappedFlag<?>> getFlag(String name) {
|
||||
public <T> Optional<IWrappedFlag<T>> getFlag(String name, Class<T> type) {
|
||||
return Optional.ofNullable(flagRegistry.get(name))
|
||||
.map(WrappedFlag::new);
|
||||
.map(flag -> (IWrappedFlag<T>) new WrappedFlag(flag));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper-implementation</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.1.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>worldguardwrapper-implementation-v7</artifactId>
|
||||
|
@ -18,7 +18,7 @@
|
|||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>worldguardwrapper-api</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.1.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -76,10 +76,11 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
return queryValue(player, location, wrappedFlag);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Optional<IWrappedFlag<?>> getFlag(String name) {
|
||||
public <T> Optional<IWrappedFlag<T>> getFlag(String name, Class<T> type) {
|
||||
return Optional.ofNullable(flagRegistry.get(name))
|
||||
.map(WrappedFlag::new);
|
||||
.map(flag -> (IWrappedFlag<T>) new WrappedFlag(flag));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper-parent</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.1.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>worldguardwrapper</artifactId>
|
||||
|
@ -18,18 +18,18 @@
|
|||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>worldguardwrapper-api</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.1.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>worldguardwrapper-implementation-v6</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.1.1-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>worldguardwrapper-implementation-v7</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.1.1-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
Loading…
Reference in New Issue
Block a user