Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package org.skriptlang.skript.bukkit.block;

import ch.njol.skript.lang.util.SimpleEvent;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockDamageAbortEvent;
import org.skriptlang.skript.addon.AddonModule;
import org.skriptlang.skript.addon.HierarchicalAddonModule;
import org.skriptlang.skript.addon.SkriptAddon;
import org.skriptlang.skript.bukkit.block.furnace.FurnaceModule;
import org.skriptlang.skript.bukkit.block.sign.SignModule;
import org.skriptlang.skript.bukkit.lang.eventvalue.EventValue;
import org.skriptlang.skript.bukkit.lang.eventvalue.EventValueRegistry;
import org.skriptlang.skript.bukkit.registration.BukkitSyntaxInfos;

import java.util.List;

Expand All @@ -24,7 +31,30 @@ public Iterable<AddonModule> children() {

@Override
public void loadSelf(SkriptAddon addon) {
// intentionally left blank

// Register the event
Comment thread
Pro2021CA marked this conversation as resolved.
Outdated
moduleRegistry(addon).register(BukkitSyntaxInfos.Event.KEY, BukkitSyntaxInfos.Event.builder(SimpleEvent.class, "Block Damage Abort")
.addEvent(BlockDamageAbortEvent.class)
.addPatterns("(stop|abort) [of] block (break[ing]|damag(e|ing))")
.addPatterns("block (stop|abort) (break[ing]|damag(e|ing))")
Comment thread
Pro2021CA marked this conversation as resolved.
Outdated
.addDescription("Called when a player stops breaking a block.")
.addExample("""
on block stop breaking:
send "Hey! You have to finish what you started!"
""")
.addSince("INSERT VERSION")
.supplier(() -> new SimpleEvent("block damage abort"))
.build());

// Register values for said event
Comment thread
Pro2021CA marked this conversation as resolved.
Outdated
EventValueRegistry eventValueRegistry = addon.registry(EventValueRegistry.class);
Comment thread
Pro2021CA marked this conversation as resolved.
eventValueRegistry.register(EventValue.builder(BlockDamageAbortEvent.class, Player.class)
.getter(BlockDamageAbortEvent::getPlayer)
.build());
Comment thread
Pro2021CA marked this conversation as resolved.
Outdated

eventValueRegistry.register(EventValue.builder(BlockDamageAbortEvent.class, Block.class)
.getter(BlockDamageAbortEvent::getBlock)
.build());
Comment thread
Pro2021CA marked this conversation as resolved.
Outdated
Comment thread
Pro2021CA marked this conversation as resolved.
Outdated
}

@Override
Expand Down
Loading