mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
[UNTESTED] Added plot commenting
This commit is contained in:
parent
2dc935eed6
commit
45d8556b87
@ -31,6 +31,9 @@ public enum C {
|
|||||||
* Comment
|
* Comment
|
||||||
*/
|
*/
|
||||||
COMMENT_SYNTAX("&cUse /plots comment <everyone|trusted|helper|owner|admin> <comment>"),
|
COMMENT_SYNTAX("&cUse /plots comment <everyone|trusted|helper|owner|admin> <comment>"),
|
||||||
|
INVALID_INBOX("&cThat is not a valid inbox.\n&6Accepted values: %s"),
|
||||||
|
NO_PERM_INBOX("&cYou do not have permission to read that inbox."),
|
||||||
|
COMMENT_REMOVED("&aSuccessfully deleted %s."),
|
||||||
/*
|
/*
|
||||||
* Console
|
* Console
|
||||||
*/
|
*/
|
||||||
|
@ -32,11 +32,13 @@ package com.intellectualcrafters.plot;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
@ -326,7 +328,16 @@ public class Metrics {
|
|||||||
// enabled
|
// enabled
|
||||||
String pluginVersion = description.getVersion();
|
String pluginVersion = description.getVersion();
|
||||||
String serverVersion = Bukkit.getVersion();
|
String serverVersion = Bukkit.getVersion();
|
||||||
int playersOnline = 1337; /** it's a collection for me o.o */
|
int playersOnline = 0;
|
||||||
|
try {
|
||||||
|
if (Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).getReturnType() == Collection.class)
|
||||||
|
playersOnline = ((Collection<?>)Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).invoke(null, new Object[0])).size();
|
||||||
|
else
|
||||||
|
playersOnline = ((Player[])Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).invoke(null, new Object[0])).length;
|
||||||
|
}
|
||||||
|
catch (NoSuchMethodException ex){}
|
||||||
|
catch (InvocationTargetException ex){}
|
||||||
|
catch (IllegalAccessException ex){}
|
||||||
// END server software specific section -- all code below does not use
|
// END server software specific section -- all code below does not use
|
||||||
// any code outside of this class / Java
|
// any code outside of this class / Java
|
||||||
// Construct the post data
|
// Construct the post data
|
||||||
|
@ -36,7 +36,7 @@ public class PlotSettings {
|
|||||||
*/
|
*/
|
||||||
private Biome biome;
|
private Biome biome;
|
||||||
|
|
||||||
private ArrayList<PlotComment> comments;
|
private ArrayList<PlotComment> comments = null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -169,11 +169,18 @@ public class PlotSettings {
|
|||||||
public String getLeaveMessage() {
|
public String getLeaveMessage() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
public ArrayList<PlotComment> getComments() {
|
public ArrayList<PlotComment> getComments(int tier) {
|
||||||
if (this.comments == null) {
|
ArrayList<PlotComment> c = new ArrayList<PlotComment>();
|
||||||
return new ArrayList<PlotComment>();
|
for (PlotComment comment : this.comments) {
|
||||||
|
if (comment.tier == tier) {
|
||||||
|
c.add(comment);
|
||||||
}
|
}
|
||||||
return this.comments;
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComments(ArrayList<PlotComment> comments) {
|
||||||
|
this.comments = comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addComment(PlotComment comment) {
|
public void addComment(PlotComment comment) {
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.*;
|
import com.intellectualcrafters.plot.*;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -45,7 +47,7 @@ public class Comment extends SubCommand {
|
|||||||
PlotComment comment = new PlotComment(text, plr.getName(), recipients.indexOf(args[0].toLowerCase()));
|
PlotComment comment = new PlotComment(text, plr.getName(), recipients.indexOf(args[0].toLowerCase()));
|
||||||
plot.settings.addComment(comment);
|
plot.settings.addComment(comment);
|
||||||
|
|
||||||
//DBFunc.addComment(...) // Can you do this?
|
DBFunc.setComment(plr.getWorld().getName(), plot, comment);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -14,8 +14,10 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.*;
|
import com.intellectualcrafters.plot.*;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,16 +26,16 @@ import org.bukkit.entity.Player;
|
|||||||
public class Inbox extends SubCommand {
|
public class Inbox extends SubCommand {
|
||||||
|
|
||||||
public Inbox() {
|
public Inbox() {
|
||||||
super(Command.INBOX, "Comment on a plot", "comment", CommandCategory.ACTIONS, true);
|
super(Command.INBOX, "Review a the comments for a plot", "comment", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Player plr, String... args) {
|
public boolean execute(final Player plr, final String... args) {
|
||||||
if (!PlayerFunctions.isInPlot(plr)) {
|
if (!PlayerFunctions.isInPlot(plr)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
@ -56,23 +58,114 @@ public class Inbox extends SubCommand {
|
|||||||
else {
|
else {
|
||||||
tier = 4;
|
tier = 4;
|
||||||
}
|
}
|
||||||
ArrayList<PlotComment> comments = plot.settings.getComments();
|
|
||||||
List<String> recipients = Arrays.asList(new String[] {"admin", "owner", "helper", "trusted", "everyone" });
|
|
||||||
|
|
||||||
int counter = 0;
|
if (args.length > 0) {
|
||||||
|
switch (args[0].toLowerCase()) {
|
||||||
|
case "admin":
|
||||||
|
if (tier<=0) {
|
||||||
|
tier = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_PERM_INBOX);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "owner":
|
||||||
|
if (tier<=1) {
|
||||||
|
tier = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_PERM_INBOX);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "helper":
|
||||||
|
if (tier<=2) {
|
||||||
|
tier = 2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_PERM_INBOX);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "trusted":
|
||||||
|
if (tier<=3) {
|
||||||
|
tier = 3;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_PERM_INBOX);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "everyone":
|
||||||
|
if (tier<=4) {
|
||||||
|
tier = 4;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_PERM_INBOX);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "default":
|
||||||
|
PlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[] {"admin", "owner", "helper", "trusted", "everyone" }, tier, 4));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final String world = plr.getWorld().getName();
|
||||||
|
final int tier2 = tier;
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(PlotMain.getMain(), new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ArrayList<PlotComment> comments = plot.settings.getComments(tier2);
|
||||||
|
if (comments == null) {
|
||||||
|
comments = DBFunc.getCommenst(world, plot, tier2);
|
||||||
|
plot.settings.setComments(comments);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 2) {
|
||||||
|
String[] split = args[1].toLowerCase().split(":");
|
||||||
|
if (!split[0].equals("clear")) {
|
||||||
|
PlayerFunctions.sendMessage(plr, "&c/plot inbox [tier] [clear][:#]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (split.length > 1) {
|
||||||
|
try {
|
||||||
|
int index = Integer.parseInt(split[1]);
|
||||||
|
PlotComment comment = comments.get(index-1);
|
||||||
|
DBFunc.removeComment(world, plot, comment);
|
||||||
|
PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "1 comment");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
PlayerFunctions.sendMessage(plr, "&cInvalid index:\n/plot inbox [tier] [clear][:#]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (PlotComment comment : comments) {
|
||||||
|
DBFunc.removeComment(world, plot, comment);
|
||||||
|
}
|
||||||
|
PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "all comments in that category");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final List<String> recipients = Arrays.asList(new String[] {"A", "O", "H", "T", "E" });
|
||||||
|
int count = 1;
|
||||||
StringBuilder message = new StringBuilder();
|
StringBuilder message = new StringBuilder();
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
for (PlotComment comment : comments) {
|
for (PlotComment comment : comments) {
|
||||||
if (comment.tier>=tier) {
|
message.append(prefix + "["+count+"]&6[&c" + recipients.get(tier2) + "&6] &7"+comment.senderName+"&f: "+comment.comment);
|
||||||
message.append(prefix + "&6[&c" + recipients.get(tier) + "&6] &7"+comment.senderName+"&f: "+comment.comment);
|
|
||||||
prefix = "\n";
|
prefix = "\n";
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
}
|
if (comments.size()==0) {
|
||||||
if (counter==0) {
|
message.append("&cNo messages.");
|
||||||
PlayerFunctions.sendMessage(plr, "&cNo messages.");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(plr, message.toString());
|
PlayerFunctions.sendMessage(plr, message.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import org.bukkit.OfflinePlayer;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.Flag;
|
import com.intellectualcrafters.plot.Flag;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotComment;
|
||||||
import com.intellectualcrafters.plot.PlotId;
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,4 +150,10 @@ public abstract class AbstractDB {
|
|||||||
public abstract void setDenied(final String world, final Plot plot, final OfflinePlayer player);
|
public abstract void setDenied(final String world, final Plot plot, final OfflinePlayer player);
|
||||||
|
|
||||||
public abstract double getRatings(final Plot plot);
|
public abstract double getRatings(final Plot plot);
|
||||||
|
|
||||||
|
public abstract void removeComment(String world, Plot plot, PlotComment comment);
|
||||||
|
|
||||||
|
public abstract void setComment(String world, Plot plot, PlotComment comment);
|
||||||
|
|
||||||
|
public abstract ArrayList<PlotComment> getComments(String world, Plot plot, int tier);
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,10 @@ import java.util.HashMap;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.Flag;
|
import com.intellectualcrafters.plot.Flag;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotComment;
|
||||||
import com.intellectualcrafters.plot.PlotId;
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,6 +163,30 @@ public class DBFunc {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* @param plot
|
||||||
|
* @param comment
|
||||||
|
*/
|
||||||
|
public static void removeComment(final String world, final Plot plot, final PlotComment comment) {
|
||||||
|
dbManager.removeComment(world, plot, comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param plot
|
||||||
|
* @param comment
|
||||||
|
*/
|
||||||
|
public static void setComment(final String world, final Plot plot, final PlotComment comment) {
|
||||||
|
dbManager.setComment(world, plot, comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param plot
|
||||||
|
* @param comment
|
||||||
|
*/
|
||||||
|
public static ArrayList<PlotComment> getCommenst(final String world, final Plot plot, final int tier) {
|
||||||
|
return dbManager.getComments(world, plot, tier);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param plot
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public static void removeHelper(final String world, final Plot plot, final OfflinePlayer player) {
|
public static void removeHelper(final String world, final Plot plot, final OfflinePlayer player) {
|
||||||
|
@ -10,6 +10,7 @@ package com.intellectualcrafters.plot.database;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.*;
|
import com.intellectualcrafters.plot.*;
|
||||||
import com.intellectualcrafters.plot.Logger.LogLevel;
|
import com.intellectualcrafters.plot.Logger.LogLevel;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -64,7 +65,9 @@ public class SQLManager extends AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createAllSettingsAndHelpers(ArrayList<Plot> plots) {
|
public void createAllSettingsAndHelpers(ArrayList<Plot> plots) {
|
||||||
|
|
||||||
// TODO SEVERE [ More than 5000 plots will fail in a single SQLite query.
|
// TODO SEVERE [ More than 5000 plots will fail in a single SQLite query.
|
||||||
|
|
||||||
HashMap<String, HashMap<PlotId, Integer>> stored = new HashMap<String, HashMap<PlotId, Integer>>();
|
HashMap<String, HashMap<PlotId, Integer>> stored = new HashMap<String, HashMap<PlotId, Integer>>();
|
||||||
HashMap<Integer, ArrayList<UUID>> helpers = new HashMap<Integer, ArrayList<UUID>>();
|
HashMap<Integer, ArrayList<UUID>> helpers = new HashMap<Integer, ArrayList<UUID>>();
|
||||||
try {
|
try {
|
||||||
@ -236,6 +239,10 @@ public class SQLManager extends AbstractDB {
|
|||||||
+ "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
+ "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + PREFIX + "plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL,"
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + PREFIX + "plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL,"
|
||||||
+ "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
+ "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + PREFIX + "plot_comments` (" + "`plot_plot_id` INT(11) NOT NULL,"
|
||||||
|
+ "`comment` VARCHAR(40) NOT NULL,"
|
||||||
|
+ "`tier` INT(11) NOT NULL,"
|
||||||
|
+ "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + PREFIX + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL,"
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + PREFIX + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL,"
|
||||||
+ "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
+ "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + PREFIX + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL,"
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + PREFIX + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL,"
|
||||||
@ -262,6 +269,10 @@ public class SQLManager extends AbstractDB {
|
|||||||
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + PREFIX + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL,"
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + PREFIX + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL,"
|
||||||
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
||||||
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + PREFIX + "plot_comments` (" + "`plot_plot_id` INT(11) NOT NULL,"
|
||||||
|
+ "`comment` VARCHAR(40) NOT NULL,"
|
||||||
|
+ "`tier` INT(11) NOT NULL,"
|
||||||
|
+ "`sender` VARCHAR(40) NOT NULL" + ")");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + PREFIX + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL,"
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + PREFIX + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL,"
|
||||||
+ " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0,"
|
+ " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0,"
|
||||||
+ " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000',"
|
+ " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000',"
|
||||||
@ -515,8 +526,6 @@ public class SQLManager extends AbstractDB {
|
|||||||
|
|
||||||
stmt = connection.createStatement();
|
stmt = connection.createStatement();
|
||||||
r = stmt.executeQuery("SELECT * FROM `" + PREFIX + "plot_settings`");
|
r = stmt.executeQuery("SELECT * FROM `" + PREFIX + "plot_settings`");
|
||||||
String var;
|
|
||||||
Object val;
|
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
id = r.getInt("plot_plot_id");
|
id = r.getInt("plot_plot_id");
|
||||||
Plot plot = plots.get(id);
|
Plot plot = plots.get(id);
|
||||||
@ -542,7 +551,6 @@ public class SQLManager extends AbstractDB {
|
|||||||
plot.settings.setAlias(alias);
|
plot.settings.setAlias(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotHomePosition position = null;
|
|
||||||
String pos = r.getString("position");
|
String pos = r.getString("position");
|
||||||
if (pos!=null) {
|
if (pos!=null) {
|
||||||
for (PlotHomePosition plotHomePosition : PlotHomePosition.values()) {
|
for (PlotHomePosition plotHomePosition : PlotHomePosition.values()) {
|
||||||
@ -950,77 +958,78 @@ public class SQLManager extends AbstractDB {
|
|||||||
}
|
}
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private ArrayList<UUID> plotDenied(int id) {
|
|
||||||
ArrayList<UUID> l = new ArrayList<UUID>();
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
try {
|
|
||||||
stmt = connection.prepareStatement("SELECT `user_uuid` FROM `" + PREFIX + "plot_denied` WHERE `plot_plot_id` = ?");
|
|
||||||
stmt.setInt(1, id);
|
|
||||||
ResultSet r = stmt.executeQuery();
|
|
||||||
UUID u;
|
|
||||||
while (r.next()) {
|
|
||||||
u = UUID.fromString(r.getString("user_uuid"));
|
|
||||||
l.add(u);
|
|
||||||
}
|
|
||||||
stmt.close();
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
Logger.add(LogLevel.DANGER, "Failed to load denied for plot: " + id);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @param id
|
public void removeComment(final String world, final Plot plot, final PlotComment comment) {
|
||||||
* @return
|
runTask(new Runnable() {
|
||||||
*/
|
@Override
|
||||||
private ArrayList<UUID> plotHelpers(int id) {
|
public void run() {
|
||||||
ArrayList<UUID> l = new ArrayList<UUID>();
|
|
||||||
Statement stmt = null;
|
|
||||||
try {
|
try {
|
||||||
stmt = connection.createStatement();
|
PreparedStatement statement =
|
||||||
ResultSet r = stmt.executeQuery("SELECT `user_uuid` FROM `" + PREFIX + "plot_helpers` WHERE `plot_plot_id` = " + id);
|
connection.prepareStatement("DELETE FROM `"+PREFIX+"plot_comments` WHERE `plot_plot_id` = ? AND `comment` = ? AND `tier` = ? AND `sender` = ?");
|
||||||
UUID u;
|
statement.setInt(1, getId(world, plot.id));
|
||||||
while (r.next()) {
|
statement.setString(2, comment.comment);
|
||||||
u = UUID.fromString(r.getString("user_uuid"));
|
statement.setInt(3, comment.tier);
|
||||||
l.add(u);
|
statement.setString(4, comment.senderName);
|
||||||
}
|
statement.executeUpdate();
|
||||||
stmt.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
Logger.add(LogLevel.WARNING, "Failed to load helpers for plot: " + id);
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Logger.add(LogLevel.WARNING, "Failed to remove helper for plot " + plot.id);
|
||||||
}
|
}
|
||||||
return l;
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param id
|
@Override
|
||||||
* @return
|
public ArrayList<PlotComment> getComments(String world, Plot plot, int tier) {
|
||||||
*/
|
ArrayList<PlotComment> comments = new ArrayList<PlotComment>();
|
||||||
private ArrayList<UUID> plotTrusted(int id) {
|
|
||||||
ArrayList<UUID> l = new ArrayList<UUID>();
|
|
||||||
Statement stmt = null;
|
|
||||||
try {
|
try {
|
||||||
stmt = connection.createStatement();
|
PreparedStatement statement =
|
||||||
ResultSet r = stmt.executeQuery("SELECT `user_uuid` FROM `" + PREFIX + "plot_trusted` WHERE `plot_plot_id` = " + id);
|
connection.prepareStatement("SELECT `*` FROM `" + PREFIX + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` = ?");
|
||||||
UUID u;
|
statement.setInt(1, getId(plot.getWorld().getName(), plot.id));
|
||||||
while (r.next()) {
|
statement.setInt(2, tier);
|
||||||
u = UUID.fromString(r.getString("user_uuid"));
|
ResultSet set = statement.executeQuery();
|
||||||
l.add(u);
|
PlotComment comment;
|
||||||
|
while (set.next()) {
|
||||||
|
String sender = set.getString("sender");
|
||||||
|
String msg = set.getString("comment");
|
||||||
|
comment = new PlotComment(msg, sender, tier);
|
||||||
|
comments.add(comment);
|
||||||
}
|
}
|
||||||
stmt.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
Logger.add(LogLevel.WARNING, "Failed to load trusted users for plot: " + id);
|
Logger.add(LogLevel.WARNING, "Failed to fetch rating for plot " + plot.getId().toString());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return l;
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setComment(final String world, final Plot plot, final PlotComment comment) {
|
||||||
|
runTask(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
PreparedStatement statement =
|
||||||
|
connection.prepareStatement("INSERT INTO `" + PREFIX + "plot_comments` (`plot_plot_id`, `comment`, `tier`, `sender`) VALUES(?,?,?,?)");
|
||||||
|
statement.setInt(1, getId(world, plot.id));
|
||||||
|
statement.setString(2, comment.comment);
|
||||||
|
statement.setInt(3, comment.tier);
|
||||||
|
statement.setString(4, comment.senderName);
|
||||||
|
statement.executeUpdate();
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Logger.add(LogLevel.WARNING, "Failed to remove helper for plot " + plot.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1193,4 +1202,5 @@ public class SQLManager extends AbstractDB {
|
|||||||
}
|
}
|
||||||
return 0.0d;
|
return 0.0d;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -384,7 +384,9 @@ public class DefaultPlotManager extends PlotManager {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setWallFilling(World w, PlotWorld plotworld, PlotId plotid, PlotBlock plotblock) {
|
public boolean setWallFilling(World w, PlotWorld plotworld, PlotId plotid, PlotBlock plotblock) {
|
||||||
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
|
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
|
||||||
|
if (dpw.ROAD_WIDTH==0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Location bottom = PlotHelper.getPlotBottomLoc(w, plotid);
|
Location bottom = PlotHelper.getPlotBottomLoc(w, plotid);
|
||||||
Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
||||||
|
|
||||||
@ -428,7 +430,9 @@ public class DefaultPlotManager extends PlotManager {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setWall(World w, PlotWorld plotworld, PlotId plotid, PlotBlock plotblock) {
|
public boolean setWall(World w, PlotWorld plotworld, PlotId plotid, PlotBlock plotblock) {
|
||||||
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
|
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
|
||||||
|
if (dpw.ROAD_WIDTH==0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Location bottom = PlotHelper.getPlotBottomLoc(w, plotid);
|
Location bottom = PlotHelper.getPlotBottomLoc(w, plotid);
|
||||||
Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user