use of uk.co.oliwali.HawkEye.database.SearchQuery in project HawkEye by oliverwoodings.
the class HereCommand method execute.
@Override
public boolean execute() {
//Create new parser
SearchParser parser = null;
try {
//Check for valid integer
if (args.size() != 0 && !Util.isInteger(args.get(0)))
throw new IllegalArgumentException("Invalid integer supplied for radius!");
int integer;
if (args.size() > 0)
integer = Integer.parseInt(args.get(0));
else
integer = Config.DefaultHereRadius;
if ((integer > Config.MaxRadius && Config.MaxRadius > 0) || integer < 0)
throw new IllegalArgumentException("Invalid radius supplied supplied!");
//New search parser
parser = new SearchParser(player, integer);
//Add in DataTypes
for (DataType type : DataType.values()) if (type.canHere())
parser.actions.add(type);
//Check if players were supplied
if (args.size() > 1)
for (String p : args.get(1).split(",")) parser.players.add(p);
//Add in 'here' actions
for (DataType type : DataType.values()) if (type.canHere())
parser.actions.add(type);
} catch (IllegalArgumentException e) {
Util.sendMessage(sender, "&c" + e.getMessage());
return true;
}
//Run the search query
new SearchQuery(new SearchCallback(session), parser, SearchDir.DESC);
return true;
}
use of uk.co.oliwali.HawkEye.database.SearchQuery in project HawkEye by oliverwoodings.
the class PreviewCommand method execute.
@Override
public boolean execute() {
//Check if player already has a rollback processing
if (session.doingRollback()) {
Util.sendMessage(sender, "&cYou already have a rollback command processing!");
return true;
}
//Parse arguments
SearchParser parser = null;
try {
parser = new SearchParser(player, args);
parser.loc = null;
//Check that supplied actions can rollback
if (parser.actions.size() > 0) {
for (DataType type : parser.actions) if (!type.canRollback())
throw new IllegalArgumentException("You cannot rollback that action type: &7" + type.getConfigName());
} else //If none supplied, add in all rollback types
{
for (DataType type : DataType.values()) if (type.canRollback())
parser.actions.add(type);
}
} catch (IllegalArgumentException e) {
Util.sendMessage(sender, "&c" + e.getMessage());
return true;
}
//Create new SearchQuery with data
new SearchQuery(new RollbackCallback(session, RollbackType.LOCAL), parser, SearchDir.DESC);
session.setInPreview(true);
return true;
}
use of uk.co.oliwali.HawkEye.database.SearchQuery in project HawkEye by oliverwoodings.
the class RebuildCommand method execute.
@Override
public boolean execute() {
//Check if player already has a rollback processing
if (session.doingRollback()) {
Util.sendMessage(sender, "&cYou already have a query command processing!");
return true;
}
//Parse arguments
SearchParser parser = null;
try {
parser = new SearchParser(player, args);
parser.loc = null;
//Check that supplied actions can rollback
if (parser.actions.size() > 0) {
for (DataType type : parser.actions) if (!type.canRollback())
throw new IllegalArgumentException("You cannot rebuild that action type: &7" + type.getConfigName());
} else //If none supplied, add in all rollback types
{
for (DataType type : DataType.values()) if (type.canRollback())
parser.actions.add(type);
}
} catch (IllegalArgumentException e) {
Util.sendMessage(sender, "&c" + e.getMessage());
return true;
}
//Create new SearchQuery with data
new SearchQuery(new RebuildCallback(session), parser, SearchDir.ASC);
return true;
}
Aggregations