Skip to content

Commit

Permalink
Release 1.8.0 (#113)
Browse files Browse the repository at this point in the history
* Version 1.7.3

* Add ${argLine} to get jacoco coverage

* Updated Jacoco POM entry

* Address bugs reported by SonarCloud

* Updated ReadMe

* Add max mobs option #99

* Use updated Bucket event

* Added tests to cover #99

* Fixes help text for user command.

Fixes #105

* Fixed maxmobs typo instead of maxmob

* Remove unused imports

* Update to new Bukkit Loader

* Remove debug

* Create plugin.yml (#106)

* Create plugin.yml

* Update pom.xml

* Update GreenhousesPladdon.java

* Removed static getInstance usage

* Version 1.7.4

* Refactored to reduce complexity

* Update surefire plugin

* Refactored to reduce complexity

* Minor typos and grammar fixes

* Reduced complexity

* Refactor to reduce complexity

* Refactor to reduce complexity

* Update Github Action build script

* Added distribution required for Github Action

* Update pom.xml

* Fixes mob spawning when no maxmob value given.

Found while doing #108

* Code clean up.

* BentoBox 2.0.0

* Update pom.xml 1.7.5

* Update to latest Spigot API

* Version 1.8.0

* Added mobs to biomes

* Improved errors.

* Return the pladdon that was made

* Update biomes.yml

Added mangrove swamp #111

* Update to 1.21.3 and CodeMC distro (#112)

* Update to 1.21.3 and CodeMC distro

* Fix tests

---------

Co-authored-by: BONNe <bonne@bonne.id.lv>
  • Loading branch information
tastybento and BONNe authored Nov 17, 2024
1 parent a79889a commit 2299b7a
Show file tree
Hide file tree
Showing 19 changed files with 365 additions and 59 deletions.
47 changes: 36 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,9 @@
</issueManagement>

<distributionManagement>
<snapshotRepository>
<id>codemc-snapshots</id>
<url>https://repo.codemc.org/repository/maven-snapshots</url>
</snapshotRepository>
<repository>
<id>codemc-releases</id>
<url>https://repo.codemc.org/repository/maven-releases</url>
<id>bentoboxworld</id>
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
</repository>
</distributionManagement>

Expand All @@ -46,12 +42,12 @@
<java.version>17</java.version>
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.0.0-SNAPSHOT</bentobox.version>
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.7.1-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.7.5</build.version>
<build.version>1.9.0</build.version>
<build.number>-LOCAL</build.number>
<sonar.projectKey>BentoBoxWorld_Greenhouses</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
Expand Down Expand Up @@ -103,6 +99,10 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
</repository>
<repository>
<id>bentoboxworld</id>
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
Expand Down Expand Up @@ -191,14 +191,39 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.0</version>
<version>3.0.0-M5</version>
<configuration>
<argLine>
${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.concurrent=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
</argLine>

</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
*/
public class GreenhousesPladdon extends Pladdon
{
private Addon addon;
@Override
public Addon getAddon()
{
return new Greenhouses();
if (addon == null) {
addon = new Greenhouses();
}
return addon;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public boolean addMobs(EntityType mobType, double mobProbability, Material mobSp
mobTree.put(lastProb + probability, new GreenhouseMob(mobType, mobSpawnOn));
return true;
} else {
addon.logError("Mob chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + mobType);
addon.logError("Mob chances add up to > 100% in " + type + " biome recipe! Skipping " + mobType);
return false;
}
}
Expand All @@ -175,7 +175,8 @@ public boolean addPlants(Material plantMaterial, double plantProbability, Materi
// Add to probability tree
map.put(lastProb + probability, new GreenhousePlant(plantMaterial, plantGrowOn));
} else {
addon.logError("Plant chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + plantMaterial.toString());
addon.logError("Plant chances add up to > 100% in " + type + " biome recipe! Skipping "
+ plantMaterial.toString());
return false;
}
startupLog(" " + plantProbability + CHANCE_FOR + Util.prettifyText(plantMaterial.toString()) + " to grow on " + Util.prettifyText(plantGrowOn.toString()));
Expand Down Expand Up @@ -480,7 +481,7 @@ public boolean growPlant(GrowthBlock block, boolean underwater) {
Block bl = block.block();
return getRandomPlant(underwater).map(p -> {
if (bl.getY() != 0 && canGrowOn(block, p) && plantIt(bl, p)) {
bl.getWorld().spawnParticle(Particle.SNOWBALL, bl.getLocation(), 10, 2, 2, 2);
bl.getWorld().spawnParticle(Particle.ASH, bl.getLocation(), 10, 2, 2, 2);
return true;
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/world/bentobox/greenhouses/greenhouse/Roof.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package world.bentobox.greenhouses.greenhouse;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand All @@ -9,6 +8,7 @@
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Registry;
import org.bukkit.Tag;
import org.bukkit.World;
import org.bukkit.util.Vector;
Expand All @@ -24,7 +24,7 @@
*
*/
public class Roof extends MinMaxXZ {
private static final List<Material> ROOF_BLOCKS = Arrays.stream(Material.values())
private static final List<Material> ROOF_BLOCKS = Registry.MATERIAL.stream()
.filter(Material::isBlock) // Blocks only, no items
.filter(m -> Tag.TRAPDOORS.isTagged(m) // All trapdoors
|| (m.name().contains("GLASS") && !m.name().contains("GLASS_PANE")) // All glass blocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Registry;

import world.bentobox.bentobox.BentoBox;
import world.bentobox.greenhouses.world.AsyncWorldCache;

public class Walls extends MinMaxXZ {
public static final List<Material> WALL_BLOCKS = Arrays.stream(Material.values())
public static final List<Material> WALL_BLOCKS = Registry.MATERIAL.stream()
.filter(Material::isBlock) // Blocks only, no items
.filter(m -> !m.name().contains("TRAPDOOR")) // No trap doors
.filter(m -> m.name().contains("DOOR") // All doors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package world.bentobox.greenhouses.listeners;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.bukkit.Location;
import org.bukkit.Material;
Expand Down Expand Up @@ -30,15 +31,14 @@
*/
public class GreenhouseEvents implements Listener {
private static final String BIOME = "[biome]";
private static final Set<Biome> NETHER_BIOMES;
static {
NETHER_BIOMES = Set.of(Biome.NETHER_WASTES, Biome.WARPED_FOREST, Biome.CRIMSON_FOREST,
Biome.SOUL_SAND_VALLEY, Biome.BASALT_DELTAS);
}
private static List<Biome> NETHER_BIOMES;
private final Greenhouses addon;

public GreenhouseEvents(final Greenhouses addon) {
this.addon = addon;
NETHER_BIOMES = Arrays.asList(Biome.NETHER_WASTES, Biome.WARPED_FOREST, Biome.CRIMSON_FOREST,
Biome.SOUL_SAND_VALLEY,
Biome.BASALT_DELTAS);
}

/**
Expand Down Expand Up @@ -67,7 +67,7 @@ public void onPlayerInteractInNether(PlayerBucketEmptyEvent e) {
e.getPlayer().getInventory().getItemInOffHand().setType(Material.BUCKET);
}

b.getWorld().spawnParticle(Particle.SMOKE_NORMAL, b.getLocation(), 10);
b.getWorld().spawnParticle(Particle.SMOKE, b.getLocation(), 10);
b.getWorld().playSound(b.getLocation(), Sound.ENTITY_GENERIC_EXTINGUISH_FIRE, 1F, 5F);
}
}
Expand All @@ -81,14 +81,14 @@ public void onIceBreak(BlockBreakEvent e) {
if (!Tag.ICE.isTagged(e.getBlock().getType())) {
return;
}

Block b = e.getBlock();
if (b.getWorld().getEnvironment().equals(World.Environment.NETHER)
if (b.getWorld().getEnvironment() == World.Environment.NETHER
&& !addon.getManager().getMap().getGreenhouse(b.getLocation())
.map(gh -> gh.getBiomeRecipe().getBiome()).map(NETHER_BIOMES::contains).orElse(true)) {
//
.map(gh -> gh.getBiomeRecipe().getBiome()).map(NETHER_BIOMES::contains).orElse(true)) {
e.setCancelled(true);
b.setType(Material.WATER);
} else if (!e.getPlayer().getWorld().getEnvironment().equals(World.Environment.NETHER)
} else if (e.getPlayer().getWorld().getEnvironment() != World.Environment.NETHER
&& addon.getManager().getMap().getGreenhouse(b.getLocation())
.map(gh -> gh.getBiomeRecipe().getBiome()).map(NETHER_BIOMES::contains).orElse(false)) {
// Not in Nether, in a nether greenhouse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private boolean getAirBlocks(Greenhouse gh) {
Block b = Objects.requireNonNull(gh.getLocation().getWorld()).getBlockAt(x, y, z);
Material type = b.getType();
if (type.equals(Material.AIR) || type.equals(Material.SNOW)) {
b.getWorld().spawnParticle(Particle.SNOWBALL, b.getLocation(), 5);
b.getWorld().spawnParticle(Particle.SNOWFLAKE, b.getLocation(), 5);
} else {
// Add snow
if (type.equals(Material.WATER)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Registry;
import org.bukkit.block.Biome;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.EntityType;

import com.google.common.base.Enums;

import world.bentobox.bentobox.util.Util;
import world.bentobox.greenhouses.Greenhouses;
import world.bentobox.greenhouses.greenhouse.BiomeRecipe;
Expand Down Expand Up @@ -115,26 +114,26 @@ private void processEntries(String biomeType, ConfigurationSection biomeSection)
} catch (Exception e) {
addon.logError("Problem loading biome recipe - skipping! " + e.getMessage());
StringBuilder validBiomes = new StringBuilder();
for (Biome biome : Biome.values()) {
validBiomes.append(" ").append(biome.name());
}
Registry.BIOME.forEach(biome -> validBiomes.append(" ").append(biome.getKey().getKey()));
addon.logError("Valid biomes are " + validBiomes);
}

}

@SuppressWarnings("deprecation")
private Biome loadBiome(String biomeType, ConfigurationSection biomeRecipeConfig) {
if (!biomeRecipeConfig.contains("biome")) {
addon.logError("No biome defined in the biome reciepe " + biomeType + ". Skipping...");
return null;
}
String name = Objects.requireNonNull(biomeRecipeConfig.getString("biome")).toUpperCase(Locale.ENGLISH);
if (Enums.getIfPresent(Biome.class, name).isPresent()) {
return Biome.valueOf(name);
Biome b = Biome.valueOf(name);
if (b != null) {
return b;
}
// Special case for nether
if (name.equals("NETHER") || name.equals("NETHER_WASTES")) {
return Enums.getIfPresent(Biome.class, "NETHER").or(Enums.getIfPresent(Biome.class, "NETHER_WASTES").or(Biome.PLAINS));
return Biome.NETHER_WASTES;
}
addon.logError("Biome " + name + " is invalid! Use one of these...");
addon.logError(Arrays.stream(Biome.values()).map(Biome::name).collect(Collectors.joining(",")));
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/addon.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Greenhouses
main: world.bentobox.greenhouses.Greenhouses
version: ${version}${build.number}
api-version: 1.15.4
api-version: 2.7.1

authors: tastybento

Expand Down
Loading

0 comments on commit 2299b7a

Please sign in to comment.