!Fixed temp blocks, drops and default configs

This commit is contained in:
Indyuce 2020-04-04 15:50:32 +02:00
parent 400180f5a1
commit 4e189ac6e4
5 changed files with 29 additions and 20 deletions

View File

@ -88,6 +88,10 @@ public class BlockInfo {
return regen != null; return regen != null;
} }
public boolean regenerates() {
return regen != null;
}
public RegenInfo getRegenerationInfo() { public RegenInfo getRegenerationInfo() {
return regen; return regen;
} }

View File

@ -103,7 +103,7 @@ public class BlockListener implements Listener {
* apply drop tables * apply drop tables
*/ */
if (info.hasDropTable()) { if (info.hasDropTable()) {
Location dropLocation = getSafeDropLocation(block, true); Location dropLocation = getSafeDropLocation(block, !(info.regenerates() && info.getRegenerationInfo().hasTemporaryBlock()));
for (ItemStack drop : called.getDrops()) for (ItemStack drop : called.getDrops())
if (drop.getType() != Material.AIR && drop.getAmount() > 0) if (drop.getType() != Material.AIR && drop.getAmount() > 0)
block.getWorld().dropItemNaturally(dropLocation, drop); block.getWorld().dropItemNaturally(dropLocation, drop);
@ -120,7 +120,6 @@ public class BlockListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void b(BlockPlaceEvent event) { public void b(BlockPlaceEvent event) {
event.getBlock().setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true)); event.getBlock().setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true));
@ -134,12 +133,11 @@ public class BlockListener implements Listener {
BlockFace direction = event.getDirection(); BlockFace direction = event.getDirection();
movedBlock = movedBlock.getRelative(direction, 2); movedBlock = movedBlock.getRelative(direction, 2);
for (Block b : event.getBlocks()) { for (Block b : event.getBlocks())
if (b.hasMetadata("player_placed")) { if (b.hasMetadata("player_placed")) {
movedBlock = b.getRelative(direction); movedBlock = b.getRelative(direction);
movedBlock.setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true)); movedBlock.setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true));
} }
}
} }
@EventHandler @EventHandler
@ -158,10 +156,12 @@ public class BlockListener implements Listener {
if (block.getType() == Material.AIR && self) if (block.getType() == Material.AIR && self)
return block.getLocation(); return block.getLocation();
Block relative; for (BlockFace face : order) {
for (BlockFace face : order) Block relative = block.getRelative(face);
if (!(relative = block.getRelative(face)).getType().isSolid()) if (!relative.getType().isSolid())
return relative.getLocation().add(block.getLocation().subtract(relative.getLocation()).multiply(.3)); return relative.getLocation().add(block.getLocation().subtract(relative.getLocation()).multiply(.6));
}
return block.getLocation(); return block.getLocation();
} }
} }

View File

@ -90,7 +90,12 @@ public class RestrictionManager {
// recursive function to check for parent permissions // recursive function to check for parent permissions
public boolean canMine(BlockType type) { 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() { public Material getTool() {

View File

@ -20,20 +20,20 @@ exp-curve: mining
# Block Regen is currently only possible using custom mining. # Block Regen is currently only possible using custom mining.
on-mine: on-mine:
emerald: emerald:
material: EMERALD_ORE material: vanilla{type=EMERALD_ORE}
drop-table: drop-table:
items: items:
- 'vanilla{type=EMERALD} 1 1-9' - 'vanilla{type=EMERALD} 1 1-9'
vanilla-drops: false vanilla-drops: false
regen: regen:
time: 2000 time: 2000
temp-block: STONE temp-block: vanilla{type=STONE}
triggers: triggers:
- 'exp{profession=mining;amount=32}' - 'exp{profession=mining;amount=32}'
diamond: diamond:
# The material you need to mine # The material you need to mine
material: DIAMOND_ORE material: vanilla{type=DIAMOND_ORE}
# Refer to drop-tables.yml # Refer to drop-tables.yml
# The drop table used by the block. # The drop table used by the block.
@ -63,4 +63,4 @@ on-mine:
# When using the temp-block option, make sure you choose # When using the temp-block option, make sure you choose
# one temp block and don't use it anywhere else in the # one temp block and don't use it anywhere else in the
# configuration so that block regens do not affect each other # configuration so that block regens do not affect each other
temp-block: STONE temp-block: vanilla{type=STONE}

View File

@ -10,11 +10,11 @@ WOODEN_PICKAXE:
# What the tool can mine. # What the tool can mine.
can-mine: can-mine:
- COAL_ORE - vanilla{type=COAL_ORE}
STONE_PICKAXE: STONE_PICKAXE:
can-mine: can-mine:
- IRON_ORE - vanilla{type=IRON_ORE}
# The block break permissions the tool inherits. # The block break permissions the tool inherits.
# e.g a stone pickaxe can mine iron ores PLUS # e.g a stone pickaxe can mine iron ores PLUS
@ -25,16 +25,16 @@ STONE_PICKAXE:
IRON_PICKAXE: IRON_PICKAXE:
parent: STONE_PICKAXE parent: STONE_PICKAXE
can-mine: can-mine:
- GOLD_ORE - vanilla{type=GOLD_ORE}
GOLDEN_PICKAXE: GOLDEN_PICKAXE:
parent: IRON_PICKAXE parent: IRON_PICKAXE
can-mine: can-mine:
- LAPIS_ORE - vanilla{type=LAPIS_ORE}
DIAMOND_PICKAXE: DIAMOND_PICKAXE:
parent: GOLDEN_PICKAXE parent: GOLDEN_PICKAXE
can-mine: can-mine:
- DIAMOND_ORE - vanilla{type=DIAMOND_ORE}
- EMERALD_ORE - vanilla{type=EMERALD_ORE}
- REDSTONE_ORE - vanilla{type=REDSTONE_ORE}