Fix SpongeEventUtil

This commit is contained in:
Matt 2016-02-19 12:50:38 -05:00
parent 660cd1b870
commit 302fe0c2c8
3 changed files with 33 additions and 35 deletions

View File

@ -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

View File

@ -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

View File

@ -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<PlotId> plots) {
return callEvent(new PlotMergeEvent(SpongeUtil.getWorld(world), plot, plots));
public boolean callMerge(final Plot plot, final ArrayList<PlotId> plots) {
return callEvent(new PlotMergeEvent(SpongeUtil.getWorld(plot.getArea().worldname), plot, plots));
}
@Override
public boolean callUnlink(final String world, final ArrayList<PlotId> plots) {
return callEvent(new PlotUnlinkEvent(SpongeUtil.getWorld(world), plots));
public boolean callUnlink(final PlotArea area, final ArrayList<PlotId> plots) {
return callEvent(new PlotUnlinkEvent(SpongeUtil.getWorld(area.worldname), plots));
}
@Override