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;
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);
}
}
}
}