Decouple block safety from main class

This commit is contained in:
William committed 2023-04-13 18:58:24 +01:00
1 parent 5917de19e8
commit 28b7fbd686
6 files changed
+167 -126

No files matched your search

@@ -0,0 +1,34 @@
package net.william278.huskhomes.util;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.position.Location;
import org.jetbrains.annotations.NotNull;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
public interface SafetyResolver {
/**
* Returns a safe ground location for the specified {@link Location} if possible
*
* @param location the {@link Location} to find a safe ground location for
* @return a {@link CompletableFuture} that will complete with an optional of the safe ground position, if it is
* possible to find one
*/
CompletableFuture<Optional<Location>> findSafeGroundLocation(@NotNull Location location);
/**
* Returns if the block, by provided identifier, is unsafe
*
* @param blockId The block identifier (e.g. {@code minecraft:stone})
* @return {@code true} if the block is on the unsafe blocks list, {@code false} otherwise
*/
default boolean isBlockSafe(@NotNull String blockId) {
return !getPlugin().getUnsafeBlocks().isUnsafe(blockId);
}
@NotNull
HuskHomes getPlugin();
}