mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-25 17:01:28 +01:00
Remove requirement for standing in the center of a block to set spawn
This commit is contained in:
parent
f2ad1d1481
commit
a92a8abee3
@ -92,31 +92,20 @@ public class SetSpawnCommand extends SubCommand {
|
||||
|
||||
return;
|
||||
} else {
|
||||
if (LocationUtil.isLocationCentreOfBlock(location)) {
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
if (location.getBlock().getType() != Material.AIR && location.getBlock().getType() != Materials.MOVING_PISTON.parseMaterial()) {
|
||||
location.getBlock().breakNaturally();
|
||||
}
|
||||
|
||||
if (location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType() != Material.AIR && location.getBlock().getType() != Materials.MOVING_PISTON.parseMaterial()) {
|
||||
location.clone().add(0.0D, 1.0D, 0.0D).getBlock().breakNaturally();
|
||||
}
|
||||
|
||||
islandManager.removeSpawnProtection(island.getLocation(world, environment));
|
||||
}
|
||||
}.runTask(skyblock);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad
|
||||
.getString("Command.Island.SetSpawn.Protection.Centre.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
if (location.getBlock().getType() != Material.AIR && location.getBlock().getType() != Materials.MOVING_PISTON.parseMaterial()) {
|
||||
location.getBlock().breakNaturally();
|
||||
}
|
||||
|
||||
if (location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType() != Material.AIR && location.getBlock().getType() != Materials.MOVING_PISTON.parseMaterial()) {
|
||||
location.clone().add(0.0D, 1.0D, 0.0D).getBlock().breakNaturally();
|
||||
}
|
||||
|
||||
islandManager.removeSpawnProtection(island.getLocation(world, environment));
|
||||
}
|
||||
}
|
||||
|
||||
island.setLocation(world, environment, location);
|
||||
Location newSpawnLocation = new Location(location.getWorld(), location.getBlockX() + 0.5, location.getBlockY(), location.getBlockZ() + 0.5, location.getYaw(), location.getPitch());
|
||||
island.setLocation(world, environment, newSpawnLocation);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Set.Message").replace("%spawn",
|
||||
|
@ -23,16 +23,6 @@ import java.util.logging.Level;
|
||||
|
||||
public final class LocationUtil {
|
||||
|
||||
public static boolean isLocationCentreOfBlock(Location location) {
|
||||
double x = location.getX() - location.getBlockX() - 0.5D, z = location.getZ() - location.getBlockZ() - 0.5D;
|
||||
|
||||
if (Math.abs(x) < 0.2D && Math.abs(z) < 0.2D) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isLocationLocation(Location location1, Location location2) {
|
||||
if (location1.getBlockX() == location2.getBlockX() && location1.getBlockY() == location2.getBlockY()
|
||||
&& location1.getBlockZ() == location2.getBlockZ()) {
|
||||
|
Loading…
Reference in New Issue
Block a user