2016-04-14 16:24:03 +00:00
|
|
|
package me.mrCookieSlime.Slimefun.Objects;
|
|
|
|
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.entity.Player;
|
2020-03-04 23:04:18 +00:00
|
|
|
import org.bukkit.event.Event;
|
2016-04-14 16:24:03 +00:00
|
|
|
|
2020-01-12 17:39:06 +00:00
|
|
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|
|
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
|
|
|
|
2020-03-02 13:25:33 +00:00
|
|
|
/**
|
|
|
|
* 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 {
|
2020-03-05 00:01:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method gets called when the {@link Block} is placed.
|
|
|
|
* Use this method to initialize block data.
|
|
|
|
*
|
|
|
|
* @param p
|
|
|
|
* The {@link Player} who placed it
|
|
|
|
* @param b
|
|
|
|
* The {@link Block} that was placed
|
|
|
|
* @param item
|
|
|
|
* The {@link SlimefunItem} that will be stored inside the {@link 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 {@link Block} is broken.
|
|
|
|
* The {@link Player} will be null if the {@link Block} exploded
|
|
|
|
*
|
|
|
|
* @param p
|
|
|
|
* The {@link Player} who broke the {@link Block}
|
|
|
|
* @param b
|
|
|
|
* The {@link Block} that was broken
|
|
|
|
* @param item
|
|
|
|
* The {@link SlimefunItem} that was stored in that {@link Block}
|
|
|
|
* @param reason
|
|
|
|
* The reason for the {@link Block} breaking
|
|
|
|
* @return Whether the {@link Event} should be cancelled
|
|
|
|
*/
|
|
|
|
boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason);
|
2016-04-14 16:24:03 +00:00
|
|
|
}
|