Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-897 Fix dependency injector configuration class instance handling of plugin config #897

Merged
merged 6 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.eternalcode.core.injector.annotations.Inject;
import com.eternalcode.core.injector.annotations.component.Service;
import io.papermc.lib.PaperLib;
import lombok.extern.slf4j.Slf4j;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
Expand All @@ -17,6 +18,7 @@
import java.util.Set;
import java.util.concurrent.CompletableFuture;

@Slf4j
@Service
class RandomTeleportSafeLocationService {

Expand Down Expand Up @@ -49,8 +51,9 @@ public CompletableFuture<Location> getSafeRandomLocation(World world, RandomTele
int spawnX = spawnLocation.getBlockX();
int spawnZ = spawnLocation.getBlockZ();

int randomX = spawnX + this.random.nextInt(radius.maxX() - radius.minX() + 1) + radius.minX();
int randomZ = spawnZ + this.random.nextInt(radius.maxZ() - radius.minZ() + 1) + radius.minZ();
int randomX = this.random.nextInt(-radius.minX(), radius.maxX());
int randomZ = this.random.nextInt(-radius.minZ(), radius.maxZ());


return PaperLib.getChunkAtAsync(new Location(world, randomX, 100, randomZ)).thenCompose(chunk -> {
int randomY = chunk.getWorld().getHighestBlockYAt(randomX, randomZ);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ class RandomTeleportTaskService {

CompletableFuture<RandomTeleportResult> createTeleport(Player player) {
World world = resolveWorld(player, randomTeleportSettings);
RandomTeleportRadius radius = this.randomTeleportSettings.radius();
return this.randomTeleportSafeLocationService.getSafeRandomLocation(
world,
radius,
this.randomTeleportSettings.radius(),
this.randomTeleportSettings.teleportAttempts()
).thenCompose(location -> this.createTeleport(player, location));
}
Expand Down
Loading