Remove requirement for standing in the center of a block to set spawn

This commit is contained in:
Esophose 2019-04-17 20:36:12 -06:00
parent f2ad1d1481
commit a92a8abee3
2 changed files with 10 additions and 31 deletions

View File

@ -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",

View File

@ -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()) {