Add an option to teleport the player on plot clearing or deletion

This commit is contained in:
N0tMyFaultOG 2020-12-07 10:55:34 +01:00
parent ff70d5db14
commit 60859de0bd
No known key found for this signature in database
GPG Key ID: 823348042DA95A81
3 changed files with 14 additions and 0 deletions

View File

@ -31,6 +31,7 @@ import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.Result;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.PlotFlag;
@ -89,6 +90,10 @@ public class Clear extends Command {
checkTrue(force || !Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot) || Permissions
.hasPermission(player, "plots.continue"), TranslatableCaption.of("done.done_already_done"));
confirm.run(this, () -> {
if (Settings.Teleport.ON_CLEAR) {
plot.teleportPlayer(player, TeleportCause.COMMAND, result -> {
});
}
BackupManager.backup(player, plot, () -> {
final long start = System.currentTimeMillis();
boolean result = plot.getPlotModificationManager().clear(true, false, player, () -> {

View File

@ -26,6 +26,7 @@
package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
@ -98,6 +99,10 @@ public class Delete extends SubCommand {
return;
}
final long start = System.currentTimeMillis();
if (Settings.Teleport.ON_DELETE) {
plot.teleportPlayer(player, TeleportCause.COMMAND, result -> {
});
}
boolean result = plot.getPlotModificationManager().deletePlot(player, () -> {
plot.removeRunning();
if (this.econHandler.isEnabled(plotArea)) {

View File

@ -159,6 +159,8 @@ public class Settings extends Config {
Teleport.DELAY = config.getInt("teleport.delay", Teleport.DELAY);
Teleport.ON_LOGIN = config.getBoolean("teleport.on_login", Teleport.ON_LOGIN);
Teleport.ON_DEATH = config.getBoolean("teleport.on_death", Teleport.ON_DEATH);
Teleport.ON_CLEAR = config.getBoolean("teleport.on_clear", Teleport.ON_CLEAR);
Teleport.ON_DELETE = config.getBoolean("teleport.on_delete", Teleport.ON_DELETE);
// WorldEdit
//WE_ALLOW_HELPER = config.getBoolean("worldedit.enable-for-helpers");
@ -494,6 +496,8 @@ public class Settings extends Config {
@Comment({"Add a delay to all teleport commands (in seconds)",
"Assign `plots.teleport.delay.bypass` to bypass the cooldown"})
public static int DELAY = 0;
@Comment("Teleport outside of the plot before clearing") public static boolean ON_CLEAR = false;
@Comment("Teleport outside of the plot before deleting") public static boolean ON_DELETE = false;
@Comment("The visit command is ordered by world instead of globally") public static boolean
PER_WORLD_VISIT = false;
}