forked from LogBlock/LogBlock
Fixed QueryParams getTitle for custom tool params
This commit is contained in:
@@ -31,7 +31,6 @@ import de.diddiz.LogBlockQuestioner.LogBlockQuestioner;
|
|||||||
|
|
||||||
public class CommandsHandler implements CommandExecutor
|
public class CommandsHandler implements CommandExecutor
|
||||||
{
|
{
|
||||||
private final QueryParams defaultToolParams;
|
|
||||||
private final Logger log;
|
private final Logger log;
|
||||||
private final LogBlock logblock;
|
private final LogBlock logblock;
|
||||||
private final Config config;
|
private final Config config;
|
||||||
@@ -44,9 +43,6 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
config = logblock.getConfig();
|
config = logblock.getConfig();
|
||||||
scheduler = logblock.getServer().getScheduler();
|
scheduler = logblock.getServer().getScheduler();
|
||||||
questioner = (LogBlockQuestioner)logblock.getServer().getPluginManager().getPlugin("LogBlockQuestioner");
|
questioner = (LogBlockQuestioner)logblock.getServer().getPluginManager().getPlugin("LogBlockQuestioner");
|
||||||
defaultToolParams = new QueryParams(logblock);
|
|
||||||
defaultToolParams.radius = 0;
|
|
||||||
defaultToolParams.bct = BlockChangeType.ALL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -77,6 +73,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
sender.sendMessage(ChatColor.GOLD + "/lb tp [params] -- Teleports you to the location of griefing");
|
sender.sendMessage(ChatColor.GOLD + "/lb tp [params] -- Teleports you to the location of griefing");
|
||||||
sender.sendMessage(ChatColor.GOLD + "/lb writelogfile [params] -- Writes a log file");
|
sender.sendMessage(ChatColor.GOLD + "/lb writelogfile [params] -- Writes a log file");
|
||||||
sender.sendMessage(ChatColor.GOLD + "/lb lookup [params] -- Lookup");
|
sender.sendMessage(ChatColor.GOLD + "/lb lookup [params] -- Lookup");
|
||||||
|
sender.sendMessage(ChatColor.GOLD + "/lb page /lb prev /lb next -- Browse lookup result pages");
|
||||||
sender.sendMessage(ChatColor.GOLD + "/lb me -- Displays your stats");
|
sender.sendMessage(ChatColor.GOLD + "/lb me -- Displays your stats");
|
||||||
sender.sendMessage(ChatColor.GOLD + "Look at github.com/DiddiZ/LogBlock/wiki/Commands for the full commands reference");
|
sender.sendMessage(ChatColor.GOLD + "Look at github.com/DiddiZ/LogBlock/wiki/Commands for the full commands reference");
|
||||||
} else if (command.equals("params")) {
|
} else if (command.equals("params")) {
|
||||||
@@ -96,6 +93,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
sender.sendMessage(ChatColor.GOLD + "sum [none|blocks|players] -- Sums the result");
|
sender.sendMessage(ChatColor.GOLD + "sum [none|blocks|players] -- Sums the result");
|
||||||
sender.sendMessage(ChatColor.GOLD + "asc, desc -- Changes the order of the displayed log");
|
sender.sendMessage(ChatColor.GOLD + "asc, desc -- Changes the order of the displayed log");
|
||||||
sender.sendMessage(ChatColor.GOLD + "coords -- Shows coordinates for each block");
|
sender.sendMessage(ChatColor.GOLD + "coords -- Shows coordinates for each block");
|
||||||
|
sender.sendMessage(ChatColor.GOLD + "silent -- Displays lesser messages");
|
||||||
} else if (command.equals("permissions")) {
|
} else if (command.equals("permissions")) {
|
||||||
final String[] permissions = {"tool", "toolblock", "me", "lookup", "tp", "rollback", "clearlog", "hide", "ignoreRestrictions"};
|
final String[] permissions = {"tool", "toolblock", "me", "lookup", "tp", "rollback", "clearlog", "hide", "ignoreRestrictions"};
|
||||||
sender.sendMessage(ChatColor.DARK_AQUA + "You've got the following permissions:");
|
sender.sendMessage(ChatColor.DARK_AQUA + "You've got the following permissions:");
|
||||||
@@ -138,7 +136,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
sender.sendMessage(ChatColor.GREEN + "Tool parameters set to default.");
|
sender.sendMessage(ChatColor.GREEN + "Tool parameters set to default.");
|
||||||
} else if (logblock.hasPermission(player, "logblock.lookup"))
|
} else if (logblock.hasPermission(player, "logblock.lookup"))
|
||||||
try {
|
try {
|
||||||
final QueryParams params = defaultToolParams.clone();
|
final QueryParams params = config.toolQuery.clone();
|
||||||
params.parseArgs(sender, argsToList(args, 1));
|
params.parseArgs(sender, argsToList(args, 1));
|
||||||
logblock.getSession(player.getName()).toolQuery = params;
|
logblock.getSession(player.getName()).toolQuery = params;
|
||||||
sender.sendMessage(ChatColor.GREEN + "Set tool query to: " + params.getTitle());
|
sender.sendMessage(ChatColor.GREEN + "Set tool query to: " + params.getTitle());
|
||||||
@@ -185,7 +183,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
sender.sendMessage(ChatColor.GREEN + "Toolblock parameters set to default.");
|
sender.sendMessage(ChatColor.GREEN + "Toolblock parameters set to default.");
|
||||||
} else if (logblock.hasPermission(player, "logblock.lookup"))
|
} else if (logblock.hasPermission(player, "logblock.lookup"))
|
||||||
try {
|
try {
|
||||||
final QueryParams params = defaultToolParams.clone();
|
final QueryParams params = config.toolBlockQuery.clone();
|
||||||
params.parseArgs(sender, argsToList(args, 1));
|
params.parseArgs(sender, argsToList(args, 1));
|
||||||
logblock.getSession(player.getName()).toolBlockQuery = params;
|
logblock.getSession(player.getName()).toolBlockQuery = params;
|
||||||
sender.sendMessage(ChatColor.GREEN + "Set tool block query to: " + params.getTitle());
|
sender.sendMessage(ChatColor.GREEN + "Set tool block query to: " + params.getTitle());
|
||||||
@@ -200,7 +198,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (logblock.hasPermission(sender, "logblock.hide")) {
|
if (logblock.hasPermission(sender, "logblock.hide")) {
|
||||||
if (logblock.getConsumer().hide((Player)sender))
|
if (logblock.getConsumer().hide((Player)sender))
|
||||||
sender.sendMessage(ChatColor.GREEN + "You are now hided and won't appear in any log. Type '/lb hide' again to unhide");
|
sender.sendMessage(ChatColor.GREEN + "You are now hidden and aren't logged. Type '/lb hide' again to unhide");
|
||||||
else
|
else
|
||||||
sender.sendMessage(ChatColor.GREEN + "You aren't hidden anylonger.");
|
sender.sendMessage(ChatColor.GREEN + "You aren't hidden anylonger.");
|
||||||
} else
|
} else
|
||||||
@@ -408,7 +406,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
if (params.limit == 15)
|
if (params.limit == 15)
|
||||||
params.limit = config.linesLimit;
|
params.limit = config.linesLimit;
|
||||||
rs = state.executeQuery(params.getLookupQuery());
|
rs = state.executeQuery(params.getLookupQuery());
|
||||||
sender.sendMessage(ChatColor.DARK_AQUA + params.getTitle());
|
sender.sendMessage(ChatColor.DARK_AQUA + params.getTitle() + ":");
|
||||||
final List<BlockChange> blockchanges = new ArrayList<BlockChange>();
|
final List<BlockChange> blockchanges = new ArrayList<BlockChange>();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
rs.beforeFirst();
|
rs.beforeFirst();
|
||||||
|
@@ -90,6 +90,9 @@ public class QueryParams implements Cloneable
|
|||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
final StringBuilder title = new StringBuilder();
|
final StringBuilder title = new StringBuilder();
|
||||||
|
if (bct == BlockChangeType.CHESTACCESS)
|
||||||
|
title.append("chest accesses ");
|
||||||
|
else {
|
||||||
if (!types.isEmpty()) {
|
if (!types.isEmpty()) {
|
||||||
final String[] blocknames = new String[types.size()];
|
final String[] blocknames = new String[types.size()];
|
||||||
for (int i = 0; i < types.size(); i++)
|
for (int i = 0; i < types.size(); i++)
|
||||||
@@ -103,6 +106,7 @@ public class QueryParams implements Cloneable
|
|||||||
title.append("destructions ");
|
title.append("destructions ");
|
||||||
else
|
else
|
||||||
title.append("changes ");
|
title.append("changes ");
|
||||||
|
}
|
||||||
if (players.size() > 10)
|
if (players.size() > 10)
|
||||||
title.append((excludePlayersMode ? "without" : "from") + " many players ");
|
title.append((excludePlayersMode ? "without" : "from") + " many players ");
|
||||||
else if (!players.isEmpty())
|
else if (!players.isEmpty())
|
||||||
@@ -111,12 +115,19 @@ public class QueryParams implements Cloneable
|
|||||||
title.append("in the last " + minutes + " minutes ");
|
title.append("in the last " + minutes + " minutes ");
|
||||||
if (minutes < 0)
|
if (minutes < 0)
|
||||||
title.append("up to " + minutes * -1 + " minutes ago ");
|
title.append("up to " + minutes * -1 + " minutes ago ");
|
||||||
if (loc != null && radius > 0)
|
if (loc != null) {
|
||||||
title.append("within " + radius + " blocks of you ");
|
if (radius > 0)
|
||||||
if (loc != null && radius == 0)
|
title.append("within " + radius + " blocks of " + (prepareToolQuery ? "clicked block" : "you") + " ");
|
||||||
|
else if (radius == 0)
|
||||||
title.append("at " + loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ() + " ");
|
title.append("at " + loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ() + " ");
|
||||||
else if (sel != null)
|
} else if (sel != null)
|
||||||
title.append("inside selection ");
|
title.append(prepareToolQuery ? "at double chest" : "inside selection ");
|
||||||
|
else if (prepareToolQuery)
|
||||||
|
if (radius > 0)
|
||||||
|
title.append("within " + radius + " blocks of clicked block ");
|
||||||
|
else if (radius == 0)
|
||||||
|
title.append("at clicked block ");
|
||||||
|
if (!(sel != null && prepareToolQuery))
|
||||||
title.append("in " + friendlyWorldname(world.getName()));
|
title.append("in " + friendlyWorldname(world.getName()));
|
||||||
title.setCharAt(0, String.valueOf(title.charAt(0)).toUpperCase().toCharArray()[0]);
|
title.setCharAt(0, String.valueOf(title.charAt(0)).toUpperCase().toCharArray()[0]);
|
||||||
return title.toString();
|
return title.toString();
|
||||||
@@ -359,7 +370,10 @@ public class QueryParams implements Cloneable
|
|||||||
@Override
|
@Override
|
||||||
protected QueryParams clone() {
|
protected QueryParams clone() {
|
||||||
try {
|
try {
|
||||||
return (QueryParams)super.clone();
|
final QueryParams params = (QueryParams)super.clone();
|
||||||
|
params.players = new ArrayList<String>(players);
|
||||||
|
params.types = new ArrayList<Integer>(types);
|
||||||
|
return params;
|
||||||
} catch (final CloneNotSupportedException ex) {}
|
} catch (final CloneNotSupportedException ex) {}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -379,6 +393,7 @@ public class QueryParams implements Cloneable
|
|||||||
|
|
||||||
public void merge(QueryParams params) {
|
public void merge(QueryParams params) {
|
||||||
players = params.players;
|
players = params.players;
|
||||||
|
excludePlayersMode = params.excludePlayersMode;
|
||||||
types = params.types;
|
types = params.types;
|
||||||
loc = params.loc;
|
loc = params.loc;
|
||||||
radius = params.radius;
|
radius = params.radius;
|
||||||
|
Reference in New Issue
Block a user