Search in sources :

Example 6 with DataType

use of uk.co.oliwali.HawkEye.DataType in project HawkEye by oliverwoodings.

the class SearchCommand method moreHelp.

@Override
public void moreHelp() {
    List<String> acs = new ArrayList<String>();
    for (DataType type : DataType.values()) acs.add(type.getConfigName());
    Util.sendMessage(sender, "&7There are 7 parameters you can use - &ca: p: w: l: r: f: t:");
    Util.sendMessage(sender, "&6Action &ca:&7 - list of actions separated by commas. Select from the following: &8" + Util.join(acs, " "));
    Util.sendMessage(sender, "&6Player &cp:&7 - list of players. &6World &cw:&7 - list of worlds");
    Util.sendMessage(sender, "&6Filter &cf:&7 - list of keywords. &6Location &cl:&7 - x,y,z location");
    Util.sendMessage(sender, "&6Radius &cr:&7 - radius to search around given location");
    Util.sendMessage(sender, "&6Time &ct:&7 - time bracket in the following format:");
    Util.sendMessage(sender, "&7  -&c t:10h45m10s &7-back specified amount of time");
    Util.sendMessage(sender, "&7  -&c t:2011-06-02,10:45:10 &7-from given date");
    Util.sendMessage(sender, "&7  -&c t:2011-06-02,10:45:10,2011-07-04,18:15:00 &7-between dates");
}
Also used : ArrayList(java.util.ArrayList) DataType(uk.co.oliwali.HawkEye.DataType)

Example 7 with DataType

use of uk.co.oliwali.HawkEye.DataType 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)

Example 8 with DataType

use of uk.co.oliwali.HawkEye.DataType 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)

Example 9 with DataType

use of uk.co.oliwali.HawkEye.DataType 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 10 with DataType

use of uk.co.oliwali.HawkEye.DataType in project HawkEye by oliverwoodings.

the class RebuildCommand method moreHelp.

@Override
public void moreHelp() {
    List<String> acs = new ArrayList<String>();
    for (DataType type : DataType.values()) if (type.canRollback())
        acs.add(type.getConfigName());
    Util.sendMessage(sender, "&7There are 6 parameters you can use - &ca: p: w: r: f: t:");
    Util.sendMessage(sender, "&6Action &ca:&7 - list of actions separated by commas. Select from the following: &8" + Util.join(acs, " "));
    Util.sendMessage(sender, "&6Player &cp:&7 - list of players. &6World &cw:&7 - list of worlds");
    Util.sendMessage(sender, "&6Filter &cf:&7 - list of keywords (e.g. block id)");
    Util.sendMessage(sender, "&6Radius &cr:&7 - radius to search around given location");
    Util.sendMessage(sender, "&6Time &ct:&7 - time bracket in the following format:");
    Util.sendMessage(sender, "&7  -&c t:10h45m10s &7-back specified amount of time");
    Util.sendMessage(sender, "&7  -&c t:2011-06-02,10:45:10 &7-from given date");
    Util.sendMessage(sender, "&7  -&c t:2011-06-02,10:45:10,2011-07-04,18:15:00 &7-between dates");
}
Also used : ArrayList(java.util.ArrayList) DataType(uk.co.oliwali.HawkEye.DataType)

Aggregations

DataType (uk.co.oliwali.HawkEye.DataType)11 SearchParser (uk.co.oliwali.HawkEye.SearchParser)5 SearchQuery (uk.co.oliwali.HawkEye.database.SearchQuery)5 ArrayList (java.util.ArrayList)4 RollbackCallback (uk.co.oliwali.HawkEye.callbacks.RollbackCallback)3 DataEntry (uk.co.oliwali.HawkEye.entry.DataEntry)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 Method (java.lang.reflect.Method)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Event (org.bukkit.event.Event)1 EventException (org.bukkit.event.EventException)1 Listener (org.bukkit.event.Listener)1