diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml
index 08b1385c8..4bd363698 100644
--- a/PlotSquared/pom.xml
+++ b/PlotSquared/pom.xml
@@ -8,7 +8,7 @@
UTF-8
PlotSquared
- 2.7.1
+ 2.7.2
PlotSquared
jar
@@ -45,6 +45,10 @@
bukkit-repo
http://repo.bukkit.org/content/groups/public/
+
+ empcraft-repo
+ http://empcraft.com/maven2
+
spigot-repo
https://hub.spigotmc.org/nexus/content/groups/public/
@@ -73,6 +77,11 @@
bukkit
1.8-R0.1-SNAPSHOT
+
+ com.gmail.filoghost.holographicdisplays
+ HolographicDisplays
+ 2.1.4
+
net.milkbowl.vault
Vault
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
index 5bee25e2a..3593e38cd 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
@@ -21,18 +21,35 @@
package com.intellectualcrafters.plot.database;
-import com.intellectualcrafters.plot.PlotMain;
-import com.intellectualcrafters.plot.flag.Flag;
-import com.intellectualcrafters.plot.flag.FlagManager;
-import com.intellectualcrafters.plot.object.*;
-import com.intellectualcrafters.plot.util.ClusterManager;
-import com.intellectualcrafters.plot.util.TaskManager;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.block.Biome;
-import java.sql.*;
-import java.util.*;
+import com.intellectualcrafters.plot.PlotMain;
+import com.intellectualcrafters.plot.flag.Flag;
+import com.intellectualcrafters.plot.flag.FlagManager;
+import com.intellectualcrafters.plot.object.BlockLoc;
+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;
+import com.intellectualcrafters.plot.util.ClusterManager;
+import com.intellectualcrafters.plot.util.TaskManager;
/**
* @author Citymonstret
@@ -741,54 +758,26 @@ public class SQLManager implements AbstractDB {
@Override
public void run() {
/*
- update ticket
- set ticket_index = case when ticket_index = :x then :y else :x end
- where ticket_index in (:x, :y);
-
- FROM
- http://stackoverflow.com/questions/6018374/swap-two-rows-using-sql-query
-
+ * We don't need to actually swap all the rows
+ * - Just switch the plot_id_x and plot_id_z
+ * - The other tables reference the `id` so it will cascade
*/
try {
- PreparedStatement stmt = SQLManager.this.connection.prepareStatement(
- "UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `plot_plot_id` = CASE WHEN `plot_plot_id` = ? then ? else ? END WHERE `plot_plot_id` IN (?, ?)"
- );
- int id1 = getId(p1.getWorld().getName(), p1.id), id2 = getId(p2.getWorld().getName(), p2.id);
- stmt.setInt(1, id1);
- stmt.setInt(2, id2);
+ String world = p1.world;
+ int id1 = getId(world, p1.id);
+ int id2 = getId(world, p2.id);
+ PlotId pos1 = p1.getId();
+ PlotId pos2 = p2.getId();
+ PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
+ stmt.setInt(1, pos2.x);
+ stmt.setInt(2, pos2.y);
stmt.setInt(3, id1);
- stmt.setInt(4, id1);
- stmt.setInt(5, id2);
stmt.executeUpdate();
stmt.close();
- stmt = SQLManager.this.connection.prepareStatement(
- "UPDATE `" + SQLManager.this.prefix + "plot_helpers` SET `plot_plot_id` = CASE WHEN `plot_plot_id` = ? then ? else ? END WHERE `plot_plot_id` IN (?, ?)"
- );
- stmt.setInt(1, id1);
- stmt.setInt(2, id2);
- stmt.setInt(3, id1);
- stmt.setInt(4, id1);
- stmt.setInt(5, id2);
- stmt.executeUpdate();
- stmt.close();
- stmt = SQLManager.this.connection.prepareStatement(
- "UPDATE `" + SQLManager.this.prefix + "plot_denied` SET `plot_plot_id` = CASE WHEN `plot_plot_id` = ? then ? else ? END WHERE `plot_plot_id` IN (?, ?)"
- );
- stmt.setInt(1, id1);
- stmt.setInt(2, id2);
- stmt.setInt(3, id1);
- stmt.setInt(4, id1);
- stmt.setInt(5, id2);
- stmt.executeUpdate();
- stmt.close();
- stmt = SQLManager.this.connection.prepareStatement(
- "UPDATE `" + SQLManager.this.prefix + "plot_trusted` SET `plot_plot_id` = CASE WHEN `plot_plot_id` = ? then ? else ? END WHERE `plot_plot_id` IN (?, ?)"
- );
- stmt.setInt(1, id1);
- stmt.setInt(2, id2);
- stmt.setInt(3, id1);
- stmt.setInt(4, id1);
- stmt.setInt(5, id2);
+ stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
+ stmt.setInt(1, pos1.x);
+ stmt.setInt(2, pos1.y);
+ stmt.setInt(3, id2);
stmt.executeUpdate();
stmt.close();
} catch (final Exception e) {