Added block search when making a new island. Fixed sign text.

When finding a spot for a new island, the algorithm will ensure the
island location is on the grid and check around for any blocks that may
be there already. If they exist, then they will be added as unowned
islands to the database.
The sign text was not using the correct locale tags.
This commit is contained in:
Tastybento 2018-01-20 10:30:26 -08:00
parent 1b1e30c125
commit c3c0a87dbb
2 changed files with 51 additions and 3 deletions

View File

@ -648,10 +648,58 @@ public class IslandsManager {
return spawn.onIsland(playerLoc);
}
/**
* Checks if there is an island or blocks at this location
* @param location
* @return
*/
public boolean isIsland(Location location){
return islandCache.get(location) != null;
if (location == null)
return true;
location = getClosestIsland(location);
if (islandCache.contains(location))
return true;
if (!plugin.getSettings().isUseOwnGenerator()) {
// Block check
if (!location.getBlock().isEmpty() && !location.getBlock().isLiquid()) {
plugin.getLogger().info("Found solid block at island height - adding");
createIsland(location);
return true;
}
// Look around
for (int x = -5; x <= 5; x++) {
for (int y = 10; y <= 255; y++) {
for (int z = -5; z <= 5; z++) {
if (!location.getWorld().getBlockAt(x + location.getBlockX(), y, z + location.getBlockZ()).isEmpty()
&& !location.getWorld().getBlockAt(x + location.getBlockX(), y, z + location.getBlockZ()).isLiquid()) {
plugin.getLogger().info("Solid block found during long search - adding ");
createIsland(location);
return true;
}
}
}
}
}
return false;
}
/**
* This returns the coordinate of where an island should be on the grid.
*
* @param location location to query
* @return Location of closest island
*/
public Location getClosestIsland(Location location) {
long x = Math.round((double) location.getBlockX() / plugin.getSettings().getIslandDistance())
* plugin.getSettings().getIslandDistance() + plugin.getSettings().getIslandXOffset();
long z = Math.round((double) location.getBlockZ() / plugin.getSettings().getIslandDistance())
* plugin.getSettings().getIslandDistance() + plugin.getSettings().getIslandZOffset();
long y = plugin.getSettings().getIslandHeight();
return new Location(location.getWorld(), x, y, z);
}
/**
* @param uniqueId
* @return true if the player is the owner of their island, i.e., owner or team leader

View File

@ -481,8 +481,8 @@ public class IslandBuilder {
if (this.playerUUID != null) {
Sign sign = (Sign) blockToChange.getState();
User user = User.getInstance(playerUUID);
for (int i = 0; i < 4; i++) {
sign.setLine(i, user.getTranslation("island.sign.line" + i, "[player]", playerName));
for (int i = 1; i < 5; i++) {
sign.setLine(i, user.getTranslation("new-island.sign.line" + i, "[player]", playerName));
}
((org.bukkit.material.Sign) sign.getData()).setFacingDirection(BlockFace.NORTH);
sign.update();