From 5d0bb50ea8c867130ba8584a26b34456bb4703ad Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 28 Dec 2014 23:55:02 +1100 Subject: [PATCH] UUID wrapper + commands --- .../intellectualcrafters/plot/PlotMain.java | 2 + .../plot/commands/Command.java | 10 +- .../plot/commands/DebugClear.java | 93 +++++ .../plot/commands/DebugRoadRegen.java | 57 +++ .../plot/commands/MainCommand.java | 2 +- .../plot/commands/RegenAllRoads.java | 88 +++++ .../intellectualcrafters/plot/config/C.java | 1 + .../plot/config/Settings.java | 1 + .../plot/generator/HybridPlotManager.java | 362 +++++++++++++++++- .../plot/util/UUIDHandler.java | 4 + 10 files changed, 617 insertions(+), 3 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index bd2cc5dc5..a788c6762 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -868,6 +868,7 @@ import java.util.concurrent.TimeUnit; options.put("uuid.api.location", Settings.API_URL); options.put("uuid.api.custom", Settings.CUSTOM_API); options.put("uuid.fecthing", Settings.UUID_FECTHING); + options.put("UUID.read-from-disk", Settings.UUID_FROM_DISK); options.put("titles", Settings.TITLES); options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN); options.put("perm-based-mob-cap.enabled", Settings.MOB_CAP_ENABLED); @@ -898,6 +899,7 @@ import java.util.concurrent.TimeUnit; Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); Settings.OFFLINE_MODE = config.getBoolean("UUID.offline"); + Settings.UUID_FROM_DISK = config.getBoolean("UUID.read-from-disk"); Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask"); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java index a43514bc8..0409312a8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java @@ -36,10 +36,18 @@ public enum Command { // (Rating system) (ratings can be stored as the average, and number of // ratings) // - /plot rate + /** + * + */ + UNCLAIM("unclaim"), /** * */ - UNCLAIM("unclaim"), + DEBUGROADREGEN("debugroadregen"), + /** + * + */ + DEBUGCLEAR("debugclear"), /** * */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java new file mode 100644 index 000000000..af7332fa8 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -0,0 +1,93 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// 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.config.C; +import com.intellectualcrafters.plot.generator.HybridPlotManager; +import com.intellectualcrafters.plot.generator.HybridPlotWorld; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.UUIDHandler; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +public class DebugClear extends SubCommand { + + public DebugClear() { + super(Command.DEBUGCLEAR, "Clear a plot using a fast experimental algorithm", "debugclear", CommandCategory.DEBUG, false); + } + + @Override + public boolean execute(final Player plr, final String... args) { + if (plr == null) { + // Is console + if (args.length < 2) { + PlotMain.sendConsoleSenderMessage("You need to specify two arguments: ID (0;0) & World (world)"); + } else { + final PlotId id = PlotId.fromString(args[0]); + final String world = args[1]; + if (id == null) { + PlotMain.sendConsoleSenderMessage("Invalid Plot ID: " + args[0]); + } else { + if (!PlotMain.isPlotWorld(world) || !(PlotMain.getWorldSettings(world) instanceof HybridPlotWorld)) { + PlotMain.sendConsoleSenderMessage("Invalid plot world: " + world); + } else { + final Plot plot = PlotHelper.getPlot(Bukkit.getWorld(world), id); + if (plot == null) { + PlotMain.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world); + } else { + HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(world); + manager.clearPlotExperimental(Bukkit.getWorld(world), plot, false); + PlotMain.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared."); + } + } + } + } + return true; + } + + if (!PlayerFunctions.isInPlot(plr) || !(PlotMain.getWorldSettings(plr.getWorld()) instanceof HybridPlotWorld)) { + return sendMessage(plr, C.NOT_IN_PLOT); + } + final Plot plot = PlayerFunctions.getCurrentPlot(plr); + if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + return sendMessage(plr, C.UNLINK_REQUIRED); + } + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) { + return sendMessage(plr, C.NO_PLOT_PERMS); + } + assert plot != null; + HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(plr.getWorld()); + manager.clearPlotExperimental(plr.getWorld(), plot, false); + + // sign + + // wall + + return true; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java new file mode 100644 index 000000000..e04f86d4d --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -0,0 +1,57 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// 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.config.C; +import com.intellectualcrafters.plot.generator.HybridPlotManager; +import com.intellectualcrafters.plot.generator.HybridPlotWorld; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.UUIDHandler; + +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.entity.Player; + +public class DebugRoadRegen extends SubCommand { + + public DebugRoadRegen() { + super(Command.DEBUGROADREGEN, "Regenerate all road schematic in your current chunk", "debugroadregen", CommandCategory.DEBUG, true); + } + + @Override + public boolean execute(final Player player, final String... args) { + if (!(PlotMain.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) { + return sendMessage(player, C.NOT_IN_PLOT_WORLD); + } + HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(player.getWorld()); + + Chunk chunk = player.getLocation().getChunk(); + boolean result = manager.regenerateRoad(chunk); + PlayerFunctions.sendMessage(player, "&6Regenerating chunk: "+chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); + return true; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index df032b44f..158b67412 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -48,7 +48,7 @@ public class MainCommand implements CommandExecutor, TabCompleter { */ public static final String MAIN_PERMISSION = "plots.use"; - private final static SubCommand[] _subCommands = new SubCommand[]{new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand()}; + private final static SubCommand[] _subCommands = new SubCommand[]{new DebugRoadRegen(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand()}; public final static ArrayList subCommands = new ArrayList() { { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java new file mode 100644 index 000000000..e0b654bfa --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -0,0 +1,88 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// 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 java.util.ArrayList; + +import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.generator.HybridPlotManager; +import com.intellectualcrafters.plot.generator.HybridPlotWorld; +import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.PlotHelper; +import com.intellectualcrafters.plot.util.UUIDHandler; + +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.World; +import org.bukkit.entity.Player; + +public class RegenAllRoads extends SubCommand { + + public RegenAllRoads() { + super(Command.DEBUGROADREGEN, "Regenerate all road schematic in your current chunk", "debugroadregen", CommandCategory.DEBUG, false); + } + + @Override + public boolean execute(final Player player, final String... args) { + + if (player != null) { + sendMessage(player, C.NOT_CONSOLE); + return false; + } + + if (args.length != 1) { + sendMessage(player, C.NEED_PLOT_WORLD); + return false; + } + + String name = args[0]; + PlotManager manager = PlotMain.getPlotManager(name); + + if (manager == null || !(manager instanceof HybridPlotManager)) { + sendMessage(player, C.NOT_VALID_PLOT_WORLD); + return false; + } + + HybridPlotManager hpm = (HybridPlotManager) manager; + + World world = Bukkit.getWorld(name); + ArrayList chunks = hpm.getChunkChunks(world); + + PlotMain.sendConsoleSenderMessage("&6Potential chunks to update: &7"+ (chunks.size() * 256)); + PlotMain.sendConsoleSenderMessage("&6Estimated time: &7"+ (chunks.size()) + " seconds"); + + boolean result = hpm.scheduleRoadUpdate(world); + + if (!result) { + PlotMain.sendConsoleSenderMessage("&cCannot schedule mass schematic update! (Is one already in progress?)"); + return false; + } + + return true; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index e908a8652..8e1d3bb1a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -239,6 +239,7 @@ public enum C { NEED_PLOT_NUMBER("&cYou've got to specify a plot number or alias"), NEED_BLOCK("&cYou've got to specify a block"), NEED_PLOT_ID("&cYou've got to specify a plot id."), + NEED_PLOT_WORLD("&cYou've got to specify a plot world."), NEED_USER("&cYou need to specify a username"), /* * Info diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java index ef3bf019f..b7416c480 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -32,6 +32,7 @@ public class Settings { * Default UUID_FECTHING: false */ public static boolean UUID_FECTHING = false; + public static boolean UUID_FROM_DISK = false; /** * */ 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 8ec7861bd..679b147c2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -164,7 +164,8 @@ import java.util.HashSet; else { ChunkLoc loc = chunks.get(0); - System.out.print("UPDATING CHUNK: " + loc.x + ", "+loc.z + "\n - Remaining: "+chunks.size()); + PlotMain.sendConsoleSenderMessage("Updating .mcr: " + loc.x + ", "+loc.z + "(aprrox 256 chunks)"); + PlotMain.sendConsoleSenderMessage("Remaining regions: "+chunks.size()); regenerateChunkChunk(world, loc); chunks.remove(0); @@ -492,6 +493,365 @@ import java.util.HashSet; */ @Override public boolean clearPlot(final World world, final Plot plot, final boolean isDelete) { + PlotHelper.runners.put(plot, 1); + final Plugin plugin = PlotMain.getMain(); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.runners.remove(plot); + } + }, 90L); + + final HybridPlotWorld dpw = ((HybridPlotWorld) PlotMain.getWorldSettings(world)); + + final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); + final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); + + final PlotBlock[] plotfloor = dpw.TOP_BLOCK; + final PlotBlock[] filling = dpw.MAIN_BLOCK; + + // PlotBlock wall = dpw.WALL_BLOCK; + final PlotBlock wall; + + if (isDelete) { + wall = dpw.WALL_BLOCK; + } else { + wall = dpw.CLAIMED_WALL_BLOCK; + } + + final PlotBlock wall_filling = dpw.WALL_FILLING; + + final Block block = world.getBlockAt(new Location(world, pos1.getBlockX() - 1, 1, pos1.getBlockZ())); + if ((block.getTypeId() != wall_filling.id) || (block.getData() != wall_filling.data)) { + setWallFilling(world, dpw, plot.id, wall_filling); + } + + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + + final Block block = world.getBlockAt(new Location(world, pos1.getBlockX() - 1, dpw.WALL_HEIGHT + 1, pos1.getBlockZ())); + if ((block.getTypeId() != wall.id) || (block.getData() != wall.data)) { + setWall(world, dpw, plot.id, wall); + } + + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + if ((pos2.getBlockX() - pos1.getBlockX()) < 48) { + PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor); + } + }, 5L); + } + }, 5L); + } + }, 5L); + return; + } + + final int startX = (pos1.getBlockX() / 16) * 16; + final int startZ = (pos1.getBlockZ() / 16) * 16; + final int chunkX = 16 + pos2.getBlockX(); + final int chunkZ = 16 + pos2.getBlockZ(); + final Location l1 = PlotHelper.getPlotBottomLoc(world, plot.id); + final Location l2 = PlotHelper.getPlotTopLoc(world, plot.id); + final int plotMinX = l1.getBlockX() + 1; + final int plotMinZ = l1.getBlockZ() + 1; + final int plotMaxX = l2.getBlockX(); + final int plotMaxZ = l2.getBlockZ(); + Location mn = null; + Location mx = null; + for (int i = startX; i < chunkX; i += 16) { + for (int j = startZ; j < chunkZ; j += 16) { + final Plot plot1 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j)); + if ((plot1 != null) && (!plot1.getId().equals(plot.getId()))) { + break; + } + final Plot plot2 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j)); + if ((plot2 != null) && (!plot2.getId().equals(plot.getId()))) { + break; + } + final Plot plot3 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15)); + if ((plot3 != null) && (!plot3.getId().equals(plot.getId()))) { + break; + } + final Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j + 15)); + if ((plot4 != null) && (!plot4.getId().equals(plot.getId()))) { + break; + } + final Plot plot5 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15)); + if ((plot5 != null) && (!plot5.getId().equals(plot.getId()))) { + break; + } + if (mn == null) { + mn = new Location(world, Math.max(i - 1, plotMinX), 0, Math.max(j - 1, plotMinZ)); + mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ)); + } else if ((mx.getBlockZ() < (j + 15)) || (mx.getBlockX() < (i + 15))) { + mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ)); + } + world.regenerateChunk(i / 16, j / 16); + } + } + + final Location max = mx; + final Location min = mn; + + if (min == null) { + PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor); + } + }, 5L); + } + }, 5L); + } + }, 5L); + return; + } else { + + if (min.getBlockX() < plotMinX) { + min.setX(plotMinX); + } + if (min.getBlockZ() < plotMinZ) { + min.setZ(plotMinZ); + } + if (max.getBlockX() > plotMaxX) { + max.setX(plotMaxX); + } + if (max.getBlockZ() > plotMaxZ) { + max.setZ(plotMaxZ); + } + + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), filling); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); + } + }, 1L); + } + }, 1L); + } + }, 1L); + } + }, 21L); + + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, plotMinZ), new Location(world, max.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); + } + }, 1L); + } + }, 1L); + } + }, 1L); + } + }, 25L); + + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); + } + }, 1L); + } + }, 1L); + } + }, 1L); + } + }, 29L); + + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor); + } + }, 1L); + } + }, 1L); + } + }, 1L); + } + }, 33L); + + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + } + }, 1L); + } + }, 1L); + } + }, 1L); + } + }, 37L); + + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, max.getBlockZ()), new Location(world, max.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + } + }, 1L); + } + }, 1L); + } + }, 1L); + } + }, 41L); + + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, min.getBlockZ()), new Location(world, plotMaxX + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor); + } + }, 1L); + } + }, 1L); + } + }, 1L); + } + }, 45L); + + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + } + }, 1L); + } + }, 1L); + } + }, 1L); + } + }, 49L); + } + } + }, 20L); + } + }, 20L); + return true; + } + + public boolean clearPlotExperimental(final World world, final Plot plot, final boolean isDelete) { final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java index e9d97de0e..6bd190c29 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java @@ -189,6 +189,10 @@ import java.util.UUID; if ((name = getNameOnlinePlayer(uuid)) != null) { return name; } + + if (!Settings.UUID_FROM_DISK) { + return null; + } if ((name = getNameOfflinePlayer(uuid)) != null) { return name; }