diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java index c4a440c76..256f41c32 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java @@ -1,6 +1,7 @@ package com.intellectualcrafters.plot.listeners; -import org.bukkit.Location; +import java.util.UUID; + import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -9,13 +10,17 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class PlayerEvents_1_8 extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onInteract(final PlayerInteractAtEntityEvent e) { - final Location l = e.getRightClicked().getLocation(); + final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation()); if (isPlotWorld(l)) { final Player p = e.getPlayer(); if (!isInPlot(l)) { @@ -24,17 +29,20 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { e.setCancelled(true); } } else { - final Plot plot = getCurrentPlot(l); + final Plot plot = PlotHelper.getPlot(l); if ((plot == null) || !plot.hasOwner()) { if (!BukkitMain.hasPermission(p, "plots.admin.interact.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); e.setCancelled(true); } - } else if (!plot.hasRights(p)) { - if (!BukkitMain.hasPermission(p, "plots.admin.interact.other")) { - if (isPlotArea(l)) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); - e.setCancelled(true); + } else { + UUID uuid = UUIDHandler.getUUID(p); + if (!plot.isAdded(uuid)) { + if (!BukkitMain.hasPermission(p, "plots.admin.interact.other")) { + if (isPlotArea(l)) { + PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); + e.setCancelled(true); + } } } }