various fixes

This commit is contained in:
boy0001 2015-01-31 09:09:16 +11:00
parent c16a6c85e0
commit d0fd8f09c1
4 changed files with 34 additions and 47 deletions

View File

@ -72,6 +72,17 @@ public class FlagCmd extends SubCommand {
return false; return false;
} }
switch (args[0].toLowerCase()) { 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 <flag>");
return false;
}
PlayerFunctions.sendMessage(player, "&cNot implemented.");
}
case "set": { case "set": {
if (!PlotMain.hasPermission(player, "plots.set.flag")) { if (!PlotMain.hasPermission(player, "plots.set.flag")) {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag"); PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag");

View File

@ -34,6 +34,7 @@ import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.InfoInventory; import com.intellectualcrafters.plot.object.InfoInventory;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;

View File

@ -181,7 +181,15 @@ import com.intellectualcrafters.plot.object.PlotWorld;
Set<Flag> plotflags = settings.flags; Set<Flag> plotflags = settings.flags;
PlotWorld plotworld = PlotMain.getWorldSettings(world); PlotWorld plotworld = PlotMain.getWorldSettings(world);
if (plotworld != null && plotworld.DEFAULT_FLAGS != null && plotworld.DEFAULT_FLAGS.length > 0) { if (plotworld != null && plotworld.DEFAULT_FLAGS != null && plotworld.DEFAULT_FLAGS.length > 0) {
plotflags.addAll(Arrays.asList(plotworld.DEFAULT_FLAGS)); HashSet<String> 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; return plotflags;
} }

View File

@ -46,6 +46,7 @@ import org.bukkit.entity.minecart.RideableMinecart;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockFadeEvent; 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()); final Plot plot = getCurrentPlot(event.getBlock().getLocation());
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (PlotMain.hasPermission(player, "plots.admin.destroy.unowned")) { if (PlotMain.hasPermission(player, "plots.admin.destroy.unowned")) {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.unowned");
return; return;
} }
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.unowned");
event.setCancelled(true); event.setCancelled(true);
} }
if (!plot.hasRights(event.getPlayer())) { if (!plot.hasRights(event.getPlayer())) {
@ -266,17 +267,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return; return;
} }
if (PlotMain.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) { if (PlotMain.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.other");
return; return;
} }
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.other");
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
} }
if (PlotMain.hasPermission(event.getPlayer(), "plots.admin.destroy.road")) { if (PlotMain.hasPermission(event.getPlayer(), "plots.admin.destroy.road")) {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.road");
return; return;
} }
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.road");
event.setCancelled(true); event.setCancelled(true);
} }
@ -492,6 +493,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void onInteract(final PlayerInteractEvent event) { public static void onInteract(final PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
return;
}
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
if (block == null) { if (block == null) {
return; return;
@ -505,9 +509,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
final Plot plot = getCurrentPlot(event.getClickedBlock().getLocation()); final Plot plot = getCurrentPlot(event.getClickedBlock().getLocation());
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (PlotMain.hasPermission(player, "plots.admin.interact.unowned")) { if (PlotMain.hasPermission(player, "plots.admin.interact.unowned")) {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.unowned");
return; return;
} }
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.unowned");
event.setCancelled(true);
} }
Flag use = FlagManager.getPlotFlag(plot, "use"); Flag use = FlagManager.getPlotFlag(plot, "use");
if (use != null && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { if (use != null && ((HashSet<PlotBlock>) 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 (!plot.hasRights(player)) {
if (PlotMain.hasPermission(player, "plots.admin.interact.other")) { if (PlotMain.hasPermission(player, "plots.admin.interact.other")) {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.other");
return; return;
} }
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.other");
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
} }
if (PlotMain.hasPermission(player, "plots.admin.interact.road")) { if (PlotMain.hasPermission(player, "plots.admin.interact.road")) {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.road");
return; return;
} }
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.road");
event.setCancelled(true); 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) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) { public static void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) {
final Location l = e.getEntity().getLocation(); final Location l = e.getEntity().getLocation();
@ -933,10 +900,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
} else if (aPlr && !booleanFlag(plot, "pvp", false)) { } else if (aPlr && booleanFlag(plot, "pvp", false)) {
return; return;
} }
if (!aPlr && !booleanFlag(plot, "pve", false)) { if (!aPlr && booleanFlag(plot, "pve", false)) {
return; return;
} }
assert plot != null; assert plot != null;