mirror of
https://github.com/CodeMC/WorldGuardWrapper.git
synced 2025-01-18 20:22:37 +01:00
Use generics in the getFlag method
This commit is contained in:
parent
06eb96b230
commit
74399248f3
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||||
<artifactId>worldguardwrapper-parent</artifactId>
|
<artifactId>worldguardwrapper-parent</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>worldguardwrapper-api</artifactId>
|
<artifactId>worldguardwrapper-api</artifactId>
|
||||||
|
|
|
@ -40,9 +40,10 @@ public interface IWorldGuardImplementation {
|
||||||
* Returns the flag with the given name.
|
* Returns the flag with the given name.
|
||||||
*
|
*
|
||||||
* @param name The flag name
|
* @param name The flag name
|
||||||
|
* @param type The flag type
|
||||||
* @return The flag, empty if it doesn't exists
|
* @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.
|
* Registers a flag to WorldGuard's flag registry.
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||||
<artifactId>worldguardwrapper-parent</artifactId>
|
<artifactId>worldguardwrapper-parent</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>worldguardwrapper-implementation</artifactId>
|
<artifactId>worldguardwrapper-implementation</artifactId>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||||
<artifactId>worldguardwrapper-implementation</artifactId>
|
<artifactId>worldguardwrapper-implementation</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>worldguardwrapper-implementation-v6</artifactId>
|
<artifactId>worldguardwrapper-implementation-v6</artifactId>
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>worldguardwrapper-api</artifactId>
|
<artifactId>worldguardwrapper-api</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -72,10 +72,12 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||||
return queryValue(player, location, wrappedFlag);
|
return queryValue(player, location, wrappedFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public Optional<IWrappedFlag<?>> getFlag(String name) {
|
public <T> Optional<IWrappedFlag<T>> getFlag(String name, Class<T> type) {
|
||||||
return Optional.ofNullable(flagRegistry.get(name))
|
return Optional.ofNullable(flagRegistry.get(name))
|
||||||
.map(WrappedFlag::new);
|
.map(flag -> (IWrappedFlag<T>) new WrappedFlag(flag));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||||
<artifactId>worldguardwrapper-implementation</artifactId>
|
<artifactId>worldguardwrapper-implementation</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>worldguardwrapper-implementation-v7</artifactId>
|
<artifactId>worldguardwrapper-implementation-v7</artifactId>
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>worldguardwrapper-api</artifactId>
|
<artifactId>worldguardwrapper-api</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -76,10 +76,11 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||||
return queryValue(player, location, wrappedFlag);
|
return queryValue(player, location, wrappedFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public Optional<IWrappedFlag<?>> getFlag(String name) {
|
public <T> Optional<IWrappedFlag<T>> getFlag(String name, Class<T> type) {
|
||||||
return Optional.ofNullable(flagRegistry.get(name))
|
return Optional.ofNullable(flagRegistry.get(name))
|
||||||
.map(WrappedFlag::new);
|
.map(flag -> (IWrappedFlag<T>) new WrappedFlag(flag));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||||
<artifactId>worldguardwrapper-parent</artifactId>
|
<artifactId>worldguardwrapper-parent</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>worldguardwrapper</artifactId>
|
<artifactId>worldguardwrapper</artifactId>
|
||||||
|
@ -18,18 +18,18 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>worldguardwrapper-api</artifactId>
|
<artifactId>worldguardwrapper-api</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>worldguardwrapper-implementation-v6</artifactId>
|
<artifactId>worldguardwrapper-implementation-v6</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>worldguardwrapper-implementation-v7</artifactId>
|
<artifactId>worldguardwrapper-implementation-v7</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||||
<artifactId>worldguardwrapper-parent</artifactId>
|
<artifactId>worldguardwrapper-parent</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user