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
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ tasks {
finalizedBy(rootProject.tasks.jacocoTestReport)
}
runServer {
minecraftVersion("26.2")
minecraftVersion("26.3")
jvmArgs("-Dcom.mojang.eula.agree=true")
}
jacocoTestReport {
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencyResolutionManagement {
create("libs") {

version("hibernate", "7.3.13.Final")
version("paper", "26.1.2.build.+")
version("paper", "26.3.build.+")
version("luckperms", "5.5")
version("protocolLib", "5.3.0")
version("bluemapApi", "2.8.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import org.bukkit.entity.Player;
import org.incendo.cloud.SenderMapper;
import org.jetbrains.annotations.NotNull;
import org.jspecify.annotations.NonNull;


@SuppressWarnings("UnstableApiUsage")
public class BukkitSenderMapper implements SenderMapper<CommandSourceStack, CommandSender> {
private final ConsoleSenderMapper consoleSenderMapper = new ConsoleSenderMapper();

Expand All @@ -33,7 +33,7 @@ public class BukkitSenderMapper implements SenderMapper<CommandSourceStack, Comm
return new BlockSenderMapper((BlockCommandSender) mapped);
}

@SuppressWarnings({"UnstableApiUsage", "NonExtendableApiUsage"})
@SuppressWarnings({"NonExtendableApiUsage"})
private record BlockSenderMapper(BlockCommandSender blockCommandSender) implements CommandSourceStack {

@Override
Expand All @@ -51,6 +51,25 @@ public Entity getExecutor() {
return null;
}

@Override
public @NonNull Player getPlayerOrThrow() {
return getLocation().getNearbyEntitiesByType(Player.class, 16)
.stream()
.filter(player -> player.getLocation().distance(getLocation()) <= 1.0D)
.findFirst()
.orElseThrow();
}

@Override
public @NonNull Entity getEntityOrThrow() {
return getLocation().getNearbyEntitiesByType(Entity.class, 16)
.stream()
.filter(entity -> entity.getLocation().distance(getLocation()) <= 1.0D)
.findFirst()
.orElseThrow();
}


@Override
public @NotNull CommandSourceStack withLocation(@NotNull Location location) {
return this;
Expand All @@ -62,7 +81,7 @@ public Entity getExecutor() {
}
}

@SuppressWarnings({"UnstableApiUsage", "NonExtendableApiUsage"})
@SuppressWarnings({"NonExtendableApiUsage"})
private static class ConsoleSenderMapper implements CommandSourceStack {
@Override
public @NotNull Location getLocation() {
Expand All @@ -79,6 +98,16 @@ public Entity getExecutor() {
return null;
}

@Override
public @NonNull Player getPlayerOrThrow() {
throw new IllegalCallerException("A Console cannot be an Player.");
}

@Override
public @NonNull Entity getEntityOrThrow() {
throw new IllegalCallerException("A Console cannot be an Entity.");
}

@Override
public @NotNull CommandSourceStack withLocation(@NotNull Location location) {
return this;
Expand All @@ -90,7 +119,7 @@ public Entity getExecutor() {
}
}

@SuppressWarnings({"UnstableApiUsage", "NonExtendableApiUsage"})
@SuppressWarnings({"NonExtendableApiUsage"})
private record PlayerSenderMapper(Player player) implements CommandSourceStack {

@Override
Expand All @@ -108,6 +137,16 @@ public Entity getExecutor() {
return this.player;
}

@Override
public @NonNull Player getPlayerOrThrow() {
return this.player();
}

@Override
public @NonNull Entity getEntityOrThrow() {
return this.player();
}

@Override
public @NotNull CommandSourceStack withLocation(@NotNull Location location) {
return this;
Expand Down

This file was deleted.

Loading