mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 11:13:45 +01:00 
			
		
		
		
	Merge pull request #1134 from manuelgu/feature/componentevent
[WIP] Implement PlotComponentSetEvent
This commit is contained in:
		@@ -0,0 +1,55 @@
 | 
			
		||||
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 PlotComponentSetEvent extends AbstractEvent {
 | 
			
		||||
    private final Plot plot;
 | 
			
		||||
    private final String component;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * PlotDeleteEvent: Called when a plot component is set
 | 
			
		||||
     *
 | 
			
		||||
     * @param plot        The plot
 | 
			
		||||
     * @param component   The component which was set
 | 
			
		||||
     */
 | 
			
		||||
    public PlotComponentSetEvent(Plot plot, String component) {
 | 
			
		||||
        this.plot = plot;
 | 
			
		||||
        this.component = component;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the PlotId
 | 
			
		||||
     *
 | 
			
		||||
     * @return PlotId
 | 
			
		||||
     */
 | 
			
		||||
    public PlotId getPlotId() {
 | 
			
		||||
        return this.plot.getId();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the world name
 | 
			
		||||
     *
 | 
			
		||||
     * @return String
 | 
			
		||||
     */
 | 
			
		||||
    public String getWorld() {
 | 
			
		||||
        return this.plot.getArea().worldname;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the component which was set
 | 
			
		||||
     *
 | 
			
		||||
     * @return Component name
 | 
			
		||||
     */
 | 
			
		||||
    public String getComponent() {
 | 
			
		||||
        return this.component;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Cause getCause() {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -19,6 +19,7 @@ import com.plotsquared.sponge.events.PlayerPlotHelperEvent;
 | 
			
		||||
import com.plotsquared.sponge.events.PlayerPlotTrustedEvent;
 | 
			
		||||
import com.plotsquared.sponge.events.PlayerTeleportToPlotEvent;
 | 
			
		||||
import com.plotsquared.sponge.events.PlotClearEvent;
 | 
			
		||||
import com.plotsquared.sponge.events.PlotComponentSetEvent;
 | 
			
		||||
import com.plotsquared.sponge.events.PlotDeleteEvent;
 | 
			
		||||
import com.plotsquared.sponge.events.PlotFlagAddEvent;
 | 
			
		||||
import com.plotsquared.sponge.events.PlotFlagRemoveEvent;
 | 
			
		||||
@@ -52,6 +53,11 @@ public class SpongeEventUtil extends EventUtil {
 | 
			
		||||
    public boolean callTeleport(PlotPlayer player, Location from, Plot plot) {
 | 
			
		||||
        return callEvent(new PlayerTeleportToPlotEvent(SpongeUtil.getPlayer(player), from, plot));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean callComponentSet(Plot plot, String component) {
 | 
			
		||||
        return callEvent(new PlotComponentSetEvent(plot, component));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean callClear(Plot plot) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user