Skip to content

Commit 2299b7a

Browse files
tastybentoBONNe
andauthored
Release 1.8.0 (#113)
* 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>
1 parent a79889a commit 2299b7a

19 files changed

Lines changed: 365 additions & 59 deletions

File tree

pom.xml

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@
3030
</issueManagement>
3131

3232
<distributionManagement>
33-
<snapshotRepository>
34-
<id>codemc-snapshots</id>
35-
<url>https://repo.codemc.org/repository/maven-snapshots</url>
36-
</snapshotRepository>
3733
<repository>
38-
<id>codemc-releases</id>
39-
<url>https://repo.codemc.org/repository/maven-releases</url>
34+
<id>bentoboxworld</id>
35+
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
4036
</repository>
4137
</distributionManagement>
4238

@@ -46,12 +42,12 @@
4642
<java.version>17</java.version>
4743
<powermock.version>2.0.9</powermock.version>
4844
<!-- More visible way how to change dependency versions -->
49-
<spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>
50-
<bentobox.version>2.0.0-SNAPSHOT</bentobox.version>
45+
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
46+
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
5147
<!-- Revision variable removes warning about dynamic version -->
5248
<revision>${build.version}-SNAPSHOT</revision>
5349
<!-- This allows to change between versions and snapshots. -->
54-
<build.version>1.7.5</build.version>
50+
<build.version>1.9.0</build.version>
5551
<build.number>-LOCAL</build.number>
5652
<sonar.projectKey>BentoBoxWorld_Greenhouses</sonar.projectKey>
5753
<sonar.organization>bentobox-world</sonar.organization>
@@ -103,6 +99,10 @@
10399
<id>spigot-repo</id>
104100
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
105101
</repository>
102+
<repository>
103+
<id>bentoboxworld</id>
104+
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
105+
</repository>
106106
<repository>
107107
<id>codemc-repo</id>
108108
<url>https://repo.codemc.org/repository/maven-public/</url>
@@ -191,14 +191,39 @@
191191
<plugin>
192192
<groupId>org.apache.maven.plugins</groupId>
193193
<artifactId>maven-surefire-plugin</artifactId>
194-
<version>3.1.0</version>
194+
<version>3.0.0-M5</version>
195195
<configuration>
196196
<argLine>
197197
${argLine}
198198
--add-opens java.base/java.lang=ALL-UNNAMED
199+
--add-opens java.base/java.math=ALL-UNNAMED
200+
--add-opens java.base/java.io=ALL-UNNAMED
199201
--add-opens java.base/java.util=ALL-UNNAMED
200-
--add-opens java.base/java.util.concurrent=ALL-UNNAMED
202+
--add-opens
203+
java.base/java.util.stream=ALL-UNNAMED
204+
--add-opens java.base/java.text=ALL-UNNAMED
205+
--add-opens
206+
java.base/java.util.regex=ALL-UNNAMED
207+
--add-opens
208+
java.base/java.nio.channels.spi=ALL-UNNAMED
209+
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
210+
--add-opens java.base/java.net=ALL-UNNAMED
211+
--add-opens
212+
java.base/java.util.concurrent=ALL-UNNAMED
213+
--add-opens java.base/sun.nio.fs=ALL-UNNAMED
214+
--add-opens java.base/sun.nio.cs=ALL-UNNAMED
215+
--add-opens java.base/java.nio.file=ALL-UNNAMED
216+
--add-opens
217+
java.base/java.nio.charset=ALL-UNNAMED
218+
--add-opens
219+
java.base/java.lang.reflect=ALL-UNNAMED
220+
--add-opens
221+
java.logging/java.util.logging=ALL-UNNAMED
222+
--add-opens java.base/java.lang.ref=ALL-UNNAMED
223+
--add-opens java.base/java.util.jar=ALL-UNNAMED
224+
--add-opens java.base/java.util.zip=ALL-UNNAMED
201225
</argLine>
226+
202227
</configuration>
203228
</plugin>
204229
<plugin>

src/main/java/world/bentobox/greenhouses/GreenhousesPladdon.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
*/
1111
public class GreenhousesPladdon extends Pladdon
1212
{
13+
private Addon addon;
1314
@Override
1415
public Addon getAddon()
1516
{
16-
return new Greenhouses();
17+
if (addon == null) {
18+
addon = new Greenhouses();
19+
}
20+
return addon;
1721
}
1822
}

src/main/java/world/bentobox/greenhouses/greenhouse/BiomeRecipe.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public boolean addMobs(EntityType mobType, double mobProbability, Material mobSp
153153
mobTree.put(lastProb + probability, new GreenhouseMob(mobType, mobSpawnOn));
154154
return true;
155155
} else {
156-
addon.logError("Mob chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + mobType);
156+
addon.logError("Mob chances add up to > 100% in " + type + " biome recipe! Skipping " + mobType);
157157
return false;
158158
}
159159
}
@@ -175,7 +175,8 @@ public boolean addPlants(Material plantMaterial, double plantProbability, Materi
175175
// Add to probability tree
176176
map.put(lastProb + probability, new GreenhousePlant(plantMaterial, plantGrowOn));
177177
} else {
178-
addon.logError("Plant chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + plantMaterial.toString());
178+
addon.logError("Plant chances add up to > 100% in " + type + " biome recipe! Skipping "
179+
+ plantMaterial.toString());
179180
return false;
180181
}
181182
startupLog(" " + plantProbability + CHANCE_FOR + Util.prettifyText(plantMaterial.toString()) + " to grow on " + Util.prettifyText(plantGrowOn.toString()));
@@ -480,7 +481,7 @@ public boolean growPlant(GrowthBlock block, boolean underwater) {
480481
Block bl = block.block();
481482
return getRandomPlant(underwater).map(p -> {
482483
if (bl.getY() != 0 && canGrowOn(block, p) && plantIt(bl, p)) {
483-
bl.getWorld().spawnParticle(Particle.SNOWBALL, bl.getLocation(), 10, 2, 2, 2);
484+
bl.getWorld().spawnParticle(Particle.ASH, bl.getLocation(), 10, 2, 2, 2);
484485
return true;
485486
}
486487
return false;

src/main/java/world/bentobox/greenhouses/greenhouse/Roof.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package world.bentobox.greenhouses.greenhouse;
22

3-
import java.util.Arrays;
43
import java.util.List;
54
import java.util.Objects;
65
import java.util.Optional;
@@ -9,6 +8,7 @@
98
import org.bukkit.Bukkit;
109
import org.bukkit.Location;
1110
import org.bukkit.Material;
11+
import org.bukkit.Registry;
1212
import org.bukkit.Tag;
1313
import org.bukkit.World;
1414
import org.bukkit.util.Vector;
@@ -24,7 +24,7 @@
2424
*
2525
*/
2626
public class Roof extends MinMaxXZ {
27-
private static final List<Material> ROOF_BLOCKS = Arrays.stream(Material.values())
27+
private static final List<Material> ROOF_BLOCKS = Registry.MATERIAL.stream()
2828
.filter(Material::isBlock) // Blocks only, no items
2929
.filter(m -> Tag.TRAPDOORS.isTagged(m) // All trapdoors
3030
|| (m.name().contains("GLASS") && !m.name().contains("GLASS_PANE")) // All glass blocks

src/main/java/world/bentobox/greenhouses/greenhouse/Walls.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
import org.bukkit.Bukkit;
88
import org.bukkit.Location;
99
import org.bukkit.Material;
10+
import org.bukkit.Registry;
1011

1112
import world.bentobox.bentobox.BentoBox;
1213
import world.bentobox.greenhouses.world.AsyncWorldCache;
1314

1415
public class Walls extends MinMaxXZ {
15-
public static final List<Material> WALL_BLOCKS = Arrays.stream(Material.values())
16+
public static final List<Material> WALL_BLOCKS = Registry.MATERIAL.stream()
1617
.filter(Material::isBlock) // Blocks only, no items
1718
.filter(m -> !m.name().contains("TRAPDOOR")) // No trap doors
1819
.filter(m -> m.name().contains("DOOR") // All doors

src/main/java/world/bentobox/greenhouses/listeners/GreenhouseEvents.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package world.bentobox.greenhouses.listeners;
22

3+
import java.util.Arrays;
4+
import java.util.List;
35
import java.util.Optional;
4-
import java.util.Set;
56

67
import org.bukkit.Location;
78
import org.bukkit.Material;
@@ -30,15 +31,14 @@
3031
*/
3132
public class GreenhouseEvents implements Listener {
3233
private static final String BIOME = "[biome]";
33-
private static final Set<Biome> NETHER_BIOMES;
34-
static {
35-
NETHER_BIOMES = Set.of(Biome.NETHER_WASTES, Biome.WARPED_FOREST, Biome.CRIMSON_FOREST,
36-
Biome.SOUL_SAND_VALLEY, Biome.BASALT_DELTAS);
37-
}
34+
private static List<Biome> NETHER_BIOMES;
3835
private final Greenhouses addon;
3936

4037
public GreenhouseEvents(final Greenhouses addon) {
4138
this.addon = addon;
39+
NETHER_BIOMES = Arrays.asList(Biome.NETHER_WASTES, Biome.WARPED_FOREST, Biome.CRIMSON_FOREST,
40+
Biome.SOUL_SAND_VALLEY,
41+
Biome.BASALT_DELTAS);
4242
}
4343

4444
/**
@@ -67,7 +67,7 @@ public void onPlayerInteractInNether(PlayerBucketEmptyEvent e) {
6767
e.getPlayer().getInventory().getItemInOffHand().setType(Material.BUCKET);
6868
}
6969

70-
b.getWorld().spawnParticle(Particle.SMOKE_NORMAL, b.getLocation(), 10);
70+
b.getWorld().spawnParticle(Particle.SMOKE, b.getLocation(), 10);
7171
b.getWorld().playSound(b.getLocation(), Sound.ENTITY_GENERIC_EXTINGUISH_FIRE, 1F, 5F);
7272
}
7373
}
@@ -81,14 +81,14 @@ public void onIceBreak(BlockBreakEvent e) {
8181
if (!Tag.ICE.isTagged(e.getBlock().getType())) {
8282
return;
8383
}
84+
8485
Block b = e.getBlock();
85-
if (b.getWorld().getEnvironment().equals(World.Environment.NETHER)
86+
if (b.getWorld().getEnvironment() == World.Environment.NETHER
8687
&& !addon.getManager().getMap().getGreenhouse(b.getLocation())
87-
.map(gh -> gh.getBiomeRecipe().getBiome()).map(NETHER_BIOMES::contains).orElse(true)) {
88-
//
88+
.map(gh -> gh.getBiomeRecipe().getBiome()).map(NETHER_BIOMES::contains).orElse(true)) {
8989
e.setCancelled(true);
9090
b.setType(Material.WATER);
91-
} else if (!e.getPlayer().getWorld().getEnvironment().equals(World.Environment.NETHER)
91+
} else if (e.getPlayer().getWorld().getEnvironment() != World.Environment.NETHER
9292
&& addon.getManager().getMap().getGreenhouse(b.getLocation())
9393
.map(gh -> gh.getBiomeRecipe().getBiome()).map(NETHER_BIOMES::contains).orElse(false)) {
9494
// Not in Nether, in a nether greenhouse

src/main/java/world/bentobox/greenhouses/listeners/SnowTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private boolean getAirBlocks(Greenhouse gh) {
6666
Block b = Objects.requireNonNull(gh.getLocation().getWorld()).getBlockAt(x, y, z);
6767
Material type = b.getType();
6868
if (type.equals(Material.AIR) || type.equals(Material.SNOW)) {
69-
b.getWorld().spawnParticle(Particle.SNOWBALL, b.getLocation(), 5);
69+
b.getWorld().spawnParticle(Particle.SNOWFLAKE, b.getLocation(), 5);
7070
} else {
7171
// Add snow
7272
if (type.equals(Material.WATER)) {

src/main/java/world/bentobox/greenhouses/managers/RecipeManager.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313

1414
import org.bukkit.ChatColor;
1515
import org.bukkit.Material;
16+
import org.bukkit.Registry;
1617
import org.bukkit.block.Biome;
1718
import org.bukkit.configuration.ConfigurationSection;
1819
import org.bukkit.configuration.InvalidConfigurationException;
1920
import org.bukkit.configuration.file.YamlConfiguration;
2021
import org.bukkit.entity.EntityType;
2122

22-
import com.google.common.base.Enums;
23-
2423
import world.bentobox.bentobox.util.Util;
2524
import world.bentobox.greenhouses.Greenhouses;
2625
import world.bentobox.greenhouses.greenhouse.BiomeRecipe;
@@ -115,26 +114,26 @@ private void processEntries(String biomeType, ConfigurationSection biomeSection)
115114
} catch (Exception e) {
116115
addon.logError("Problem loading biome recipe - skipping! " + e.getMessage());
117116
StringBuilder validBiomes = new StringBuilder();
118-
for (Biome biome : Biome.values()) {
119-
validBiomes.append(" ").append(biome.name());
120-
}
117+
Registry.BIOME.forEach(biome -> validBiomes.append(" ").append(biome.getKey().getKey()));
121118
addon.logError("Valid biomes are " + validBiomes);
122119
}
123120

124121
}
125122

123+
@SuppressWarnings("deprecation")
126124
private Biome loadBiome(String biomeType, ConfigurationSection biomeRecipeConfig) {
127125
if (!biomeRecipeConfig.contains("biome")) {
128126
addon.logError("No biome defined in the biome reciepe " + biomeType + ". Skipping...");
129127
return null;
130128
}
131129
String name = Objects.requireNonNull(biomeRecipeConfig.getString("biome")).toUpperCase(Locale.ENGLISH);
132-
if (Enums.getIfPresent(Biome.class, name).isPresent()) {
133-
return Biome.valueOf(name);
130+
Biome b = Biome.valueOf(name);
131+
if (b != null) {
132+
return b;
134133
}
135134
// Special case for nether
136135
if (name.equals("NETHER") || name.equals("NETHER_WASTES")) {
137-
return Enums.getIfPresent(Biome.class, "NETHER").or(Enums.getIfPresent(Biome.class, "NETHER_WASTES").or(Biome.PLAINS));
136+
return Biome.NETHER_WASTES;
138137
}
139138
addon.logError("Biome " + name + " is invalid! Use one of these...");
140139
addon.logError(Arrays.stream(Biome.values()).map(Biome::name).collect(Collectors.joining(",")));

src/main/resources/addon.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Greenhouses
22
main: world.bentobox.greenhouses.Greenhouses
33
version: ${version}${build.number}
4-
api-version: 1.15.4
4+
api-version: 2.7.1
55

66
authors: tastybento
77

0 commit comments

Comments
 (0)