diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2892e811..1a8828e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,7 @@ jobs: bluemap | suggests | * dynmap | suggests | * pl3xmap | suggests | * - plan | suggests | * + plan-player-analytics | suggests | * files-primary: target/HuskHomes-Plugin-*.jar name: HuskHomes (Spigot) v${{ env.version_name }} version: ${{ env.version_name }} @@ -95,7 +95,7 @@ jobs: fabric-api | requires | * bluemap | suggests | * dynmap | suggests | * - plan | suggests | * + plan-player-analytics | suggests | * luckperms | suggests | * files-primary: target/HuskHomes-Fabric-*.jar name: HuskHomes (Fabric) v${{ env.version_name }} @@ -117,7 +117,7 @@ jobs: with: name: HuskHomes (Sponge) path: target/HuskHomes-Sponge-*.jar - - name: Upload GitHub Artifact + - name: Upload GitHub Artifact (Fabric) uses: actions/upload-artifact@v2 with: name: HuskHomes (Fabric) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a57aece..65cb05f4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -110,7 +110,7 @@ jobs: with: name: HuskHomes (Sponge) path: target/HuskHomes-Sponge-*.jar - - name: Upload GitHub Artifact + - name: Upload GitHub Artifact (Fabric) uses: actions/upload-artifact@v2 with: name: HuskHomes (Fabric) diff --git a/fabric/src/main/java/net/william278/huskhomes/command/FabricCommand.java b/fabric/src/main/java/net/william278/huskhomes/command/FabricCommand.java index 1d5b2e55..5fbb0bac 100644 --- a/fabric/src/main/java/net/william278/huskhomes/command/FabricCommand.java +++ b/fabric/src/main/java/net/william278/huskhomes/command/FabricCommand.java @@ -75,10 +75,10 @@ public class FabricCommand { // Register aliases final LiteralCommandNode node = dispatcher.register(builder); - dispatcher.register(literal("huskhomes:" + command.getName()).executes(getBrigadierExecutor()) - .requires(predicate).redirect(node)); - command.getAliases().forEach(alias -> dispatcher.register(literal(alias).executes(getBrigadierExecutor()) - .requires(predicate).redirect(node))); + dispatcher.register(literal("huskhomes:" + command.getName()) + .requires(predicate).executes(getBrigadierExecutor()).redirect(node)); + command.getAliases().forEach(alias -> dispatcher.register(literal(alias) + .requires(predicate).executes(getBrigadierExecutor()).redirect(node))); } private com.mojang.brigadier.Command getBrigadierExecutor() { diff --git a/sponge/src/main/java/net/william278/huskhomes/util/SpongeSafetyResolver.java b/sponge/src/main/java/net/william278/huskhomes/util/SpongeSafetyResolver.java index 2fba35be..61be26f7 100644 --- a/sponge/src/main/java/net/william278/huskhomes/util/SpongeSafetyResolver.java +++ b/sponge/src/main/java/net/william278/huskhomes/util/SpongeSafetyResolver.java @@ -21,6 +21,10 @@ package net.william278.huskhomes.util; import net.william278.huskhomes.position.Location; import org.jetbrains.annotations.NotNull; +import org.spongepowered.api.block.BlockState; +import org.spongepowered.api.registry.RegistryTypes; +import org.spongepowered.api.world.server.ServerLocation; +import org.spongepowered.math.vector.Vector3i; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -29,7 +33,28 @@ public interface SpongeSafetyResolver extends SafetyResolver { @Override default CompletableFuture> findSafeGroundLocation(@NotNull Location location) { - return CompletableFuture.completedFuture(Optional.of(location)); // todo + final Optional adaptedLocation = SpongeAdapter.adaptLocation(location); + if (adaptedLocation.isEmpty()) { + return CompletableFuture.completedFuture(Optional.empty()); + } + + final ServerLocation serverLocation = adaptedLocation.get(); + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + final Vector3i cursor = serverLocation.asHighestLocation().blockPosition().add(x, 0, z); + final BlockState blockState = serverLocation.world().block(cursor); + if (isBlockSafe(blockState.type().key(RegistryTypes.BLOCK_TYPE).asString())) { + return CompletableFuture.completedFuture(Optional.of(Location.at( + cursor.x() + 0.5, + cursor.y() + 1, + cursor.z() + 0.5, + location.getWorld() + ))); + } + } + } + + return CompletableFuture.completedFuture(Optional.empty()); } -} +} \ No newline at end of file