Update POM and potential fix for swap

This commit is contained in:
boy0001 2015-02-15 16:39:44 +11:00
parent 28bf44cc92
commit 1a2b680359
2 changed files with 50 additions and 52 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<artifactId>PlotSquared</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
<name>PlotSquared</name>
<packaging>jar</packaging>
<build>
@ -45,6 +45,10 @@
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
<repository>
<id>empcraft-repo</id>
<url>http://empcraft.com/maven2</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
@ -74,6 +78,11 @@
<version>1.8-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
<artifactId>HolographicDisplays</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.3.2</version>

View File

@ -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) {