Skip to content

Commit 690ac3c

Browse files
committed
Update to fix config for sounds and trees not generating.
1 parent 7928712 commit 690ac3c

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

src/main/java/world/bentobox/twerk/listeners/TreeGrowListener.java

+17-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.Map;
1010
import java.util.Random;
1111
import java.util.Set;
12+
import java.util.function.Predicate;
1213
import java.util.stream.Collectors;
1314

1415
import org.bukkit.Bukkit;
@@ -20,6 +21,7 @@
2021
import org.bukkit.World.Environment;
2122
import org.bukkit.block.Block;
2223
import org.bukkit.block.BlockFace;
24+
import org.bukkit.block.BlockState;
2325
import org.bukkit.entity.Player;
2426
import org.bukkit.event.EventHandler;
2527
import org.bukkit.event.EventPriority;
@@ -32,6 +34,7 @@
3234

3335
import com.google.common.base.Enums;
3436

37+
import world.bentobox.bentobox.BentoBox;
3538
import world.bentobox.bentobox.database.objects.Island;
3639
import world.bentobox.bentobox.lists.Flags;
3740
import world.bentobox.bentobox.util.Util;
@@ -132,18 +135,16 @@ protected void growTree(Block b) {
132135
}
133136
if (SAPLING_TO_TREE_TYPE.containsKey(t)) {
134137
TreeType type = SAPLING_TO_TREE_TYPE.getOrDefault(b.getType(), TreeType.TREE);
138+
BentoBox.getInstance().logDebug("Setting " + b + " mat " + t + " to air");
135139
b.setType(Material.AIR);
136-
137-
if (b.getWorld().generateTree(b.getLocation(), RAND, type,
138-
bs -> bs.getType() != Material.DIRT
139-
&& (Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld())
140-
|| addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent()))) {
140+
if (b.getWorld().generateTree(b.getLocation(), RAND, type, (Predicate<BlockState>) this::checkPlace)) {
141141
if (addon.getSettings().isEffectsEnabled()) {
142142
showSparkles(b);
143143
}
144144
if (addon.getSettings().isSoundsEnabled()) {
145145
b.getWorld().playSound(b.getLocation(), addon.getSettings().getSoundsGrowingSmallTreeSound(),
146-
(float)addon.getSettings().getSoundsGrowingSmallTreeVolume(), (float)addon.getSettings().getSoundsGrowingSmallTreePitch());
146+
(float) addon.getSettings().getSoundsGrowingSmallTreeVolume(),
147+
(float) addon.getSettings().getSoundsGrowingSmallTreePitch());
147148
}
148149
} else {
149150
// Tree generation failed, so reset block
@@ -152,6 +153,16 @@ protected void growTree(Block b) {
152153
}
153154
}
154155

156+
private Boolean checkPlace(BlockState bs) {
157+
System.out.println("Not Dirt " + (bs.getType() != Material.DIRT));
158+
System.out.println("Outside range flag set? " + Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld()));
159+
System.out.println("Inside island? " + addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent());
160+
System.out.println("Overall = " + (bs.getType() != Material.DIRT && (Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld())
161+
|| addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent())));
162+
return bs.getType() != Material.DIRT && (Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld())
163+
|| addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent());
164+
}
165+
155166
protected boolean bigTreeSaplings(Block b) {
156167
Material treeType = b.getType();
157168
TreeType type = SAPLING_TO_BIG_TREE_TYPE.get(treeType);

src/main/resources/config.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# TwerkingForTrees configuration file. {$version}
2-
#
2+
#
33
# How many times the player must twerk before the tree start growing faster.
44
# If the player has not twerked enough, then the tree will not grow faster.
55
minimum-twerks: 4
@@ -17,21 +17,21 @@ sounds:
1717
# Sound that plays when the player twerked enough for the sapling to start growing faster.
1818
# Available sounds are the following:
1919
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html
20-
sound: BLOCK_NOTE_BLOCK_BASS
20+
sound: block.note_block.bass
2121
volume: 1.0
2222
pitch: 2.0
2323
growing-small-tree:
2424
# Sound that plays when a small tree (1x1) grows.
2525
# Available sounds are the following:
2626
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html
27-
sound: BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT
27+
sound: block.bubble_column.upwards_ambient
2828
volume: 1.0
2929
pitch: 1.0
3030
growing-big-tree:
3131
# Sound that plays when a big tree (2x2) grows.
3232
# Available sounds are the following:
3333
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html
34-
sound: BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT
34+
sound: block.bubble_column.upwards_ambient
3535
volume: 1.0
3636
pitch: 1.0
3737
effects:

0 commit comments

Comments
 (0)