This commit is contained in:
boy0001 2015-02-20 18:24:23 +11:00
parent a9ef50b6bc
commit c0cf2f85cc

View File

@ -1,6 +1,7 @@
package com.intellectualcrafters.plot.listeners; package com.intellectualcrafters.plot.listeners;
import org.bukkit.Location; import java.util.UUID;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -9,13 +10,17 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.BukkitMain;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; 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.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class PlayerEvents_1_8 extends PlotListener implements Listener { public class PlayerEvents_1_8 extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void onInteract(final PlayerInteractAtEntityEvent e) { public static void onInteract(final PlayerInteractAtEntityEvent e) {
final Location l = e.getRightClicked().getLocation(); final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation());
if (isPlotWorld(l)) { if (isPlotWorld(l)) {
final Player p = e.getPlayer(); final Player p = e.getPlayer();
if (!isInPlot(l)) { if (!isInPlot(l)) {
@ -24,13 +29,15 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
e.setCancelled(true); e.setCancelled(true);
} }
} else { } else {
final Plot plot = getCurrentPlot(l); final Plot plot = PlotHelper.getPlot(l);
if ((plot == null) || !plot.hasOwner()) { if ((plot == null) || !plot.hasOwner()) {
if (!BukkitMain.hasPermission(p, "plots.admin.interact.unowned")) { if (!BukkitMain.hasPermission(p, "plots.admin.interact.unowned")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned"); PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned");
e.setCancelled(true); e.setCancelled(true);
} }
} else if (!plot.hasRights(p)) { } else {
UUID uuid = UUIDHandler.getUUID(p);
if (!plot.isAdded(uuid)) {
if (!BukkitMain.hasPermission(p, "plots.admin.interact.other")) { if (!BukkitMain.hasPermission(p, "plots.admin.interact.other")) {
if (isPlotArea(l)) { if (isPlotArea(l)) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other"); PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other");
@ -41,4 +48,5 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
} }
} }
} }
}
} }