1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Revert "feat: added MultiBlockBreakEvent"

This reverts commit bd85eab39c.
This commit is contained in:
NgLoader 2021-07-24 03:21:51 +02:00
parent 73e757212e
commit c1b373fc83
No known key found for this signature in database
GPG Key ID: 74455A66C00F16B3
5 changed files with 1 additions and 115 deletions

View File

@ -1,83 +0,0 @@
package io.github.thebusybiscuit.slimefun4.api.events;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* This {@link Event} is called when a {@link Player} breaks multiply blocks.
*
* @author TheBusyBiscuit
*
*/
public class MultiBlockBreakEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Player player;
private final Block clickedBlock;
private final List<Block> blocks;
private boolean cancelled;
@ParametersAreNonnullByDefault
public MultiBlockBreakEvent(@Nullable Player player, Block clicked, List<Block> blocks) {
this.player = player;
this.clickedBlock = clicked;
this.blocks = blocks;
}
/**
* This returns the specific {@link Block} that was breaked.
*
* @return The {@link Block} that was breaked
*/
@Nonnull
public Block getClickedBlock() {
return clickedBlock;
}
/**
* This returns the list of all breaking blocks.
*
* @return A list of {@link Block}
*/
@Nonnull
public List<Block> getBlocks() {
return this.blocks;
}
@Nullable
public Player getPlayer() {
return this.player;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@Nonnull
public static HandlerList getHandlerList() {
return handlers;
}
@Nonnull
@Override
public HandlerList getHandlers() {
return getHandlerList();
}
}

View File

@ -19,7 +19,6 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.blocks.Vein;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockBreakEvent;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
@ -49,13 +48,6 @@ public class WoodcutterAndroid extends ProgrammableAndroid {
List<Block> list = Vein.find(target, MAX_REACH, block -> Tag.LOGS.isTagged(block.getType()));
if (!list.isEmpty()) {
MultiBlockBreakEvent event = new MultiBlockBreakEvent(null, target, list);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
Block log = list.get(list.size() - 1);
log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType());

View File

@ -6,7 +6,6 @@ import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Axis;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -17,7 +16,6 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.blocks.Vein;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockBreakEvent;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler;
@ -77,13 +75,6 @@ public class LumberAxe extends SlimefunItem implements NotPlaceable {
logs.remove(block);
}
MultiBlockBreakEvent event = new MultiBlockBreakEvent(e.getPlayer(), block, logs);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
for (Block b : logs) {
if (!BlockStorage.hasBlockInfo(b) && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b, ProtectableAction.BREAK_BLOCK)) {
stripLog(b);

View File

@ -4,7 +4,6 @@ import java.util.List;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -15,7 +14,6 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.blocks.Vein;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockBreakEvent;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting;
import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler;
@ -49,14 +47,8 @@ public class PickaxeOfVeinMining extends SimpleSlimefunItem<ToolUseHandler> {
return (e, tool, fortune, drops) -> {
if (SlimefunTag.PICKAXE_OF_VEIN_MINING_BLOCKS.isTagged(e.getBlock().getType())) {
List<Block> blocks = Vein.find(e.getBlock(), maxBlocks.getValue(), b -> SlimefunTag.PICKAXE_OF_VEIN_MINING_BLOCKS.isTagged(b.getType()));
MultiBlockBreakEvent event = new MultiBlockBreakEvent(e.getPlayer(), e.getBlock(), blocks);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
breakBlocks(e.getPlayer(), blocks, fortune, tool);
}
}
};
}

View File

@ -14,7 +14,6 @@ import org.bukkit.event.Listener;
import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
import io.github.thebusybiscuit.slimefun4.api.events.ExplosiveToolBreakBlocksEvent;
import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockBreakEvent;
import io.github.thebusybiscuit.slimefun4.api.events.ReactorExplodeEvent;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import net.imprex.orebfuscator.api.OrebfuscatorService;
@ -61,9 +60,4 @@ public class OrebfuscatorIntegration implements Listener {
public void onReactorExplode(ReactorExplodeEvent event) {
this.service.deobfuscate(Arrays.asList(event.getLocation().getBlock()));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMultiBlockBreak(MultiBlockBreakEvent event) {
this.service.deobfuscate(event.getBlocks());
}
}