Easier claim management on water.

If in water, shovel and stick ignore water.  Otherwise they treat water
is a solid block.  Should make creating claims on water and resizing
claims when the corner to be moved is beneath water much easier.
This commit is contained in:
ryanhamshire 2015-12-15 20:07:08 -08:00
parent f62a412932
commit 5d5584241b
2 changed files with 10 additions and 4 deletions

View File

@ -1387,6 +1387,7 @@ public abstract class DataStore
this.addDefault(defaults, Messages.BookDisabledChestClaims, " On this server, placing a chest will NOT claim land for you.", null);
this.addDefault(defaults, Messages.BookUsefulCommands, "Useful Commands:", null);
this.addDefault(defaults, Messages.NoProfanity, "Please moderate your language.", null);
this.addDefault(defaults, Messages.IsIgnoringYou, "That player is ignoring you.", null);
//load the config file
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(messagesFilePath));

View File

@ -2671,14 +2671,19 @@ class PlayerEventHandler implements Listener
static Block getTargetBlock(Player player, int maxDistance) throws IllegalStateException
{
BlockIterator iterator = new BlockIterator(player.getLocation(), player.getEyeHeight(), maxDistance);
Location eye = player.getEyeLocation();
Material eyeMaterial = eye.getBlock().getType();
boolean passThroughWater = (eyeMaterial == Material.WATER || eyeMaterial == Material.STATIONARY_WATER);
BlockIterator iterator = new BlockIterator(player.getLocation(), player.getEyeHeight(), maxDistance);
Block result = player.getLocation().getBlock().getRelative(BlockFace.UP);
while (iterator.hasNext())
{
result = iterator.next();
if(result.getType() != Material.AIR &&
result.getType() != Material.STATIONARY_WATER &&
result.getType() != Material.LONG_GRASS) return result;
Material type = result.getType();
if(type != Material.AIR &&
(!passThroughWater || type != Material.STATIONARY_WATER) &&
(!passThroughWater || type != Material.WATER) &&
type != Material.LONG_GRASS) return result;
}
return result;