diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index 2c84dbab7..c04cd10c8 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -758,6 +758,9 @@ public class PlotSquared { if (this_max < last_max) { plot.getArea().setMeta("lastPlot", plot.getId()); } + if (callEvent) { + eventDispatcher.callPostDelete(plot); + } return true; } return false; diff --git a/Core/src/main/java/com/plotsquared/core/command/Auto.java b/Core/src/main/java/com/plotsquared/core/command/Auto.java index f4392f4d8..7d234a3bd 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Auto.java +++ b/Core/src/main/java/com/plotsquared/core/command/Auto.java @@ -344,6 +344,7 @@ public class Auto extends SubCommand { continue; } plot.claim(player, !plotIterator.hasNext(), null, true, true); + eventDispatcher.callPostAuto(player, plot); } final PlotAutoMergeEvent mergeEvent = this.eventDispatcher.callAutoMerge( plots.get(0), diff --git a/Core/src/main/java/com/plotsquared/core/command/Claim.java b/Core/src/main/java/com/plotsquared/core/command/Claim.java index 12040cfb0..4833a7ad7 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Claim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java @@ -208,13 +208,15 @@ public class Claim extends SubCommand { Template.of("value", "Auto merge on claim") ); } else { - plot.getPlotModificationManager().autoMerge( + if (plot.getPlotModificationManager().autoMerge( mergeEvent.getDir(), mergeEvent.getMax(), player.getUUID(), player, true - ); + )) { + eventDispatcher.callPostMerge(player, plot); + } } } return null; 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 e68133855..5ff603023 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Delete.java +++ b/Core/src/main/java/com/plotsquared/core/command/Delete.java @@ -130,6 +130,7 @@ public class Delete extends SubCommand { Template.of("amount", String.valueOf(System.currentTimeMillis() - start)), Template.of("plot", plot.getId().toString()) ); + eventDispatcher.callPostDelete(plot); }); if (result) { plot.addRunning(); diff --git a/Core/src/main/java/com/plotsquared/core/command/Merge.java b/Core/src/main/java/com/plotsquared/core/command/Merge.java index 9121ec748..485aba3ca 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Merge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Merge.java @@ -189,6 +189,7 @@ public class Merge extends SubCommand { ); } player.sendMessage(TranslatableCaption.of("merge.success_merge")); + eventDispatcher.callPostMerge(player, plot); return true; } player.sendMessage(TranslatableCaption.of("merge.no_available_automerge")); @@ -225,6 +226,7 @@ public class Merge extends SubCommand { ); } player.sendMessage(TranslatableCaption.of("merge.success_merge")); + eventDispatcher.callPostMerge(player, plot); return true; } Plot adjacent = plot.getRelative(direction); @@ -272,6 +274,7 @@ public class Merge extends SubCommand { ); } player.sendMessage(TranslatableCaption.of("merge.success_merge")); + eventDispatcher.callPostMerge(player, plot); }; if (!force && hasConfirmation(player)) { CmdConfirm.addPending(accepter, MINI_MESSAGE.serialize(MINI_MESSAGE diff --git a/Core/src/main/java/com/plotsquared/core/command/Owner.java b/Core/src/main/java/com/plotsquared/core/command/Owner.java index 66a991413..668bd4e8a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Owner.java +++ b/Core/src/main/java/com/plotsquared/core/command/Owner.java @@ -44,6 +44,7 @@ import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.task.TaskManager; import net.kyori.adventure.text.minimessage.Template; import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Collection; import java.util.Collections; @@ -76,6 +77,7 @@ public class Owner extends SetCommand { ); return false; } + @Nullable final UUID oldOwner = plot.getOwnerAbs(); Set plots = plot.getConnectedPlots(); final Consumer uuidConsumer = uuid -> { @@ -124,12 +126,15 @@ public class Owner extends SetCommand { ); return; } - plot.getPlotModificationManager().unlinkPlot(unlinkEvent.isCreateRoad(), unlinkEvent.isCreateRoad()); + if (plot.getPlotModificationManager().unlinkPlot(unlinkEvent.isCreateRoad(), unlinkEvent.isCreateRoad())) { + eventDispatcher.callPostUnlink(plot, PlotUnlinkEvent.REASON.NEW_OWNER); + } Set connected = plot.getConnectedPlots(); for (Plot current : connected) { current.unclaim(); current.getPlotModificationManager().removeSign(); } + eventDispatcher.callPostOwnerChange(player, plot, oldOwner); player.sendMessage(TranslatableCaption.of("owner.set_owner")); return; } @@ -178,6 +183,7 @@ public class Owner extends SetCommand { } plot.getPlotModificationManager().setSign(finalName); player.sendMessage(TranslatableCaption.of("owner.set_owner")); + eventDispatcher.callPostOwnerChange(player, plot, oldOwner); if (other != null) { other.sendMessage( TranslatableCaption.of("owner.now_owner"), diff --git a/Core/src/main/java/com/plotsquared/core/command/Unlink.java b/Core/src/main/java/com/plotsquared/core/command/Unlink.java index 75a4678b4..96c8d224c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Unlink.java +++ b/Core/src/main/java/com/plotsquared/core/command/Unlink.java @@ -109,6 +109,7 @@ public class Unlink extends SubCommand { return; } player.sendMessage(TranslatableCaption.of("merge.unlink_success")); + eventDispatcher.callPostUnlink(plot, PlotUnlinkEvent.REASON.PLAYER_COMMAND); }; if (hasConfirmation(player)) { CmdConfirm.addPending(player, "/plot unlink " + plot.getId(), runnable); diff --git a/Core/src/main/java/com/plotsquared/core/events/post/PostPlayerAutoPlotEvent.java b/Core/src/main/java/com/plotsquared/core/events/post/PostPlayerAutoPlotEvent.java new file mode 100644 index 000000000..743293631 --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/events/post/PostPlayerAutoPlotEvent.java @@ -0,0 +1,51 @@ +/* + * _____ _ _ _____ _ + * | __ \| | | | / ____| | | + * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| | + * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | + * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| | + * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_| + * | | + * |_| + * PlotSquared plot management system for Minecraft + * Copyright (C) 2021 IntellectualSites + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.plotsquared.core.events.post; + +import com.plotsquared.core.events.PlotPlayerEvent; +import com.plotsquared.core.player.PlotPlayer; +import com.plotsquared.core.plot.Plot; + +/** + * Called after a plot was chosen for a player by {@code /plot auto} + *
+ * Called after {@link com.plotsquared.core.events.PlayerAutoPlotEvent} and only, if no listener cancelled the action. + * + * @since 6.2.0 + */ +public class PostPlayerAutoPlotEvent extends PlotPlayerEvent { + + /** + * Instantiate a new PlayerAutoPlotPostEvent. + * + * @param plotPlayer The player who claims a new plot by {@code /plot auto}. + * @param plot The plot that is assigned to the player. + */ + public PostPlayerAutoPlotEvent(final PlotPlayer plotPlayer, final Plot plot) { + super(plotPlayer, plot); + } + +} diff --git a/Core/src/main/java/com/plotsquared/core/events/post/PostPlotChangeOwnerEvent.java b/Core/src/main/java/com/plotsquared/core/events/post/PostPlotChangeOwnerEvent.java new file mode 100644 index 000000000..20d89540c --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/events/post/PostPlotChangeOwnerEvent.java @@ -0,0 +1,80 @@ +/* + * _____ _ _ _____ _ + * | __ \| | | | / ____| | | + * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| | + * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | + * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| | + * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_| + * | | + * |_| + * PlotSquared plot management system for Minecraft + * Copyright (C) 2021 IntellectualSites + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.plotsquared.core.events.post; + +import com.plotsquared.core.events.PlotPlayerEvent; +import com.plotsquared.core.player.PlotPlayer; +import com.plotsquared.core.plot.Plot; +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.UUID; + +/** + * Called after the owner of a plot was updated. + * + * @since 6.2.0 + */ +public class PostPlotChangeOwnerEvent extends PlotPlayerEvent { + + @Nullable + private final UUID oldOwner; + + /** + * Instantiate a new PlotChangedOwnerEvent. + * + * @param initiator The player who executed the owner change. + * @param plot The plot which owner was changed. + * @param oldOwner The previous owner - if present, otherwise {@code null}. + */ + public PostPlotChangeOwnerEvent(final PlotPlayer initiator, final Plot plot, @Nullable UUID oldOwner) { + super(initiator, plot); + this.oldOwner = oldOwner; + } + + /** + * @return the old owner of the plot - if present, otherwise {@code null}. + */ + public @Nullable UUID getOldOwner() { + return oldOwner; + } + + /** + * @return {@code true} if the plot had an owner, {@code false} otherwise. + * @see #getOldOwner() + */ + public boolean hasOldOwner() { + return getOldOwner() != null; + } + + /** + * @return {@code true} if the plot now has an owner, {@code false} otherwise. + * @see Plot#hasOwner() + */ + public boolean hasNewOwner() { + return getPlot().hasOwner(); + } + +} diff --git a/Core/src/main/java/com/plotsquared/core/events/post/PostPlotDeleteEvent.java b/Core/src/main/java/com/plotsquared/core/events/post/PostPlotDeleteEvent.java new file mode 100644 index 000000000..672cb9726 --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/events/post/PostPlotDeleteEvent.java @@ -0,0 +1,47 @@ +/* + * _____ _ _ _____ _ + * | __ \| | | | / ____| | | + * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| | + * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | + * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| | + * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_| + * | | + * |_| + * PlotSquared plot management system for Minecraft + * Copyright (C) 2021 IntellectualSites + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.plotsquared.core.events.post; + +import com.plotsquared.core.events.PlotEvent; +import com.plotsquared.core.plot.Plot; + +/** + * Called after a {@link Plot} was deleted. + * + * @since 6.2.0 + */ +public class PostPlotDeleteEvent extends PlotEvent { + + /** + * Instantiate a new PlotDeleteEvent. + * + * @param plot The plot which was deleted. + */ + public PostPlotDeleteEvent(final Plot plot) { + super(plot); + } + +} diff --git a/Core/src/main/java/com/plotsquared/core/events/post/PostPlotMergeEvent.java b/Core/src/main/java/com/plotsquared/core/events/post/PostPlotMergeEvent.java new file mode 100644 index 000000000..b321630f1 --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/events/post/PostPlotMergeEvent.java @@ -0,0 +1,49 @@ +/* + * _____ _ _ _____ _ + * | __ \| | | | / ____| | | + * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| | + * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | + * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| | + * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_| + * | | + * |_| + * PlotSquared plot management system for Minecraft + * Copyright (C) 2021 IntellectualSites + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.plotsquared.core.events.post; + +import com.plotsquared.core.events.PlotPlayerEvent; +import com.plotsquared.core.player.PlotPlayer; +import com.plotsquared.core.plot.Plot; + +/** + * Called after multiple plots were merged with another. + * + * @since 6.2.0 + */ +public class PostPlotMergeEvent extends PlotPlayerEvent { + + /** + * Instantiate a new PlotMergedEvent. + * + * @param plotPlayer The {@link PlotPlayer} that initiated the merge. + * @param plot The final merged plot. + */ + public PostPlotMergeEvent(final PlotPlayer plotPlayer, final Plot plot) { + super(plotPlayer, plot); + } + +} diff --git a/Core/src/main/java/com/plotsquared/core/events/post/PostPlotUnlinkEvent.java b/Core/src/main/java/com/plotsquared/core/events/post/PostPlotUnlinkEvent.java new file mode 100644 index 000000000..4759fe218 --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/events/post/PostPlotUnlinkEvent.java @@ -0,0 +1,61 @@ +/* + * _____ _ _ _____ _ + * | __ \| | | | / ____| | | + * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| | + * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | + * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| | + * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_| + * | | + * |_| + * PlotSquared plot management system for Minecraft + * Copyright (C) 2021 IntellectualSites + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.plotsquared.core.events.post; + +import com.plotsquared.core.events.PlotEvent; +import com.plotsquared.core.events.PlotUnlinkEvent; +import com.plotsquared.core.plot.Plot; + +/** + * Called when several plots were unlinked. + * + * @since 6.2.0 + */ +public class PostPlotUnlinkEvent extends PlotEvent { + + private final PlotUnlinkEvent.REASON reason; + + /** + * Instantiate a new PlotUnlinkedEvent. + * + * @param plot The unlinked plot. + * @param reason The reason for the unlink. + */ + public PostPlotUnlinkEvent(final Plot plot, PlotUnlinkEvent.REASON reason) { + super(plot); + this.reason = reason; + } + + /** + * The original reason provided by {@link PlotUnlinkEvent}. + * + * @return The reason for the unlink. + */ + public PlotUnlinkEvent.REASON getReason() { + return reason; + } + +} diff --git a/Core/src/main/java/com/plotsquared/core/events/post/package-info.java b/Core/src/main/java/com/plotsquared/core/events/post/package-info.java new file mode 100644 index 000000000..d23f65d6f --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/events/post/package-info.java @@ -0,0 +1,33 @@ +/* + * _____ _ _ _____ _ + * | __ \| | | | / ____| | | + * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| | + * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | + * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| | + * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_| + * | | + * |_| + * PlotSquared plot management system for Minecraft + * Copyright (C) 2021 IntellectualSites + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +/** + * Contains events which are fired after specific actions are completed. + *
+ * E.g. {@link com.plotsquared.core.events.PlotDeleteEvent} is called before a plot is actually deleted and useful for + * cancelling the action itself. {@link com.plotsquared.core.events.post.PostPlotDeleteEvent} will be called after the plot was + * deleted. + */ +package com.plotsquared.core.events.post; diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java index c11d6a2a8..59d0bb3ef 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java @@ -229,8 +229,8 @@ public final class PlotModificationManager { !isDelete, isDelete ? PlotUnlinkEvent.REASON.DELETE : PlotUnlinkEvent.REASON.CLEAR ); - if (event.getEventResult() != Result.DENY) { - this.unlinkPlot(event.isCreateRoad(), event.isCreateSign()); + if (event.getEventResult() != Result.DENY && this.unlinkPlot(event.isCreateRoad(), event.isCreateSign())) { + PlotSquared.get().getEventDispatcher().callPostUnlink(plot, event.getReason()); } final PlotManager manager = this.plot.getArea().getPlotManager(); Runnable run = new Runnable() { @@ -502,7 +502,9 @@ public final class PlotModificationManager { } return; } - plot.getPlotModificationManager().autoMerge(event.getDir(), event.getMax(), uuid, player, true); + if (plot.getPlotModificationManager().autoMerge(event.getDir(), event.getMax(), uuid, player, true)) { + PlotSquared.get().getEventDispatcher().callPostMerge(player, plot); + } } }); return true; diff --git a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java index 678129ea2..2e63a2ef0 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java @@ -426,8 +426,11 @@ public class ExpireManager { .callUnlink(plot.getArea(), plot, true, false, PlotUnlinkEvent.REASON.EXPIRE_DELETE ); - if (event.getEventResult() != Result.DENY) { - plot.getPlotModificationManager().unlinkPlot(event.isCreateRoad(), event.isCreateSign()); + if (event.getEventResult() != Result.DENY && plot.getPlotModificationManager().unlinkPlot( + event.isCreateRoad(), + event.isCreateSign() + )) { + this.eventDispatcher.callPostUnlink(plot, PlotUnlinkEvent.REASON.EXPIRE_DELETE); } } for (UUID helper : plot.getTrusted()) { diff --git a/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java b/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java index 93f04c2f2..7173ecdcb 100644 --- a/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java +++ b/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java @@ -51,6 +51,11 @@ import com.plotsquared.core.events.PlotMergeEvent; import com.plotsquared.core.events.PlotRateEvent; import com.plotsquared.core.events.PlotUnlinkEvent; import com.plotsquared.core.events.TeleportCause; +import com.plotsquared.core.events.post.PostPlayerAutoPlotEvent; +import com.plotsquared.core.events.post.PostPlotChangeOwnerEvent; +import com.plotsquared.core.events.post.PostPlotDeleteEvent; +import com.plotsquared.core.events.post.PostPlotMergeEvent; +import com.plotsquared.core.events.post.PostPlotUnlinkEvent; import com.plotsquared.core.listener.PlayerBlockEventType; import com.plotsquared.core.location.Direction; import com.plotsquared.core.location.Location; @@ -135,6 +140,12 @@ public class EventDispatcher { return event; } + public PostPlayerAutoPlotEvent callPostAuto(PlotPlayer player, Plot plot) { + PostPlayerAutoPlotEvent event = new PostPlayerAutoPlotEvent(player, plot); + callEvent(event); + return event; + } + public PlayerAutoPlotsChosenEvent callAutoPlotsChosen( PlotPlayer player, List plots ) { @@ -174,6 +185,12 @@ public class EventDispatcher { return event; } + public PostPlotDeleteEvent callPostDelete(Plot plot) { + PostPlotDeleteEvent event = new PostPlotDeleteEvent(plot); + callEvent(event); + return event; + } + public PlotFlagAddEvent callFlagAdd(PlotFlag flag, Plot plot) { PlotFlagAddEvent event = new PlotFlagAddEvent(flag, plot); callEvent(event); @@ -192,6 +209,12 @@ public class EventDispatcher { return event; } + public PostPlotMergeEvent callPostMerge(PlotPlayer player, Plot plot) { + PostPlotMergeEvent event = new PostPlotMergeEvent(player, plot); + callEvent(event); + return event; + } + public PlotAutoMergeEvent callAutoMerge(Plot plot, List plots) { PlotAutoMergeEvent event = new PlotAutoMergeEvent(plot.getWorldName(), plot, plots); callEvent(event); @@ -207,6 +230,12 @@ public class EventDispatcher { return event; } + public PostPlotUnlinkEvent callPostUnlink(Plot plot, PlotUnlinkEvent.REASON reason) { + PostPlotUnlinkEvent event = new PostPlotUnlinkEvent(plot, reason); + callEvent(event); + return event; + } + public PlayerEnterPlotEvent callEntry(PlotPlayer player, Plot plot) { PlayerEnterPlotEvent event = new PlayerEnterPlotEvent(player, plot); callEvent(event); @@ -256,6 +285,12 @@ public class EventDispatcher { return event; } + public PostPlotChangeOwnerEvent callPostOwnerChange(PlotPlayer player, Plot plot, @Nullable UUID oldOwner) { + PostPlotChangeOwnerEvent event = new PostPlotChangeOwnerEvent(player, plot, oldOwner); + callEvent(event); + return event; + } + public PlotRateEvent callRating(PlotPlayer player, Plot plot, Rating rating) { PlotRateEvent event = new PlotRateEvent(player, rating, plot); eventBus.post(event); diff --git a/Core/src/main/java/com/plotsquared/core/util/task/AutoClaimFinishTask.java b/Core/src/main/java/com/plotsquared/core/util/task/AutoClaimFinishTask.java index 301ea50c0..7eb548b82 100644 --- a/Core/src/main/java/com/plotsquared/core/util/task/AutoClaimFinishTask.java +++ b/Core/src/main/java/com/plotsquared/core/util/task/AutoClaimFinishTask.java @@ -69,6 +69,7 @@ public final class AutoClaimFinishTask implements Callable { return false; } plot.claim(player, true, schematic, false, true); + eventDispatcher.callPostAuto(player, plot); if (area.isAutoMerge()) { PlotMergeEvent event = this.eventDispatcher.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player); if (event.getEventResult() == Result.DENY) { @@ -77,7 +78,9 @@ public final class AutoClaimFinishTask implements Callable { Templates.of("value", "Auto Merge") ); } else { - plot.getPlotModificationManager().autoMerge(event.getDir(), event.getMax(), player.getUUID(), player, true); + if (plot.getPlotModificationManager().autoMerge(event.getDir(), event.getMax(), player.getUUID(), player, true)) { + eventDispatcher.callPostMerge(player, plot); + } } } return true;