Skip to content

Commit 9c6ba93

Browse files
authored
Merge pull request #470 from BentoBoxWorld/develop
Version 1.22.1
2 parents 6e88cf3 + 03124b2 commit 9c6ba93

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2561
-685
lines changed

CLAUDE.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Commands
6+
7+
```bash
8+
# Build
9+
mvn clean package
10+
11+
# Run all tests
12+
mvn test
13+
14+
# Run a single test class
15+
mvn test -Dtest=TestClassName
16+
17+
# Run a single test method
18+
mvn test -Dtest=TestClassName#methodName
19+
20+
# Full verify with coverage (JaCoCo)
21+
mvn verify
22+
```
23+
24+
## Project Overview
25+
26+
AOneBlock is a BentoBox GameModeAddon for Minecraft. Players start on a single magic block in the sky; mining that block cycles through 18+ sequential phases (Plains, Underground, Ocean, Jungle, etc.), each with its own blocks, mobs, and chest loot. The plugin extends `GameModeAddon` from BentoBox and hooks into the Bukkit event system.
27+
28+
## Key Architecture
29+
30+
**Entry point:** `AOneBlock.java` — registers listeners, commands, generators, and the `OneBlocksManager`.
31+
32+
**Phase system (`oneblocks/`):**
33+
- `OneBlocksManager` — loads phase YAML files from `src/main/resources/phases/`, tracks per-island block counts, handles phase transitions, and resolves what block/mob/chest appears next.
34+
- `OneBlockPhase` — represents a single phase with its block pool, mob pool, and chest tables.
35+
- `OneBlockObject` — a single block-pool entry (can be a vanilla block, custom block, or mob spawn).
36+
- `customblock/` — adapters for custom block types (ItemsAdder, Mob, raw BlockData).
37+
38+
**Data persistence:** `OneBlockIslands` (in `dataobjects/`) is stored via BentoBox's database abstraction. It tracks block count, phase name, and hologram state per island.
39+
40+
**Listeners (`listeners/`):** Handle the magic block break event (core gameplay loop), boss bar updates, hologram placement, island join/leave hooks, and protection flags.
41+
42+
**Events (`events/`):** `MagicBlockEvent`, `MagicBlockPhaseEvent`, and `BlockClearEvent` are fired during gameplay so other plugins can react.
43+
44+
**Commands:**
45+
- Player: `/ob` (`PlayerCommand`) — sub-commands: count, phases, actionbar, bossbar, respawnblock, setcount
46+
- Admin: `/oba` (`AdminCommand`) — sub-commands: setchest, sanitycheck, setcount
47+
48+
**World generation:** `ChunkGeneratorWorld` generates the empty void world with the single starter block.
49+
50+
**GUI:** `PhasesPanel` provides a clickable phase browser.
51+
52+
## Testing
53+
54+
All tests extend `CommonTestSetup`, which sets up a MockBukkit server, mocks BentoBox and its managers (islands, players, worlds), and tears everything down after each test. Use Mockito and the repository's `world.bentobox.aoneblock.WhiteBox` helper for injecting state into private fields.
55+
56+
Phase YAML files under `src/main/resources/phases/` are loaded at startup; tests that exercise `OneBlocksManager` need those resources on the classpath (they are by default via Maven's test resource path).

pom.xml

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,17 @@
5656
<mockito.version>5.11.0</mockito.version>
5757
<mock-bukkit.version>v1.21-SNAPSHOT</mock-bukkit.version>
5858
<!-- More visible way how to change dependency versions -->
59-
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
59+
<bentobox.version>3.10.0</bentobox.version>
6060
<items-adder.version>4.0.10</items-adder.version>
61+
<nexo.version>1.8.0</nexo.version>
6162
<level.version>2.6.2</level.version>
6263
<bank.version>1.3.0</bank.version>
6364
<!-- Revision variable removes warning about dynamic version -->
6465
<revision>${build.version}-SNAPSHOT</revision>
6566
<!-- Do not change unless you want different name for local builds. -->
6667
<build.number>-LOCAL</build.number>
6768
<!-- This allows to change between versions. -->
68-
<build.version>1.22.0</build.version>
69+
<build.version>1.22.1</build.version>
6970
<!-- SonarCloud -->
7071
<sonar.projectKey>BentoBoxWorld_AOneBlock</sonar.projectKey>
7172
<sonar.organization>bentobox-world</sonar.organization>
@@ -123,51 +124,75 @@
123124

124125

125126
<repositories>
127+
<!-- MockBukkit (com.github.*) snapshots live here -->
126128
<repository>
127129
<id>jitpack.io</id>
128130
<url>https://jitpack.io</url>
131+
<releases><enabled>true</enabled></releases>
132+
<snapshots><enabled>true</enabled></snapshots>
129133
</repository>
134+
<!-- BentoBox, Level, Bank releases -->
130135
<repository>
131-
<id>papermc</id>
132-
<url>https://repo.papermc.io/repository/maven-public/</url>
136+
<id>bentoboxworld</id>
137+
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
138+
<releases><enabled>true</enabled></releases>
139+
<snapshots><enabled>false</enabled></snapshots>
133140
</repository>
141+
<!-- Paper API snapshots -->
134142
<repository>
135-
<id>minecraft-repo</id>
136-
<url>https://libraries.minecraft.net/</url>
143+
<id>papermc</id>
144+
<url>https://repo.papermc.io/repository/maven-public/</url>
145+
<releases><enabled>true</enabled></releases>
146+
<snapshots><enabled>true</enabled></snapshots>
137147
</repository>
148+
<!-- ItemsAdder API -->
138149
<repository>
139-
<id>bentoboxworld</id>
140-
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
141-
</repository>
150+
<id>matteodev</id>
151+
<url>https://maven.devs.beer/</url>
152+
<releases><enabled>true</enabled></releases>
153+
<snapshots><enabled>false</enabled></snapshots>
154+
</repository>
155+
<!-- Nexo API -->
142156
<repository>
143-
<id>codemc</id>
144-
<url>https://repo.codemc.org/repository/maven-snapshots/</url>
157+
<id>nexomc</id>
158+
<url>https://repo.nexomc.com/releases/</url>
159+
<releases><enabled>true</enabled></releases>
160+
<snapshots><enabled>false</enabled></snapshots>
145161
</repository>
162+
<!-- General Maven public mirror -->
146163
<repository>
147164
<id>codemc-repo</id>
148165
<url>https://repo.codemc.org/repository/maven-public/</url>
166+
<releases><enabled>true</enabled></releases>
167+
<snapshots><enabled>false</enabled></snapshots>
149168
</repository>
169+
<!-- Mojang/Minecraft libraries (releases only) -->
150170
<repository>
151-
<id>jitpack-repo</id>
152-
<url>https://jitpack.io</url>
171+
<id>minecraft-repo</id>
172+
<url>https://libraries.minecraft.net/</url>
173+
<releases><enabled>true</enabled></releases>
174+
<snapshots><enabled>false</enabled></snapshots>
153175
</repository>
154-
<repository>
155-
<id>matteodev</id>
156-
<url>https://maven.devs.beer/</url>
176+
<!-- CodeMC snapshots (BentoBox CI builds if needed) -->
177+
<repository>
178+
<id>codemc</id>
179+
<url>https://repo.codemc.org/repository/maven-snapshots/</url>
180+
<releases><enabled>false</enabled></releases>
181+
<snapshots><enabled>true</enabled></snapshots>
157182
</repository>
158183
</repositories>
159184

160185
<dependencies>
161186
<dependency>
162187
<groupId>com.github.MockBukkit</groupId>
163188
<artifactId>MockBukkit</artifactId>
164-
<version>v1.21-SNAPSHOT</version>
189+
<version>${mock-bukkit.version}</version>
165190
<scope>test</scope>
166191
</dependency>
167192
<dependency>
168193
<groupId>io.papermc.paper</groupId>
169194
<artifactId>paper-api</artifactId>
170-
<version>1.21.10-R0.1-SNAPSHOT</version>
195+
<version>1.21.11-R0.1-SNAPSHOT</version>
171196
<scope>provided</scope>
172197
</dependency>
173198
<!-- Apache Commons Text -->
@@ -185,7 +210,6 @@
185210
<scope>provided</scope>
186211
</dependency>
187212
<!-- Mockito (Unit testing) -->
188-
<!-- Mockito (Unit testing) This goes at the top to ensure the dependencies are accurate. -->
189213
<dependency>
190214
<groupId>org.junit.jupiter</groupId>
191215
<artifactId>junit-jupiter-api</artifactId>
@@ -235,6 +259,18 @@
235259
<version>${items-adder.version}</version>
236260
<scope>provided</scope>
237261
</dependency>
262+
<dependency>
263+
<groupId>com.nexomc</groupId>
264+
<artifactId>nexo</artifactId>
265+
<version>${nexo.version}</version>
266+
<scope>provided</scope>
267+
<exclusions>
268+
<exclusion>
269+
<groupId>*</groupId>
270+
<artifactId>*</artifactId>
271+
</exclusion>
272+
</exclusions>
273+
</dependency>
238274
</dependencies>
239275

240276
<build>
@@ -302,6 +338,11 @@
302338
<artifactId>maven-surefire-plugin</artifactId>
303339
<version>3.5.4</version>
304340
<configuration>
341+
<includes>
342+
<include>**/*Test.java</include>
343+
<include>**/*Test?.java</include>
344+
<include>**/*Test??.java</include>
345+
</includes>
305346
<argLine>
306347
--add-opens java.base/java.lang=ALL-UNNAMED
307348
--add-opens java.base/java.math=ALL-UNNAMED

src/main/java/world/bentobox/aoneblock/AOneBlock.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
import world.bentobox.aoneblock.listeners.InfoListener;
2525
import world.bentobox.aoneblock.listeners.ItemsAdderListener;
2626
import world.bentobox.aoneblock.listeners.JoinLeaveListener;
27+
import world.bentobox.aoneblock.listeners.NexoListener;
2728
import world.bentobox.aoneblock.listeners.NoBlockHandler;
2829
import world.bentobox.aoneblock.listeners.StartSafetyListener;
2930
import world.bentobox.aoneblock.oneblocks.OneBlockCustomBlockCreator;
3031
import world.bentobox.aoneblock.oneblocks.OneBlocksManager;
3132
import world.bentobox.aoneblock.oneblocks.customblock.ItemsAdderCustomBlock;
33+
import world.bentobox.aoneblock.oneblocks.customblock.NexoCustomBlock;
3234
import world.bentobox.aoneblock.requests.IslandStatsHandler;
3335
import world.bentobox.aoneblock.requests.LocationStatsHandler;
3436
import world.bentobox.bentobox.api.addons.GameModeAddon;
@@ -53,6 +55,8 @@ public class AOneBlock extends GameModeAddon {
5355
private static final String THE_END = "_the_end";
5456
/** Whether ItemsAdder is present on the server */
5557
private boolean hasItemsAdder = false;
58+
/** Whether Nexo is present on the server */
59+
private boolean hasNexo = false;
5660

5761
/** The addon settings */
5862
private Settings settings;
@@ -116,6 +120,13 @@ public void onLoad() {
116120
OneBlockCustomBlockCreator.register("itemsadder", ItemsAdderCustomBlock::fromMap);
117121
hasItemsAdder = true;
118122
}
123+
// Check if Nexo exists, if yes register listener
124+
if (Bukkit.getPluginManager().getPlugin("Nexo") != null) {
125+
registerListener(new NexoListener(this));
126+
OneBlockCustomBlockCreator.register(NexoCustomBlock::fromId);
127+
OneBlockCustomBlockCreator.register("nexo", NexoCustomBlock::fromMap);
128+
hasNexo = true;
129+
}
119130
// Save the default config from config.yml
120131
saveDefaultConfig();
121132
// Load settings from config.yml. This will check if there are any issues with
@@ -398,6 +409,13 @@ public boolean hasItemsAdder() {
398409
return hasItemsAdder;
399410
}
400411

412+
/**
413+
* @return true if Nexo is on the server
414+
*/
415+
public boolean hasNexo() {
416+
return hasNexo;
417+
}
418+
401419
/**
402420
* Set the addon's world. Used only for testing.
403421
* @param world world

src/main/java/world/bentobox/aoneblock/commands/admin/AdminSanityCheck.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public boolean canExecute(User user, String label, List<String> args) {
4242
// Check phase
4343
Optional<OneBlockPhase> opPhase = addon.getOneBlockManager().getPhase(args.getFirst().toUpperCase());
4444
if (opPhase.isEmpty()) {
45-
user.sendMessage("aoneblock.commands.admin.setchest.unknown-phase");
45+
user.sendMessage("aoneblock.commands.admin.sanity.unknown-phase");
4646
return false;
4747
} else {
4848
phase = opPhase.get();
@@ -59,7 +59,7 @@ public boolean execute(User user, String label, List<String> args) {
5959
addon.getOneBlockManager().getProbs(phase);
6060
}
6161
if (user.isPlayer()) {
62-
user.sendMessage("aoneblock.commands.admin.setchest.see-console");
62+
user.sendMessage("aoneblock.commands.admin.sanity.see-console");
6363
}
6464
return true;
6565
}

0 commit comments

Comments
 (0)