use of uk.co.oliwali.HawkEye.callbacks.RollbackCallback 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;
}
use of uk.co.oliwali.HawkEye.callbacks.RollbackCallback 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.callbacks.RollbackCallback 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;
}
Aggregations