Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/minevalley/chestluck/api/core/Lockable.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package minevalley.chestluck.api.core;

import minevalley.chestluck.api.core.capabilities.Capability;
import minevalley.core.api.Registrant;
import org.bukkit.Location;
import org.jetbrains.annotations.Contract;
Expand Down Expand Up @@ -90,7 +91,7 @@ public interface Lockable {
*/
@Nonnull
@Contract(pure = true)
default <T> Optional<T> as(@Nonnull Class<T> capability) throws IllegalArgumentException {
default <T extends Capability> Optional<T> as(@Nonnull Class<T> capability) throws IllegalArgumentException {
if (capability == null) throw new IllegalArgumentException("Capability class cannot be null");
return capability.isInstance(this) ? Optional.of(capability.cast(this)) : Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.annotation.Nonnull;

@SuppressWarnings("unused")
public interface AutoCloseable {
public interface AutoCloseable extends Capability{

/**
* Checks whether the AutoCloseable should automatically close after it has been opened
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.annotation.Nonnull;

@SuppressWarnings("unused")
public interface AutoOpenable {
public interface AutoOpenable extends Capability {

/**
* Checks whether the AutoOpenable will automatically open for registrants.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package minevalley.chestluck.api.core.capabilities;

@SuppressWarnings("unused")
public interface Capability {

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.annotation.Nonnull;

@SuppressWarnings("unused")
public interface ItemReceiver {
public interface ItemReceiver extends Capability {

/**
* Checks whether the ItemReceiver can receive items or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.annotation.Nonnull;

@SuppressWarnings("unused")
public interface ItemSupplier {
public interface ItemSupplier extends Capability {

/**
* Checks whether the ItemReceiver can supply items or not.
Expand Down
Loading