Skip to content

Commit

Permalink
Add plant growth event
Browse files Browse the repository at this point in the history
  • Loading branch information
bensku committed Mar 21, 2016
1 parent 098a7a2 commit f96f782
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/ch/njol/skript/classes/data/BukkitEventValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockSpreadEvent;
Expand Down Expand Up @@ -310,6 +311,15 @@ public Player get(final SignChangeEvent e) {
return e.getPlayer();
}
}, 0);
// BlockGrowEvent
EventValues.registerEventValue(BlockGrowEvent.class, Block.class, new Getter<Block, BlockGrowEvent>() {
@Override
@Nullable
public Block get(BlockGrowEvent e) {
return new BlockStateBlock(e.getBlock().getState(), true);
}

}, 0);

// === EntityEvents ===
EventValues.registerEventValue(EntityEvent.class, Entity.class, new Getter<Entity, EntityEvent>() {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/ch/njol/skript/events/EvtBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.bukkit.event.block.BlockEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingEvent;
Expand All @@ -50,6 +51,7 @@
import ch.njol.skript.lang.Literal;
import ch.njol.skript.lang.SkriptEvent;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleEvent;
import ch.njol.skript.registrations.Classes;
import ch.njol.util.Checker;

Expand Down Expand Up @@ -82,6 +84,10 @@ public class EvtBlock extends SkriptEvent {
.description("Called when a block is created, but not by a player, e.g. snow forms due to snowfall, water freezes in cold biomes, or a block spreads (see <a href='#spread'>spread event</a>).")
.examples("on form of snow", "on form of a mushroom")
.since("1.0");
Skript.registerEvent("Block Growth", EvtBlock.class, BlockGrowEvent.class, "(plant|crop|block) grow[(th|ing)] [[of] %itemtypes%]")
.description("Called when a crop grows.")
.examples("on crop growth")
.since("2.2-Fixes-V10");
}

@Nullable
Expand Down
1 change: 1 addition & 0 deletions src/main/java/ch/njol/skript/events/SimpleEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.bukkit.event.block.BlockCanBuildEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
Expand Down

0 comments on commit f96f782

Please sign in to comment.