mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Plot moving (possible unstable)
This commit is contained in:
parent
1a2b680359
commit
eba445cd23
@ -102,13 +102,13 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.titles.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.titles.DefaultTitle;
|
||||
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.ConsoleColors;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.Lag;
|
||||
import com.intellectualcrafters.plot.util.Logger;
|
||||
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
||||
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||
import com.intellectualcrafters.plot.util.Metrics;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
|
@ -220,7 +220,7 @@ public class Auto extends SubCommand {
|
||||
lastPlot = false;
|
||||
}
|
||||
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
|
||||
if (isUnowned(world, start, end)) {
|
||||
if (PlotHelper.isUnowned(world, start, end)) {
|
||||
for (int i = start.x; i <= end.x; i++) {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
final Plot plot = PlotHelper.getPlot(world, new PlotId(i, j));
|
||||
@ -246,17 +246,4 @@ public class Auto extends SubCommand {
|
||||
return PlotHelper.lastPlot.get(world);
|
||||
}
|
||||
|
||||
public boolean isUnowned(final World world, final PlotId pos1, final PlotId pos2) {
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final PlotId id = new PlotId(x, y);
|
||||
if (PlotMain.getPlots(world).get(id) != null) {
|
||||
if (PlotMain.getPlots(world).get(id).owner != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -32,11 +32,9 @@ import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SetBlockFast;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
@ -84,7 +82,7 @@ public class Claim extends SubCommand {
|
||||
final HybridPlotWorld pW = (HybridPlotWorld) world;
|
||||
if (!(pW.CLAIMED_WALL_BLOCK.equals(pW.WALL_BLOCK))) {
|
||||
PlotMain.getPlotManager(plot.getWorld()).setWall(plot.getWorld(), world, plot.getId(), pW.CLAIMED_WALL_BLOCK);
|
||||
PlotHelper.update(player);
|
||||
PlotHelper.update(player.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,8 @@ 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.util.AbstractSetBlock;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.SetBlockFast;
|
||||
|
||||
public class CreateRoadSchematic extends SubCommand {
|
||||
|
||||
@ -56,7 +54,7 @@ public class CreateRoadSchematic extends SubCommand {
|
||||
HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(player.getWorld());
|
||||
|
||||
manager.setupRoadSchematic(plot);
|
||||
PlotHelper.update(player);
|
||||
PlotHelper.update(player.getLocation());
|
||||
PlayerFunctions.sendMessage(player, "&6Saved new road schematic");
|
||||
|
||||
return true;
|
||||
|
@ -34,7 +34,6 @@ import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -42,11 +41,9 @@ import org.bukkit.entity.Player;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
public class DebugExec extends SubCommand {
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -28,6 +30,7 @@ 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.util.AbstractSetBlock;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
|
||||
public class DebugRoadRegen extends SubCommand {
|
||||
@ -45,6 +48,9 @@ public class DebugRoadRegen extends SubCommand {
|
||||
|
||||
Chunk chunk = player.getLocation().getChunk();
|
||||
boolean result = manager.regenerateRoad(chunk);
|
||||
if (result) {
|
||||
AbstractSetBlock.setBlockManager.update(Arrays.asList(new Chunk[] {chunk}));
|
||||
}
|
||||
PlayerFunctions.sendMessage(player, "&6Regenerating chunk: "+chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed"));
|
||||
return true;
|
||||
}
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@ -32,9 +32,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
|
||||
/**
|
||||
* PlotMain command class
|
||||
@ -48,7 +49,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
||||
*/
|
||||
public static final String MAIN_PERMISSION = "plots.use";
|
||||
|
||||
private final static SubCommand[] _subCommands = new SubCommand[]{new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), 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 Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags() };
|
||||
private final static SubCommand[] _subCommands = new SubCommand[]{new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), 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 Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move() };
|
||||
|
||||
public final static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
||||
{
|
||||
|
@ -36,10 +36,8 @@ import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.SetBlockFast;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
/**
|
||||
@ -176,10 +174,10 @@ public class Merge extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
PlayerFunctions.sendMessage(plr, "&cPlots have been merged");
|
||||
PlotHelper.mergePlots(world, plots);
|
||||
PlotHelper.mergePlots(world, plots, true);
|
||||
|
||||
PlotHelper.setSign(world, UUIDHandler.getName(plot.owner), plot);
|
||||
PlotHelper.update(plr);
|
||||
PlotHelper.update(plr.getLocation());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,103 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
/**
|
||||
* Created 2014-08-01 for PlotSquared
|
||||
*
|
||||
* @author Empire92
|
||||
*/
|
||||
public class Move extends SubCommand {
|
||||
|
||||
public Move() {
|
||||
super("move", "plots.admin", "plot moving debug test", "move", "condense", CommandCategory.DEBUG, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final Player plr, final String... args) {
|
||||
World world = plr.getWorld();
|
||||
PlotId plot1 = PlotHelper.parseId(args[0]);
|
||||
PlotId plot2 = PlotHelper.parseId(args[1]);
|
||||
if (move(world, plot1, plot2, null)) {
|
||||
PlayerFunctions.sendMessage(plr, "MOVE SUCCESS");
|
||||
}
|
||||
else {
|
||||
PlayerFunctions.sendMessage(plr, "MOVE FAILED");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean move(final World world, final PlotId current, PlotId newPlot, final Runnable whenDone) {
|
||||
Location bot1 = PlotHelper.getPlotBottomLoc(world, current);
|
||||
Location bot2 = PlotHelper.getPlotBottomLoc(world, newPlot);
|
||||
Location top = PlotHelper.getPlotTopLoc(world, current);
|
||||
final Plot currentPlot = PlotHelper.getPlot(world, current);
|
||||
if (currentPlot.owner == null) {
|
||||
return false;
|
||||
}
|
||||
Plot pos1 = PlayerFunctions.getBottomPlot(world, currentPlot);
|
||||
Plot pos2 = PlayerFunctions.getTopPlot(world, currentPlot);
|
||||
PlotId size = PlotHelper.getSize(world, currentPlot);
|
||||
if (!PlotHelper.isUnowned(world, newPlot, new PlotId(newPlot.x + size.x - 1, newPlot.y + size.y - 1))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int offset_x = newPlot.x - current.x;
|
||||
int offset_y = newPlot.y - current.y;
|
||||
ArrayList<PlotId> selection = PlayerFunctions.getPlotSelectionIds(pos1.id, pos2.id);
|
||||
String worldname = world.getName();
|
||||
for (PlotId id : selection) {
|
||||
DBFunc.movePlot(world.getName(), new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y));
|
||||
Plot plot = PlotMain.getPlots(worldname).get(id);
|
||||
PlotMain.getPlots(worldname).remove(id);
|
||||
plot.id.x += offset_x;
|
||||
plot.id.y += offset_y;
|
||||
PlotMain.getPlots(worldname).put(plot.id, plot);
|
||||
}
|
||||
ChunkManager.copyRegion(bot1, top, bot2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.clear(null, world, PlotHelper.getPlot(world, current), true);
|
||||
if (whenDone != null) {
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
@ -36,13 +36,11 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.DataCollection;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
|
||||
import com.intellectualcrafters.plot.util.SetBlockFast;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
public class Schematic extends SubCommand {
|
||||
@ -141,7 +139,7 @@ public class Schematic extends SubCommand {
|
||||
final int start = Schematic.this.counter * 5000;
|
||||
if (start > blen) {
|
||||
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
PlotHelper.update(plr);
|
||||
PlotHelper.update(plr.getLocation());
|
||||
Schematic.this.running = false;
|
||||
Bukkit.getScheduler().cancelTask(Schematic.this.task);
|
||||
return;
|
||||
|
@ -21,21 +21,19 @@
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import org.bukkit.World;
|
||||
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.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotSelection;
|
||||
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.SetBlockFast;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created 2014-08-01 for PlotSquared
|
||||
*
|
||||
@ -95,7 +93,7 @@ public class Swap extends SubCommand {
|
||||
// TODO Requires testing!!
|
||||
|
||||
PlayerFunctions.sendMessage(plr, C.SWAP_SUCCESS);
|
||||
PlotHelper.update(plr);
|
||||
PlotHelper.update(plr.getLocation());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -27,13 +27,10 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -35,10 +35,8 @@ 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.AbstractSetBlock;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.SetBlockFast;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
/**
|
||||
@ -71,7 +69,7 @@ public class Unlink extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
PlotHelper.update(plr);
|
||||
PlotHelper.update(plr.getLocation());
|
||||
} catch (final Exception e) {
|
||||
// execute(final Player plr, final String... args) {
|
||||
try {
|
||||
|
@ -21,11 +21,16 @@
|
||||
|
||||
package com.intellectualcrafters.plot.config;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualsites.translation.*;
|
||||
import com.intellectualsites.translation.bukkit.BukkitTranslation;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualsites.translation.TranslationFile;
|
||||
import com.intellectualsites.translation.TranslationLanguage;
|
||||
import com.intellectualsites.translation.TranslationManager;
|
||||
import com.intellectualsites.translation.TranslationObject;
|
||||
import com.intellectualsites.translation.YamlTranslationFile;
|
||||
import com.intellectualsites.translation.bukkit.BukkitTranslation;
|
||||
|
||||
/**
|
||||
* Captions class.
|
||||
*
|
||||
|
@ -21,11 +21,20 @@
|
||||
|
||||
package com.intellectualcrafters.plot.database;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotClusterId;
|
||||
import com.intellectualcrafters.plot.object.PlotComment;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
@ -321,4 +330,6 @@ public interface AbstractDB {
|
||||
public void createCluster(PlotCluster cluster);
|
||||
|
||||
public void resizeCluster(PlotCluster current, PlotClusterId resize);
|
||||
|
||||
public void movePlot(String world, PlotId originalPlot, PlotId newPlot);
|
||||
}
|
||||
|
@ -52,6 +52,10 @@ public class DBFunc {
|
||||
*/
|
||||
public static AbstractDB dbManager;
|
||||
|
||||
public static void movePlot(String world, PlotId originalPlot, PlotId newPlot) {
|
||||
dbManager.movePlot(world, originalPlot, newPlot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the owner of a plot
|
||||
*
|
||||
|
@ -42,7 +42,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
@ -787,6 +787,28 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) {
|
||||
TaskManager.runTask(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
int id = getId(world, originalPlot);
|
||||
PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
|
||||
stmt.setInt(1, newPlot.x);
|
||||
stmt.setInt(2, newPlot.y);
|
||||
stmt.setInt(3, id);
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlags(final String world, final Plot plot, final Set<Flag> flags) {
|
||||
|
@ -6,12 +6,10 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.object.BlockWrapper;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
@ -21,14 +21,10 @@
|
||||
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
@ -37,10 +33,18 @@ import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
|
||||
@SuppressWarnings("deprecation") public class HybridPlotManager extends ClassicPlotManager {
|
||||
|
||||
@ -174,18 +178,16 @@ import java.util.HashSet;
|
||||
int sx = loc.x << 5;
|
||||
int sz = loc.z << 5;
|
||||
|
||||
HashSet<Chunk> chunks = new HashSet<Chunk>();
|
||||
|
||||
for (int x = sx; x < sx + 32; x++) {
|
||||
for (int z = sz; z < sz + 32; z++) {
|
||||
Chunk chunk = world.getChunkAt(x, z);
|
||||
chunk.load(false);
|
||||
chunks.add(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<Chunk> chunks2 = new ArrayList<>();
|
||||
for (int x = sx; x < sx + 16; x++) {
|
||||
for (int z = sz; z < sz + 16; z++) {
|
||||
for (int x = sx; x < sx + 32; x++) {
|
||||
for (int z = sz; z < sz + 32; z++) {
|
||||
Chunk chunk = world.getChunkAt(x, z);
|
||||
chunks2.add(chunk);
|
||||
regenerateRoad(chunk);
|
||||
@ -265,10 +267,8 @@ import java.util.HashSet;
|
||||
|
||||
public boolean regenerateRoad(Chunk chunk) {
|
||||
World world = chunk.getWorld();
|
||||
|
||||
int x = chunk.getX() << 4;
|
||||
int z = chunk.getZ() << 4;
|
||||
|
||||
int ex = x + 15;
|
||||
int ez = z + 15;
|
||||
|
||||
|
@ -550,13 +550,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
}
|
||||
final PlotWorld pW = getPlotWorld(world);
|
||||
final CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason();
|
||||
if (!(reason == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG) && pW.SPAWN_EGGS) {
|
||||
if ((reason == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG) && pW.SPAWN_EGGS) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (!(reason == CreatureSpawnEvent.SpawnReason.BREEDING) && pW.SPAWN_BREEDING) {
|
||||
} else if ((reason == CreatureSpawnEvent.SpawnReason.BREEDING) && pW.SPAWN_BREEDING) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (!(reason == CreatureSpawnEvent.SpawnReason.CUSTOM) && pW.SPAWN_CUSTOM && !(event.getEntityType().getTypeId() == 30)) {
|
||||
} else if ((reason == CreatureSpawnEvent.SpawnReason.CUSTOM) && pW.SPAWN_CUSTOM && !(event.getEntityType().getTypeId() == 30)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -21,15 +21,18 @@
|
||||
|
||||
package com.intellectualcrafters.plot.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
|
||||
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import org.bukkit.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -43,7 +46,14 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.*;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
|
||||
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
/**
|
||||
* Created 2014-10-30 for PlotSquared
|
||||
|
@ -1,13 +1,14 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created 2015-02-14 for PlotSquared
|
||||
|
@ -26,11 +26,11 @@ public class PlotId {
|
||||
/**
|
||||
* x value
|
||||
*/
|
||||
public final Integer x;
|
||||
public Integer x;
|
||||
/**
|
||||
* y value
|
||||
*/
|
||||
public final Integer y;
|
||||
public Integer y;
|
||||
|
||||
/**
|
||||
* PlotId class (PlotId x,y values do not correspond to Block locations)
|
||||
|
@ -29,7 +29,6 @@ import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.SetBlockFast;
|
||||
|
||||
/**
|
||||
* Created 2014-10-12 for PlotSquared
|
||||
|
@ -15,15 +15,15 @@ import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Horse.Color;
|
||||
import org.bukkit.entity.Horse.Style;
|
||||
import org.bukkit.entity.Horse.Variant;
|
||||
import org.bukkit.entity.Rabbit.Type;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Painting;
|
||||
import org.bukkit.entity.Rabbit;
|
||||
import org.bukkit.entity.Rabbit.Type;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
@ -375,15 +375,24 @@ public class EntityWrapper {
|
||||
final Location loc = new Location(world, this.x + x_offset, this.y, this.z + z_offset);
|
||||
loc.setYaw(this.yaw);
|
||||
loc.setPitch(this.pitch);
|
||||
EntityType type = EntityType.fromId(this.id);
|
||||
if (type == EntityType.DROPPED_ITEM) {
|
||||
return world.dropItem(loc, this.stack);
|
||||
}
|
||||
if (type == EntityType.LEASH_HITCH) {
|
||||
if (this.id == -1) {
|
||||
return null;
|
||||
}
|
||||
EntityType type = EntityType.fromId(this.id);
|
||||
Entity entity;
|
||||
switch (type) {
|
||||
case DROPPED_ITEM: {
|
||||
return world.dropItem(loc, this.stack);
|
||||
}
|
||||
case PLAYER:
|
||||
case LEASH_HITCH: {
|
||||
return null;
|
||||
}
|
||||
default:
|
||||
entity = world.spawnEntity(loc, type);
|
||||
break;
|
||||
}
|
||||
|
||||
final Entity entity = world.spawnEntity(loc, type);
|
||||
if (this.depth == 0) {
|
||||
return entity;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
|
||||
@ -9,5 +9,5 @@ public abstract class AbstractSetBlock {
|
||||
|
||||
public abstract boolean set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data);
|
||||
|
||||
public abstract void update(ArrayList<Chunk> chunks);
|
||||
public abstract void update(List<Chunk> list);
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import org.bukkit.block.Skull;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -128,6 +129,56 @@ public class ChunkManager {
|
||||
|
||||
private static HashSet<EntityWrapper> entities;
|
||||
|
||||
public static boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone) {
|
||||
int relX = newPos.getBlockX() - pos1.getBlockX();
|
||||
int relZ = newPos.getBlockZ() - pos1.getBlockZ();
|
||||
RegionWrapper region = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ());
|
||||
|
||||
final World world = pos1.getWorld();
|
||||
Chunk c1 = world.getChunkAt(pos1);
|
||||
Chunk c2 = world.getChunkAt(pos2);
|
||||
|
||||
final int sx = pos1.getBlockX();
|
||||
final int sz = pos1.getBlockZ();
|
||||
final int ex = pos2.getBlockX();
|
||||
final int ez = pos2.getBlockZ();
|
||||
|
||||
final int c1x = c1.getX();
|
||||
final int c1z = c1.getZ();
|
||||
final int c2x = c2.getX();
|
||||
final int c2z = c2.getZ();
|
||||
|
||||
// Copy entities
|
||||
initMaps();
|
||||
for (int x = c1x; x <= c2x; x ++) {
|
||||
for (int z = c1z; z <= c2z; z ++) {
|
||||
Chunk chunk = world.getChunkAt(x, z);
|
||||
chunk.load(false);
|
||||
saveEntitiesIn(chunk, region);
|
||||
restoreEntities(world, relX, relZ);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy blocks
|
||||
int maxY = world.getMaxHeight();
|
||||
for (int x = sx; x <= ex; x++) {
|
||||
for (int z = sz; z <= ez; z++) {
|
||||
saveBlocks(world, maxY, x, z);
|
||||
for (int y = 1; y <= maxY; y++) {
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
int id = block.getTypeId();
|
||||
byte data = block.getData();
|
||||
AbstractSetBlock.setBlockManager.set(world, x + relX, y, z + relZ, id, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
restoreBlocks(world, relX, relZ);
|
||||
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone) {
|
||||
index.increment();
|
||||
final Plugin plugin = (Plugin) PlotMain.getMain();
|
||||
@ -190,7 +241,7 @@ public class ChunkManager {
|
||||
for (int X = 0; X < 16; X++) {
|
||||
for (int Z = 0; Z < 16; Z++) {
|
||||
if ((X + absX < sx || Z + absZ < sz) || (X + absX > ex || Z + absZ > ez)) {
|
||||
saveBlock(world, maxY, X + absX, Z + absZ);
|
||||
saveBlocks(world, maxY, X + absX, Z + absZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -200,13 +251,13 @@ public class ChunkManager {
|
||||
save = true;
|
||||
for (int Z = 0; Z < 16; Z++) {
|
||||
if ((X + absX > ex || Z + absZ > ez) || (X + absX < sx || Z + absZ < sz)) {
|
||||
saveBlock(world, maxY, X + absX, Z + absZ);
|
||||
saveBlocks(world, maxY, X + absX, Z + absZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (save) {
|
||||
saveEntities(chunk, CURRENT_PLOT_CLEAR);
|
||||
saveEntitiesOut(chunk, CURRENT_PLOT_CLEAR);
|
||||
}
|
||||
world.regenerateChunk(x, z);
|
||||
if (save) {
|
||||
@ -252,7 +303,7 @@ public class ChunkManager {
|
||||
return (x >= region.minX && x <= region.maxX && z >= region.minZ && z <= region.maxZ);
|
||||
}
|
||||
|
||||
public static void saveEntities(Chunk chunk, RegionWrapper region) {
|
||||
public static void saveEntitiesOut(Chunk chunk, RegionWrapper region) {
|
||||
for (Entity entity : chunk.getEntities()) {
|
||||
Location loc = entity.getLocation();
|
||||
int x = loc.getBlockX();
|
||||
@ -268,13 +319,29 @@ public class ChunkManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveEntitiesIn(Chunk chunk, RegionWrapper region) {
|
||||
for (Entity entity : chunk.getEntities()) {
|
||||
Location loc = entity.getLocation();
|
||||
int x = loc.getBlockX();
|
||||
int z = loc.getBlockZ();
|
||||
if (!isIn(region, x, z)) {
|
||||
continue;
|
||||
}
|
||||
if (entity.getVehicle() != null) {
|
||||
continue;
|
||||
}
|
||||
EntityWrapper wrap = new EntityWrapper(entity, (short) 2);
|
||||
entities.add(wrap);
|
||||
}
|
||||
}
|
||||
|
||||
public static void restoreEntities(World world, int x_offset, int z_offset) {
|
||||
for (EntityWrapper entity : entities) {
|
||||
try {
|
||||
entity.spawn(world, x_offset, z_offset);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.print("Failed to restore entity " + entity.x + "," + entity.y + "," + entity.z + " : " + entity.id);
|
||||
System.out.print("Failed to restore entity " + entity.x + "," + entity.y + "," + entity.z + " : " + entity.id +" : " + EntityType.fromId(entity.id));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -453,7 +520,7 @@ public class ChunkManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveBlock(World world, int maxY, int x, int z) {
|
||||
public static void saveBlocks(World world, int maxY, int x, int z) {
|
||||
HashMap<Short, Short> ids = new HashMap<>();
|
||||
HashMap<Short, Byte> datas = new HashMap<>();
|
||||
for (short y = 1; y < maxY; y++) {
|
||||
|
@ -29,6 +29,7 @@ import java.util.UUID;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.apache.logging.log4j.core.pattern.IntegerPatternConverter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
@ -51,6 +52,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
|
||||
/**
|
||||
@ -146,7 +148,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
PlayerFunctions.sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
return mergePlots(world, plotIds);
|
||||
return mergePlots(world, plotIds, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,7 +162,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
*
|
||||
* @return boolean (success)
|
||||
*/
|
||||
public static boolean mergePlots(final World world, final ArrayList<PlotId> plotIds) {
|
||||
public static boolean mergePlots(final World world, final ArrayList<PlotId> plotIds, boolean removeRoads) {
|
||||
if (plotIds.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
@ -188,19 +190,22 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
|
||||
Plot plot2 = null;
|
||||
|
||||
removeSign(world, plot);
|
||||
|
||||
if (removeRoads) {
|
||||
removeSign(world, plot);
|
||||
}
|
||||
if (lx) {
|
||||
if (ly) {
|
||||
if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) {
|
||||
changed = true;
|
||||
manager.removeRoadSouthEast(plotworld, plot);
|
||||
if (removeRoads) {
|
||||
manager.removeRoadSouthEast(plotworld, plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!plot.settings.getMerged(1)) {
|
||||
changed = true;
|
||||
plot2 = PlotMain.getPlots(world).get(new PlotId(x + 1, y));
|
||||
mergePlot(world, plot, plot2);
|
||||
mergePlot(world, plot, plot2, removeRoads);
|
||||
plot.settings.setMerged(1, true);
|
||||
plot2.settings.setMerged(3, true);
|
||||
}
|
||||
@ -209,7 +214,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
if (!plot.settings.getMerged(2)) {
|
||||
changed = true;
|
||||
plot2 = PlotMain.getPlots(world).get(new PlotId(x, y + 1));
|
||||
mergePlot(world, plot, plot2);
|
||||
mergePlot(world, plot, plot2, removeRoads);
|
||||
plot.settings.setMerged(2, true);
|
||||
plot2.settings.setMerged(0, true);
|
||||
}
|
||||
@ -239,7 +244,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
* @param lesserPlot
|
||||
* @param greaterPlot
|
||||
*/
|
||||
public static void mergePlot(final World world, final Plot lesserPlot, final Plot greaterPlot) {
|
||||
public static void mergePlot(final World world, final Plot lesserPlot, final Plot greaterPlot, boolean removeRoads) {
|
||||
final PlotManager manager = PlotMain.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
|
||||
@ -247,13 +252,17 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
if (!lesserPlot.settings.getMerged(2)) {
|
||||
lesserPlot.settings.setMerged(2, true);
|
||||
greaterPlot.settings.setMerged(0, true);
|
||||
manager.removeRoadSouth(plotworld, lesserPlot);
|
||||
if (removeRoads) {
|
||||
manager.removeRoadSouth(plotworld, lesserPlot);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!lesserPlot.settings.getMerged(1)) {
|
||||
lesserPlot.settings.setMerged(1, true);
|
||||
greaterPlot.settings.setMerged(3, true);
|
||||
manager.removeRoadEast(plotworld, lesserPlot);
|
||||
if (removeRoads) {
|
||||
manager.removeRoadEast(plotworld, lesserPlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -387,15 +396,15 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
|
||||
manager.setWall(world, plotworld, plot.id, block);
|
||||
update(player);
|
||||
update(player.getLocation());
|
||||
}
|
||||
|
||||
public static void update(Player player) {
|
||||
public static void update(Location loc) {
|
||||
ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
final int distance = Bukkit.getViewDistance();
|
||||
for (int cx = -distance; cx < distance; cx++) {
|
||||
for (int cz = -distance; cz < distance; cz++) {
|
||||
final Chunk chunk = player.getWorld().getChunkAt(player.getLocation().getChunk().getX() + cx, player.getLocation().getChunk().getZ() + cz);
|
||||
final Chunk chunk = loc.getWorld().getChunkAt(loc.getChunk().getX() + cx, loc.getChunk().getZ() + cz);
|
||||
chunks.add(chunk);
|
||||
}
|
||||
}
|
||||
@ -425,7 +434,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
final PlotId top = PlayerFunctions.getTopPlot(world, plot).id;
|
||||
plots = PlayerFunctions.getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
||||
if (ownsPlots(world, plots, player, 0)) {
|
||||
final boolean result = mergePlots(world, plots);
|
||||
final boolean result = mergePlots(world, plots, true);
|
||||
if (result) {
|
||||
merge = true;
|
||||
continue;
|
||||
@ -433,7 +442,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
}
|
||||
plots = PlayerFunctions.getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
||||
if (ownsPlots(world, plots, player, 1)) {
|
||||
final boolean result = mergePlots(world, plots);
|
||||
final boolean result = mergePlots(world, plots, true);
|
||||
if (result) {
|
||||
merge = true;
|
||||
continue;
|
||||
@ -441,7 +450,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
}
|
||||
plots = PlayerFunctions.getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
||||
if (ownsPlots(world, plots, player, 2)) {
|
||||
final boolean result = mergePlots(world, plots);
|
||||
final boolean result = mergePlots(world, plots, true);
|
||||
if (result) {
|
||||
merge = true;
|
||||
continue;
|
||||
@ -449,7 +458,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
}
|
||||
plots = PlayerFunctions.getPlotSelectionIds(new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
||||
if (ownsPlots(world, plots, player, 3)) {
|
||||
final boolean result = mergePlots(world, plots);
|
||||
final boolean result = mergePlots(world, plots, true);
|
||||
if (result) {
|
||||
merge = true;
|
||||
continue;
|
||||
@ -457,7 +466,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
}
|
||||
merge = false;
|
||||
}
|
||||
update(player);
|
||||
update(player.getLocation());
|
||||
}
|
||||
|
||||
private static boolean ownsPlots(final World world, final ArrayList<PlotId> plots, final Player player, final int dir) {
|
||||
@ -498,21 +507,33 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plot and notify the world border and plot merger
|
||||
*/
|
||||
public static boolean createPlot(final Player player, final Plot plot) {
|
||||
if (PlotHelper.worldBorder.containsKey(plot.world)) {
|
||||
updateWorldBorder(plot);
|
||||
}
|
||||
final World w = plot.getWorld();
|
||||
final Plot p = new Plot(plot.id, UUIDHandler.getUUID(player), plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
|
||||
PlotMain.updatePlot(p);
|
||||
DBFunc.createPlotAndSettings(p);
|
||||
if (PlotHelper.worldBorder.containsKey(plot.world)) {
|
||||
updateWorldBorder(plot);
|
||||
}
|
||||
World w = player.getWorld();
|
||||
UUID uuid = UUIDHandler.getUUID(player);
|
||||
Plot p = createPlotAbs(uuid, plot);
|
||||
final PlotWorld plotworld = PlotMain.getWorldSettings(w);
|
||||
if (plotworld.AUTO_MERGE) {
|
||||
autoMerge(w, p, player);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plot without notifying the merge function or world border manager
|
||||
*/
|
||||
public static Plot createPlotAbs(final UUID uuid, final Plot plot) {
|
||||
final World w = plot.getWorld();
|
||||
final Plot p = new Plot(plot.id, uuid, plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
|
||||
PlotMain.updatePlot(p);
|
||||
DBFunc.createPlotAndSettings(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
public static int getLoadedChunks(final World world) {
|
||||
return world.getLoadedChunks().length;
|
||||
@ -553,7 +574,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
manager.setWallFilling(world, plotworld, plot.id, block);
|
||||
PlayerFunctions.sendMessage(requester, C.SET_BLOCK_ACTION_FINISHED);
|
||||
update(requester);
|
||||
update(requester.getLocation());
|
||||
}
|
||||
|
||||
public static void setFloor(final Player requester, final Plot plot, final PlotBlock[] blocks) {
|
||||
@ -567,7 +588,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
PlayerFunctions.sendMessage(requester, C.SET_BLOCK_ACTION_FINISHED);
|
||||
manager.setFloor(world, plotworld, plot.id, blocks);
|
||||
update(requester);
|
||||
update(requester.getLocation());
|
||||
}
|
||||
|
||||
public static int square(final int x) {
|
||||
@ -622,7 +643,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
state = h;
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
|
||||
final Location location = PlotHelper.getPlotHomeDefault(plot);
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
if (plotworld.TERRAIN != 0) {
|
||||
runners.put(plot, 1);
|
||||
@ -649,7 +670,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
if (player != null && player.isOnline()) {
|
||||
PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start))));
|
||||
}
|
||||
update(player);
|
||||
update(location);
|
||||
}
|
||||
}, 90L);
|
||||
}
|
||||
@ -942,6 +963,30 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
||||
}
|
||||
|
||||
public static boolean isUnowned(final World world, final PlotId pos1, final PlotId pos2) {
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final PlotId id = new PlotId(x, y);
|
||||
if (PlotMain.getPlots(world).get(id) != null) {
|
||||
if (PlotMain.getPlots(world).get(id).owner != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static PlotId getSize(World world, Plot plot) {
|
||||
PlotSettings settings = plot.settings;
|
||||
if (!settings.isMerged()) {
|
||||
return new PlotId(1,1);
|
||||
}
|
||||
Plot top = PlayerFunctions.getTopPlot(world, plot);
|
||||
Plot bot = PlayerFunctions.getBottomPlot(world, plot);
|
||||
return new PlotId(top.id.x - bot.id.x + 1, top.id.y - bot.id.y + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the plot from the main class
|
||||
*
|
||||
|
@ -49,7 +49,6 @@ import com.intellectualcrafters.jnbt.StringTag;
|
||||
import com.intellectualcrafters.jnbt.Tag;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,6 @@ package com.intellectualcrafters.plot.util;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -58,7 +57,7 @@ public class SendChunk {
|
||||
ChunkCoordIntPairCon = classChunkCoordIntPair.getConstructor(int.class, int.class);
|
||||
}
|
||||
|
||||
public static void sendChunk(final ArrayList<Chunk> chunks) {
|
||||
public static void sendChunk(final List<Chunk> chunks) {
|
||||
int diffx, diffz;
|
||||
final int view = Bukkit.getServer().getViewDistance() << 4;
|
||||
for (final Chunk chunk : chunks) {
|
||||
|
@ -23,11 +23,9 @@ package com.intellectualcrafters.plot.util;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||
@ -90,7 +88,7 @@ public class SetBlockFast extends AbstractSetBlock {
|
||||
* @param player Player whose chunks we're updating
|
||||
*/
|
||||
@Override
|
||||
public void update(ArrayList<Chunk> chunks) {
|
||||
public void update(List<Chunk> chunks) {
|
||||
if (chunks.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -23,9 +23,8 @@ package com.intellectualcrafters.plot.util;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
@ -101,7 +100,7 @@ public class SetBlockFast_1_8 extends AbstractSetBlock {
|
||||
* @param player Player whose chunks we're updating
|
||||
*/
|
||||
@Override
|
||||
public void update(ArrayList<Chunk> chunks) {
|
||||
public void update(List<Chunk> chunks) {
|
||||
if (chunks.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SetBlockSlow extends AbstractSetBlock {
|
||||
|
||||
@ -27,7 +26,7 @@ public class SetBlockSlow extends AbstractSetBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ArrayList<Chunk> chunks) {
|
||||
public void update(List<Chunk> chunks) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,9 @@ public class TaskManager {
|
||||
}
|
||||
|
||||
public static void runTaskLater(final Runnable r, int delay) {
|
||||
if (r == null) {
|
||||
return;
|
||||
}
|
||||
PlotMain.getMain().getServer().getScheduler().runTaskLater(PlotMain.getMain(), r, delay);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user