Search in sources :

Example 1 with SearchQuery

use of uk.co.oliwali.HawkEye.database.SearchQuery 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 SearchQuery

use of uk.co.oliwali.HawkEye.database.SearchQuery 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 SearchQuery

use of uk.co.oliwali.HawkEye.database.SearchQuery in project HawkEye by oliverwoodings.

the class DeleteCommand 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 DeleteCallback(session), parser, SearchDir.DESC);
    return true;
}
Also used : SearchQuery(uk.co.oliwali.HawkEye.database.SearchQuery) DeleteCallback(uk.co.oliwali.HawkEye.callbacks.DeleteCallback) SearchParser(uk.co.oliwali.HawkEye.SearchParser)

Example 4 with SearchQuery

use of uk.co.oliwali.HawkEye.database.SearchQuery in project HawkEye by oliverwoodings.

the class RollbackCommand 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.GLOBAL), parser, SearchDir.DESC);
    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 5 with SearchQuery

use of uk.co.oliwali.HawkEye.database.SearchQuery in project HawkEye by oliverwoodings.

the class WorldEditRollbackCommand 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;
    }
    //Check if WorldEdit is enabled
    if (HawkEye.worldEdit == null) {
        Util.sendMessage(sender, "&7WorldEdit&c is not enabled, unable to perform rollbacks in selected region");
        return true;
    }
    //Check if the WorldEdit selection is complete
    Region region = null;
    try {
        LocalPlayer lp = new BukkitPlayer(HawkEye.worldEdit, HawkEye.worldEdit.getWorldEdit().getServer(), player);
        LocalWorld lw = lp.getWorld();
        region = HawkEye.worldEdit.getWorldEdit().getSession(lp).getSelection(lw);
    } catch (IncompleteRegionException e) {
        Util.sendMessage(sender, "&cPlease complete your selection before doing a &7WorldEdit&c rollback!");
        return true;
    }
    //Parse arguments
    SearchParser parser = null;
    try {
        parser = new SearchParser(player, args);
        //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;
    }
    //Set WorldEdit locations
    parser.minLoc = new Vector(region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
    parser.maxLoc = new Vector(region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
    //Create new SearchQuery with data
    new SearchQuery(new RollbackCallback(session, RollbackType.GLOBAL), parser, SearchDir.DESC);
    return true;
}
Also used : SearchQuery(uk.co.oliwali.HawkEye.database.SearchQuery) LocalWorld(com.sk89q.worldedit.LocalWorld) LocalPlayer(com.sk89q.worldedit.LocalPlayer) IncompleteRegionException(com.sk89q.worldedit.IncompleteRegionException) Region(com.sk89q.worldedit.regions.Region) DataType(uk.co.oliwali.HawkEye.DataType) SearchParser(uk.co.oliwali.HawkEye.SearchParser) Vector(org.bukkit.util.Vector) RollbackCallback(uk.co.oliwali.HawkEye.callbacks.RollbackCallback) BukkitPlayer(com.sk89q.worldedit.bukkit.BukkitPlayer)

Aggregations

SearchQuery (uk.co.oliwali.HawkEye.database.SearchQuery)8 SearchParser (uk.co.oliwali.HawkEye.SearchParser)7 DataType (uk.co.oliwali.HawkEye.DataType)5 RollbackCallback (uk.co.oliwali.HawkEye.callbacks.RollbackCallback)3 SearchCallback (uk.co.oliwali.HawkEye.callbacks.SearchCallback)3 Vector (org.bukkit.util.Vector)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 DeleteCallback (uk.co.oliwali.HawkEye.callbacks.DeleteCallback)1 RebuildCallback (uk.co.oliwali.HawkEye.callbacks.RebuildCallback)1