diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index da181b94d..4991dd668 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -10,9 +10,13 @@
-
-
-
+
+
+
+
+
+
+
@@ -36,101 +40,107 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -153,7 +163,6 @@
-
@@ -172,7 +181,6 @@
-
@@ -183,19 +191,25 @@
-
-
-
+
+
+
+
+
+
+
+
+
@@ -236,6 +250,8 @@
+
+
@@ -308,32 +324,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -362,8 +352,6 @@
-
-
@@ -420,118 +408,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -692,7 +568,8 @@
-
+
+
1411382351159
@@ -818,11 +695,19 @@
1413045351175
1413045351175
-
+
+ 1413069528017
+ 1413069528017
+
+
+ 1413103688160
+ 1413103688160
+
+
-
+
@@ -860,6 +745,7 @@
+
@@ -871,10 +757,37 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
@@ -916,18 +827,12 @@
-
+
+
+
-
-
- file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java
- 173
-
-
-
-
@@ -936,27 +841,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -999,13 +883,6 @@
-
-
-
-
-
-
-
@@ -1020,13 +897,6 @@
-
-
-
-
-
-
-
@@ -1041,13 +911,6 @@
-
-
-
-
-
-
-
@@ -1069,13 +932,6 @@
-
-
-
-
-
-
-
@@ -1097,22 +953,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1127,13 +967,6 @@
-
-
-
-
-
-
-
@@ -1156,14 +989,6 @@
-
-
-
-
-
-
-
-
@@ -1184,7 +1009,6 @@
-
@@ -1192,7 +1016,6 @@
-
@@ -1200,7 +1023,6 @@
-
@@ -1208,15 +1030,6 @@
-
-
-
-
-
-
-
-
-
@@ -1224,7 +1037,6 @@
-
@@ -1232,7 +1044,6 @@
-
@@ -1240,7 +1051,6 @@
-
@@ -1248,7 +1058,6 @@
-
@@ -1256,7 +1065,6 @@
-
@@ -1264,7 +1072,6 @@
-
@@ -1272,7 +1079,6 @@
-
@@ -1280,7 +1086,6 @@
-
@@ -1292,30 +1097,131 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/C.java b/PlotSquared/src/com/intellectualcrafters/plot/C.java
index 9d2c9115a..82562509c 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/C.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/C.java
@@ -16,6 +16,13 @@ import org.bukkit.ChatColor;
* @author Citymonstret
*/
public enum C {
+ /*
+ Clipboard
+ */
+ CLIPBOARD_SET("&cThe current plot is now copied, use &6/plot paste&c to pate it"),
+ PASTED("&cThe plot selection was successfully pasted"),
+ PASTE_FAILED("&cFailed to paste the selection. Reason: &c%s"),
+ NO_CLIPBOARD("&cYou don't have a selection in your clipboard"),
/*
* Ratings
*/
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotSelection.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotSelection.java
new file mode 100644
index 000000000..7bc6bc511
--- /dev/null
+++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotSelection.java
@@ -0,0 +1,82 @@
+package com.intellectualcrafters.plot;
+
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.block.Block;
+
+import java.util.HashMap;
+
+/**
+ * Created by Citymonstret on 2014-10-12.
+ */
+public class PlotSelection {
+
+ public static HashMap currentSelection = new HashMap<>();
+
+ private PlotBlock[] plotBlocks;
+
+ private int width;
+
+ public PlotSelection(int width, World world, Plot plot) {
+ this.width = width;
+
+ plotBlocks = new PlotBlock[(width * width) * (world.getMaxHeight() - 1)];
+
+ Location
+ bot = PlotHelper.getPlotBottomLocAbs(world, plot.getId()),
+ top = PlotHelper.getPlotTopLocAbs(world, plot.getId());
+ int
+ minX = bot.getBlockX(),
+ maxX = top.getBlockX(),
+ minZ = bot.getBlockZ(),
+ maxZ = top.getBlockZ(),
+ minY = 1,
+ maxY = world.getMaxHeight();
+ Block current;
+
+ int index = 0;
+ for (int x = minX; x < maxX; x++) {
+ for (int z = minZ; z < maxZ; z++) {
+ for (int y = minY; y < maxY; y++) {
+ current = world.getBlockAt(x + 1, y, z + 1);
+ plotBlocks[index++] = new PlotBlock(
+ (short) current.getTypeId(),
+ current.getData()
+ );
+ }
+ }
+ }
+ //Yay :D
+ }
+
+ public PlotBlock[] getBlocks() {
+ return plotBlocks;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public void paste(World world, Plot plot) {
+ Location
+ bot = PlotHelper.getPlotBottomLocAbs(world, plot.getId()),
+ top = PlotHelper.getPlotTopLocAbs(world, plot.getId());
+ int
+ minX = bot.getBlockX(),
+ maxX = top.getBlockX(),
+ minZ = bot.getBlockZ(),
+ maxZ = top.getBlockZ(),
+ minY = 1,
+ maxY = world.getMaxHeight();
+ int index = 0;
+ PlotBlock current;
+ for (int x = minX; x < maxX; x++) {
+ for (int z = minZ; z < maxZ; z++) {
+ for (int y = minY; y < maxY; y++) {
+ current = plotBlocks[index++];
+ world.getBlockAt(x + 1, y, z + 1).setTypeIdAndData(current.id, current.data, true);
+ }
+ }
+ }
+ }
+}
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/SchematicHandler.java b/PlotSquared/src/com/intellectualcrafters/plot/SchematicHandler.java
index e2d8f9cc1..fdcae2bfa 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/SchematicHandler.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/SchematicHandler.java
@@ -1,24 +1,19 @@
package com.intellectualcrafters.plot;
+import com.sk89q.jnbt.*;
+import com.sk89q.worldedit.CuboidClipboard;
+import com.sk89q.worldedit.EditSession;
+import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.bukkit.BukkitWorld;
+import org.bukkit.Location;
+import org.bukkit.plugin.java.JavaPlugin;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Map;
import java.util.zip.GZIPInputStream;
-import org.bukkit.Location;
-import org.bukkit.plugin.java.JavaPlugin;
-
-import com.sk89q.jnbt.ByteArrayTag;
-import com.sk89q.jnbt.CompoundTag;
-import com.sk89q.jnbt.NBTInputStream;
-import com.sk89q.jnbt.ShortTag;
-import com.sk89q.jnbt.Tag;
-import com.sk89q.worldedit.CuboidClipboard;
-import com.sk89q.worldedit.EditSession;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.bukkit.BukkitWorld;
-
/**
* Created by Citymonstret on 2014-09-15.
*/
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java
index 14d8d6394..b21ec6815 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java
@@ -32,6 +32,7 @@ public enum Command {
/**
*
*/
+ PASTE("paste"),
COPY("copy"),
/**
*
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Copy.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Copy.java
index 05eefd37b..57bb142a7 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Copy.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Copy.java
@@ -8,12 +8,9 @@
package com.intellectualcrafters.plot.commands;
+import com.intellectualcrafters.plot.*;
import org.bukkit.entity.Player;
-import com.intellectualcrafters.plot.C;
-import com.intellectualcrafters.plot.PlayerFunctions;
-import com.intellectualcrafters.plot.Plot;
-
/**
* Created by Citymonstret on 2014-08-01.
*/
@@ -35,7 +32,15 @@ public class Copy extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}
- plot.clear(plr);
+ assert plot != null;
+ int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
+ PlotSelection selection = new PlotSelection(size, plr.getWorld(), plot);
+ if(PlotSelection.currentSelection.containsKey(plr.getName())) {
+ PlotSelection.currentSelection.remove(plr.getName());
+ }
+ PlotSelection.currentSelection.put(plr.getName(), selection);
+ sendMessage(plr, C.CLIPBOARD_SET);
+ //section.paste(plr.getWorld(), PlotHelper.getPlot(plr.getWorld()zs, new PlotId(plot.getId().x + 1, plot.getId().y)));
return true;
}
}
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/MainCommand.java
index 230cc2e8f..0803d842d 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/commands/MainCommand.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/MainCommand.java
@@ -8,18 +8,17 @@
package com.intellectualcrafters.plot.commands;
-import java.util.ArrayList;
-import java.util.Arrays;
-
+import com.intellectualcrafters.plot.C;
+import com.intellectualcrafters.plot.PlayerFunctions;
+import com.intellectualcrafters.plot.PlotMain;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import com.intellectualcrafters.plot.C;
-import com.intellectualcrafters.plot.PlayerFunctions;
-import com.intellectualcrafters.plot.PlotMain;
+import java.util.ArrayList;
+import java.util.Arrays;
/**
* PlotMain command class
@@ -28,7 +27,7 @@ import com.intellectualcrafters.plot.PlotMain;
*/
public class MainCommand implements CommandExecutor {
- private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Auto(), new Home(), new Visit(),
+ private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Paste(), new Copy(), 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 Reload(), new Merge(), new Unlink(), new Kick(), new Setup() };
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Paste.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Paste.java
new file mode 100644
index 000000000..43ff8d289
--- /dev/null
+++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Paste.java
@@ -0,0 +1,45 @@
+package com.intellectualcrafters.plot.commands;
+
+import com.intellectualcrafters.plot.*;
+import org.bukkit.entity.Player;
+
+/**
+ * Created by Citymonstret on 2014-10-12.
+ */
+public class Paste extends SubCommand {
+
+ public Paste() {
+ super(Command.PASTE, "Paste a plot", "paste", CommandCategory.ACTIONS);
+ }
+
+ @Override
+ public boolean execute(Player plr, String... args) {
+ if (!PlayerFunctions.isInPlot(plr)) {
+ PlayerFunctions.sendMessage(plr, "You're not in a plot.");
+ return false;
+ }
+ Plot plot = PlayerFunctions.getCurrentPlot(plr);
+ if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))
+ && !plr.hasPermission("plots.admin")) {
+ PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
+ return false;
+ }
+ assert plot != null;
+ int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
+
+ if(PlotSelection.currentSelection.containsKey(plr.getName())) {
+ PlotSelection selection = PlotSelection.currentSelection.get(plr.getName());
+ if(size != selection.getWidth()) {
+ sendMessage(plr, C.PASTE_FAILED, "The size of the current plot is not the same as the paste");
+ return false;
+ }
+ selection.paste(plr.getWorld(), plot);
+ sendMessage(plr, C.PASTED);
+ } else {
+ sendMessage(plr, C.NO_CLIPBOARD);
+ return false;
+ }
+ PlotSelection.currentSelection.remove(plr.getName());
+ return true;
+ }
+}