diff --git a/src/main/java/net/Indyuce/mmocore/api/block/BlockInfo.java b/src/main/java/net/Indyuce/mmocore/api/block/BlockInfo.java index e207bc4a..16c64292 100644 --- a/src/main/java/net/Indyuce/mmocore/api/block/BlockInfo.java +++ b/src/main/java/net/Indyuce/mmocore/api/block/BlockInfo.java @@ -88,6 +88,10 @@ public class BlockInfo { return regen != null; } + public boolean regenerates() { + return regen != null; + } + public RegenInfo getRegenerationInfo() { return regen; } diff --git a/src/main/java/net/Indyuce/mmocore/listener/BlockListener.java b/src/main/java/net/Indyuce/mmocore/listener/BlockListener.java index ba8089c4..8a2ddef7 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/BlockListener.java +++ b/src/main/java/net/Indyuce/mmocore/listener/BlockListener.java @@ -103,7 +103,7 @@ public class BlockListener implements Listener { * apply drop tables */ if (info.hasDropTable()) { - Location dropLocation = getSafeDropLocation(block, true); + Location dropLocation = getSafeDropLocation(block, !(info.regenerates() && info.getRegenerationInfo().hasTemporaryBlock())); for (ItemStack drop : called.getDrops()) if (drop.getType() != Material.AIR && drop.getAmount() > 0) block.getWorld().dropItemNaturally(dropLocation, drop); @@ -120,7 +120,6 @@ public class BlockListener implements Listener { } } - @EventHandler(priority = EventPriority.HIGH) public void b(BlockPlaceEvent event) { event.getBlock().setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true)); @@ -134,12 +133,11 @@ public class BlockListener implements Listener { BlockFace direction = event.getDirection(); movedBlock = movedBlock.getRelative(direction, 2); - for (Block b : event.getBlocks()) { + for (Block b : event.getBlocks()) if (b.hasMetadata("player_placed")) { movedBlock = b.getRelative(direction); movedBlock.setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true)); } - } } @EventHandler @@ -158,10 +156,12 @@ public class BlockListener implements Listener { if (block.getType() == Material.AIR && self) return block.getLocation(); - Block relative; - for (BlockFace face : order) - if (!(relative = block.getRelative(face)).getType().isSolid()) - return relative.getLocation().add(block.getLocation().subtract(relative.getLocation()).multiply(.3)); + for (BlockFace face : order) { + Block relative = block.getRelative(face); + if (!relative.getType().isSolid()) + return relative.getLocation().add(block.getLocation().subtract(relative.getLocation()).multiply(.6)); + } + return block.getLocation(); } } diff --git a/src/main/java/net/Indyuce/mmocore/manager/RestrictionManager.java b/src/main/java/net/Indyuce/mmocore/manager/RestrictionManager.java index 2d6d52c3..513b682b 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/RestrictionManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/RestrictionManager.java @@ -90,7 +90,12 @@ public class RestrictionManager { // recursive function to check for parent permissions public boolean canMine(BlockType type) { - return mineable.contains(type) || (parent != null && parent.canMine(type)); + String key = type.generateKey(); + for (BlockType mineable : this.mineable) + if (mineable.generateKey().equals(key)) + return true; + + return parent != null && parent.canMine(type); } public Material getTool() { diff --git a/src/main/resources/default/professions/mining.yml b/src/main/resources/default/professions/mining.yml index b018e5cb..7c474969 100644 --- a/src/main/resources/default/professions/mining.yml +++ b/src/main/resources/default/professions/mining.yml @@ -20,20 +20,20 @@ exp-curve: mining # Block Regen is currently only possible using custom mining. on-mine: emerald: - material: EMERALD_ORE + material: vanilla{type=EMERALD_ORE} drop-table: items: - 'vanilla{type=EMERALD} 1 1-9' vanilla-drops: false regen: time: 2000 - temp-block: STONE + temp-block: vanilla{type=STONE} triggers: - 'exp{profession=mining;amount=32}' diamond: # The material you need to mine - material: DIAMOND_ORE + material: vanilla{type=DIAMOND_ORE} # Refer to drop-tables.yml # The drop table used by the block. @@ -63,4 +63,4 @@ on-mine: # When using the temp-block option, make sure you choose # one temp block and don't use it anywhere else in the # configuration so that block regens do not affect each other - temp-block: STONE \ No newline at end of file + temp-block: vanilla{type=STONE} \ No newline at end of file diff --git a/src/main/resources/default/restrictions.yml b/src/main/resources/default/restrictions.yml index 7f0b8744..e1bf4705 100644 --- a/src/main/resources/default/restrictions.yml +++ b/src/main/resources/default/restrictions.yml @@ -10,11 +10,11 @@ WOODEN_PICKAXE: # What the tool can mine. can-mine: - - COAL_ORE + - vanilla{type=COAL_ORE} STONE_PICKAXE: can-mine: - - IRON_ORE + - vanilla{type=IRON_ORE} # The block break permissions the tool inherits. # e.g a stone pickaxe can mine iron ores PLUS @@ -25,16 +25,16 @@ STONE_PICKAXE: IRON_PICKAXE: parent: STONE_PICKAXE can-mine: - - GOLD_ORE + - vanilla{type=GOLD_ORE} GOLDEN_PICKAXE: parent: IRON_PICKAXE can-mine: - - LAPIS_ORE + - vanilla{type=LAPIS_ORE} DIAMOND_PICKAXE: parent: GOLDEN_PICKAXE can-mine: - - DIAMOND_ORE - - EMERALD_ORE - - REDSTONE_ORE + - vanilla{type=DIAMOND_ORE} + - vanilla{type=EMERALD_ORE} + - vanilla{type=REDSTONE_ORE}