From 60859de0bd81c6eb4a8ec38f101faa684d2854dc Mon Sep 17 00:00:00 2001 From: N0tMyFaultOG Date: Mon, 7 Dec 2020 10:55:34 +0100 Subject: [PATCH] Add an option to teleport the player on plot clearing or deletion --- Core/src/main/java/com/plotsquared/core/command/Clear.java | 5 +++++ Core/src/main/java/com/plotsquared/core/command/Delete.java | 5 +++++ .../java/com/plotsquared/core/configuration/Settings.java | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/Core/src/main/java/com/plotsquared/core/command/Clear.java b/Core/src/main/java/com/plotsquared/core/command/Clear.java index 000f293d3..8c4d644cd 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Clear.java +++ b/Core/src/main/java/com/plotsquared/core/command/Clear.java @@ -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, () -> { diff --git a/Core/src/main/java/com/plotsquared/core/command/Delete.java b/Core/src/main/java/com/plotsquared/core/command/Delete.java index 6ff6ef879..52d73039c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Delete.java +++ b/Core/src/main/java/com/plotsquared/core/command/Delete.java @@ -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)) { diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java index 98e3d3f9a..5e932e774 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java @@ -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; }