Search in sources :

Example 1 with SearchCallback

use of uk.co.oliwali.HawkEye.callbacks.SearchCallback in project HawkEye by oliverwoodings.

the class SearchCommand method execute.

@Override
public boolean execute() {
    //Parse arguments
    SearchParser parser = null;
    try {
        parser = new SearchParser(sender, args);
    } catch (IllegalArgumentException e) {
        Util.sendMessage(sender, "&c" + e.getMessage());
        return true;
    }
    //Create new SeachQuery with data
    new SearchQuery(new SearchCallback(session), parser, SearchDir.DESC);
    return true;
}
Also used : SearchQuery(uk.co.oliwali.HawkEye.database.SearchQuery) SearchCallback(uk.co.oliwali.HawkEye.callbacks.SearchCallback) SearchParser(uk.co.oliwali.HawkEye.SearchParser)

Example 2 with SearchCallback

use of uk.co.oliwali.HawkEye.callbacks.SearchCallback in project HawkEye by oliverwoodings.

the class ToolManager method toolSearch.

/**
	 * Performs a HawkEye tool search at the specified location
	 * @param player
	 * @param loc
	 */
public static void toolSearch(Player player, Location loc) {
    PlayerSession session = SessionManager.getSession(player);
    SearchParser parser;
    //If parameters aren't bound, do some default
    if (session.getToolCommand().length == 0 || session.getToolCommand()[0] == "") {
        parser = new SearchParser(player);
        for (DataType type : DataType.values()) if (type.canHere())
            parser.actions.add(type);
    } else //Else use the default ones
    {
        parser = new SearchParser(player, Arrays.asList(session.getToolCommand()));
    }
    Vector vec = Util.getSimpleLocation(loc).toVector();
    parser.loc = vec;
    parser.minLoc = null;
    parser.maxLoc = null;
    parser.worlds = new String[] { loc.getWorld().getName() };
    new SearchQuery(new SearchCallback(SessionManager.getSession(player)), parser, SearchDir.DESC);
}
Also used : SearchQuery(uk.co.oliwali.HawkEye.database.SearchQuery) SearchCallback(uk.co.oliwali.HawkEye.callbacks.SearchCallback) Vector(org.bukkit.util.Vector)

Example 3 with SearchCallback

use of uk.co.oliwali.HawkEye.callbacks.SearchCallback 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;
}
Also used : SearchQuery(uk.co.oliwali.HawkEye.database.SearchQuery) SearchCallback(uk.co.oliwali.HawkEye.callbacks.SearchCallback) DataType(uk.co.oliwali.HawkEye.DataType) SearchParser(uk.co.oliwali.HawkEye.SearchParser)

Aggregations

SearchCallback (uk.co.oliwali.HawkEye.callbacks.SearchCallback)3 SearchQuery (uk.co.oliwali.HawkEye.database.SearchQuery)3 SearchParser (uk.co.oliwali.HawkEye.SearchParser)2 Vector (org.bukkit.util.Vector)1 DataType (uk.co.oliwali.HawkEye.DataType)1