mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Small fixes
This commit is contained in:
parent
5601315c41
commit
f465484c20
@ -267,7 +267,6 @@ public class PlotMain extends JavaPlugin {
|
|||||||
/**
|
/**
|
||||||
* Replace the plot object with an updated version
|
* Replace the plot object with an updated version
|
||||||
*
|
*
|
||||||
* @param id plot Id
|
|
||||||
* @param plot plot object
|
* @param plot plot object
|
||||||
*/
|
*/
|
||||||
public static void updatePlot(Plot plot) {
|
public static void updatePlot(Plot plot) {
|
||||||
@ -673,8 +672,16 @@ public class PlotMain extends JavaPlugin {
|
|||||||
Location location;
|
Location location;
|
||||||
long ticked = 0l;
|
long ticked = 0l;
|
||||||
long error = 0l;
|
long error = 0l;
|
||||||
|
{
|
||||||
|
sendConsoleSenderMessage(C.PREFIX.s() + "KillAllEntities started.");
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if(ticked > 36000l) {
|
||||||
|
ticked = 0l;
|
||||||
|
sendConsoleSenderMessage(C.PREFIX.s() + "KillAllEntities has been running for 60 minutes. Error-count: " + error);
|
||||||
|
error = 0l;
|
||||||
|
}
|
||||||
for (String w: getPlotWorlds()) {
|
for (String w: getPlotWorlds()) {
|
||||||
World world = Bukkit.getWorld(w);
|
World world = Bukkit.getWorld(w);
|
||||||
try {
|
try {
|
||||||
|
@ -8,29 +8,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.database;
|
package com.intellectualcrafters.plot.database;
|
||||||
import com.intellectualcrafters.plot.Flag;
|
import com.intellectualcrafters.plot.*;
|
||||||
import com.intellectualcrafters.plot.Logger;
|
|
||||||
import com.intellectualcrafters.plot.Logger.LogLevel;
|
import com.intellectualcrafters.plot.Logger.LogLevel;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
|
||||||
import com.intellectualcrafters.plot.PlotHomePosition;
|
|
||||||
import com.intellectualcrafters.plot.PlotId;
|
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.ResultSetMetaData;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static com.intellectualcrafters.plot.PlotMain.connection;
|
import static com.intellectualcrafters.plot.PlotMain.connection;
|
||||||
@ -103,19 +92,20 @@ public class DBFunc {
|
|||||||
"PRIMARY KEY (`id`)" +
|
"PRIMARY KEY (`id`)" +
|
||||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
|
||||||
|
|
||||||
|
|
||||||
stmt.addBatch(
|
stmt.addBatch(
|
||||||
"CREATE TABLE IF NOT EXISTS `plot_helpers` (" +
|
"CREATE TABLE IF NOT EXISTS `plot_helpers` (" +
|
||||||
"`plot_plot_id` int(11) NOT NULL," +
|
"`plot_plot_id` int(11) NOT NULL," +
|
||||||
"`user_uuid` varchar(40) NOT NULL" +
|
"`user_uuid` varchar(40) NOT NULL" +
|
||||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8"
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8"
|
||||||
);
|
);
|
||||||
|
|
||||||
stmt.addBatch(
|
stmt.addBatch(
|
||||||
"CREATE TABLE IF NOT EXISTS `plot_denied` (" +
|
"CREATE TABLE IF NOT EXISTS `plot_denied` (" +
|
||||||
"`plot_plot_id` int(11) NOT NULL," +
|
"`plot_plot_id` int(11) NOT NULL," +
|
||||||
"`user_uuid` varchar(40) NOT NULL" +
|
"`user_uuid` varchar(40) NOT NULL" +
|
||||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8"
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8"
|
||||||
);
|
);
|
||||||
|
|
||||||
stmt.addBatch(
|
stmt.addBatch(
|
||||||
"CREATE TABLE IF NOT EXISTS `plot_settings` (" +
|
"CREATE TABLE IF NOT EXISTS `plot_settings` (" +
|
||||||
" `plot_plot_id` INT(11) NOT NULL," +
|
" `plot_plot_id` INT(11) NOT NULL," +
|
||||||
@ -131,9 +121,11 @@ public class DBFunc {
|
|||||||
" UNIQUE KEY `unique_alias` (`alias`)" +
|
" UNIQUE KEY `unique_alias` (`alias`)" +
|
||||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8"
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8"
|
||||||
);
|
);
|
||||||
|
|
||||||
stmt.addBatch(
|
stmt.addBatch(
|
||||||
"ALTER TABLE `plot_settings` ADD CONSTRAINT `plot_settings_ibfk_1` FOREIGN KEY (`plot_plot_id`) REFERENCES `plot` (`id`) ON DELETE CASCADE"
|
"ALTER TABLE `plot_settings` ADD CONSTRAINT `plot_settings_ibfk_1` FOREIGN KEY (`plot_plot_id`) REFERENCES `plot` (`id`) ON DELETE CASCADE"
|
||||||
);
|
);
|
||||||
|
|
||||||
stmt.executeBatch();
|
stmt.executeBatch();
|
||||||
stmt.clearBatch();
|
stmt.clearBatch();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -227,12 +219,33 @@ public class DBFunc {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getId(String world, PlotId id2) {
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
stmt = connection.prepareStatement("SELECT `id` FROM `plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC");
|
||||||
|
stmt.setInt(1, id2.x);
|
||||||
|
stmt.setInt(2, id2.y);
|
||||||
|
stmt.setString(3, world);
|
||||||
|
ResultSet r = stmt.executeQuery();
|
||||||
|
int id = Integer.MAX_VALUE;
|
||||||
|
while (r.next()) {
|
||||||
|
id = r.getInt("id");
|
||||||
|
}
|
||||||
|
stmt.close();
|
||||||
|
return id;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a plot id
|
* Get a plot id
|
||||||
* @param plot_id
|
* @param plot_id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static int getId(String world, PlotId id2) {
|
/*public static int getId(String world, PlotId id2) {
|
||||||
Statement stmt = null;
|
Statement stmt = null;
|
||||||
try {
|
try {
|
||||||
stmt = connection.createStatement();
|
stmt = connection.createStatement();
|
||||||
@ -247,7 +260,7 @@ public class DBFunc {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -435,10 +448,11 @@ public class DBFunc {
|
|||||||
*/
|
*/
|
||||||
public static HashMap<String, Object> getSettings(int id) {
|
public static HashMap<String, Object> getSettings(int id) {
|
||||||
HashMap<String, Object> h = new HashMap<String, Object>();
|
HashMap<String, Object> h = new HashMap<String, Object>();
|
||||||
Statement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
stmt = connection.createStatement();
|
stmt = connection.prepareStatement("SELECT * FROM `plot_settings` WHERE `plot_plot_id` = ?");
|
||||||
ResultSet r = stmt.executeQuery("SELECT * FROM `plot_settings` WHERE `plot_plot_id` = " + id);
|
stmt.setInt(1, id);
|
||||||
|
ResultSet r = stmt.executeQuery();
|
||||||
String var;
|
String var;
|
||||||
Object val;
|
Object val;
|
||||||
while(r.next()) {
|
while(r.next()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user