From e876a93ef671ff1dad435403876459c7d579ca1c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 3 Jan 2015 01:38:04 +1100 Subject: [PATCH] Added /plot weanywhere --- .../intellectualcrafters/plot/PlotMain.java | 3 ++ .../plot/commands/Auto.java | 3 +- .../plot/commands/WE_Anywhere.java | 47 +++++++++++++++++++ .../plot/generator/HybridGen.java | 26 +++++----- .../plot/generator/HybridPlotManager.java | 2 +- .../plot/listeners/WorldEditListener.java | 5 +- 6 files changed, 71 insertions(+), 15 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index a12b6ccb9..b6988312b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -21,8 +21,10 @@ package com.intellectualcrafters.plot; +import com.intellectualcrafters.plot.api.PlotAPI; import com.intellectualcrafters.plot.commands.Auto; import com.intellectualcrafters.plot.commands.MainCommand; +import com.intellectualcrafters.plot.commands.WE_Anywhere; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.Settings; @@ -1477,6 +1479,7 @@ import java.util.concurrent.TimeUnit; PlotMain.sendConsoleSenderMessage("&c - http://builds.enginehub.org/job/worldedit"); } else { getServer().getPluginManager().registerEvents(new WorldEditListener(), this); + MainCommand.subCommands.add(new WE_Anywhere()); } } if (Settings.WORLDGUARD) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index e0d59b0ec..3c214b124 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -163,7 +163,7 @@ import org.bukkit.entity.Player; if ((size_x == 1) && (size_z == 1)) { while (!br) { final Plot plot = PlotHelper.getPlot(world, Auto.lastPlot); - if ((plot == null) || (plot.owner == null)) { + if ((plot.owner == null)) { Claim.claimPlot(plr, plot, true, true); br = true; final PlotWorld pw = PlotMain.getWorldSettings(world); @@ -212,6 +212,7 @@ import org.bukkit.entity.Player; } } } + Auto.lastPlot = new PlotId(0, 0); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java new file mode 100644 index 000000000..80ab6c117 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PlotSquared - A plot manager and world generator for the Bukkit API / +// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / +// / +// This program is free software; you can redistribute it and/or modify / +// it under the terms of the GNU General Public License as published by / +// the Free Software Foundation; either version 3 of the License, or / +// (at your option) any later version. / +// / +// This program is distributed in the hope that it will be useful, / +// but WITHOUT ANY WARRANTY; without even the implied warranty of / +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / +// GNU General Public License for more details. / +// / +// You should have received a copy of the GNU General Public License / +// along with this program; if not, write to the Free Software Foundation, / +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / +// / +// You can contact us via: support@intellectualsites.com / +//////////////////////////////////////////////////////////////////////////////////////////////////// + +package com.intellectualcrafters.plot.commands; + +import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.util.PWE; +import com.intellectualcrafters.plot.util.PlayerFunctions; + +import org.bukkit.entity.Player; + +public class WE_Anywhere extends SubCommand { + + public WE_Anywhere() { + super("weanywhere", "plots.worldedit.bypass", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true); + } + + @Override + public boolean execute(final Player plr, final String... args) { + if (PlotMain.worldEdit == null) { + PlayerFunctions.sendMessage(plr, "&cWorldEdit is not enabled on this server"); + return false; + } + PWE.removeMask(plr); + PlayerFunctions.sendMessage(plr, "&6Removed your WorldEdit mask"); + return true; + } + +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index f1b3a8e48..afaa19662 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -34,6 +34,7 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -51,7 +52,7 @@ public class HybridGen extends PlotGenerator { /** * Set to static to re-use the same managet for all Default World Generators */ - private PlotManager manager = null; + private static PlotManager manager = null; /** * Some generator specific variables (implementation dependent) @@ -146,10 +147,10 @@ public class HybridGen extends PlotGenerator { */ @Override public PlotManager getPlotManager() { - if (manager == null) { - manager = new HybridPlotManager(); + if (this.manager == null) { + this.manager = new HybridPlotManager(); } - return manager; + return this.manager; } /** @@ -220,7 +221,8 @@ public class HybridGen extends PlotGenerator { } // You can have as many populators as you would like, e.g. tree // populator, ore populator - return Arrays.asList((BlockPopulator) new HybridPop(this.plotworld)); +// return Arrays.asList((BlockPopulator) new HybridPop(this.plotworld)); + return new ArrayList<>(); } /** @@ -258,8 +260,8 @@ public class HybridGen extends PlotGenerator { int X = cx << 4; int Z = cz << 4; - short sx = (short) ((X) % this.size); - short sz = (short) ((Z) % this.size); + int sx = ((X) % this.size); + int sz = ((Z) % this.size); if (sx < 0) { sx += this.size; @@ -293,8 +295,8 @@ public class HybridGen extends PlotGenerator { return this.result; } - short sx = (short) ((cx << 4) % this.size); - short sz = (short) ((cz << 4) % this.size); + int sx = ((cx << 4) % this.size); + int sz = ((cz << 4) % this.size); if (sx < 0) { sx += this.size; @@ -310,8 +312,8 @@ public class HybridGen extends PlotGenerator { biomes.setBiome(x, z, this.biome); - short absX = (short) ((sx + x) % this.size); - short absZ = (short) ((sz + z) % this.size); + int absX = ((sx + x) % this.size); + int absZ = ((sz + z) % this.size); boolean gx = absX > pathWidthLower; boolean gz = absZ > pathWidthLower; @@ -348,7 +350,7 @@ public class HybridGen extends PlotGenerator { if (blocks != null) { for (short y : blocks.keySet()) { setBlock(this.result, x, this.roadheight + y, z, blocks.get(y)); - } + } } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index b797ce361..d58150ade 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -60,7 +60,7 @@ import java.util.HashSet; @SuppressWarnings("deprecation") public class HybridPlotManager extends PlotManager { - public RegionWrapper CURRENT_PLOT_CLEAR; + public RegionWrapper CURRENT_PLOT_CLEAR = null; public HashMap> GENERATE_BLOCKS = new HashMap<>(); public HashMap> GENERATE_DATA = new HashMap<>(); private int task; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java index 8e61c5cad..52ee9492b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -185,10 +185,13 @@ import java.util.Set; @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerJoin(final PlayerJoinEvent e) { final Player p = e.getPlayer(); + final Location l = p.getLocation(); if (PlotMain.hasPermission(p, "plots.worldedit.bypass")) { + if (isPlotWorld(l)) { + PWE.removeMask(p); + } return; } - final Location l = p.getLocation(); if (isPlotWorld(l)) { PWE.setMask(p, l); } else {