Search in sources :

Example 6 with SearchParser

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

Example 7 with SearchParser

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

Aggregations

SearchParser (uk.co.oliwali.HawkEye.SearchParser)7 SearchQuery (uk.co.oliwali.HawkEye.database.SearchQuery)7 DataType (uk.co.oliwali.HawkEye.DataType)5 RollbackCallback (uk.co.oliwali.HawkEye.callbacks.RollbackCallback)3 SearchCallback (uk.co.oliwali.HawkEye.callbacks.SearchCallback)2 IncompleteRegionException (com.sk89q.worldedit.IncompleteRegionException)1 LocalPlayer (com.sk89q.worldedit.LocalPlayer)1 LocalWorld (com.sk89q.worldedit.LocalWorld)1 BukkitPlayer (com.sk89q.worldedit.bukkit.BukkitPlayer)1 Region (com.sk89q.worldedit.regions.Region)1 Vector (org.bukkit.util.Vector)1 DeleteCallback (uk.co.oliwali.HawkEye.callbacks.DeleteCallback)1 RebuildCallback (uk.co.oliwali.HawkEye.callbacks.RebuildCallback)1