Skip to content

Commit 4e7b695

Browse files
authored
Merge pull request #351 from BentoBoxWorld/develop
Release 2.19.1
2 parents bc2fc1e + 16936d6 commit 4e7b695

File tree

4 files changed

+121
-7
lines changed

4 files changed

+121
-7
lines changed

docs/MAIN-CLASSES.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# **Level Plugin Documentation**
2+
3+
📌 **Repository:** [BentoBoxWorld/Level](https://github.com/BentoBoxWorld/Level)
4+
📌 **Purpose:** This document provides documentation for all major classes in the Level plugin.
5+
📌 **Target Audience:** Programmers or maintainers of this code.
6+
7+
## **Table of Contents**
8+
- [Core Classes](#core-classes)
9+
- [Managers](#managers)
10+
- [Calculators](#calculators)
11+
- [Commands](#commands)
12+
- [Events](#events)
13+
- [Panels (GUI)](#panels-gui)
14+
- [Utilities](#utilities)
15+
16+
---
17+
18+
## **1️⃣ Core Classes**
19+
### **Level**
20+
📍 [`Level.java`](https://github.com/BentoBoxWorld/Level/blob/develop/src/main/java/world/bentobox/level/Level.java)
21+
Handles configuration, plugin hooks, and initialization. Level uses the BentoBox Addon API, which follows the Plugin style.
22+
**Main Methods:**
23+
- `onLoad()`, `onEnable()`, `allLoaded()`, `getIslandLevel()`, `setIslandLevel()`
24+
25+
`allLoaded()` is a method that BentoBox calls when all the Addons have been loaded, which usually means that all the BentoBox worlds have been loaded. This is important because Level will be referencing worlds.
26+
`getIslandLevel()` is used by the Level addon, but is also used by external Plugins to obtain island levels for players.
27+
28+
### **LevelPladdon**
29+
📍 [`LevelPladdon.java`](https://github.com/BentoBoxWorld/Level/blob/develop/src/main/java/world/bentobox/level/LevelPladdon.java)
30+
A wrapper for registering the Level addon. Pladdons are wrappers that make Addons Plugins. This is required because servers like Paper
31+
do byte-code-level conversions when the code is loaded and so the Addons have to be Plugins to benefit from this.
32+
**Main Method:**
33+
- `getAddon()`
34+
35+
---
36+
37+
## **2️⃣ Managers**
38+
### **LevelsManager**
39+
📍 [`LevelsManager.java`](https://github.com/BentoBoxWorld/Level/blob/develop/src/main/java/world/bentobox/level/LevelsManager.java)
40+
Manages island level calculations, leaderboards, and formatting.
41+
**Main Methods:**
42+
- `calculateLevel()`, `getIslandLevel()`, `getTopTen()`
43+
44+
### **PlaceholderManager**
45+
📍 [`PlaceholderManager.java`](https://github.com/BentoBoxWorld/Level/blob/develop/src/main/java/world/bentobox/level/PlaceholderManager.java)
46+
Handles dynamic placeholders.
47+
**Main Methods:**
48+
- `registerPlaceholders()`, `getRankName()`, `getVisitedIslandLevel()`
49+
50+
---
51+
52+
## **3️⃣ Calculators**
53+
### **EquationEvaluator**
54+
📍 [`EquationEvaluator.java`](https://github.com/BentoBoxWorld/Level/blob/develop/src/main/java/world/bentobox/level/calculators/EquationEvaluator.java)
55+
Evaluates mathematical expressions dynamically.
56+
**Main Method:**
57+
- `eval(String)`
58+
59+
### **IslandLevelCalculator**
60+
📍 [`IslandLevelCalculator.java`](https://github.com/BentoBoxWorld/Level/blob/develop/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java)
61+
Computes island levels by scanning blocks and entities.
62+
**Main Methods:**
63+
- `scanIsland()`, `calculateLevel()`
64+
65+
### **UltimateStackerCalc**
66+
📍 [`UltimateStackerCalc.java`](https://github.com/BentoBoxWorld/Level/blob/develop/src/main/java/world/bentobox/level/calculators/UltimateStackerCalc.java)
67+
Handles calculations for stacked blocks from the plugin UltimateStacker.
68+
**Main Method:**
69+
- `addStackers()`
70+
71+
---
72+
73+
## **4️⃣ Commands**
74+
📌 [Command Handlers Directory](https://github.com/BentoBoxWorld/Level/tree/develop/src/main/java/world/bentobox/level/commands)
75+
76+
- **Admin Commands**
77+
- [`AdminLevelStatusCommand.java`](#) → Displays islands in calculation queue.
78+
- [`AdminSetInitialLevelCommand.java`](#) → Sets initial island level.
79+
80+
- **Player Commands**
81+
- [`IslandLevelCommand.java`](#) → Triggers level calculation.
82+
- [`IslandTopCommand.java`](#) → Shows top island levels.
83+
84+
---
85+
86+
## **5️⃣ Events**
87+
### **IslandActivitiesListeners**
88+
📍 [`IslandActivitiesListeners.java`](https://github.com/BentoBoxWorld/Level/blob/develop/src/main/java/world/bentobox/level/listeners/IslandActivitiesListeners.java)
89+
Handles **island creation, deletion, and ownership changes**.
90+
**Main Events:**
91+
- `onNewIsland()`, `onIslandDelete()`, `onNewIslandOwner()`
92+
93+
---
94+
95+
## **6️⃣ Panels (GUI)**
96+
### **TopLevelPanel**
97+
📍 [`TopLevelPanel.java`](https://github.com/BentoBoxWorld/Level/blob/develop/src/main/java/world/bentobox/level/panels/TopLevelPanel.java)
98+
Displays the **top 10 ranked islands** in a GUI.
99+
**Main Methods:**
100+
- `build()`, `createPlayerButton()`, `openPanel()`
101+
102+
### **ValuePanel**
103+
📍 [`ValuePanel.java`](https://github.com/BentoBoxWorld/Level/blob/develop/src/main/java/world/bentobox/level/panels/ValuePanel.java)
104+
Displays **block values** for island levels.
105+
**Main Methods:**
106+
- `build()`, `createMaterialButton()`, `openPanel()`
107+
108+
---
109+
110+
## **7️⃣ Utilities**
111+
📌 [Utility Classes Directory](https://github.com/BentoBoxWorld/Level/tree/develop/src/main/java/world/bentobox/level/util)
112+
113+
- **Utils.java** → General helper methods.
114+
- **ConversationUtils.java** → Handles player text input in conversations.
115+

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<!-- Do not change unless you want different name for local builds. -->
6868
<build.number>-LOCAL</build.number>
6969
<!-- This allows to change between versions. -->
70-
<build.version>2.19.0</build.version>
70+
<build.version>2.19.1</build.version>
7171
<sonar.projectKey>BentoBoxWorld_Level</sonar.projectKey>
7272
<sonar.organization>bentobox-world</sonar.organization>
7373
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

src/main/java/world/bentobox/level/config/BlockConfig.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ public Integer getValue(World world, Object obj) {
238238
* @return true if hidden
239239
*/
240240
public boolean isHiddenBlock(Object obj) {
241-
if (obj instanceof Material m) {
241+
if (obj instanceof String s) {
242+
return hiddenBlocks.contains(s);
243+
} else if (obj instanceof Material m) {
242244
return hiddenBlocks.contains(m.name());
243245
}
244246
return hiddenBlocks.contains(Material.SPAWNER.name());
@@ -250,11 +252,7 @@ public boolean isHiddenBlock(Object obj) {
250252
* @return false if hidden
251253
*/
252254
public boolean isNotHiddenBlock(Object obj) {
253-
if (obj instanceof Material m) {
254-
return !hiddenBlocks.contains(m.name());
255-
} else {
256-
return !hiddenBlocks.contains(Material.SPAWNER.name());
257-
}
255+
return !isHiddenBlock(obj);
258256
}
259257

260258
/**

src/main/java/world/bentobox/level/panels/ValuePanel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ private ValuePanel(Level addon,
135135
this.activeFilter = Filter.NAME_ASC;
136136

137137
addon.getBlockConfig().getBlockValues().entrySet().stream().filter(en -> this.getIcon(en.getKey()) != null)
138+
.filter(en -> addon.getBlockConfig().isNotHiddenBlock(en.getKey()))
138139
.forEach(en -> blockRecordList
139140
.add(new BlockRecord(en.getKey(), Objects.requireNonNullElse(en.getValue(), 0),
140141
Objects.requireNonNullElse(addon.getBlockConfig().getLimit(en.getKey()), 0))));

0 commit comments

Comments
 (0)