This commit is contained in:
MattBDev 2019-05-01 12:11:35 -04:00
parent 72291b09f2
commit f72d39ed85

View File

@ -1808,7 +1808,7 @@ import org.bukkit.util.Vector;
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInteract(PlayerInteractAtEntityEvent e) { public void onInteract(PlayerInteractAtEntityEvent e) {
Entity entity = e.getRightClicked(); Entity entity = e.getRightClicked();
if (!(entity instanceof ArmorStand)) { if (!(entity instanceof ArmorStand) && !(entity instanceof ItemFrame)) {
return; return;
} }
Location location = BukkitUtil.getLocation(e.getRightClicked().getLocation()); Location location = BukkitUtil.getLocation(e.getRightClicked().getLocation());
@ -1816,25 +1816,34 @@ import org.bukkit.util.Vector;
if (area == null) { if (area == null) {
return; return;
} }
EntitySpawnListener.testNether(entity); EntitySpawnListener.testNether(entity);
Plot plot = location.getPlotAbs();
Plot plot = area.getPlotAbs(location);
PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road");
e.setCancelled(true);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
MainUtil MainUtil
.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.unowned"); .sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road");
e.setCancelled(true); e.setCancelled(true);
} }
} else { } else {
UUID uuid = pp.getUUID(); if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
if (!plot.isAdded(uuid)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER);
e.setCancelled(true);
return;
}
}
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
"plots.admin.interact.unowned");
e.setCancelled(true);
}
} else {
UUID uuid = pp.getUUID();
if (plot.isAdded(uuid)) {
return;
}
if (Flags.MISC_INTERACT.isTrue(plot)) { if (Flags.MISC_INTERACT.isTrue(plot)) {
return; return;
} }