DB changes

This commit is contained in:
Jesse Boyd 2015-01-18 12:30:32 -08:00
parent ad22db3290
commit cd170915d8
7 changed files with 54 additions and 69 deletions

View File

@ -77,21 +77,16 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
return false;
}
OfflinePlayer player = null;
if (plot.trusted.contains(uuid)) {
plot.trusted.remove(uuid);
player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
DBFunc.removeTrusted(plr.getWorld().getName(), plot, player);
DBFunc.removeTrusted(plr.getWorld().getName(), plot, uuid);
}
if (plot.helpers.contains(uuid)) {
plot.helpers.remove(uuid);
if (player == null) {
player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
}
DBFunc.removeHelper(plr.getWorld().getName(), plot, player);
DBFunc.removeHelper(plr.getWorld().getName(), plot, uuid);
}
plot.addDenied(uuid);
DBFunc.setDenied(plr.getWorld().getName(), plot, UUIDHandler.uuidWrapper.getOfflinePlayer(uuid));
DBFunc.setDenied(plr.getWorld().getName(), plot, uuid);
final PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event);
} else {
@ -116,13 +111,13 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
return true;
}
plot.removeDenied(uuid);
DBFunc.removeDenied(plr.getWorld().getName(), plot, UUIDHandler.uuidWrapper.getOfflinePlayer(uuid));
DBFunc.removeDenied(plr.getWorld().getName(), plot, uuid);
PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED);
return true;
}
final UUID uuid = UUIDHandler.getUUID(args[1]);
plot.removeDenied(uuid);
DBFunc.removeDenied(plr.getWorld().getName(), plot, UUIDHandler.uuidWrapper.getOfflinePlayer(uuid));
DBFunc.removeDenied(plr.getWorld().getName(), plot, uuid);
final PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, false);
Bukkit.getPluginManager().callEvent(event);
PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED);

View File

@ -76,21 +76,16 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
return false;
}
OfflinePlayer player = null;
if (plot.trusted.contains(uuid)) {
plot.trusted.remove(uuid);
player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
DBFunc.removeTrusted(plr.getWorld().getName(), plot, player);
DBFunc.removeTrusted(plr.getWorld().getName(), plot, uuid);
}
if (plot.denied.contains(uuid)) {
plot.denied.remove(uuid);
if (player == null) {
player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
}
DBFunc.removeDenied(plr.getWorld().getName(), plot, player);
DBFunc.removeDenied(plr.getWorld().getName(), plot, uuid);
}
plot.addHelper(uuid);
DBFunc.setHelper(plr.getWorld().getName(), plot, UUIDHandler.uuidWrapper.getOfflinePlayer(uuid));
DBFunc.setHelper(plr.getWorld().getName(), plot, uuid);
final PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event);
} else {
@ -107,13 +102,13 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
return true;
}
plot.removeHelper(uuid);
DBFunc.removeHelper(plr.getWorld().getName(), plot, UUIDHandler.uuidWrapper.getOfflinePlayer(uuid));
DBFunc.removeHelper(plr.getWorld().getName(), plot, uuid);
PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED);
return true;
}
final UUID uuid = UUIDHandler.getUUID(args[1]);
plot.removeHelper(uuid);
DBFunc.removeHelper(plr.getWorld().getName(), plot, UUIDHandler.uuidWrapper.getOfflinePlayer(uuid));
DBFunc.removeHelper(plr.getWorld().getName(), plot, uuid);
final PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, false);
Bukkit.getPluginManager().callEvent(event);
PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED);

View File

@ -77,21 +77,16 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
return false;
}
OfflinePlayer player = null;
if (plot.helpers.contains(uuid)) {
plot.helpers.remove(uuid);
player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
DBFunc.removeHelper(plr.getWorld().getName(), plot, player);
DBFunc.removeHelper(plr.getWorld().getName(), plot, uuid);
}
if (plot.denied.contains(uuid)) {
plot.denied.remove(uuid);
if (player == null) {
player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
}
DBFunc.removeDenied(plr.getWorld().getName(), plot, player);
DBFunc.removeDenied(plr.getWorld().getName(), plot, uuid);
}
plot.addTrusted(uuid);
DBFunc.setTrusted(plr.getWorld().getName(), plot, UUIDHandler.uuidWrapper.getOfflinePlayer(uuid));
DBFunc.setTrusted(plr.getWorld().getName(), plot, uuid);
final PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event);
} else {
@ -108,13 +103,13 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
return true;
}
plot.removeTrusted(uuid);
DBFunc.removeTrusted(plr.getWorld().getName(), plot, UUIDHandler.uuidWrapper.getOfflinePlayer(uuid));
DBFunc.removeTrusted(plr.getWorld().getName(), plot, uuid);
PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED);
return true;
}
final UUID uuid = UUIDHandler.getUUID(args[1]);
plot.removeTrusted(uuid);
DBFunc.removeTrusted(plr.getWorld().getName(), plot, UUIDHandler.uuidWrapper.getOfflinePlayer(uuid));
DBFunc.removeTrusted(plr.getWorld().getName(), plot, uuid);
final PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, false);
Bukkit.getPluginManager().callEvent(event);
PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED);

View File

@ -174,39 +174,39 @@ public interface AbstractDB {
/**
* @param plot Plot Object
* @param player Player that should be removed
* @param uuid Player that should be removed
*/
public void removeHelper(final String world, final Plot plot, final OfflinePlayer player);
public void removeHelper(final String world, final Plot plot, final UUID uuid);
/**
* @param plot Plot Object
* @param player Player that should be removed
* @param uuid Player that should be removed
*/
public void removeTrusted(final String world, final Plot plot, final OfflinePlayer player);
public void removeTrusted(final String world, final Plot plot, final UUID uuid);
/**
* @param plot Plot Object
* @param player Player that should be removed
* @param uuid Player that should be removed
*/
public void setHelper(final String world, final Plot plot, final OfflinePlayer player);
public void setHelper(final String world, final Plot plot, final UUID uuid);
/**
* @param plot Plot Object
* @param uuid Player that should be added
*/
public void setTrusted(final String world, final Plot plot, final UUID uuid);
/**
* @param plot Plot Object
* @param player Player that should be added
*/
public void setTrusted(final String world, final Plot plot, final OfflinePlayer player);
public void removeDenied(final String world, final Plot plot, final UUID uuid);
/**
* @param plot Plot Object
* @param player Player that should be added
*/
public void removeDenied(final String world, final Plot plot, final OfflinePlayer player);
/**
* @param plot Plot Object
* @param player Player that should be added
*/
public void setDenied(final String world, final Plot plot, final OfflinePlayer player);
public void setDenied(final String world, final Plot plot, final UUID uuid);
/**
* Get Plots ratings

View File

@ -222,48 +222,48 @@ public class DBFunc {
* @param plot
* @param player
*/
public static void removeHelper(final String world, final Plot plot, final OfflinePlayer player) {
dbManager.removeHelper(world, plot, player);
public static void removeHelper(final String world, final Plot plot, final UUID uuid) {
dbManager.removeHelper(world, plot, uuid);
}
/**
* @param plot
* @param player
*/
public static void removeTrusted(final String world, final Plot plot, final OfflinePlayer player) {
dbManager.removeTrusted(world, plot, player);
public static void removeTrusted(final String world, final Plot plot, final UUID uuid) {
dbManager.removeTrusted(world, plot, uuid);
}
/**
* @param plot
* @param player
*/
public static void setHelper(final String world, final Plot plot, final OfflinePlayer player) {
dbManager.setHelper(world, plot, player);
public static void setHelper(final String world, final Plot plot, final UUID uuid) {
dbManager.setHelper(world, plot, uuid);
}
/**
* @param plot
* @param player
*/
public static void setTrusted(final String world, final Plot plot, final OfflinePlayer player) {
dbManager.setTrusted(world, plot, player);
public static void setTrusted(final String world, final Plot plot, final UUID uuid) {
dbManager.setTrusted(world, plot, uuid);
}
/**
* @param plot
* @param player
*/
public static void removeDenied(final String world, final Plot plot, final OfflinePlayer player) {
dbManager.removeDenied(world, plot, player);
public static void removeDenied(final String world, final Plot plot, final UUID uuid) {
dbManager.removeDenied(world, plot, uuid);
}
/**
* @param plot
* @param player
*/
public static void setDenied(final String world, final Plot plot, final OfflinePlayer player) {
dbManager.setDenied(world, plot, player);
public static void setDenied(final String world, final Plot plot, final UUID uuid) {
dbManager.setDenied(world, plot, uuid);
}
public static double getRatings(final Plot plot) {

View File

@ -1060,14 +1060,14 @@ public class SQLManager implements AbstractDB {
* @param player
*/
@Override
public void removeHelper(final String world, final Plot plot, final OfflinePlayer player) {
public void removeHelper(final String world, final Plot plot, final UUID uuid) {
TaskManager.runTask(new Runnable() {
@Override
public void run() {
try {
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
statement.setInt(1, getId(world, plot.id));
statement.setString(2, UUIDHandler.getUUID(player).toString());
statement.setString(2, uuid.toString());
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {
@ -1083,14 +1083,14 @@ public class SQLManager implements AbstractDB {
* @param player
*/
@Override
public void removeTrusted(final String world, final Plot plot, final OfflinePlayer player) {
public void removeTrusted(final String world, final Plot plot, final UUID uuid) {
TaskManager.runTask(new Runnable() {
@Override
public void run() {
try {
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_trusted` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
statement.setInt(1, getId(world, plot.id));
statement.setString(2, UUIDHandler.getUUID(player).toString());
statement.setString(2, uuid.toString());
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {
@ -1106,14 +1106,14 @@ public class SQLManager implements AbstractDB {
* @param player
*/
@Override
public void setHelper(final String world, final Plot plot, final OfflinePlayer player) {
public void setHelper(final String world, final Plot plot, final UUID uuid) {
TaskManager.runTask(new Runnable() {
@Override
public void run() {
try {
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
statement.setInt(1, getId(world, plot.id));
statement.setString(2, UUIDHandler.getUUID(player).toString());
statement.setString(2, uuid.toString());
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {
@ -1147,14 +1147,14 @@ public class SQLManager implements AbstractDB {
* @param player
*/
@Override
public void setTrusted(final String world, final Plot plot, final OfflinePlayer player) {
public void setTrusted(final String world, final Plot plot, final UUID uuid) {
TaskManager.runTask(new Runnable() {
@Override
public void run() {
try {
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_trusted` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
statement.setInt(1, getId(world, plot.id));
statement.setString(2, UUIDHandler.getUUID(player).toString());
statement.setString(2, uuid.toString());
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {
@ -1170,14 +1170,14 @@ public class SQLManager implements AbstractDB {
* @param player
*/
@Override
public void removeDenied(final String world, final Plot plot, final OfflinePlayer player) {
public void removeDenied(final String world, final Plot plot, final UUID uuid) {
TaskManager.runTask(new Runnable() {
@Override
public void run() {
try {
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
statement.setInt(1, getId(world, plot.id));
statement.setString(2, UUIDHandler.getUUID(player).toString());
statement.setString(2, uuid.toString());
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {
@ -1193,14 +1193,14 @@ public class SQLManager implements AbstractDB {
* @param player
*/
@Override
public void setDenied(final String world, final Plot plot, final OfflinePlayer player) {
public void setDenied(final String world, final Plot plot, final UUID uuid) {
TaskManager.runTask(new Runnable() {
@Override
public void run() {
try {
final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
statement.setInt(1, getId(world, plot.id));
statement.setString(2, UUIDHandler.getUUID(player).toString());
statement.setString(2, uuid.toString());
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {

View File

@ -146,7 +146,7 @@ public class ExpireManager {
continue;
}
OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
if (!op.hasPlayedBefore()) {
if (op==null || !op.hasPlayedBefore()) {
toRemove.add(plot);
PlotMain.removePlot(plot.world, plot.id, true);
continue;