diff --git a/PlotSquared/src/com/intellectualcrafters/plot/FlagManager.java b/PlotSquared/src/com/intellectualcrafters/plot/FlagManager.java index 09b046beb..6b8e962cc 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/FlagManager.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/FlagManager.java @@ -13,7 +13,7 @@ public class FlagManager { // - greeting / leaving message // OR in the flag command, allow users to set worldguard flags. - private static ArrayList flags; + private static ArrayList flags = new ArrayList(); /** * Register an AbstractFlag with PlotSquared diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java index 497bd54c0..d8bc45812 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java @@ -781,10 +781,10 @@ public class PlotHelper { state = h; if ((pos2.getBlockX() - pos1.getBlockX()) < 16) { - setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), 1, pos2.getBlockZ()), (short) 7); - setSimpleCuboid(world, new Location(world, pos1.getBlockX(), plotworld.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), world.getMaxHeight(), pos2.getBlockZ()), (short) 0); - setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), plotworld.PLOT_HEIGHT, pos2.getBlockZ()), filling, filling_data); - setCuboid(world, new Location(world, pos1.getBlockX(), plotworld.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), plotworld.PLOT_HEIGHT + 1, pos2.getBlockZ()), plotfloors, plotfloors_data); + setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), (short) 7); + setSimpleCuboid(world, new Location(world, pos1.getBlockX(), plotworld.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), (short) 0); + setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, plotworld.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling, filling_data); + setCuboid(world, new Location(world, pos1.getBlockX(), plotworld.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, plotworld.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloors, plotfloors_data); PlayerFunctions.sendMessage(requester, "&c(depreciated) &r" + C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.nanoTime() - start) / 1000000.0))); return; } @@ -830,52 +830,52 @@ public class PlotHelper { } } -// if (min == null) { - setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), 1, pos2.getBlockZ()), (short) 7); - setSimpleCuboid(world, new Location(world, pos1.getBlockX(), plotworld.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), world.getMaxHeight(), pos2.getBlockZ()), (short) 0); - setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), plotworld.PLOT_HEIGHT, pos2.getBlockZ()), filling, filling_data); - setCuboid(world, new Location(world, pos1.getBlockX(), plotworld.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), plotworld.PLOT_HEIGHT + 1, pos2.getBlockZ()), plotfloors, plotfloors_data); -// } else { -// setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getBlockX(), 1, min.getBlockZ()), (short) 7); -// setSimpleCuboid(world, new Location(world, plotMinX, plotworld.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getBlockX(), world.getMaxHeight(), min.getBlockZ()), (short) 0); -// setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT, min.getBlockZ()), filling, filling_data); -// setCuboid(world, new Location(world, plotMinX, plotworld.PLOT_HEIGHT, plotMinZ), new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT + 1, min.getBlockZ()), plotfloors, plotfloors_data); -// -// setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, plotMinZ), new Location(world, max.getBlockX(), 1, min.getBlockZ()), (short) 7); -// setSimpleCuboid(world, new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getBlockX(), world.getMaxHeight(), min.getBlockZ()), (short) 0); -// setCuboid(world, new Location(world, min.getBlockX(), 1, plotMinZ), new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT, min.getBlockZ()), filling, filling_data); -// setCuboid(world, new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT, plotMinZ), new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT + 1, min.getBlockZ()), plotfloors, plotfloors_data); -// -// setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, plotMinZ), new Location(world, plotMaxX, 1, min.getBlockZ()), (short) 7); -// setSimpleCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX, world.getMaxHeight(), min.getBlockZ()), (short) 0); -// setCuboid(world, new Location(world, max.getBlockX(), 1, plotMinZ), new Location(world, plotMaxX, plotworld.PLOT_HEIGHT, min.getBlockZ()), filling, filling_data); -// setCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX, plotworld.PLOT_HEIGHT + 1, min.getBlockZ()), plotfloors, plotfloors_data); -// -// setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getBlockZ()), new Location(world, min.getBlockX(), 1, max.getBlockZ()), (short) 7); -// setSimpleCuboid(world, new Location(world, plotMinX, plotworld.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, min.getBlockX(), world.getMaxHeight(), max.getBlockZ()), (short) 0); -// setCuboid(world, new Location(world, plotMinX, 1, min.getBlockZ()), new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT, max.getBlockZ()), filling, filling_data); -// setCuboid(world, new Location(world, plotMinX, plotworld.PLOT_HEIGHT, min.getBlockZ()), new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT + 1, max.getBlockZ()), plotfloors, plotfloors_data); -// -// setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getBlockZ()), new Location(world, min.getBlockX(), 1, plotMaxZ), (short) 7); -// setSimpleCuboid(world, new Location(world, plotMinX, plotworld.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, min.getBlockX(), world.getMaxHeight(), plotMaxZ), (short) 0); -// setCuboid(world, new Location(world, plotMinX, 1, max.getBlockZ()), new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT, plotMaxZ), filling, filling_data); -// setCuboid(world, new Location(world, plotMinX, plotworld.PLOT_HEIGHT, max.getBlockZ()), new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT + 1, plotMaxZ), plotfloors, plotfloors_data); -// -// setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, max.getBlockZ()), new Location(world, max.getBlockX(), 1, plotMaxZ), (short) 7); -// setSimpleCuboid(world, new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, max.getBlockX(), world.getMaxHeight(), plotMaxZ), (short) 0); -// setCuboid(world, new Location(world, min.getBlockX(), 1, max.getBlockZ()), new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT, plotMaxZ), filling, filling_data); -// setCuboid(world, new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT, max.getBlockZ()), new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT + 1, plotMaxZ), plotfloors, plotfloors_data); -// -// setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, min.getBlockZ()), new Location(world, plotMaxX, 1, max.getBlockZ()), (short) 7); -// setSimpleCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, plotMaxX, world.getMaxHeight(), plotMaxZ), (short) 0); -// setCuboid(world, new Location(world, max.getBlockX(), 1, min.getBlockZ()), new Location(world, plotMaxX, plotworld.PLOT_HEIGHT, max.getBlockZ()), filling, filling_data); -// setCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT, min.getBlockZ()), new Location(world, plotMaxX, plotworld.PLOT_HEIGHT + 1, max.getBlockZ()), plotfloors, plotfloors_data); -// -// setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX, 1, plotMaxZ), (short) 7); -// setSimpleCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, plotMaxX, world.getMaxHeight(), plotMaxZ), (short) 0); -// setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX, plotworld.PLOT_HEIGHT, plotMaxZ), filling, filling_data); -// setCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX, plotworld.PLOT_HEIGHT + 1, plotMaxZ), plotfloors, plotfloors_data); -// } + if (min == null) { + setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), (short) 7); + setSimpleCuboid(world, new Location(world, pos1.getBlockX(), plotworld.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), (short) 0); + setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, plotworld.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling, filling_data); + setCuboid(world, new Location(world, pos1.getBlockX(), plotworld.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, plotworld.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloors, plotfloors_data); + } else { + setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getBlockX() + 1, 1, min.getBlockZ() + 1), (short) 7); + setSimpleCuboid(world, new Location(world, plotMinX, plotworld.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), (short) 0); + setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getBlockX() + 1, plotworld.PLOT_HEIGHT + 1, min.getBlockZ() + 1), filling, filling_data); + setCuboid(world, new Location(world, plotMinX, plotworld.PLOT_HEIGHT, plotMinZ), new Location(world, min.getBlockX() + 1, plotworld.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloors, plotfloors_data); + + setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, plotMinZ), new Location(world, max.getBlockX() + 1, 1, min.getBlockZ() + 1), (short) 7); + setSimpleCuboid(world, new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), (short) 0); + setCuboid(world, new Location(world, min.getBlockX(), 1, plotMinZ), new Location(world, max.getBlockX() + 1, plotworld.PLOT_HEIGHT, min.getBlockZ() + 1), filling, filling_data); + setCuboid(world, new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT, plotMinZ), new Location(world, max.getBlockX() + 1, plotworld.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloors, plotfloors_data); + + setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getBlockZ() + 1), (short) 7); + setSimpleCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), (short) 0); + setCuboid(world, new Location(world, max.getBlockX(), 1, plotMinZ), new Location(world, plotMaxX + 1, plotworld.PLOT_HEIGHT, min.getBlockZ() + 1), filling, filling_data); + setCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, plotworld.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloors, plotfloors_data); + + setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, max.getBlockZ() + 1), (short) 7); + setSimpleCuboid(world, new Location(world, plotMinX, plotworld.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), (short) 0); + setCuboid(world, new Location(world, plotMinX, 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, plotworld.PLOT_HEIGHT, max.getBlockZ() + 1), filling, filling_data); + setCuboid(world, new Location(world, plotMinX, plotworld.PLOT_HEIGHT, min.getBlockZ()), new Location(world, min.getBlockX() + 1, plotworld.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloors, plotfloors_data); + + setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, plotMaxZ + 1), (short) 7); + setSimpleCuboid(world, new Location(world, plotMinX, plotworld.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), (short) 0); + setCuboid(world, new Location(world, plotMinX, 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, plotworld.PLOT_HEIGHT, plotMaxZ + 1), filling, filling_data); + setCuboid(world, new Location(world, plotMinX, plotworld.PLOT_HEIGHT, max.getBlockZ()), new Location(world, min.getBlockX() + 1, plotworld.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloors, plotfloors_data); + + setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, max.getBlockZ()), new Location(world, max.getBlockX() + 1, 1, plotMaxZ + 1), (short) 7); + setSimpleCuboid(world, new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), (short) 0); + setCuboid(world, new Location(world, min.getBlockX(), 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, plotworld.PLOT_HEIGHT, plotMaxZ + 1), filling, filling_data); + setCuboid(world, new Location(world, min.getBlockX(), plotworld.PLOT_HEIGHT, max.getBlockZ()), new Location(world, max.getBlockX() + 1, plotworld.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloors, plotfloors_data); + + setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, min.getBlockZ()), new Location(world, plotMaxX + 1, 1, max.getBlockZ() + 1), (short) 7); + setSimpleCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), (short) 0); + setCuboid(world, new Location(world, max.getBlockX(), 1, min.getBlockZ()), new Location(world, plotMaxX + 1, plotworld.PLOT_HEIGHT, max.getBlockZ() + 1), filling, filling_data); + setCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT, min.getBlockZ()), new Location(world, plotMaxX + 1, plotworld.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloors, plotfloors_data); + + setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), (short) 7); + setSimpleCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), (short) 0); + setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX + 1, plotworld.PLOT_HEIGHT, plotMaxZ + 1), filling, filling_data); + setCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX + 1, plotworld.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloors, plotfloors_data); + } PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.nanoTime() - start) / 1000000.0))); if (canSetFast) { SetBlockFast.update(requester); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java index c5ba0b727..64a031db8 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java @@ -93,7 +93,8 @@ public class PlotMain extends JavaPlugin { */ public static CameraAPI cameraAPI; - public static WorldGuardPlugin worldGuard; + public static WorldGuardPlugin worldGuard = null; + public static WorldGuardListener worldGuardListener = null; public static Economy economy; public static boolean useEconomy; @@ -548,7 +549,8 @@ public class PlotMain extends JavaPlugin { if (Settings.WORLDGUARD) if (getServer().getPluginManager().getPlugin("WorldGuard") != null) { worldGuard = (WorldGuardPlugin) getServer().getPluginManager().getPlugin("WorldGuard"); - getServer().getPluginManager().registerEvents(new WorldGuardListener(this), this); + worldGuardListener = new WorldGuardListener(this); + getServer().getPluginManager().registerEvents(worldGuardListener, this); } if(Settings.AUTO_CLEAR) { checkExpired(PlotMain.getMain(), true); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java index 9d7082c9a..56a334af8 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java @@ -24,7 +24,6 @@ import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; /** @@ -59,16 +58,14 @@ public class Set extends SubCommand{ builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s()); builder.append(getArgumentList(values)); PlayerFunctions.sendMessage(plr, builder.toString()); - return true; + return false; } - for(int i = 0; i < aliases.length; i++) { if(aliases[i].equalsIgnoreCase(args[0])) { args[0] = values[i]; break; } } - /* TODO: Implement option */ boolean advanced_permissions = false; if(advanced_permissions) { @@ -80,10 +77,17 @@ public class Set extends SubCommand{ if(args[0].equalsIgnoreCase("flag")) { if(args.length < 2) { - PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", StringUtils.join(FlagManager.getFlags(),"&c, &6"))); + String message = StringUtils.join(FlagManager.getFlags(),"&c, &6"); + if (PlotMain.worldGuardListener != null) { + if (message.equals("")) + message = StringUtils.join(PlotMain.worldGuardListener.str_flags,"&c, &6"); + else + message += ","+StringUtils.join(PlotMain.worldGuardListener.str_flags,"&c, &6"); + } + PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message)); return false; } - if (!FlagManager.getFlags().contains(args[1])) { + if (!FlagManager.getFlags().contains(args[1].toLowerCase()) && PlotMain.worldGuardListener != null && !PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG); return false; } @@ -93,6 +97,12 @@ public class Set extends SubCommand{ } if (args.length==2) { if (plot.settings.getFlag(args[1].toLowerCase())==null) { + if (PlotMain.worldGuardListener != null) { + if (PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) { + PlotMain.worldGuardListener.removeFlag(plr, plr.getWorld(), plot, args[1]); + return false; + } + } PlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT); return false; } @@ -115,7 +125,11 @@ public class Set extends SubCommand{ } try { String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length)," "); - Flag flag = new Flag(FlagManager.getFlag(args[1], true), value); + if (FlagManager.getFlag(args[1].toLowerCase())==null && PlotMain.worldGuardListener != null) { + PlotMain.worldGuardListener.addFlag(plr, plr.getWorld(), plot, args[1], value); + return false; + } + Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), value); PlotFlagAddEvent event = new PlotFlagAddEvent(flag,plot); Bukkit.getServer().getPluginManager().callEvent(event); if(event.isCancelled()) { @@ -338,8 +352,11 @@ public class Set extends SubCommand{ PlotHelper.adjustWallFilling(plr, plr.getWorld(), plot, (short)material.getId(), data); return true; } - PlayerFunctions.sendMessage(plr, "Not a valid option. Use {TODO: Insert list.}"); - return true; + StringBuilder builder = new StringBuilder(); + builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s()); + builder.append(getArgumentList(values)); + PlayerFunctions.sendMessage(plr, builder.toString()); + return false; } private String getMaterial(Material m) { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java index f17c4d5ba..6b1cc5a88 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -147,56 +147,61 @@ public class PlayerEvents implements Listener { @EventHandler public void PlayerMove(PlayerMoveEvent event) { - Player player = event.getPlayer(); - Location from = event.getFrom(); - Location to = event.getTo(); - if ((from.getBlockX() != to.getBlockX()) || (from.getBlockZ() != to.getBlockZ())) { - if (!isPlotWorld(player.getWorld())) { - return; - } - if (enteredPlot(event.getFrom(), event.getTo())) { - Plot plot = getCurrentPlot(event.getTo()); - if (plot.hasOwner()) { - if (C.TITLE_ENTERED_PLOT.s().length() > 2) { - String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", plot.getDisplayName()); - String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)); - ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()); - ChatColor sTitleSubColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()); - Title title = new Title(sTitleMain, sTitleSub, 10, 20, 10); - title.setTitleColor(sTitleMainColor); - title.setSubtitleColor(sTitleSubColor); - title.setTimingsToTicks(); - title.send(player); + try { + Player player = event.getPlayer(); + Location from = event.getFrom(); + Location to = event.getTo(); + if ((from.getBlockX() != to.getBlockX()) || (from.getBlockZ() != to.getBlockZ())) { + if (!isPlotWorld(player.getWorld())) { + return; + } + if (enteredPlot(event.getFrom(), event.getTo())) { + Plot plot = getCurrentPlot(event.getTo()); + if (plot.hasOwner()) { + if (C.TITLE_ENTERED_PLOT.s().length() > 2) { + String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", plot.getDisplayName()); + String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)); + ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()); + ChatColor sTitleSubColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()); + Title title = new Title(sTitleMain, sTitleSub, 10, 20, 10); + title.setTitleColor(sTitleMainColor); + title.setSubtitleColor(sTitleSubColor); + title.setTimingsToTicks(); + title.send(player); + } + { + PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot); + Bukkit.getPluginManager().callEvent(callEvent); + } + boolean admin = player.hasPermission("plots.admin"); + + PlayerFunctions.sendMessage(player, plot.settings.getJoinMessage()); + if (plot.deny_entry(player) && !admin) { + event.setCancelled(true); + return; + } + if (plot.settings.getRain()) { + PlayerFunctions.togglePlotWeather(player, plot); + } + if (plot.settings.getChangeTime()) { + PlayerFunctions.togglePlotTime(player, plot); + } } + } else if (leftPlot(event.getFrom(), event.getTo())) { + Plot plot = getCurrentPlot(event.getFrom()); { - PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot); + PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot); Bukkit.getPluginManager().callEvent(callEvent); } - boolean admin = player.hasPermission("plots.admin"); - - PlayerFunctions.sendMessage(player, plot.settings.getJoinMessage()); - if (plot.deny_entry(player) && !admin) { - event.setCancelled(true); - return; - } - if (plot.settings.getRain()) { - PlayerFunctions.togglePlotWeather(player, plot); - } - if (plot.settings.getChangeTime()) { - PlayerFunctions.togglePlotTime(player, plot); - } + event.getPlayer().resetPlayerTime(); + event.getPlayer().resetPlayerWeather(); + PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage()); } - } else if (leftPlot(event.getFrom(), event.getTo())) { - Plot plot = getCurrentPlot(event.getFrom()); - { - PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot); - Bukkit.getPluginManager().callEvent(callEvent); - } - event.getPlayer().resetPlayerTime(); - event.getPlayer().resetPlayerWeather(); - PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage()); } } + catch (Exception e) { + // Gotta catch them all. + } } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java index 6e5bb975c..042f58f4a 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java @@ -1,7 +1,9 @@ package com.intellectualcrafters.plot.listeners; import java.util.ArrayList; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.UUID; import com.intellectualcrafters.plot.Plot; @@ -14,7 +16,9 @@ import com.intellectualcrafters.plot.events.PlotMergeEvent; import com.intellectualcrafters.plot.events.PlotUnlinkEvent; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldguard.LocalPlayer; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.domains.DefaultDomain; +import com.sk89q.worldguard.protection.flags.DefaultFlag; import com.sk89q.worldguard.protection.flags.Flag; import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; @@ -32,8 +36,55 @@ import org.bukkit.event.Listener; * Created by Citymonstret on 2014-09-24. */ public class WorldGuardListener implements Listener { + public ArrayList str_flags = new ArrayList(); + public ArrayList> flags = new ArrayList>(); + + public WorldGuardListener(PlotMain plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); + for (Flag flag:DefaultFlag.getFlags()) { + str_flags.add(flag.getName()); + flags.add(flag); + } + } + public void removeFlag(Player requester, World world, Plot plot,String key) { + boolean op = requester.isOp(); + requester.setOp(true); + try { + RegionManager manager = PlotMain.worldGuard.getRegionManager(world); + ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y); + for (Flag flag:flags) { + if (flag.getName().equalsIgnoreCase(key)) { + requester.performCommand("region flag "+(plot.id.x + "-" + plot.id.y)+" "+key); + } + } + } + catch (Exception e) { + requester.setOp(op); + } + finally { + requester.setOp(op); + } + } + + public void addFlag(Player requester, World world, Plot plot,String key, String value) { + boolean op = requester.isOp(); + requester.setOp(true); + try { + RegionManager manager = PlotMain.worldGuard.getRegionManager(world); + ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y); + for (Flag flag:flags) { + if (flag.getName().equalsIgnoreCase(key)) { + requester.performCommand("region flag "+(plot.id.x + "-" + plot.id.y)+" "+key+" "+value); + } + } + } + catch (Exception e) { + requester.setOp(op); + } + finally { + requester.setOp(op); + } } @EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)