/** * {@inheritDoc} */ @Override public Location getLocation(Entity entity) { if (entity instanceof Player) { if (this.playername.isEmpty()) this.knownBedLoc = this.plugin.getBlockSafety().getSafeBedSpawn(((Player) entity).getBedSpawnLocation()); else this.knownBedLoc = this.plugin.getBlockSafety().getSafeBedSpawn(Bukkit.getOfflinePlayer(this.playername).getBedSpawnLocation()); if (this.knownBedLoc == null) { ((Player) entity).sendMessage("The bed was " + ChatColor.RED + "invalid or blocked" + ChatColor.RESET + ". Sorry."); } return this.knownBedLoc; } return null; }
if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) { return true; if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) { return true; if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) { return true; if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) { return true; if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) { return true; if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) { return true;
public Location getSafeLocation(Entity e, MVDestination d) { Location l = d.getLocation(e); if (plugin.getBlockSafety().playerCanSpawnHereSafely(l)) { plugin.log(Level.FINE, "The first location you gave me was safe."); return l; if (!plugin.getBlockSafety().canSpawnCartSafely(m)) { return null; if (!plugin.getBlockSafety().canSpawnVehicleSafely(v)) { return null; if (safeLocation != null) { if (e instanceof Minecart && !plugin.getBlockSafety().isEntitiyOnTrack(safeLocation)) { safeLocation.setY(safeLocation.getBlockY() + .5); this.plugin.log(Level.FINER, "Player was inside a minecart. Offsetting Y location.");
@Override public Location validateChange(String property, Location newValue, Location oldValue, MVWorld object) throws ChangeDeniedException { if (newValue == null) throw new ChangeDeniedException(); if (props.getAdjustSpawn()) { BlockSafety bs = plugin.getBlockSafety(); // verify that the location is safe if (!bs.playerCanSpawnHereSafely(newValue)) { // it's not ==> find a better one! plugin.log(Level.WARNING, String.format("Somebody tried to set the spawn location for '%s' to an unsafe value! Adjusting...", getAlias())); plugin.log(Level.WARNING, "Old Location: " + plugin.getLocationManipulation().strCoordsRaw(oldValue)); plugin.log(Level.WARNING, "New (unsafe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue)); SafeTTeleporter teleporter = plugin.getSafeTTeleporter(); newValue = teleporter.getSafeLocation(newValue, SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS); if (newValue == null) { plugin.log(Level.WARNING, "Couldn't fix the location. I have to abort the spawn location-change :/"); throw new ChangeDeniedException(); } plugin.log(Level.WARNING, "New (safe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue)); } } return super.validateChange(property, newValue, oldValue, object); } }
private Location readSpawnFromWorld(World w) { Location location = w.getSpawnLocation(); BlockSafety bs = this.plugin.getBlockSafety();
if (foundWorld != null) { foundWorld.setSpawnLocation(p.getLocation()); BlockSafety bs = this.plugin.getBlockSafety(); if (!bs.playerCanSpawnHereSafely(p.getLocation()) && foundWorld.getAdjustSpawn()) { sender.sendMessage("It looks like that location would normally be unsafe. But I trust you.");