PlotSquared icon indicating copy to clipboard operation
PlotSquared copied to clipboard

Add Events for Plot Move + Plot Swap

Open PierreSchwang opened this issue 3 years ago • 4 comments

Overview

Fixes #3692

Description

Adds a cancellable PlotMoveEvent and informational PostPlotMoveEvent. (+ Swap) ~~Found no fitting case for handling the FORCE result, therefor marked that as not supported (just supporting DENY and ACCEPT).~~

Submitter Checklist

  • [x] Make sure you are opening from a topic branch (/feature/fix/docs/ branch (right side)) and not your main branch.
  • [x] Ensure that the pull request title represents the desired changelog entry.
  • [x] New public fields and methods are annotated with @since TODO.
  • [x] I read and followed the contribution guidelines.

PierreSchwang avatar Aug 12 '22 18:08 PierreSchwang

Validated the functionality of this change using a simple addon plugin:

public class TestAddonPlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        new PlotAPI().registerListener(new Object() {

            @Subscribe
            public void onPlotMove(PlotMoveEvent event) {
                event.setEventResult(Result.DENY);
                System.out.println("cancelled");
            }

            @Subscribe
            public void onPostPlotMove(PostPlotMoveEvent event) {
                System.out.println("Plot was moved");
            }

        });
    }
}

The FORCE result may be used to move the plot to occupied places as well? Opinions about that @IntellectualSites/plotsquared-team?

PierreSchwang avatar Aug 13 '22 11:08 PierreSchwang

The destination of the move should be able to be changed in the event. Also, the FORCE result needs to be implemented (the event call needs to be moved further up)

I'd also say that a PlotSwapEvent should be added as the two commands are very similar

dordsor21 avatar Aug 19 '22 11:08 dordsor21

Please take a moment and address the merge conflicts of your pull request. Thanks!

github-actions[bot] avatar Oct 22 '23 10:10 github-actions[bot]