Skip to content

Commit 1c15f3a

Browse files
tastybentoBONNeTechirion
authored
Release 2.6.0 (#129)
* Update pom.xml * BentoBox 2.0.0 API * Updated Github Build Action * Avoid potential error if island owner is null User.getInstance(island.getOwner()); * Added initial test class for StoneGeneratorManager. Refactored some code to not use Optional as a method parameter. * Added tests. * Try org.apache.commonscommons-lang3 to compile * Upgrade to BentoBox 2.0.0 and Spigot 1.20 * Update to 1.20.4 * Update BentoBox 2.0.0 API for RanksManager * Update TIPPED ARROW to use Spigot API in panels * Update to Java 21 * Fix project key * Validate island data once owner is changed Add TeamSetownerEvent that validates unlocked generatrs once owner is changed. * Return the Pladdon that was made. * Only register IslandLevelListener if Level addon is present (#134) * Update to 1.21.3 and CodeMC (#138) * Update to 1.21.3 and CodeMC * Fix typo * Update versions in POM * Update POM, fix JavaDoc * Update POM * Update maven-compiler-plugin --------- Co-authored-by: BONNe <[email protected]> Co-authored-by: IAISI <[email protected]>
1 parent 210841e commit 1c15f3a

File tree

18 files changed

+2716
-2563
lines changed

18 files changed

+2716
-2563
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,29 @@ on:
33
push:
44
branches:
55
- develop
6-
- master
6+
pull_request:
7+
types: [opened, synchronize, reopened]
78
jobs:
89
build:
910
name: Build
1011
runs-on: ubuntu-latest
1112
steps:
12-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1314
with:
1415
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
15-
- name: Set up JDK 17
16-
uses: actions/setup-java@v1
16+
- name: Set up JDK 21
17+
uses: actions/setup-java@v3
1718
with:
18-
java-version: 17
19+
distribution: 'adopt'
20+
java-version: '21'
1921
- name: Cache SonarCloud packages
20-
uses: actions/cache@v1
22+
uses: actions/cache@v3
2123
with:
2224
path: ~/.sonar/cache
2325
key: ${{ runner.os }}-sonar
2426
restore-keys: ${{ runner.os }}-sonar
2527
- name: Cache Maven packages
26-
uses: actions/cache@v1
28+
uses: actions/cache@v3
2729
with:
2830
path: ~/.m2
2931
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
@@ -32,4 +34,11 @@ jobs:
3234
env:
3335
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
3436
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
35-
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
37+
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BentoBoxWorld_MagicCobblestoneGenerator
38+
- run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install
39+
- run: mkdir staging && cp target/*.jar staging
40+
- name: Save artifacts
41+
uses: actions/upload-artifact@v3
42+
with:
43+
name: Package
44+
path: staging

pom.xml

Lines changed: 57 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@
3232
<properties>
3333
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3434
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
35-
<java.version>17</java.version>
35+
<java.version>21</java.version>
3636
<!-- More visible way how to change dependency versions -->
37-
<spigot.version>1.18-R0.1-SNAPSHOT</spigot.version>
38-
<bentobox.version>1.20.0</bentobox.version>
37+
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
38+
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
3939
<level.version>2.5.0</level.version>
4040
<bank.version>1.4.0</bank.version>
41+
<!-- Mocks -->
42+
<powermock.version>2.0.9</powermock.version>
4143
<!-- Panel Utils version -->
42-
<panelutils.version>1.0.0</panelutils.version>
44+
<panelutils.version>1.2.0</panelutils.version>
4345
<!-- Vault API version -->
4446
<vault.version>1.7</vault.version>
4547
<!-- Revision variable removes warning about dynamic version -->
@@ -85,13 +87,9 @@
8587
</profiles>
8688

8789
<distributionManagement>
88-
<snapshotRepository>
89-
<id>codemc-snapshots</id>
90-
<url>https://repo.codemc.io/repository/maven-snapshots</url>
91-
</snapshotRepository>
9290
<repository>
93-
<id>codemc-releases</id>
94-
<url>https://repo.codemc.io/repository/maven-releases</url>
91+
<id>bentoboxworld</id>
92+
<url>https://repo.codemc.io/repository/bentoboxworld/</url>
9593
</repository>
9694
</distributionManagement>
9795

@@ -108,14 +106,14 @@
108106
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
109107
</repository>
110108
<repository>
111-
<id>codemc-repo</id>
112-
<url>https://repo.codemc.io/repository/maven-public/</url>
109+
<id>bentoboxworld</id>
110+
<url>https://repo.codemc.io/repository/bentoboxworld/</url>
113111
</repository>
114-
<!--Vault Repo is down. -->
115112
<repository>
116-
<id>vault-repo</id>
117-
<url>https://nexus.hc.to/content/repositories/pub_releases</url>
113+
<id>codemc-repo</id>
114+
<url>https://repo.codemc.io/repository/maven-public/</url>
118115
</repository>
116+
<!--Vault Repo -->
119117
<repository>
120118
<id>jitpack.io</id>
121119
<url>https://jitpack.io</url>
@@ -163,9 +161,36 @@
163161
<artifactId>panelutils</artifactId>
164162
<version>${panelutils.version}</version>
165163
</dependency>
164+
<!-- Mockito (Unit testing) -->
165+
<dependency>
166+
<groupId>org.mockito</groupId>
167+
<artifactId>mockito-core</artifactId>
168+
<version>3.11.1</version>
169+
<scope>test</scope>
170+
</dependency>
171+
<dependency>
172+
<groupId>org.powermock</groupId>
173+
<artifactId>powermock-module-junit4</artifactId>
174+
<version>${powermock.version}</version>
175+
<scope>test</scope>
176+
</dependency>
177+
<dependency>
178+
<groupId>org.powermock</groupId>
179+
<artifactId>powermock-api-mockito2</artifactId>
180+
<version>${powermock.version}</version>
181+
<scope>test</scope>
182+
</dependency>
166183
</dependencies>
167184

168185
<build>
186+
<!-- By default ${revision} is ${build.version}-SNAPSHOT -->
187+
<!-- If GIT_BRANCH variable is set to origin/master, then it will
188+
be only ${build.version}. -->
189+
190+
<!-- By default ${build.number} is -LOCAL. -->
191+
<!-- If the BUILD_NUMBER variable is set, then it will be -b[number]. -->
192+
<!-- If GIT_BRANCH variable is set to origin/master, then it will
193+
be the empty string. -->
169194
<finalName>${project.name}-${revision}${build.number}</finalName>
170195

171196
<defaultGoal>clean package</defaultGoal>
@@ -178,34 +203,32 @@
178203
<directory>src/main/resources/locales</directory>
179204
<targetPath>./locales</targetPath>
180205
<filtering>false</filtering>
181-
<includes>
182-
<include>*.yml</include>
183-
</includes>
184206
</resource>
185207
</resources>
186-
<plugins>
208+
<plugins>
187209
<plugin>
188210
<groupId>org.apache.maven.plugins</groupId>
189211
<artifactId>maven-clean-plugin</artifactId>
190-
<version>3.1.0</version>
212+
<version>3.4.0</version>
191213
</plugin>
192214
<plugin>
193215
<groupId>org.apache.maven.plugins</groupId>
194216
<artifactId>maven-resources-plugin</artifactId>
195-
<version>3.1.0</version>
217+
<version>3.3.1</version>
196218
</plugin>
197219
<plugin>
198220
<groupId>org.apache.maven.plugins</groupId>
199221
<artifactId>maven-compiler-plugin</artifactId>
200-
<version>3.8.1</version>
222+
<version>3.13.0</version>
201223
<configuration>
202224
<release>${java.version}</release>
225+
<!-- <source>${java.version}</source> <target>${java.version}</target> -->
203226
</configuration>
204227
</plugin>
205228
<plugin>
206229
<groupId>org.apache.maven.plugins</groupId>
207230
<artifactId>maven-surefire-plugin</artifactId>
208-
<version>3.0.0-M5</version>
231+
<version>3.5.2</version>
209232
<configuration>
210233
<argLine>
211234
${argLine}
@@ -242,24 +265,21 @@
242265
<plugin>
243266
<groupId>org.apache.maven.plugins</groupId>
244267
<artifactId>maven-jar-plugin</artifactId>
245-
<version>3.1.0</version>
268+
<version>3.4.2</version>
246269
</plugin>
247270
<plugin>
248271
<groupId>org.apache.maven.plugins</groupId>
249272
<artifactId>maven-javadoc-plugin</artifactId>
250-
<version>3.3.0</version>
273+
<version>3.11.1</version>
251274
<configuration>
252-
<source>16</source>
253-
<show>private</show>
275+
<doclint>none</doclint> <!-- Turnoff all checks -->
254276
<failOnError>false</failOnError>
255-
<additionalJOption>-Xdoclint:none</additionalJOption>
256-
<!-- To compile with Java 11, this tag may be required -->
257-
<!-- <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable> -->
277+
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
278+
<source>17</source>
258279
</configuration>
259280
<executions>
260281
<execution>
261282
<id>attach-javadocs</id>
262-
<phase>install</phase>
263283
<goals>
264284
<goal>jar</goal>
265285
</goals>
@@ -269,7 +289,7 @@
269289
<plugin>
270290
<groupId>org.apache.maven.plugins</groupId>
271291
<artifactId>maven-source-plugin</artifactId>
272-
<version>3.0.1</version>
292+
<version>3.3.1</version>
273293
<executions>
274294
<execution>
275295
<id>attach-sources</id>
@@ -279,67 +299,28 @@
279299
</execution>
280300
</executions>
281301
</plugin>
282-
<plugin>
283-
<groupId>org.apache.maven.plugins</groupId>
284-
<artifactId>maven-shade-plugin</artifactId>
285-
<version>3.3.1-SNAPSHOT</version>
286-
<configuration>
287-
<minimizeJar>true</minimizeJar>
288-
<artifactSet>
289-
<includes>
290-
<include>lv.id.bonne:panelutils:*</include>
291-
</includes>
292-
</artifactSet>
293-
<transformers>
294-
<!-- Add a transformer to exclude any other manifest files (possibly from dependencies). -->
295-
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
296-
<resource>MANIFEST.MF</resource>
297-
</transformer>
298-
<!-- Add a transformer to include your custom manifest file. -->
299-
<transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
300-
<resource>META-INF/MANIFEST.MF</resource>
301-
<file>src/main/resources/META-INF/MANIFEST.MF</file>
302-
</transformer>
303-
</transformers>
304-
</configuration>
305-
<executions>
306-
<execution>
307-
<phase>package</phase>
308-
<goals>
309-
<goal>shade</goal>
310-
</goals>
311-
</execution>
312-
</executions>
313-
</plugin>
314302
<plugin>
315303
<groupId>org.apache.maven.plugins</groupId>
316304
<artifactId>maven-install-plugin</artifactId>
317-
<version>2.5.2</version>
305+
<version>3.1.3</version>
318306
</plugin>
319307
<plugin>
320308
<groupId>org.apache.maven.plugins</groupId>
321309
<artifactId>maven-deploy-plugin</artifactId>
322-
<version>2.8.2</version>
323-
<executions>
324-
<execution>
325-
<id>default-deploy</id>
326-
<phase>deploy</phase>
327-
<goals>
328-
<goal>deploy</goal>
329-
</goals>
330-
</execution>
331-
</executions>
310+
<version>3.1.3</version>
332311
</plugin>
333312
<plugin>
334313
<groupId>org.jacoco</groupId>
335314
<artifactId>jacoco-maven-plugin</artifactId>
336-
<version>0.8.7</version>
315+
<version>0.8.10</version>
337316
<configuration>
338317
<append>true</append>
339318
<excludes>
340319
<!-- This is required to prevent Jacoco from adding
341320
synthetic fields to a JavaBean class (causes errors in testing) -->
342321
<exclude>**/*Names*</exclude>
322+
<!-- Prevents the Material is too large to mock error -->
323+
<exclude>org/bukkit/Material*</exclude>
343324
</excludes>
344325
</configuration>
345326
<executions>
@@ -364,5 +345,4 @@
364345
</plugin>
365346
</plugins>
366347
</build>
367-
368348
</project>

src/main/java/world/bentobox/magiccobblestonegenerator/StoneGeneratorAddon.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ private void setupAddon()
122122
//this.registerListener(new MagicGeneratorListener(this));
123123

124124
this.registerListener(new JoinLeaveListener(this));
125-
this.registerListener(new IslandLevelListener(this));
125+
if(this.getAddonByName("Level").isPresent())
126+
this.registerListener(new IslandLevelListener(this));
126127

127128
// Register Flags
128129
this.registerFlag(MAGIC_COBBLESTONE_GENERATOR);

src/main/java/world/bentobox/magiccobblestonegenerator/StoneGeneratorPladdon.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@
1616
*/
1717
public class StoneGeneratorPladdon extends Pladdon
1818
{
19+
private Addon addon;
20+
1921
@Override
2022
public Addon getAddon()
2123
{
22-
return new StoneGeneratorAddon();
24+
if (addon == null) {
25+
addon = new StoneGeneratorAddon();
26+
}
27+
return addon;
2328
}
2429
}

src/main/java/world/bentobox/magiccobblestonegenerator/database/objects/GeneratorTierObject.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,10 @@ public void setDeployed(boolean deployed)
242242

243243

244244
/**
245-
* Method GeneratorTierObject#getBlockChanceMap returns the blockChanceMap of this object.
245+
* Returns the blockChanceMap of this object.
246246
*
247-
* @return the blockChanceMap (type Map<Double, Material>) of this object.
247+
* @return a {@code TreeMap} where the keys are {@code Double} values representing chances,
248+
* and the values are {@code Material} objects.
248249
*/
249250
public TreeMap<Double, Material> getBlockChanceMap()
250251
{
@@ -264,9 +265,10 @@ public void setBlockChanceMap(TreeMap<Double, Material> blockChanceMap)
264265

265266

266267
/**
267-
* Method GeneratorTierObject#getTreasureChanceMap returns the treasureChanceMap of this object.
268+
* Returns the treasureChanceMap of this object.
268269
*
269-
* @return the treasureChanceMap (type Map<Double, Material>) of this object.
270+
* @return a {@code TreeMap} where the keys are {@code Double} values representing chances,
271+
* and the values are {@code Material} objects.
270272
*/
271273
public TreeMap<Double, Material> getTreasureChanceMap()
272274
{

src/main/java/world/bentobox/magiccobblestonegenerator/listeners/GeneratorListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected void playEffects(Block block)
136136
// This spawns 8 large smoke particles.
137137
for (int counter = 0; counter < 8; ++counter)
138138
{
139-
block.getWorld().spawnParticle(Particle.SMOKE_LARGE,
139+
block.getWorld().spawnParticle(Particle.SMOKE,
140140
blockX + Math.random(),
141141
blockY + 1 + Math.random(),
142142
blockZ + Math.random(),

src/main/java/world/bentobox/magiccobblestonegenerator/listeners/JoinLeaveListener.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import world.bentobox.bentobox.api.events.island.IslandDeleteEvent;
1717
import world.bentobox.bentobox.api.events.island.IslandRegisteredEvent;
1818
import world.bentobox.bentobox.api.events.island.IslandResettedEvent;
19+
import world.bentobox.bentobox.api.events.team.TeamSetownerEvent;
1920
import world.bentobox.magiccobblestonegenerator.StoneGeneratorAddon;
2021

2122

@@ -82,6 +83,18 @@ public void onIslandCreated(IslandRegisteredEvent event)
8283
}
8384

8485

86+
/**
87+
* This method handles Team Owner Change event
88+
*
89+
* @param event Event that must be handled.
90+
*/
91+
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
92+
public void onTeamOwnerChange(TeamSetownerEvent event)
93+
{
94+
this.addon.getAddonManager().validateIslandData(event.getIsland());
95+
}
96+
97+
8598
/**
8699
* This method handles island deletion. On island deletion it should remove generator data too.
87100
*
@@ -98,4 +111,4 @@ public void onIslandDelete(IslandDeleteEvent event)
98111
* stores addon instance
99112
*/
100113
private final StoneGeneratorAddon addon;
101-
}
114+
}

0 commit comments

Comments
 (0)