diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java index 5a8a1881f..2b281bf5f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -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); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java index 6d2b5dab0..05378be1a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -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); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java index 8a7030f71..7c3e75ba2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -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); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index 3a96a3314..820531718 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -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 diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index 440765f6a..e3fdb2bd2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -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) { 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 df682467f..d3e34330b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -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) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index 7e0448a10..cdfb0766e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -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;