Skip to content

Commit d694410

Browse files
If there is room for a player, don't tp to highest block
1 parent f5675fd commit d694410

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/main/java/me/eccentric_nz/TARDIS/commands/utils/TARDISTeleportCommand.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.bukkit.Location;
2727
import org.bukkit.World;
2828
import org.bukkit.World.Environment;
29+
import org.bukkit.block.BlockFace;
2930
import org.bukkit.command.Command;
3031
import org.bukkit.command.CommandExecutor;
3132
import org.bukkit.command.CommandSender;
@@ -90,12 +91,16 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
9091
while (!world.getChunkAt(spawn).isLoaded()) {
9192
world.getChunkAt(spawn).load();
9293
}
93-
int highest = (world.getEnvironment() == Environment.NETHER) ? spawn.getBlockY() - 1 : world.getHighestBlockYAt(spawn);
94+
int highest = spawn.getBlockY();
95+
// check if there is room for a player
96+
if (!spawn.getBlock().getType().isAir() || !spawn.getBlock().getRelative(BlockFace.UP).getType().isAir()) {
97+
highest = (world.getEnvironment() == Environment.NETHER) ? spawn.getBlockY() : world.getHighestBlockYAt(spawn) + 1;
98+
}
9499
float yaw = player.getLocation().getYaw();
95100
float pitch = player.getLocation().getPitch();
96101
spawn.setYaw(yaw);
97102
spawn.setPitch(pitch);
98-
spawn.setY(highest + 1);
103+
spawn.setY(highest);
99104
player.teleport(spawn);
100105
} else {
101106
plugin.getMessenger().sendColouredCommand(player, "WORLD_NOT_FOUND", "/tardisworld", plugin);

src/main/java/me/eccentric_nz/TARDIS/upgrades/SystemUpgradeChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public boolean has(String uuid, SystemTree upgrade) {
3333
if (!rs.fromUUID(uuid)) {
3434
return false;
3535
}
36-
// get player's artron energy level
36+
// does the player have the system upgrade for their TARDIS
3737
ResultSetSystemUpgrades rsp = new ResultSetSystemUpgrades(plugin, rs.getTardisId(), uuid);
3838
if (!rsp.resultset()) {
3939
return false;

0 commit comments

Comments
 (0)