various fixes

This commit is contained in:
boy0001 2014-11-06 18:23:21 +11:00
parent 766dc0f703
commit a30e8eec9a
7 changed files with 30 additions and 11 deletions

View File

@ -1179,10 +1179,13 @@ public class PlotMain extends JavaPlugin {
worlds = new HashSet<String>(); worlds = new HashSet<String>();
} }
if ((generator != null) && (generator instanceof PlotGenerator)) { if ((generator != null) && (generator instanceof PlotGenerator)) {
sendConsoleSenderMessage(C.PREFIX.s() + "&aDetected world load for '" + world + "'."); sendConsoleSenderMessage(C.PREFIX.s() + "&aDetected world load for '" + world + "'");
final PlotGenerator plotgen = (PlotGenerator) generator; final PlotGenerator plotgen = (PlotGenerator) generator;
sendConsoleSenderMessage(C.PREFIX.s() + "&3 - generator: &7" + generator.getClass().getName());
final PlotWorld plotworld = plotgen.getNewPlotWorld(world); final PlotWorld plotworld = plotgen.getNewPlotWorld(world);
sendConsoleSenderMessage(C.PREFIX.s() + "&3 - plotworld: &7" + plotworld.getClass().getName());
final PlotManager manager = plotgen.getPlotManager(); final PlotManager manager = plotgen.getPlotManager();
sendConsoleSenderMessage(C.PREFIX.s() + "&3 - manager: &7" + manager.getClass().getName());
if (!config.contains("worlds." + world)) { if (!config.contains("worlds." + world)) {
config.createSection("worlds." + world); config.createSection("worlds." + world);

View File

@ -178,7 +178,19 @@ public class PlotSettings {
public void setComments(final ArrayList<PlotComment> comments) { public void setComments(final ArrayList<PlotComment> comments) {
this.comments = comments; this.comments = comments;
} }
public void removeComment(PlotComment comment) {
if (this.comments.contains(comment)) {
this.comments.remove(comment);
}
}
public void removeComments(ArrayList<PlotComment> comments) {
for (PlotComment comment : comments) {
removeComment(comment);
}
}
public void addComment(final PlotComment comment) { public void addComment(final PlotComment comment) {
if (this.comments == null) { if (this.comments == null) {
this.comments = new ArrayList<PlotComment>(); this.comments = new ArrayList<PlotComment>();

View File

@ -138,6 +138,7 @@ public class Inbox extends SubCommand {
final int index = Integer.parseInt(split[1]); final int index = Integer.parseInt(split[1]);
final PlotComment comment = comments.get(index - 1); final PlotComment comment = comments.get(index - 1);
DBFunc.removeComment(world, plot, comment); DBFunc.removeComment(world, plot, comment);
plot.settings.removeComment(comment);
PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "1 comment"); PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "1 comment");
return; return;
} }
@ -149,6 +150,7 @@ public class Inbox extends SubCommand {
for (final PlotComment comment : comments) { for (final PlotComment comment : comments) {
DBFunc.removeComment(world, plot, comment); DBFunc.removeComment(world, plot, comment);
} }
plot.settings.removeComments(comments);
PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "all comments in that category"); PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "all comments in that category");
return; return;
} }

View File

@ -59,15 +59,10 @@ public class Purge extends SubCommand {
return false; return false;
} }
if (args[1].equals("-o")) { if (args[1].equals("-o")) {
final PlotWorld plotworld = PlotMain.getWorldSettings(args[0]); if (PlotMain.getPlots(args[0])==null) {
if (plotworld == null) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
return false; return false;
} }
if (plr != null) {
PlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE));
return false;
}
PlotMain.removePlotWorld(args[0]); PlotMain.removePlotWorld(args[0]);
DBFunc.purge(args[0]); DBFunc.purge(args[0]);
PlayerFunctions.sendMessage(plr, (C.PURGE_SUCCESS)); PlayerFunctions.sendMessage(plr, (C.PURGE_SUCCESS));

View File

@ -28,14 +28,13 @@ public class Visit extends SubCommand {
public List<Plot> getPlots(final UUID uuid) { public List<Plot> getPlots(final UUID uuid) {
final List<Plot> plots = new ArrayList<>(); final List<Plot> plots = new ArrayList<>();
for (final Plot p : PlotMain.getPlots()) { for (final Plot p : PlotMain.getPlots()) {
if (p.owner.equals(uuid)) { if (p.hasOwner() && p.owner.equals(uuid)) {
plots.add(p); plots.add(p);
} }
} }
return plots; return plots;
} }
@SuppressWarnings("deprecation")
@Override @Override
public boolean execute(final Player plr, final String... args) { public boolean execute(final Player plr, final String... args) {
if (args.length < 1) { if (args.length < 1) {

View File

@ -297,6 +297,9 @@ public class SQLManager extends AbstractDB {
stmt.setInt(1, id); stmt.setInt(1, id);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
stmt = connection.prepareStatement("DELETE FROM `" + PREFIX + "plot_comments` WHERE `plot_plot_id` = ?");
stmt.setInt(1, id);
stmt.executeUpdate();
stmt = connection.prepareStatement("DELETE FROM `" + PREFIX + "plot` WHERE `id` = ?"); stmt = connection.prepareStatement("DELETE FROM `" + PREFIX + "plot` WHERE `id` = ?");
stmt.setInt(1, id); stmt.setInt(1, id);
stmt.executeUpdate(); stmt.executeUpdate();
@ -596,8 +599,13 @@ public class SQLManager extends AbstractDB {
} }
newplots.get(world).put(plot.id, plot); newplots.get(world).put(plot.id, plot);
} }
boolean invalidPlot = false;
for (final String worldname : noExist.keySet()) { for (final String worldname : noExist.keySet()) {
PlotMain.sendConsoleSenderMessage("&c[WARNING] Found " + noExist.get(worldname) + " plots in DB for non existant world; '" + worldname + "'!!!\n&c - Please create this world, or remove the plots from the DB using the purge command!"); invalidPlot = true;
PlotMain.sendConsoleSenderMessage("&c[WARNING] Found " + noExist.get(worldname) + " plots in DB for non existant world; '" + worldname + "'.");
}
if (invalidPlot) {
PlotMain.sendConsoleSenderMessage("&c[WARNING] - Please create the world/s or remove the plots using the purge command");
} }
} }
catch (final SQLException e) { catch (final SQLException e) {

View File

@ -1,6 +1,6 @@
name: PlotSquared name: PlotSquared
main: com.intellectualcrafters.plot.PlotMain main: com.intellectualcrafters.plot.PlotMain
version: 2.2.0 version: 2.2.1
load: STARTUP load: STARTUP
description: > description: >
Easy, yet powerful Plot World generation and management. Easy, yet powerful Plot World generation and management.