Skip to content
Open
Changes from 7 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,18 @@
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.bukkit.inventory.ItemStack;
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 +32,32 @@ public Iterable<AddonModule> children() {

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

moduleRegistry(addon).register(BukkitSyntaxInfos.Event.KEY, BukkitSyntaxInfos.Event.builder(SimpleEvent.class, "Block Damage Abort")
.addEvent(BlockDamageAbortEvent.class)
.addPatterns(
"[player] (stop|abort[ing]) (damag(e|ing)|break(ing)) [a] block",
"block damage abort",
"block damage being aborted"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm iffy about these patterns but I can't think of anything better

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the best I could think of :/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some other ideas, but i don't really have any great ones either

on block break interrupt[ion]
on interrupt[ion] of block break[ing]
on block breaking interrupt[ed]

on incomplete block break[ing]
on unfinished block break[ing]

I'm iffy about using the word damage here, since it kind of implies the block is damaging something. It's probably still good to have as an option in the pattern tho since users may already be familiar, but I don't think it should be the primary option

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it's atleast decent now, I decided to keep damage in since it's also in the oficial event name.

)
.addDescription("Called when a player stops breaking a block.")
.addExample("""
on stop breaking block:
send "Hey! You have to finish what you started!"
Comment thread
Pro2021CA marked this conversation as resolved.
Outdated
""")
.addSince("INSERT VERSION")
.supplier(() -> new SimpleEvent("block damage abort"))
.build());

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


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

@Override
Expand Down