Skip to content

Commit

Permalink
Merge pull request #6 from BentoBoxWorld/develop
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
tastybento authored Sep 8, 2024
2 parents a51037d + 1386c82 commit e7bf1fd
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 34 deletions.
34 changes: 17 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>
<powermock.version>1.7.4</powermock.version>
<java.version>21</java.version>
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.19-R0.1-SNAPSHOT</spigot.version>
<spigot.version>1.21.1-R0.1-SNAPSHOT</spigot.version>
<!-- BentoBox API version -->
<bentobox.version>1.20.0</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.0.0</build.version>
<build.version>1.1.0</build.version>
<build.number>-LOCAL</build.number>
</properties>

Expand Down Expand Up @@ -94,7 +94,7 @@
<!-- Override only if necessary -->
<revision>${build.version}</revision>
<!-- Empties build.number value -->
<build.number></build.number>
<build.number/>
</properties>
</profile>
<profile>
Expand All @@ -108,7 +108,7 @@
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.6.0.1398</version>
<version>4.0.0.4121</version>
<executions>
<execution>
<phase>verify</phase>
Expand Down Expand Up @@ -154,7 +154,7 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>22.0.0</version>
<version>24.1.0</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -191,12 +191,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
Expand All @@ -205,17 +205,17 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<version>3.5.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<version>3.4.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<version>3.10.0</version>
<configuration>
<show>public</show>
<failOnError>false</failOnError>
Expand All @@ -233,7 +233,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -246,12 +246,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<version>3.1.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.1-SNAPSHOT</version>
<version>3.6.0</version>
<configuration>
<minimizeJar>true</minimizeJar>
<artifactSet>
Expand Down Expand Up @@ -282,12 +282,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<version>3.1.3</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.10</version>
<version>0.8.12</version>
<configuration>
<append>true</append>
<excludes>
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/world/bentobox/farmersdance/FarmersDanceAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.Listener;

import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.configuration.Config;
Expand Down Expand Up @@ -40,6 +39,7 @@ public void onLoad()
this.saveDefaultConfig();

this.settings = new Config<>(this, Settings.class).loadConfigObject();
this.saveSettings();

if (this.settings == null)
{
Expand Down Expand Up @@ -73,12 +73,12 @@ public void onEnable()
if (this.settings.isLazyDancing())
{
this.dancingHandler = new LazyDancingListener(this);
this.registerListener((Listener) this.dancingHandler);
this.registerListener(this.dancingHandler);
}
else
{
this.dancingHandler = new FastDancingListener(this);
this.registerListener((Listener) this.dancingHandler);
this.registerListener(this.dancingHandler);
}
}

Expand Down Expand Up @@ -125,7 +125,9 @@ public void onReload()
public void onDisable()
{
// Stop all running tasks.
this.dancingHandler.stopTasks();
if (this.dancingHandler != null) {
this.dancingHandler.stopTasks();
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@

public class FarmersDancePladdon extends Pladdon
{

private FarmersDanceAddon addon;

@Override
public Addon getAddon()
{
return new FarmersDanceAddon();
if (addon == null) {
addon = new FarmersDanceAddon();
}
return addon;
}
}
33 changes: 31 additions & 2 deletions src/main/java/world/bentobox/farmersdance/configs/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,28 @@ public void setGrowBerries(boolean growBerries)
}


/**
* Is grow spore blossom boolean.
*
* @return the boolean
*/
public boolean isGrowSporeBlossom()
{
return this.growSporeBlossom;
}


/**
* Sets grow spore blossom.
*
* @param growSporeBlossom the grow spore blossom
*/
public void setGrowSporeBlossom(boolean growSporeBlossom)
{
this.growSporeBlossom = growSporeBlossom;
}


/**
* Gets maximal cactus size.
*
Expand Down Expand Up @@ -614,7 +636,7 @@ public void setMaximalSugarCaneSize(int maximalSugarCaneSize)
private boolean growVines = true;

@ConfigComment("")
@ConfigComment("Toggles if dancing will affect tall flowers.")
@ConfigComment("Toggles if dancing will affect tall flowers and pink petals.")
@ConfigComment("It means that tall flowers will drop their item, like using bone meal.")
@ConfigComment("Default value = true.")
@ConfigEntry(path = "groups.grow-tall-flowers")
Expand Down Expand Up @@ -647,6 +669,13 @@ public void setMaximalSugarCaneSize(int maximalSugarCaneSize)
@ConfigEntry(path = "groups.grow-berries")
private boolean growBerries = true;

@ConfigComment("")
@ConfigComment("Toggles if dancing will affect spore blossoms.")
@ConfigComment("Dancing near spore blossoms will drop new spore blossom.")
@ConfigComment("Default value = false.")
@ConfigEntry(path = "groups.spore-blossoms")
private boolean growSporeBlossom = true;

@ConfigComment("")
@ConfigComment("The maximal cactus size that it can grow to.")
@ConfigComment("Default value = 3.")
Expand All @@ -657,5 +686,5 @@ public void setMaximalSugarCaneSize(int maximalSugarCaneSize)
@ConfigComment("The maximal sugar cane size that it can grow to.")
@ConfigComment("Default value = 3.")
@ConfigEntry(path = "size.sugar-cane-size")
private int maximalSugarCaneSize;
private int maximalSugarCaneSize = 3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void stopTasks()
* @param world World where dancing happens.
* @param player The player who triggers dancing.
*/
protected void buildTask(final World world, final Player player)
protected void buildTask(final World world, final @NotNull Player player)
{
boolean growSaplings = this.addon.getSettings().isGrowSaplings();
boolean growCrops = this.addon.getSettings().isGrowCrops();
Expand All @@ -70,6 +70,7 @@ protected void buildTask(final World world, final Player player)
boolean growKelpAndDripLeaf = this.addon.getSettings().isGrowKelpAndDripLeaf();
boolean growChorusFlower = this.addon.getSettings().isGrowChorusFlower();
boolean growBerries = this.addon.getSettings().isGrowBerries();
boolean growSporeBlossom = this.addon.getSettings().isGrowSporeBlossom();

final int xRange = this.addon.getSettings().getAffectRadius();
final int zRange = this.addon.getSettings().getAffectRadius();
Expand All @@ -84,7 +85,7 @@ protected void buildTask(final World world, final Player player)
{
Block block = world.getBlockAt(
location.getBlockX() + this.random.nextInt(xRange * 2 + 1) - xRange,
location.getBlockY() + this.random.nextInt(yRange * 2 + 1) - yRange,
(int) Math.round(location.getY()) + this.random.nextInt(yRange * 2 + 1) - yRange,
location.getBlockZ() + this.random.nextInt(zRange * 2 + 1) - zRange);

if (Tag.SAPLINGS.isTagged(block.getType()) ||
Expand Down Expand Up @@ -142,7 +143,7 @@ else if (Material.PUMPKIN_STEM.equals(block.getType()) || Material.MELON_STEM.eq

if (!blockList.isEmpty())
{
Block newPlant = blockList.iterator().next();
Block newPlant = blockList.getFirst();

if (Material.PUMPKIN_STEM.equals(block.getType()))
{
Expand All @@ -167,7 +168,7 @@ else if (Tag.CROPS.isTagged(block.getType()))
this.spawnParticle(block.getLocation());
}
}
else if (Tag.TALL_FLOWERS.isTagged(block.getType()))
else if (Tag.TALL_FLOWERS.isTagged(block.getType()) || Material.PINK_PETALS.equals(block.getType()))
{
if (growTallFlowers)
{
Expand Down Expand Up @@ -232,7 +233,7 @@ else if (Material.CACTUS.equals(block.getType()) || Material.SUGAR_CANE.equals(b
rootBlock = rootBlock.getRelative(BlockFace.DOWN);
}

int height = 1;
int height = 0;

// Get max height based on block data.
int maxHeight = Material.CACTUS.equals(block.getType()) ?
Expand Down Expand Up @@ -351,6 +352,15 @@ else if (Material.CHORUS_FLOWER.equals(block.getType()))
}
}
}
else if (Material.SPORE_BLOSSOM.equals(block.getType()))
{
if (growSporeBlossom)
{
// Apply bone meal to spore blossom
block.getDrops().forEach(drop -> block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), drop));
this.spawnParticle(block.getLocation());
}
}
}
}

Expand All @@ -361,7 +371,7 @@ else if (Material.CHORUS_FLOWER.equals(block.getType()))
*/
private void spawnParticle(@NotNull Location location)
{
Objects.requireNonNull(location.getWorld()).spawnParticle(Particle.VILLAGER_HAPPY,
Objects.requireNonNull(location.getWorld()).spawnParticle(Particle.HAPPY_VILLAGER,
location.add(0.5, 0.5, 0.5),
20,
0.3D,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.scheduler.BukkitTask;

import org.jetbrains.annotations.NotNull;
import world.bentobox.bentobox.util.Util;
import world.bentobox.farmersdance.FarmersDanceAddon;

Expand All @@ -40,7 +41,7 @@ public LazyDancingListener(FarmersDanceAddon addon)
* @param event Player Toggle Sneak Event.
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onDancing(PlayerToggleSneakEvent event)
public void onDancing(@NotNull PlayerToggleSneakEvent event)
{
Player player = event.getPlayer();
World world = player.getWorld();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/addon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ main: world.bentobox.farmersdance.FarmersDanceAddon
# Version of your addon. Can use maven variables.
version: ${version}
# API version allows to specify minimal BentoBox version for your addon.
api-version: 1.20.0
api-version: 2.4.0
# Allow to send metric about this addon usage.
metrics: true
# GitHub version check. Will work only for GitHub.
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ groups:
# Default value = true.
grow-vines: true
#
# Toggles if dancing will affect tall flowers.
# Toggles if dancing will affect tall flowers and pink petals.
# It means that tall flowers will drop their item, like using bone meal.
# Default value = true.
grow-tall-flowers: true
Expand All @@ -105,6 +105,11 @@ groups:
# Dancing near berries will produce berries.
# Default value = true.
grow-berries: true
#
# Toggles if dancing will affect spore blossoms.
# Dancing near spore blossoms will drop new spore blossom.
# Default value = true.
grow-spore-blossoms: false
size:
# The maximal cactus size that it can grow to.
# Default value = 3.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: BentoBox-FarmersDance
main: world.bentobox.farmersdance.FarmersDancePladdon
version: ${project.version}${build.number}
api-version: "1.19"
api-version: "1.21"

authors: [BONNe]
contributors: ["The BentoBoxWorld Community"]
Expand Down

0 comments on commit e7bf1fd

Please sign in to comment.