Fixed plot rating

This commit is contained in:
boy0001 2015-06-05 20:45:13 +10:00
parent 8a90753aa7
commit 28dc3f6c9a
7 changed files with 97 additions and 81 deletions

View File

@ -645,13 +645,6 @@ public class PlotSquared {
} }
public void setupDatabase() { public void setupDatabase() {
final String[] tables;
if (Settings.ENABLE_CLUSTERS) {
MainCommand.subCommands.add(new Cluster());
tables = new String[] { "plot_trusted", "plot_ratings", "plot_comments", "cluster" };
} else {
tables = new String[] { "plot_trusted", "plot_ratings", "plot_comments" };
}
if (Settings.DB.USE_MYSQL) { if (Settings.DB.USE_MYSQL) {
try { try {
database = new MySQL(THIS, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD); database = new MySQL(THIS, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD);
@ -660,18 +653,7 @@ public class PlotSquared {
if (DBFunc.dbManager == null) { if (DBFunc.dbManager == null) {
DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX); DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX);
} }
final DatabaseMetaData meta = connection.getMetaData(); DBFunc.createTables("mysql");
ResultSet res = meta.getTables(null, null, Settings.DB.PREFIX + "plot", null);
if (!res.next()) {
DBFunc.createTables("mysql", true);
} else {
for (final String table : tables) {
res = meta.getTables(null, null, Settings.DB.PREFIX + table, null);
if (!res.next()) {
DBFunc.createTables("mysql", false);
}
}
}
} }
} catch (final Exception e) { } catch (final Exception e) {
log("&c[Plots] MySQL is not setup correctly. The plugin will disable itself."); log("&c[Plots] MySQL is not setup correctly. The plugin will disable itself.");
@ -699,16 +681,7 @@ public class PlotSquared {
DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX); DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX);
final DatabaseMetaData meta = connection.getMetaData(); final DatabaseMetaData meta = connection.getMetaData();
ResultSet res = meta.getTables(null, null, Settings.DB.PREFIX + "plot", null); ResultSet res = meta.getTables(null, null, Settings.DB.PREFIX + "plot", null);
if (!res.next()) { DBFunc.createTables("sqlite");
DBFunc.createTables("sqlite", true);
} else {
for (final String table : tables) {
res = meta.getTables(null, null, Settings.DB.PREFIX + table, null);
if (!res.next()) {
DBFunc.createTables("sqlite", false);
}
}
}
} }
} catch (final Exception e) { } catch (final Exception e) {
log(C.PREFIX.s() + "&cFailed to open SQLite connection. The plugin will disable itself."); log(C.PREFIX.s() + "&cFailed to open SQLite connection. The plugin will disable itself.");

View File

@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;
import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.MySQL; import com.intellectualcrafters.plot.database.MySQL;
import com.intellectualcrafters.plot.database.SQLManager; import com.intellectualcrafters.plot.database.SQLManager;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
@ -23,8 +24,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
* @author Citymonstret * @author Citymonstret
*/ */
public class Database extends SubCommand { public class Database extends SubCommand {
final String[] tables = new String[] { "plot_trusted", "plot_ratings", "plot_comments" };
public Database() { public Database() {
super(Command.DATABASE, "Convert/Backup Storage", "database [type] [...details]", CommandCategory.DEBUG, false); super(Command.DATABASE, "Convert/Backup Storage", "database [type] [...details]", CommandCategory.DEBUG, false);
} }
@ -106,18 +105,7 @@ public class Database extends SubCommand {
} }
final SQLManager manager = new SQLManager(n, prefix); final SQLManager manager = new SQLManager(n, prefix);
try { try {
final DatabaseMetaData meta = n.getMetaData(); manager.createTables(Settings.DB.USE_MYSQL ? "mysql" : "sqlite");
ResultSet set = meta.getTables(null, null, prefix + "plot", null);
if (!set.next()) {
manager.createTables("mysql", true);
} else {
for (final String s : this.tables) {
set = meta.getTables(null, null, prefix + s, null);
if (!set.next()) {
manager.createTables("mysql", false);
}
}
}
} catch (final SQLException e) { } catch (final SQLException e) {
e.printStackTrace(); e.printStackTrace();
return sendMessage(plr, "Could not create the required tables and/or load the database") && sendMessage(plr, "Please see the stacktrace for more information"); return sendMessage(plr, "Could not create the required tables and/or load the database") && sendMessage(plr, "Please see the stacktrace for more information");

View File

@ -233,7 +233,7 @@ public class DebugUUID extends SubCommand {
MainUtil.sendConsoleMessage("&7 - Creating tables"); MainUtil.sendConsoleMessage("&7 - Creating tables");
try { try {
database.createTables(Settings.DB.USE_MYSQL ? "mysql" : "sqlite", true); database.createTables(Settings.DB.USE_MYSQL ? "mysql" : "sqlite");
if (!result) { if (!result) {
MainUtil.sendConsoleMessage("&cConversion failed! Attempting recovery"); MainUtil.sendConsoleMessage("&cConversion failed! Attempting recovery");
for (Plot plot : PlotSquared.getPlots()) { for (Plot plot : PlotSquared.getPlots()) {

View File

@ -20,12 +20,17 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import org.apache.commons.lang.StringUtils;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager;
public class Rate extends SubCommand { public class Rate extends SubCommand {
/* /*
@ -56,39 +61,31 @@ public class Rate extends SubCommand {
return true; return true;
} }
final String arg = args[0]; final String arg = args[0];
boolean o = false; final int rating;
for (final char c : arg.toCharArray()) { if (StringUtils.isNumeric(arg) && arg.length() < 3 && arg.length() > 0) {
if (!Character.isDigit(c)) { rating = Integer.parseInt(arg);
o = true; if (rating > 10) {
break; sendMessage(plr, C.RATING_NOT_VALID);
return false;
} }
} }
int rating = 0; else {
if (!o) {
rating = Integer.parseInt(arg);
}
if (o || ((rating < 0) || (rating > 10))) {
sendMessage(plr, C.RATING_NOT_VALID); sendMessage(plr, C.RATING_NOT_VALID);
return true;
}
// TODO implement check for already rated
boolean rated = true;
try {
DBFunc.getRatings(plot);
} catch (final Exception e) {
rated = false;
}
if (rated) {
sendMessage(plr, C.RATING_ALREADY_EXISTS, plot.getId().toString());
return false; return false;
} }
final boolean success = true; final UUID uuid = plr.getUUID();
if (success) { // TODO implement check for already rated
sendMessage(plr, C.RATING_APPLIED, plot.getId().toString()); TaskManager.runTaskAsync(new Runnable() {
} else { @Override
sendMessage(plr, C.COMMAND_WENT_WRONG); public void run() {
} if (DBFunc.hasRated(plot.world, plot.id, uuid)) {
DBFunc.setRating(plot, plr.getUUID(), rating); sendMessage(plr, C.RATING_ALREADY_EXISTS, plot.getId().toString());
return;
}
DBFunc.setRating(plot, uuid, rating);
sendMessage(plr, C.RATING_APPLIED, plot.getId().toString());
}
});
return true; return true;
} }
} }

View File

@ -76,7 +76,7 @@ public interface AbstractDB {
* *
* @throws SQLException If the database manager is unable to create the tables * @throws SQLException If the database manager is unable to create the tables
*/ */
public void createTables(final String database, final boolean add_constraint) throws Exception; public void createTables(final String database) throws Exception;
/** /**
* Delete a plot * Delete a plot
@ -287,6 +287,13 @@ public interface AbstractDB {
*/ */
public double getRatings(final Plot plot); public double getRatings(final Plot plot);
/**
* if uuid has rated
* @param uuid
* @return
*/
public boolean hasRated(String world, PlotId id, UUID uuid);
/** /**
* Set a rating for a plot * Set a rating for a plot
* @param plot * @param plot

View File

@ -121,8 +121,8 @@ public class DBFunc {
* *
* @throws Exception * @throws Exception
*/ */
public static void createTables(final String database, final boolean add_constraint) throws Exception { public static void createTables(final String database) throws Exception {
dbManager.createTables(database, add_constraint); dbManager.createTables(database);
} }
/** /**
@ -346,6 +346,10 @@ public class DBFunc {
return dbManager.getRatings(plot); return dbManager.getRatings(plot);
} }
public static boolean hasRated(String world, PlotId id, final UUID uuid) {
return dbManager.hasRated(world, id, uuid);
}
public static void setRating(Plot plot, UUID rater, int value) { public static void setRating(Plot plot, UUID rater, int value) {
dbManager.setRating(plot, rater, value); dbManager.setRating(plot, rater, value);
} }

View File

@ -673,7 +673,34 @@ public class SQLManager implements AbstractDB {
* @throws SQLException * @throws SQLException
*/ */
@Override @Override
public void createTables(final String database, final boolean add_constraint) throws SQLException { public void createTables(final String database) throws SQLException {
final String[] tables;
if (Settings.ENABLE_CLUSTERS) {
tables = new String[] { "plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", "plot_rating", "plot_settings", "cluster" };
}
else {
tables = new String[] { "plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", "plot_rating", "plot_settings" };
}
final DatabaseMetaData meta = connection.getMetaData();
int create = 0;
for (final String s : tables) {
ResultSet set = meta.getTables(null, null, prefix + s, null);
if (!set.next()) {
create++;
}
set.close();
}
if (create == 0) {
return;
}
boolean add_constraint;
if (create == tables.length) {
add_constraint = true;
}
else {
add_constraint = false;
}
PlotSquared.log("Creating tables");
final boolean mysql = database.equals("mysql"); final boolean mysql = database.equals("mysql");
final Statement stmt = this.connection.createStatement(); final Statement stmt = this.connection.createStatement();
if (mysql) { if (mysql) {
@ -683,7 +710,7 @@ public class SQLManager implements AbstractDB {
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)," + " UNIQUE KEY `unique_alias` (`alias`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)," + " UNIQUE KEY `unique_alias` (`alias`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_ratings` ( `plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_rating` ( `plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
if (add_constraint) { if (add_constraint) {
stmt.addBatch("ALTER TABLE `" + this.prefix + "plot_settings` ADD CONSTRAINT `" + this.prefix + "plot_settings_ibfk_1` FOREIGN KEY (`plot_plot_id`) REFERENCES `" + this.prefix + "plot` (`id`) ON DELETE CASCADE"); stmt.addBatch("ALTER TABLE `" + this.prefix + "plot_settings` ADD CONSTRAINT `" + this.prefix + "plot_settings_ibfk_1` FOREIGN KEY (`plot_plot_id`) REFERENCES `" + this.prefix + "plot` (`id`) ON DELETE CASCADE");
} }
@ -698,7 +725,7 @@ public class SQLManager implements AbstractDB {
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_rating` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL)");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
@ -1604,7 +1631,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public double getRatings(final Plot plot) { public double getRatings(final Plot plot) {
try { try {
final PreparedStatement statement = this.connection.prepareStatement("SELECT AVG(`rating`) AS `rating` FROM `" + this.prefix + "plot_ratings` WHERE `plot_plot_id` = ? "); final PreparedStatement statement = this.connection.prepareStatement("SELECT AVG(`rating`) AS `rating` FROM `" + this.prefix + "plot_rating` WHERE `plot_plot_id` = ? ");
statement.setInt(1, getId(plot.world, plot.id)); statement.setInt(1, getId(plot.world, plot.id));
final ResultSet set = statement.executeQuery(); final ResultSet set = statement.executeQuery();
double rating = 0; double rating = 0;
@ -1628,7 +1655,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void run() { public void run() {
try { try {
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT IGNORE INTO `" + SQLManager.this.prefix + "plot_ratings` (`plot_plot_id`, `rating`, `player`) VALUES(?,?,?)"); final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_rating` (`plot_plot_id`, `rating`, `player`) VALUES(?,?,?)");
statement.setInt(1, getId(plot.world, plot.id)); statement.setInt(1, getId(plot.world, plot.id));
statement.setInt(2, value); statement.setInt(2, value);
statement.setString(3, rater.toString()); statement.setString(3, rater.toString());
@ -2142,7 +2169,7 @@ public class SQLManager implements AbstractDB {
stmt.addBatch("DROP TABLE `" + prefix + "cluster_invited`"); stmt.addBatch("DROP TABLE `" + prefix + "cluster_invited`");
stmt.addBatch("DROP TABLE `" + prefix + "cluster_helpers`"); stmt.addBatch("DROP TABLE `" + prefix + "cluster_helpers`");
stmt.addBatch("DROP TABLE `" + prefix + "cluster`"); stmt.addBatch("DROP TABLE `" + prefix + "cluster`");
stmt.addBatch("DROP TABLE `" + prefix + "plot_ratings`"); stmt.addBatch("DROP TABLE `" + prefix + "plot_rating`");
stmt.addBatch("DROP TABLE `" + prefix + "plot_settings`"); stmt.addBatch("DROP TABLE `" + prefix + "plot_settings`");
stmt.addBatch("DROP TABLE `" + prefix + "plot_comments`"); stmt.addBatch("DROP TABLE `" + prefix + "plot_comments`");
stmt.addBatch("DROP TABLE `" + prefix + "plot_trusted`"); stmt.addBatch("DROP TABLE `" + prefix + "plot_trusted`");
@ -2162,4 +2189,24 @@ public class SQLManager implements AbstractDB {
return false; return false;
} }
} }
@Override
public boolean hasRated(String world, PlotId id, UUID uuid) {
try {
PreparedStatement stmt = SQLManager.this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_rating` WHERE `plot_plot_id` = ? AND `player` = ?");
stmt.setInt(1, getId(world, id));
stmt.setString(2, uuid.toString());
final ResultSet r = stmt.executeQuery();
if (r.next()) {
stmt.close();
return true;
}
stmt.close();
return false;
}
catch (Exception e) {
e.printStackTrace();
}
return false;
}
} }