diff --git a/src/me/aleksilassila/islands/generation/IslandGeneration.java b/src/me/aleksilassila/islands/generation/IslandGeneration.java index 9801c88..51963fc 100644 --- a/src/me/aleksilassila/islands/generation/IslandGeneration.java +++ b/src/me/aleksilassila/islands/generation/IslandGeneration.java @@ -239,7 +239,7 @@ public boolean isBlockInIslandSphere(int x, int y, int z, int islandSize) { <= Math.pow(islandSize / 2.0, 2); } - public boolean isBlockInIslandCircle(int relativeX, int relativeZ, int islandSize) { + public boolean isBlockInIslandCylinder(int relativeX, int relativeZ, int islandSize) { return (Math.pow(relativeX - islandSize / 2.0, 2) + Math.pow(relativeZ - islandSize / 2.0, 2)) <= Math.pow(islandSize / 2.0, 2); } diff --git a/src/me/aleksilassila/islands/generation/IslandGrid.java b/src/me/aleksilassila/islands/generation/IslandGrid.java index 5d47a72..4add754 100644 --- a/src/me/aleksilassila/islands/generation/IslandGrid.java +++ b/src/me/aleksilassila/islands/generation/IslandGrid.java @@ -244,7 +244,7 @@ public String getBlockOwnerUUID(int x, int z) { int relativeX = x - (xIndex * islandSpacing + islandSpacing / 2 - islandSize / 2); int relativeZ = z - (zIndex * islandSpacing + islandSpacing / 2 - islandSize / 2); - boolean isInside = islands.islandGeneration.isBlockInIslandCircle(relativeX, relativeZ, islandSize); + boolean isInside = islands.islandGeneration.isBlockInIslandCylinder(relativeX + 2, relativeZ + 2, islandSize + 4); if (!isInside) return null; diff --git a/src/me/aleksilassila/islands/listeners/IslandsListener.java b/src/me/aleksilassila/islands/listeners/IslandsListener.java index 128b808..6792b58 100644 --- a/src/me/aleksilassila/islands/listeners/IslandsListener.java +++ b/src/me/aleksilassila/islands/listeners/IslandsListener.java @@ -1,6 +1,7 @@ package me.aleksilassila.islands.listeners; import me.aleksilassila.islands.Main; +import me.aleksilassila.islands.utils.Messages; import me.aleksilassila.islands.utils.Permissions; import me.aleksilassila.islands.utils.ChatUtils; import org.bukkit.ChatColor; @@ -128,7 +129,7 @@ public void onEntityDamageEvent(EntityDamageByEntityEvent e) { e.setCancelled(true); - e.getDamager().sendMessage(error("You cannot interact here.")); + e.getDamager().sendMessage(Messages.error.NOT_TRUSTED); } } } @@ -151,7 +152,7 @@ public void onPlayerInteract(PlayerInteractEvent e) { e.setCancelled(true); - e.getPlayer().sendMessage(error("You cannot interact here.")); + e.getPlayer().sendMessage(Messages.error.NOT_TRUSTED); } } } @@ -161,6 +162,7 @@ public void onPlayerInteract(PlayerInteractEvent e) { private void onBlockPlace(BlockPlaceEvent e) { if (e.isCancelled()) return; if (e.getPlayer().hasPermission(Permissions.bypass.interactEverywhere)) return; + if (e.getBlock().getWorld().equals(plugin.islandsWorld)) { int x = e.getBlock().getX(); int z = e.getBlock().getZ(); @@ -174,8 +176,9 @@ private void onBlockPlace(BlockPlaceEvent e) { e.setCancelled(true); - e.getPlayer().sendMessage(error("You cannot interact here.")); + if (ownerUUID != null) e.getPlayer().sendMessage(Messages.error.NOT_TRUSTED); } + } } } diff --git a/src/me/aleksilassila/islands/utils/Messages.java b/src/me/aleksilassila/islands/utils/Messages.java index 17aa183..66521f9 100644 --- a/src/me/aleksilassila/islands/utils/Messages.java +++ b/src/me/aleksilassila/islands/utils/Messages.java @@ -23,6 +23,7 @@ public static class error { public static final String NO_LOCATIONS_FOR_BIOME = error("No available locations for specified biome."); public static final String ISLAND_NOT_FOUND = error("404 - Home not found."); public static final String HOME_NOT_FOUND = error("404 - Home not found :("); + public static final String NOT_TRUSTED = error("You need owner's permission to interact here."); public static String COOLDOWN(int remainingTime) { return error("You took damage recently. You have to wait for " + remainingTime + "s before teleporting.");