2019-06-05 20:13:30 +00:00
|
|
|
/*
|
2018-08-12 14:03:07 +00:00
|
|
|
package com.boydti.fawe.regions.general.plot;
|
|
|
|
|
|
|
|
import com.boydti.fawe.object.FawePlayer;
|
|
|
|
import com.boydti.fawe.object.RunnableVal;
|
|
|
|
import com.boydti.fawe.util.StringMan;
|
|
|
|
import com.boydti.fawe.util.TaskManager;
|
|
|
|
import com.boydti.fawe.wrappers.FakePlayer;
|
2019-02-17 08:47:32 +00:00
|
|
|
import com.github.intellectualsites.plotsquared.commands.Command;
|
|
|
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
|
|
|
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
|
|
|
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
|
|
|
|
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
|
2019-03-06 08:06:47 +00:00
|
|
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
2019-02-17 08:47:32 +00:00
|
|
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
|
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|
|
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|
|
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
|
|
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
|
|
|
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
|
|
|
|
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.event.platform.CommandEvent;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
2018-08-12 14:03:07 +00:00
|
|
|
|
|
|
|
@CommandDeclaration(
|
|
|
|
command = "replaceall",
|
|
|
|
permission = "plots.replaceall",
|
|
|
|
category = CommandCategory.APPEARANCE,
|
|
|
|
requiredType = RequiredType.NONE,
|
|
|
|
description = "Replace all block in the plot",
|
|
|
|
usage = "/plots replaceall <from> <to>"
|
|
|
|
)
|
|
|
|
public class ReplaceAll extends Command {
|
|
|
|
public ReplaceAll() {
|
|
|
|
super(MainCommand.getInstance(), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
2019-03-06 08:06:47 +00:00
|
|
|
checkTrue(args.length >= 1, Captions.COMMAND_SYNTAX, getUsage());
|
|
|
|
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
|
|
|
checkTrue(plot.isOwner(player.getUUID()), Captions.NOW_OWNER);
|
|
|
|
checkTrue(plot.getRunning() == 0, Captions.WAIT_FOR_TIMER);
|
2018-08-12 14:03:07 +00:00
|
|
|
final PlotArea area = plot.getArea();
|
|
|
|
if (area instanceof SinglePlotArea) {
|
|
|
|
plot.addRunning();
|
|
|
|
FawePlayer<Object> fp = FawePlayer.wrap(player.getName());
|
2019-03-06 08:06:47 +00:00
|
|
|
Captions.TASK_START.send(player);
|
2021-12-22 19:58:23 +00:00
|
|
|
TaskManager.taskManager().async(() -> fp.runAction(() -> {
|
2019-06-05 20:13:30 +00:00
|
|
|
String worldName = plot.getWorldName();
|
2021-12-22 19:58:23 +00:00
|
|
|
TaskManager.taskManager().sync(new RunnableVal<Object>() {
|
2019-06-05 20:13:30 +00:00
|
|
|
@Override
|
|
|
|
public void run(Object value) {
|
|
|
|
SetupUtils.manager.unload(worldName, true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
FakePlayer actor = FakePlayer.getConsole();
|
|
|
|
String cmd = "/replaceallpattern " + worldName + " " + StringMan.join(args, " ");
|
|
|
|
CommandEvent event = new CommandEvent(actor, cmd);
|
2019-07-06 00:46:48 +00:00
|
|
|
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
2021-12-22 19:58:23 +00:00
|
|
|
TaskManager.taskManager().sync(new RunnableVal<Object>() {
|
2019-06-05 20:13:30 +00:00
|
|
|
@Override
|
|
|
|
public void run(Object value) {
|
|
|
|
plot.teleportPlayer(player);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
plot.removeRunning();
|
|
|
|
}, true, false));
|
2018-08-12 14:03:07 +00:00
|
|
|
} else {
|
|
|
|
player.sendMessage("Must have the `worlds` component enabled in the PlotSquared config.yml");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-06-05 20:13:30 +00:00
|
|
|
}
|
|
|
|
*/
|