mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Removed SlimefunBlockHandler
This commit is contained in:
parent
c3028058c0
commit
d2e17af2a1
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#### Changes
|
#### Changes
|
||||||
* Renamed "Solar Panel" to "Photovoltaic Cell" to avoid confusions with solar generators
|
* Renamed "Solar Panel" to "Photovoltaic Cell" to avoid confusions with solar generators
|
||||||
|
* (API) Removed deprecated "SlimefunBlockHandler"
|
||||||
|
|
||||||
#### Fixes
|
#### Fixes
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockInfoConfig;
|
import me.mrCookieSlime.Slimefun.api.BlockInfoConfig;
|
||||||
@ -92,7 +91,6 @@ public final class SlimefunRegistry {
|
|||||||
private final Map<String, BlockMenuPreset> blockMenuPresets = new HashMap<>();
|
private final Map<String, BlockMenuPreset> blockMenuPresets = new HashMap<>();
|
||||||
private final Map<String, UniversalBlockMenu> universalInventories = new HashMap<>();
|
private final Map<String, UniversalBlockMenu> universalInventories = new HashMap<>();
|
||||||
private final Map<Class<? extends ItemHandler>, Set<ItemHandler>> globalItemHandlers = new HashMap<>();
|
private final Map<Class<? extends ItemHandler>, Set<ItemHandler>> globalItemHandlers = new HashMap<>();
|
||||||
private final Map<String, SlimefunBlockHandler> blockHandlers = new HashMap<>();
|
|
||||||
|
|
||||||
public void load(@Nonnull SlimefunPlugin plugin, @Nonnull Config cfg) {
|
public void load(@Nonnull SlimefunPlugin plugin, @Nonnull Config cfg) {
|
||||||
Validate.notNull(plugin, "The Plugin cannot be null!");
|
Validate.notNull(plugin, "The Plugin cannot be null!");
|
||||||
@ -333,12 +331,6 @@ public final class SlimefunRegistry {
|
|||||||
return globalItemHandlers;
|
return globalItemHandlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@Nonnull
|
|
||||||
public Map<String, SlimefunBlockHandler> getBlockHandlers() {
|
|
||||||
return blockHandlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public Map<String, BlockStorage> getWorlds() {
|
public Map<String, BlockStorage> getWorlds() {
|
||||||
return worlds;
|
return worlds;
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockExplodeEvent;
|
import org.bukkit.event.block.BlockExplodeEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -20,15 +21,14 @@ import io.github.thebusybiscuit.slimefun4.api.events.ExplosiveToolBreakBlocksEve
|
|||||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
@ -64,12 +64,12 @@ public class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements
|
|||||||
b.getWorld().playSound(b.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.2F, 1F);
|
b.getWorld().playSound(b.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.2F, 1F);
|
||||||
|
|
||||||
List<Block> blocks = findBlocks(b);
|
List<Block> blocks = findBlocks(b);
|
||||||
breakBlocks(p, tool, b, blocks, drops);
|
breakBlocks(e, p, tool, b, blocks, drops);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void breakBlocks(Player p, ItemStack item, Block b, List<Block> blocks, List<ItemStack> drops) {
|
private void breakBlocks(BlockBreakEvent e, Player p, ItemStack item, Block b, List<Block> blocks, List<ItemStack> drops) {
|
||||||
List<Block> blocksToDestroy = new ArrayList<>();
|
List<Block> blocksToDestroy = new ArrayList<>();
|
||||||
|
|
||||||
if (callExplosionEvent.getValue().booleanValue()) {
|
if (callExplosionEvent.getValue().booleanValue()) {
|
||||||
@ -96,7 +96,7 @@ public class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements
|
|||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
for (Block block : blocksToDestroy) {
|
for (Block block : blocksToDestroy) {
|
||||||
breakBlock(p, item, block, drops);
|
breakBlock(e, p, item, block, drops);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ public class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void breakBlock(Player p, ItemStack item, Block b, List<ItemStack> drops) {
|
private void breakBlock(BlockBreakEvent e, Player p, ItemStack item, Block b, List<ItemStack> drops) {
|
||||||
SlimefunPlugin.getProtectionManager().logAction(p, b, ProtectableAction.BREAK_BLOCK);
|
SlimefunPlugin.getProtectionManager().logAction(p, b, ProtectableAction.BREAK_BLOCK);
|
||||||
Material material = b.getType();
|
Material material = b.getType();
|
||||||
|
|
||||||
@ -149,10 +149,8 @@ public class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements
|
|||||||
SlimefunItem sfItem = BlockStorage.check(b);
|
SlimefunItem sfItem = BlockStorage.check(b);
|
||||||
|
|
||||||
if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
|
if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
|
||||||
SlimefunBlockHandler handler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getId());
|
if (!sfItem.callItemHandler(BlockBreakHandler.class, handler -> handler.onPlayerBreak(e, item, drops))) {
|
||||||
|
drops.addAll(sfItem.getDrops(p));
|
||||||
if (handler != null && !handler.onBreak(p, b, sfItem, UnregisterReason.PLAYER_BREAK)) {
|
|
||||||
drops.add(BlockStorage.retrieve(b));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
b.breakNaturally(item);
|
b.breakNaturally(item);
|
||||||
|
@ -30,9 +30,7 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
|
|
||||||
@ -157,23 +155,11 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
|
if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
|
||||||
SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getId());
|
|
||||||
|
|
||||||
if (blockHandler != null) {
|
|
||||||
try {
|
|
||||||
if (!blockHandler.onBreak(e.getPlayer(), e.getBlock(), sfItem, UnregisterReason.PLAYER_BREAK)) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (Exception | LinkageError x) {
|
|
||||||
sfItem.error("Something went wrong while triggering a BlockHandler", x);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sfItem.callItemHandler(BlockBreakHandler.class, handler -> handler.onPlayerBreak(e, item, drops));
|
sfItem.callItemHandler(BlockBreakHandler.class, handler -> handler.onPlayerBreak(e, item, drops));
|
||||||
|
|
||||||
if (e.isCancelled()) {
|
if (e.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
drops.addAll(sfItem.getDrops());
|
drops.addAll(sfItem.getDrops());
|
||||||
BlockStorage.clearBlockInfo(e.getBlock());
|
BlockStorage.clearBlockInfo(e.getBlock());
|
||||||
@ -219,14 +205,6 @@ public class BlockListener implements Listener {
|
|||||||
SlimefunItem sfItem = BlockStorage.check(blockAbove);
|
SlimefunItem sfItem = BlockStorage.check(blockAbove);
|
||||||
|
|
||||||
if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
|
if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
|
||||||
SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getId());
|
|
||||||
|
|
||||||
if (blockHandler != null) {
|
|
||||||
if (blockHandler.onBreak(e.getPlayer(), blockAbove, sfItem, UnregisterReason.PLAYER_BREAK)) {
|
|
||||||
blockAbove.getWorld().dropItemNaturally(blockAbove.getLocation(), BlockStorage.retrieve(blockAbove));
|
|
||||||
blockAbove.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/*
|
/*
|
||||||
* We create a dummy here to pass onto the BlockBreakHandler.
|
* We create a dummy here to pass onto the BlockBreakHandler.
|
||||||
* This will set the correct block context.
|
* This will set the correct block context.
|
||||||
@ -245,7 +223,6 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Fixes #2944 - Don't forget to clear the Block Data
|
// Fixes #2944 - Don't forget to clear the Block Data
|
||||||
BlockStorage.clearBlockInfo(blockAbove);
|
BlockStorage.clearBlockInfo(blockAbove);
|
||||||
|
@ -5,6 +5,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -18,9 +19,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.WitherProof;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.WitherProof;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,14 +57,16 @@ public class ExplosionsListener implements Listener {
|
|||||||
if (item != null) {
|
if (item != null) {
|
||||||
blocks.remove();
|
blocks.remove();
|
||||||
|
|
||||||
if (!(item instanceof WitherProof)) {
|
if (!(item instanceof WitherProof) && !item.callItemHandler(BlockBreakHandler.class, handler -> handleExplosion(handler, block))) {
|
||||||
SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(item.getId());
|
BlockStorage.clearBlockInfo(block);
|
||||||
boolean success = true;
|
block.setType(Material.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (blockHandler != null) {
|
@ParametersAreNonnullByDefault
|
||||||
success = blockHandler.onBreak(null, block, item, UnregisterReason.EXPLODE);
|
private void handleExplosion(BlockBreakHandler handler, Block block) {
|
||||||
} else {
|
|
||||||
item.callItemHandler(BlockBreakHandler.class, handler -> {
|
|
||||||
if (handler.isExplosionAllowed(block)) {
|
if (handler.isExplosionAllowed(block)) {
|
||||||
BlockStorage.clearBlockInfo(block);
|
BlockStorage.clearBlockInfo(block);
|
||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
@ -79,17 +80,5 @@ public class ExplosionsListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
BlockStorage.clearBlockInfo(block);
|
|
||||||
block.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Objects;
|
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler;
|
|
||||||
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
|
|
||||||
*
|
|
||||||
* @deprecated Please use the {@link BlockBreakHandler} instead.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface SlimefunBlockHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
}
|
|
@ -40,7 +40,6 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.Placeable;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
|
||||||
@ -532,11 +531,6 @@ public class SlimefunItem implements Placeable {
|
|||||||
// Send out deprecation warnings for any classes or interfaces
|
// Send out deprecation warnings for any classes or interfaces
|
||||||
checkForDeprecations(getClass());
|
checkForDeprecations(getClass());
|
||||||
|
|
||||||
// Inform addon developers about the BlockBreakHandler
|
|
||||||
if (SlimefunPlugin.getUpdater().getBranch() != SlimefunBranch.DEVELOPMENT && SlimefunPlugin.getRegistry().getBlockHandlers().containsKey(getId())) {
|
|
||||||
warn("This item uses a deprecated SlimefunBlockHandler which will be removed in the very near future! Please switch to the BlockBreakHandler as soon as possible.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for an illegal stack size
|
// Check for an illegal stack size
|
||||||
if (itemStackTemplate.getAmount() != 1) {
|
if (itemStackTemplate.getAmount() != 1) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
@ -1200,19 +1194,4 @@ public class SlimefunItem implements Placeable {
|
|||||||
return SlimefunPlugin.getRegistry().getPublicItemHandlers().computeIfAbsent(identifier, c -> new HashSet<>());
|
return SlimefunPlugin.getRegistry().getPublicItemHandlers().computeIfAbsent(identifier, c -> new HashSet<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This has been deprecated.
|
|
||||||
*
|
|
||||||
* @deprecated Please use {@link #addItemHandler(ItemHandler...)} and {@link BlockBreakHandler} instead
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* The id
|
|
||||||
* @param handler
|
|
||||||
* The handler
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static void registerBlockHandler(@Nonnull String id, @Nullable me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler handler) {
|
|
||||||
SlimefunPlugin.getRegistry().getBlockHandlers().put(id, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,36 +0,0 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem;
|
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines how a block handled by Slimefun is being unregistered.
|
|
||||||
* <p>
|
|
||||||
* It is notably used by
|
|
||||||
* {@link me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler#onBreak(org.bukkit.entity.Player, org.bukkit.block.Block, SlimefunItem, UnregisterReason)}.
|
|
||||||
*
|
|
||||||
* @author TheBusyBiscuit
|
|
||||||
*
|
|
||||||
* @deprecated This enum is no longer needed
|
|
||||||
*
|
|
||||||
* @see SlimefunBlockHandler
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public enum UnregisterReason {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An explosion destroys the block.
|
|
||||||
*/
|
|
||||||
EXPLODE,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A player breaks the block.
|
|
||||||
*/
|
|
||||||
PLAYER_BREAK,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An android miner breaks the block.
|
|
||||||
*/
|
|
||||||
ANDROID_DIG
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user