mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
A few more changes
This commit is contained in:
parent
1aeba31a96
commit
8d1e427409
@ -39,6 +39,7 @@
|
|||||||
* Fixed #2147
|
* Fixed #2147
|
||||||
* Fixed #2179
|
* Fixed #2179
|
||||||
* Fixed Reinforced Spawners not working sometimes
|
* Fixed Reinforced Spawners not working sometimes
|
||||||
|
* Fixed Explosive Pickaxe not handling normal Shulker boxes correctly
|
||||||
|
|
||||||
## Release Candidate 15 (01 Aug 2020)
|
## Release Candidate 15 (01 Aug 2020)
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
|
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -31,15 +28,8 @@ public class ExplosiveShovel extends ExplosiveTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void breakBlock(Player p, ItemStack item, Block b, int fortune, List<ItemStack> drops) {
|
protected boolean canBreak(Player p, Block b) {
|
||||||
if (MaterialTools.getBreakableByShovel().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
return MaterialTools.getBreakableByShovel().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK);
|
||||||
SlimefunPlugin.getProtectionManager().logAction(p, b, ProtectableAction.BREAK_BLOCK);
|
|
||||||
|
|
||||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
|
||||||
b.breakNaturally(item);
|
|
||||||
|
|
||||||
damageItem(p, item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,15 @@ 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This {@link SlimefunItem} is a super class for items like the {@link ExplosivePickaxe} or {@link ExplosiveShovel}.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
* @see ExplosivePickaxe
|
||||||
|
* @see ExplosiveShovel
|
||||||
|
*
|
||||||
|
*/
|
||||||
class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements NotPlaceable, DamageableItem {
|
class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements NotPlaceable, DamageableItem {
|
||||||
|
|
||||||
private final ItemSetting<Boolean> damageOnUse = new ItemSetting<>("damage-on-use", true);
|
private final ItemSetting<Boolean> damageOnUse = new ItemSetting<>("damage-on-use", true);
|
||||||
@ -61,16 +70,20 @@ class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements NotPla
|
|||||||
|
|
||||||
if (!blockExplodeEvent.isCancelled()) {
|
if (!blockExplodeEvent.isCancelled()) {
|
||||||
for (Block block : blockExplodeEvent.blockList()) {
|
for (Block block : blockExplodeEvent.blockList()) {
|
||||||
|
if (canBreak(p, block)) {
|
||||||
breakBlock(p, item, block, fortune, drops);
|
breakBlock(p, item, block, fortune, drops);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
for (Block block : blocks) {
|
for (Block block : blocks) {
|
||||||
|
if (canBreak(p, block)) {
|
||||||
breakBlock(p, item, block, fortune, drops);
|
breakBlock(p, item, block, fortune, drops);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List<Block> findBlocks(Block b) {
|
private List<Block> findBlocks(Block b) {
|
||||||
List<Block> blocks = new ArrayList<>(26);
|
List<Block> blocks = new ArrayList<>(26);
|
||||||
@ -96,8 +109,19 @@ class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements NotPla
|
|||||||
return damageOnUse.getValue();
|
return damageOnUse.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void breakBlock(Player p, ItemStack item, Block b, int fortune, List<ItemStack> drops) {
|
protected boolean canBreak(Player p, Block b) {
|
||||||
if (!b.isEmpty() && !b.isLiquid() && !MaterialCollections.getAllUnbreakableBlocks().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
if (b.isEmpty() || b.isLiquid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (MaterialCollections.getAllUnbreakableBlocks().contains(b.getType())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void breakBlock(Player p, ItemStack item, Block b, int fortune, List<ItemStack> drops) {
|
||||||
SlimefunPlugin.getProtectionManager().logAction(p, b, ProtectableAction.BREAK_BLOCK);
|
SlimefunPlugin.getProtectionManager().logAction(p, b, ProtectableAction.BREAK_BLOCK);
|
||||||
|
|
||||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
||||||
@ -110,8 +134,8 @@ class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements NotPla
|
|||||||
drops.add(BlockStorage.retrieve(b));
|
drops.add(BlockStorage.retrieve(b));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (b.getType() == Material.PLAYER_HEAD || b.getType().name().endsWith("_SHULKER_BOX")) {
|
else if (b.getType() == Material.PLAYER_HEAD || b.getType() == Material.SHULKER_BOX || b.getType().name().endsWith("_SHULKER_BOX")) {
|
||||||
b.breakNaturally();
|
b.breakNaturally(item);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
boolean applyFortune = b.getType().name().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE;
|
boolean applyFortune = b.getType().name().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE;
|
||||||
@ -128,6 +152,5 @@ class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements NotPla
|
|||||||
|
|
||||||
damageItem(p, item);
|
damageItem(p, item);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user