Skip to content

Commit

Permalink
Release 1.5.0 (#30)
Browse files Browse the repository at this point in the history
* Version 1.4.3

* Remove sync chunk loading when twerking

#24

* WIP putting back tree growing code.

* Version 1.4.4

* Revert back to the original way to grow trees.

Apparently, the bee hive bug has been fixed. This will therefore prevent
trees growing outside of the island border again.

#23
#9

* Add 1.17 and 1.19 trees to the twerking.

* Added GitHubs action script and funding info

* Update pom.xml

* Fix javadoc plugin in POM

* BentoBox 2.0.0 API

* Update pom.xml version 1.5.0

* Added cherry and grow trees that may have beehives on them.

Update to latest APIs

* Fix predicate check

* Remove non-saplings

* Add sonar cube

---------

Co-authored-by: BONNe <bonne@bonne.id.lv>
  • Loading branch information
tastybento and BONNe committed Jan 14, 2024
1 parent a047279 commit baca35a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 80 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: SonarCloud
on:
push:
branches:
Expand All @@ -8,7 +8,7 @@ on:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -17,8 +17,8 @@ jobs:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
Expand All @@ -35,4 +35,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BentoBoxWorld_TwerkingForTrees
8 changes: 5 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@
<java.version>1.8</java.version>
<powermock.version>2.0.4</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.19.1-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.14.0-SNAPSHOT</bentobox.version>
<spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.0.0-SNAPSHOT</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>1.4.4</build.version>
<build.version>1.5.0</build.version>
<build.number>-LOCAL</build.number>
<sonar.organization>bentobox-world</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>

<profiles>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;

Expand All @@ -30,6 +31,7 @@
import org.eclipse.jdt.annotation.NonNull;

import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.util.Util;
import world.bentobox.twerk.TwerkingForTrees;

Expand Down Expand Up @@ -59,6 +61,8 @@ public class TreeGrowListener implements Listener {
conv.put(Material.AZALEA, TreeType.AZALEA);
conv.put(Material.FLOWERING_AZALEA, TreeType.AZALEA);
conv.put(Material.MANGROVE_PROPAGULE, TreeType.MANGROVE);
conv.put(Material.CHERRY_SAPLING, TreeType.CHERRY);
conv.put(Material.DARK_OAK_SAPLING, TreeType.DARK_OAK);
SAPLING_TO_TREE_TYPE = Collections.unmodifiableMap(conv);
}
private static final Map<Material, TreeType> SAPLING_TO_BIG_TREE_TYPE;
Expand All @@ -70,6 +74,8 @@ public class TreeGrowListener implements Listener {
SAPLING_TO_BIG_TREE_TYPE = Collections.unmodifiableMap(conv);
}

private static final Random RAND = new Random();

private TwerkingForTrees addon;
private Map<Island, Integer> twerkCount;
private Set<Island> isTwerking;
Expand Down Expand Up @@ -114,7 +120,10 @@ protected void growTree(Block b) {
} else if (SAPLING_TO_TREE_TYPE.containsKey(t)) {
TreeType type = SAPLING_TO_TREE_TYPE.getOrDefault(b.getType(), TreeType.TREE);
b.setType(Material.AIR);
if (b.getWorld().generateTree(b.getLocation(), type, new BlockChangeHandler(addon, b.getWorld()))) {

if (b.getWorld().generateTree(b.getLocation(), RAND, type,
bs -> Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld())
|| addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent())) {
if (addon.getSettings().isEffectsEnabled()) {
showSparkles(b);
}
Expand All @@ -128,6 +137,39 @@ protected void growTree(Block b) {
}
}
}

protected boolean bigTreeSaplings(Block b) {
Material treeType = b.getType();
TreeType type = SAPLING_TO_BIG_TREE_TYPE.get(treeType);
for (List<BlockFace> q : QUADS) {
if (q.stream().map(b::getRelative).allMatch(c -> c.getType().equals(treeType))) {
// All the same sapling type found in this quad
q.stream().map(b::getRelative).forEach(c -> c.setType(Material.AIR));
// Get the tree planting location
Location l = b.getRelative(q.get(0)).getLocation();
if (b.getWorld().generateTree(l, RAND, type,
bs -> Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld())
|| addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent())) {
if (addon.getSettings().isEffectsEnabled()) {
showSparkles(b);
}
if (addon.getSettings().isSoundsEnabled()) {
b.getWorld().playSound(b.getLocation(), addon.getSettings().getSoundsGrowingBigTreeSound(),
(float)addon.getSettings().getSoundsGrowingBigTreeVolume(), (float)addon.getSettings().getSoundsGrowingBigTreePitch());
}
return true;
} else {
// Generation failed, reset saplings
q.stream().map(b::getRelative).forEach(c -> c.setType(treeType));
}
}
}
return false;
}

protected void showSparkles(Block b) {
AROUND.stream().map(b::getRelative).map(Block::getLocation).forEach(x -> x.getWorld().playEffect(x, addon.getSettings().getEffectsTwerk(), 0));
}

protected boolean bigTreeSaplings(Block b) {
Material treeType = b.getType();
Expand Down

0 comments on commit baca35a

Please sign in to comment.