From 302fe0c2c8466e5bbb4d266a50d22effe650f11b Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 19 Feb 2016 12:50:38 -0500 Subject: [PATCH] Fix SpongeEventUtil --- .../sponge/events/PlotClearEvent.java | 22 +++++++-------- .../sponge/events/PlotDeleteEvent.java | 18 ++++++------ .../sponge/util/SpongeEventUtil.java | 28 +++++++++---------- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java b/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java index 5e3f533ba..9dd91f05d 100644 --- a/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java +++ b/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java @@ -1,5 +1,6 @@ package com.plotsquared.sponge.events; +import com.intellectualcrafters.plot.object.Plot; import org.spongepowered.api.event.Cancellable; import org.spongepowered.api.event.cause.Cause; import org.spongepowered.api.event.impl.AbstractEvent; @@ -7,28 +8,27 @@ import org.spongepowered.api.event.impl.AbstractEvent; import com.intellectualcrafters.plot.object.PlotId; public class PlotClearEvent extends AbstractEvent implements Cancellable { - private final PlotId id; - private final String world; + private boolean cancelled; - + private Plot plot; + /** * PlotDeleteEvent: Called when a plot is cleared * - * @param world The world in which the plot was cleared - * @param id The plot that was cleared + * @param plot The plot that was cleared */ - public PlotClearEvent(final String world, final PlotId id) { - this.id = id; - this.world = world; + + public PlotClearEvent(Plot plot) { + this.plot = plot; } - + /** * Get the PlotId * * @return PlotId */ public PlotId getPlotId() { - return id; + return plot.getId(); } /** @@ -37,7 +37,7 @@ public class PlotClearEvent extends AbstractEvent implements Cancellable { * @return String */ public String getWorld() { - return world; + return plot.getArea().worldname; } @Override diff --git a/src/main/java/com/plotsquared/sponge/events/PlotDeleteEvent.java b/src/main/java/com/plotsquared/sponge/events/PlotDeleteEvent.java index 61a11422f..2a7477312 100644 --- a/src/main/java/com/plotsquared/sponge/events/PlotDeleteEvent.java +++ b/src/main/java/com/plotsquared/sponge/events/PlotDeleteEvent.java @@ -1,23 +1,21 @@ package com.plotsquared.sponge.events; +import com.intellectualcrafters.plot.object.Plot; import org.spongepowered.api.event.cause.Cause; import org.spongepowered.api.event.impl.AbstractEvent; import com.intellectualcrafters.plot.object.PlotId; public class PlotDeleteEvent extends AbstractEvent { - private final PlotId id; - private final String world; - + private final Plot plot; + /** * PlotDeleteEvent: Called when a plot is deleted * - * @param world The world in which the plot was deleted - * @param id The ID of the plot that was deleted + * @param plot The plot that was deleted */ - public PlotDeleteEvent(final String world, final PlotId id) { - this.id = id; - this.world = world; + public PlotDeleteEvent(Plot plot) { + this.plot = plot; } /** @@ -26,7 +24,7 @@ public class PlotDeleteEvent extends AbstractEvent { * @return PlotId */ public PlotId getPlotId() { - return id; + return plot.getId(); } /** @@ -35,7 +33,7 @@ public class PlotDeleteEvent extends AbstractEvent { * @return String */ public String getWorld() { - return world; + return plot.getArea().worldname; } @Override diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java b/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java index 6d91b8177..a77c5820b 100644 --- a/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java @@ -1,14 +1,9 @@ package com.plotsquared.sponge.util; -import java.util.ArrayList; -import java.util.UUID; - -import org.spongepowered.api.event.Event; -import org.spongepowered.api.event.EventManager; - import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -30,6 +25,11 @@ import com.plotsquared.sponge.events.PlotFlagRemoveEvent; import com.plotsquared.sponge.events.PlotMergeEvent; import com.plotsquared.sponge.events.PlotRateEvent; import com.plotsquared.sponge.events.PlotUnlinkEvent; +import org.spongepowered.api.event.Event; +import org.spongepowered.api.event.EventManager; + +import java.util.ArrayList; +import java.util.UUID; public class SpongeEventUtil extends EventUtil { @@ -54,13 +54,13 @@ public class SpongeEventUtil extends EventUtil { } @Override - public boolean callClear(final String world, final PlotId id) { - return callEvent(new PlotClearEvent(world, id)); + public boolean callClear(final Plot plot) { + return callEvent(new PlotClearEvent(plot)); } @Override - public void callDelete(final String world, final PlotId id) { - callEvent(new PlotDeleteEvent(world, id)); + public void callDelete(Plot plot) { + callEvent(new PlotDeleteEvent(plot)); } @Override @@ -74,13 +74,13 @@ public class SpongeEventUtil extends EventUtil { } @Override - public boolean callMerge(final String world, final Plot plot, final ArrayList plots) { - return callEvent(new PlotMergeEvent(SpongeUtil.getWorld(world), plot, plots)); + public boolean callMerge(final Plot plot, final ArrayList plots) { + return callEvent(new PlotMergeEvent(SpongeUtil.getWorld(plot.getArea().worldname), plot, plots)); } @Override - public boolean callUnlink(final String world, final ArrayList plots) { - return callEvent(new PlotUnlinkEvent(SpongeUtil.getWorld(world), plots)); + public boolean callUnlink(final PlotArea area, final ArrayList plots) { + return callEvent(new PlotUnlinkEvent(SpongeUtil.getWorld(area.worldname), plots)); } @Override