diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a44be74..463ef3f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,24 +1,23 @@ -name: SonarCloud +name: Build on: push: branches: - develop - - master pull_request: types: [opened, synchronize, reopened] jobs: build: - name: Build and analyze + name: Build runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: 17 - distribution: 'zulu' # Alternative distribution options are available. + distribution: 'adopt' + java-version: '21' - name: Cache SonarCloud packages uses: actions/cache@v3 with: @@ -35,4 +34,11 @@ 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 -Dsonar.projectKey=BentoBoxWorld_TwerkingForTrees \ No newline at end of file + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BentoBoxWorld_TwerkingForTrees + - run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install + - run: mkdir staging && cp target/*.jar staging + - name: Save artifacts + uses: actions/upload-artifact@v3 + with: + name: Package + path: staging \ No newline at end of file diff --git a/pom.xml b/pom.xml index 6d30890..90163ef 100644 --- a/pom.xml +++ b/pom.xml @@ -33,28 +33,24 @@ - - codemc-snapshots - https://repo.codemc.org/repository/maven-snapshots - - - codemc-releases - https://repo.codemc.org/repository/maven-releases + + bentoboxworld + https://repo.codemc.org/repository/bentoboxworld/ UTF-8 UTF-8 - 1.8 + 21 2.0.4 - 1.20.6-R0.1-SNAPSHOT - 2.0.0-SNAPSHOT + 1.21.3-R0.1-SNAPSHOT + 2.7.1-SNAPSHOT ${build.version}-SNAPSHOT - 1.5.2 + 1.6.0 -LOCAL bentobox-world https://sonarcloud.io @@ -129,6 +125,10 @@ spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots + + bentoboxworld + https://repo.codemc.org/repository/bentoboxworld/ + codemc-repo https://repo.codemc.org/repository/maven-public/ @@ -207,16 +207,47 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + 3.8.0 - ${java.version} - ${java.version} + ${java.version} org.apache.maven.plugins maven-surefire-plugin - 2.22.0 + 3.0.0-M5 + + + ${argLine} + --add-opens java.base/java.lang=ALL-UNNAMED + --add-opens java.base/java.math=ALL-UNNAMED + --add-opens java.base/java.io=ALL-UNNAMED + --add-opens java.base/java.util=ALL-UNNAMED + --add-opens + java.base/java.util.stream=ALL-UNNAMED + --add-opens java.base/java.text=ALL-UNNAMED + --add-opens + java.base/java.util.regex=ALL-UNNAMED + --add-opens + java.base/java.nio.channels.spi=ALL-UNNAMED + --add-opens java.base/sun.nio.ch=ALL-UNNAMED + --add-opens java.base/java.net=ALL-UNNAMED + --add-opens + java.base/java.util.concurrent=ALL-UNNAMED + --add-opens java.base/sun.nio.fs=ALL-UNNAMED + --add-opens java.base/sun.nio.cs=ALL-UNNAMED + --add-opens java.base/java.nio.file=ALL-UNNAMED + --add-opens + java.base/java.nio.charset=ALL-UNNAMED + --add-opens + java.base/java.lang.reflect=ALL-UNNAMED + --add-opens + java.logging/java.util.logging=ALL-UNNAMED + --add-opens java.base/java.lang.ref=ALL-UNNAMED + --add-opens java.base/java.util.jar=ALL-UNNAMED + --add-opens java.base/java.util.zip=ALL-UNNAMED + + org.apache.maven.plugins @@ -226,19 +257,16 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + 3.0.1 - ${java.version} - private - true false -Xdoclint:none ${java.home}/bin/javadoc + 16 attach-javadocs - package jar diff --git a/src/main/java/world/bentobox/twerk/listeners/TreeGrowListener.java b/src/main/java/world/bentobox/twerk/listeners/TreeGrowListener.java index 5755b43..343261d 100644 --- a/src/main/java/world/bentobox/twerk/listeners/TreeGrowListener.java +++ b/src/main/java/world/bentobox/twerk/listeners/TreeGrowListener.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.Random; import java.util.Set; +import java.util.function.Predicate; import java.util.stream.Collectors; import org.bukkit.Bukkit; @@ -20,6 +21,7 @@ import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -32,6 +34,7 @@ import com.google.common.base.Enums; +import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.util.Util; @@ -132,18 +135,16 @@ protected void growTree(Block b) { } if (SAPLING_TO_TREE_TYPE.containsKey(t)) { TreeType type = SAPLING_TO_TREE_TYPE.getOrDefault(b.getType(), TreeType.TREE); + BentoBox.getInstance().logDebug("Setting " + b + " mat " + t + " to air"); b.setType(Material.AIR); - - if (b.getWorld().generateTree(b.getLocation(), RAND, type, - bs -> bs.getType() != Material.DIRT - && (Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld()) - || addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent()))) { + if (b.getWorld().generateTree(b.getLocation(), RAND, type, (Predicate) this::checkPlace)) { if (addon.getSettings().isEffectsEnabled()) { showSparkles(b); } if (addon.getSettings().isSoundsEnabled()) { b.getWorld().playSound(b.getLocation(), addon.getSettings().getSoundsGrowingSmallTreeSound(), - (float)addon.getSettings().getSoundsGrowingSmallTreeVolume(), (float)addon.getSettings().getSoundsGrowingSmallTreePitch()); + (float) addon.getSettings().getSoundsGrowingSmallTreeVolume(), + (float) addon.getSettings().getSoundsGrowingSmallTreePitch()); } } else { // Tree generation failed, so reset block @@ -152,6 +153,16 @@ protected void growTree(Block b) { } } + private Boolean checkPlace(BlockState bs) { + System.out.println("Not Dirt " + (bs.getType() != Material.DIRT)); + System.out.println("Outside range flag set? " + Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld())); + System.out.println("Inside island? " + addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent()); + System.out.println("Overall = " + (bs.getType() != Material.DIRT && (Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld()) + || addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent()))); + return bs.getType() != Material.DIRT && (Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld()) + || addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent()); + } + protected boolean bigTreeSaplings(Block b) { Material treeType = b.getType(); TreeType type = SAPLING_TO_BIG_TREE_TYPE.get(treeType); diff --git a/src/main/resources/addon.yml b/src/main/resources/addon.yml index cf024b1..0dcdf96 100644 --- a/src/main/resources/addon.yml +++ b/src/main/resources/addon.yml @@ -2,7 +2,7 @@ name: TwerkingForTrees main: world.bentobox.twerk.TwerkingForTrees version: ${version}${build.number} icon: OAK_SAPLING -api-version: 1.13 +api-version: 2.7.1 prefix: TwerkingForTrees diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 78ebee4..0a85c0a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,5 @@ # TwerkingForTrees configuration file. {$version} -# +# # How many times the player must twerk before the tree start growing faster. # If the player has not twerked enough, then the tree will not grow faster. minimum-twerks: 4 @@ -17,21 +17,21 @@ sounds: # Sound that plays when the player twerked enough for the sapling to start growing faster. # Available sounds are the following: # https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html - sound: BLOCK_NOTE_BLOCK_BASS + sound: block.note_block.bass volume: 1.0 pitch: 2.0 growing-small-tree: # Sound that plays when a small tree (1x1) grows. # Available sounds are the following: # https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html - sound: BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT + sound: block.bubble_column.upwards_ambient volume: 1.0 pitch: 1.0 growing-big-tree: # Sound that plays when a big tree (2x2) grows. # Available sounds are the following: # https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html - sound: BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT + sound: block.bubble_column.upwards_ambient volume: 1.0 pitch: 1.0 effects: