1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-21 12:15:50 +00:00
Slimefun4/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunBlockHandler.java

46 lines
1.4 KiB
Java
Raw Normal View History

2016-04-14 16:24:03 +00:00
package me.mrCookieSlime.Slimefun.Objects;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
2020-01-12 17:39:06 +00:00
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
/**
* A {@link SlimefunBlockHandler} handles breaking and placing of blocks.
* You can use this class to initialize block data but also to correctly
* destroy blocks.
*
* {@code SlimefunItem.registerBlockHandler(String, SlimefunBlockHandler); }
*
* @author TheBusyBiscuit
*
*/
2019-08-30 19:02:55 +00:00
@FunctionalInterface
2016-04-14 16:24:03 +00:00
public interface SlimefunBlockHandler {
2019-08-30 19:02:55 +00:00
/**
* This method gets called when the Block is placed.
* Use this method to initialize block data.
*
* @param p The Player who placed it
* @param b The Block that was placed
* @param item The Item that will be stored inside the Block
*/
default void onPlace(Player p, Block b, SlimefunItem item) {
// This method can optionally be implemented by classes implementing it.
}
/**
* This method gets called when the Block is broken.
* The {@link Player} will be null if the Block is exploded
2019-08-30 19:02:55 +00:00
*
* @param p The Player who broke the Block
* @param b The Block that was broken
* @param item The SlimefunItem that was stored in that block
* @param reason The reason for the Block breaking
* @return Whether the Event should be cancelled
*/
2016-04-14 16:24:03 +00:00
boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason);
}