mirror of
https://github.com/shansen/EggCatcher.git
synced 2024-11-22 18:16:15 +01:00
added cancellable EggCaptureEvent
This commit is contained in:
parent
2787a65585
commit
b1b7dbd71d
@ -0,0 +1,41 @@
|
||||
package me.shansen.EggCatcher.events;
|
||||
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
|
||||
public class EggCaptureEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
boolean cancelled = false;
|
||||
Egg egg;
|
||||
|
||||
public EggCaptureEvent(Entity what, Egg egg) {
|
||||
super(what);
|
||||
this.egg = egg;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public Egg getEgg() {
|
||||
return this.egg;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean isCancelled) {
|
||||
this.cancelled = isCancelled;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package me.shansen.EggCatcher.listeners;
|
||||
|
||||
import me.shansen.EggCatcher.events.EggCaptureEvent;
|
||||
import me.shansen.EggCatcher.EggCatcher;
|
||||
import me.shansen.EggCatcher.EggType;
|
||||
|
||||
@ -142,6 +143,13 @@ public class EggCatcherEntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EggCaptureEvent eggCaptureEvent = new EggCaptureEvent(entity, egg);
|
||||
this.plugin.getServer().getPluginManager().callEvent(eggCaptureEvent);
|
||||
if (eggCaptureEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (egg.getShooter() instanceof Player) {
|
||||
Player player = (Player) egg.getShooter();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user