Skip to content

Commit

Permalink
Added option to spawn broken block on block. Made it default.
Browse files Browse the repository at this point in the history
Fixes #38
  • Loading branch information
tastybento committed May 31, 2020
1 parent 1c3cb6b commit f3981c5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/main/java/world/bentobox/aoneblock/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ public class Settings implements WorldSettings {
// ---------------------------------------------

/* ISLAND */
@ConfigComment("Drop broken blocks on top of magic block")
@ConfigEntry(path = "island.drop-on-top", since = "1.3.0")
private boolean dropOnTop = true;

@ConfigComment("Magic block mob warning")
@ConfigComment("Players might be able to hear hostile mobs up to this many blocks away")
@ConfigComment("Minimum is 0 (no warning), max is 5")
Expand Down Expand Up @@ -1691,4 +1695,12 @@ public List<String> getMobLimitSettings() {
public void setMobLimitSettings(List<String> mobLimitSettings) {
this.mobLimitSettings = mobLimitSettings;
}

public boolean isDropOnTop() {
return dropOnTop;
}

public void setDropOnTop(boolean dropOnTop) {
this.dropOnTop = dropOnTop;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,14 @@ private void process(Cancellable e, Island i, @Nullable Player player, @NonNull
if (e instanceof BlockBreakEvent) {
e.setCancelled(true);
ItemStack tool = Objects.requireNonNull(player).getInventory().getItemInMainHand();
block.breakNaturally(tool);
if (addon.getSettings().isDropOnTop()) {
// Drop the drops
block.getDrops(tool, player).forEach(item -> world.dropItem(block.getRelative(BlockFace.UP).getLocation().add(new Vector(0.5, 0, 0.5)), item));
// Set the air
block.setType(Material.AIR);
} else {
block.breakNaturally(tool);
}
// Give exp
Objects.requireNonNull(player).giveExp(((BlockBreakEvent)e).getExpToDrop());
// Damage tool
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ endGenerate: false
endIslands: false
dragonSpawn: false
island:
# Drop broken blocks on top of magic block
drop-on-top: true
# Magic block mob warning
# Players might be able to hear hostile mobs up to this many blocks away
# Minimum is 0 (no warning), max is 5
Expand Down

0 comments on commit f3981c5

Please sign in to comment.