From d0fd8f09c1ae1278becbf6f8ed8d986370f94b22 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 31 Jan 2015 09:09:16 +1100 Subject: [PATCH] various fixes --- .../plot/commands/FlagCmd.java | 11 ++++ .../plot/commands/Info.java | 1 + .../plot/flag/FlagManager.java | 10 +++- .../plot/listeners/PlayerEvents.java | 59 ++++--------------- 4 files changed, 34 insertions(+), 47 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index 038797a82..7965f5912 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -72,6 +72,17 @@ public class FlagCmd extends SubCommand { return false; } switch (args[0].toLowerCase()) { + case "info": { + if (!PlotMain.hasPermission(player, "plots.set.flag")) { + PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.info"); + return false; + } + if (args.length != 2) { + PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); + return false; + } + PlayerFunctions.sendMessage(player, "&cNot implemented."); + } case "set": { if (!PlotMain.hasPermission(player, "plots.set.flag")) { PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 8a1021929..158d80b84 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -34,6 +34,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.InfoInventory; import com.intellectualcrafters.plot.object.Plot; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 80f966345..286833ed4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -181,7 +181,15 @@ import com.intellectualcrafters.plot.object.PlotWorld; Set plotflags = settings.flags; PlotWorld plotworld = PlotMain.getWorldSettings(world); if (plotworld != null && plotworld.DEFAULT_FLAGS != null && plotworld.DEFAULT_FLAGS.length > 0) { - plotflags.addAll(Arrays.asList(plotworld.DEFAULT_FLAGS)); + HashSet flagStrings = new HashSet<>(); + for (Flag flag : plotflags) { + flagStrings.add(flag.getKey()); + } + for (Flag newflag : plotworld.DEFAULT_FLAGS) { + if (!flagStrings.contains(newflag.getKey())) { + plotflags.add(newflag); + } + } } return plotflags; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index bb16cc3d3..e43d79a93 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -46,6 +46,7 @@ import org.bukkit.entity.minecart.RideableMinecart; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockFadeEvent; @@ -254,9 +255,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Plot plot = getCurrentPlot(event.getBlock().getLocation()); if (!plot.hasOwner()) { if (PlotMain.hasPermission(player, "plots.admin.destroy.unowned")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.unowned"); return; } + PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.unowned"); event.setCancelled(true); } if (!plot.hasRights(event.getPlayer())) { @@ -266,17 +267,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (PlotMain.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.other"); return; } + PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.other"); event.setCancelled(true); } return; } if (PlotMain.hasPermission(event.getPlayer(), "plots.admin.destroy.road")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.road"); return; } + PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.road"); event.setCancelled(true); } @@ -492,6 +493,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onInteract(final PlayerInteractEvent event) { + if (event.getAction() == Action.LEFT_CLICK_BLOCK) { + return; + } Block block = event.getClickedBlock(); if (block == null) { return; @@ -505,9 +509,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Plot plot = getCurrentPlot(event.getClickedBlock().getLocation()); if (!plot.hasOwner()) { if (PlotMain.hasPermission(player, "plots.admin.interact.unowned")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.unowned"); return; } + PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.unowned"); + event.setCancelled(true); } Flag use = FlagManager.getPlotFlag(plot, "use"); if (use != null && ((HashSet) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { @@ -515,17 +520,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (!plot.hasRights(player)) { if (PlotMain.hasPermission(player, "plots.admin.interact.other")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.other"); return; } + PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.other"); event.setCancelled(true); } return; } if (PlotMain.hasPermission(player, "plots.admin.interact.road")) { - PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.road"); return; } + PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.road"); event.setCancelled(true); } @@ -867,44 +872,6 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } - @EventHandler - public void ArmorStandDestroy(EntityDamageByEntityEvent e){ - final Location l = e.getEntity().getLocation(); - if (isPlotWorld(l)) { - Entity d = e.getDamager(); - if (d instanceof Player) { - final Player p = (Player) d; - final PlotWorld pW = getPlotWorld(l.getWorld()); - if (!isInPlot(l)) { - if (!PlotMain.hasPermission(p, "plots.admin.destroy.road")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.road"); - e.setCancelled(true); - } - } else { - final Plot plot = getCurrentPlot(l); - if (plot == null || !plot.hasOwner()) { - if (!PlotMain.hasPermission(p, "plots.admin.destroy.unowned")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.unowned"); - e.setCancelled(true); - return; - } - return; - } - if (!plot.hasRights(p)) { - if (FlagManager.isPlotFlagTrue(plot, "hanging-break")) { - return; - } - if (!PlotMain.hasPermission(p, "plots.admin.destroy.other")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.destroy.other"); - e.setCancelled(true); - } - } - } - } - } - } - - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) { final Location l = e.getEntity().getLocation(); @@ -933,10 +900,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi e.setCancelled(true); return; } - } else if (aPlr && !booleanFlag(plot, "pvp", false)) { + } else if (aPlr && booleanFlag(plot, "pvp", false)) { return; } - if (!aPlr && !booleanFlag(plot, "pve", false)) { + if (!aPlr && booleanFlag(plot, "pve", false)) { return; } assert plot != null;