forked from LogBlock/LogBlock
Added coords parameter
This commit is contained in:
@@ -355,7 +355,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
rs = state.executeQuery(params.getQuery());
|
rs = state.executeQuery(params.getLookupQuery());
|
||||||
sender.sendMessage(ChatColor.DARK_AQUA + params.getTitle());
|
sender.sendMessage(ChatColor.DARK_AQUA + params.getTitle());
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
rs.beforeFirst();
|
rs.beforeFirst();
|
||||||
@@ -366,7 +366,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
else if (sum == SummarizationMode.PLAYERS)
|
else if (sum == SummarizationMode.PLAYERS)
|
||||||
sender.sendMessage(ChatColor.GOLD + String.format("%-6s %-6s %s", "Created", "Destroyed", "Playername"));
|
sender.sendMessage(ChatColor.GOLD + String.format("%-6s %-6s %s", "Created", "Destroyed", "Playername"));
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
sender.sendMessage(ChatColor.GOLD + histformatter.format(rs));
|
sender.sendMessage(ChatColor.GOLD + histformatter.format(rs, params.coords));
|
||||||
} else
|
} else
|
||||||
sender.sendMessage(ChatColor.DARK_AQUA + "No results found.");
|
sender.sendMessage(ChatColor.DARK_AQUA + "No results found.");
|
||||||
} catch (final SQLException ex) {
|
} catch (final SQLException ex) {
|
||||||
@@ -388,7 +388,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
public void run() {
|
public void run() {
|
||||||
File file = null;
|
File file = null;
|
||||||
try {
|
try {
|
||||||
rs = state.executeQuery(params.getQuery());
|
rs = state.executeQuery(params.getLookupQuery());
|
||||||
file = new File("plugins/LogBlock/log/" + params.getTitle() + ".log");
|
file = new File("plugins/LogBlock/log/" + params.getTitle() + ".log");
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
final FileWriter writer = new FileWriter(file);
|
final FileWriter writer = new FileWriter(file);
|
||||||
@@ -397,7 +397,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
sender.sendMessage(ChatColor.GREEN + "Creating " + file.getName());
|
sender.sendMessage(ChatColor.GREEN + "Creating " + file.getName());
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
writer.write(histformatter.format(rs) + newline);
|
writer.write(histformatter.format(rs, params.coords) + newline);
|
||||||
writer.close();
|
writer.close();
|
||||||
sender.sendMessage(ChatColor.GREEN + "Done");
|
sender.sendMessage(ChatColor.GREEN + "Done");
|
||||||
} catch (final SQLException ex) {
|
} catch (final SQLException ex) {
|
||||||
|
@@ -15,7 +15,7 @@ public class HistoryFormatter
|
|||||||
this.sum = sum;
|
this.sum = sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
String format(ResultSet rs) throws SQLException {
|
String format(ResultSet rs, boolean coords) throws SQLException {
|
||||||
if (sum == SummarizationMode.NONE) {
|
if (sum == SummarizationMode.NONE) {
|
||||||
final StringBuilder msg = new StringBuilder(formatter.format(rs.getTimestamp("date")) + " " + rs.getString("playername") + " ");
|
final StringBuilder msg = new StringBuilder(formatter.format(rs.getTimestamp("date")) + " " + rs.getString("playername") + " ");
|
||||||
final int type = rs.getInt("type");
|
final int type = rs.getInt("type");
|
||||||
@@ -50,6 +50,8 @@ public class HistoryFormatter
|
|||||||
msg.append("created " + getMaterialName(type));
|
msg.append("created " + getMaterialName(type));
|
||||||
else
|
else
|
||||||
msg.append("replaced " + getMaterialName(replaced) + " with " + getMaterialName(type));
|
msg.append("replaced " + getMaterialName(replaced) + " with " + getMaterialName(type));
|
||||||
|
if (coords)
|
||||||
|
msg.append(" at " + rs.getInt("x") + ":" + rs.getInt("y") + ":" + rs.getInt("z"));
|
||||||
return msg.toString();
|
return msg.toString();
|
||||||
} else if (sum == SummarizationMode.TYPES)
|
} else if (sum == SummarizationMode.TYPES)
|
||||||
return fillWithSpaces(rs.getInt("created")) + fillWithSpaces(rs.getInt("destroyed")) + getMaterialName(rs.getInt("type"));
|
return fillWithSpaces(rs.getInt("created")) + fillWithSpaces(rs.getInt("destroyed")) + getMaterialName(rs.getInt("type"));
|
||||||
|
@@ -23,13 +23,13 @@ import com.sk89q.worldedit.bukkit.selections.Selection;
|
|||||||
|
|
||||||
public class QueryParams implements Cloneable
|
public class QueryParams implements Cloneable
|
||||||
{
|
{
|
||||||
private static final HashSet<Integer> keywords = new HashSet<Integer>(Arrays.asList("player".hashCode(), "area".hashCode(), "selection".hashCode(), "sel".hashCode(), "block".hashCode(), "type".hashCode(), "sum".hashCode(), "destroyed".hashCode(), "created".hashCode(), "chestaccess".hashCode(), "all".hashCode(), "time".hashCode(), "since".hashCode(), "before".hashCode(), "limit".hashCode(), "world".hashCode(), "asc".hashCode(), "desc".hashCode(), "last".hashCode()));
|
private static final HashSet<Integer> keywords = new HashSet<Integer>(Arrays.asList("player".hashCode(), "area".hashCode(), "selection".hashCode(), "sel".hashCode(), "block".hashCode(), "type".hashCode(), "sum".hashCode(), "destroyed".hashCode(), "created".hashCode(), "chestaccess".hashCode(), "all".hashCode(), "time".hashCode(), "since".hashCode(), "before".hashCode(), "limit".hashCode(), "world".hashCode(), "asc".hashCode(), "desc".hashCode(), "last".hashCode(), "coords".hashCode()));
|
||||||
public BlockChangeType bct = BlockChangeType.BOTH;
|
public BlockChangeType bct = BlockChangeType.BOTH;
|
||||||
public int limit = 15, minutes = 0, radius = -1;
|
public int limit = 15, minutes = 0, radius = -1;
|
||||||
public Location loc = null;
|
public Location loc = null;
|
||||||
public Order order = Order.DESC;
|
public Order order = Order.DESC;
|
||||||
public List<String> players = new ArrayList<String>();
|
public List<String> players = new ArrayList<String>();
|
||||||
public boolean prepareToolQuery = false;
|
public boolean prepareToolQuery = false, coords = false;
|
||||||
public Selection sel = null;
|
public Selection sel = null;
|
||||||
public SummarizationMode sum = SummarizationMode.NONE;
|
public SummarizationMode sum = SummarizationMode.NONE;
|
||||||
public List<Integer> types = new ArrayList<Integer>();
|
public List<Integer> types = new ArrayList<Integer>();
|
||||||
@@ -61,10 +61,12 @@ public class QueryParams implements Cloneable
|
|||||||
return "ORDER BY date " + order + ", id " + order + " ";
|
return "ORDER BY date " + order + ", id " + order + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getQuery() {
|
public String getLookupQuery() {
|
||||||
if (sum == SummarizationMode.NONE) {
|
if (sum == SummarizationMode.NONE) {
|
||||||
String select = "SELECT date, replaced, type, playername";
|
String select = "SELECT date, replaced, type, playername";
|
||||||
String from = "FROM `" + getTable() + "` INNER JOIN `lb-players` USING (playerid) ";
|
String from = "FROM `" + getTable() + "` INNER JOIN `lb-players` USING (playerid) ";
|
||||||
|
if (coords)
|
||||||
|
select += ", x, y, z";
|
||||||
if (types.size() == 0 || types.contains(63) || types.contains(68)) {
|
if (types.size() == 0 || types.contains(63) || types.contains(68)) {
|
||||||
select += ", signtext";
|
select += ", signtext";
|
||||||
from += "LEFT JOIN `" + getTable() + "-sign` USING (id) ";
|
from += "LEFT JOIN `" + getTable() + "-sign` USING (id) ";
|
||||||
@@ -310,6 +312,8 @@ public class QueryParams implements Cloneable
|
|||||||
order = Order.ASC;
|
order = Order.ASC;
|
||||||
else if (param.equals("desc"))
|
else if (param.equals("desc"))
|
||||||
order = Order.DESC;
|
order = Order.DESC;
|
||||||
|
else if (param.equals("coords"))
|
||||||
|
coords = true;
|
||||||
else
|
else
|
||||||
throw new IllegalArgumentException("Not a valid argument: '" + param + "'");
|
throw new IllegalArgumentException("Not a valid argument: '" + param + "'");
|
||||||
if (values != null)
|
if (values != null)
|
||||||
|
Reference in New Issue
Block a user