Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<mock-bukkit.version>v1.21-SNAPSHOT</mock-bukkit.version>
<!-- More visible way how to change dependency versions -->
<paper.version>1.21.11-R0.1-SNAPSHOT</paper.version>
<bentobox.version>3.14.1-SNAPSHOT</bentobox.version>
<bentobox.version>3.15.0-SNAPSHOT</bentobox.version>
<!-- Warps addon version -->
<warps.version>1.12.0</warps.version>
<!-- Visit addon version -->
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/world/bentobox/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -515,4 +515,12 @@ public boolean isNexo() {
&& Bukkit.getPluginManager().isPluginEnabled("Nexo");
}

/**
* @return true if the CraftEngine plugin is hooked and not disabled in config
*/
public boolean isCraftEngine() {
return !getSettings().getDisabledPluginHooks().contains("CraftEngine")
&& getPlugin().getHooks().getHook("CraftEngine").isPresent();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import us.lynuxcraft.deadsilenceiv.advancedchests.chest.gui.page.ChestPage;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.hooks.CraftEngineHook;
import world.bentobox.bentobox.hooks.ItemsAdderHook;
import world.bentobox.bentobox.hooks.OraxenHook;
import world.bentobox.bentobox.util.Pair;
Expand Down Expand Up @@ -553,7 +554,7 @@
* @param globalX The block's global X coordinate in the world.
* @param globalZ The block's global Z coordinate in the world.
*/
private void processBlock(ChunkPair cp, int x, int y, int z, int globalX, int globalZ) {

Check warning on line 557 in src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

A "Brain Method" was detected. Refactor it to reduce at least one of the following metrics: LOC from 66 to 64, Complexity from 29 to 14, Nesting Level from 3 to 2, Number of Variables from 14 to 6.

See more on https://sonarcloud.io/project/issues?id=BentoBoxWorld_Level&issues=AZ24zK5A3CJrm6sXYRS4&open=AZ24zK5A3CJrm6sXYRS4&pullRequest=419
BlockData blockData = cp.chunkSnapshot.getBlockData(x, y, z);
Material m = blockData.getMaterial();

Expand All @@ -562,11 +563,11 @@
// Create a Location object only when needed for more complex checks.
Location loc = null;

// === Custom Block Hooks (ItemsAdder, Oraxen, Nexo) ===
// === Custom Block Hooks (ItemsAdder, Oraxen, Nexo, CraftEngine) ===
// These hooks can define custom blocks that override vanilla behavior.
// They must be checked first.
if (addon.isItemsAdder() || BentoBox.getInstance().getHooks().getHook("Oraxen").isPresent()
|| addon.isNexo()) {
|| addon.isNexo() || addon.isCraftEngine()) {
loc = new Location(cp.world, globalX, y, globalZ);
String customBlockId = null;
if (addon.isItemsAdder()) {
Expand All @@ -584,6 +585,9 @@
customBlockId = "nexo:" + nexoMechanic.getItemID();
}
}
if (customBlockId == null && addon.isCraftEngine()) {
customBlockId = CraftEngineHook.getBlockId(loc);
}

if (customBlockId != null) {
// If a custom block is found, count it and stop further processing for this block.
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/world/bentobox/level/config/BlockConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.nexomc.nexo.api.NexoItems;

import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.hooks.CraftEngineHook;
import world.bentobox.bentobox.hooks.ItemsAdderHook;
import world.bentobox.bentobox.hooks.OraxenHook;
import world.bentobox.level.Level;
Expand Down Expand Up @@ -111,7 +112,11 @@ private boolean isOther(String key) {
return NexoItems.exists(key.substring(5));
}
// Check ItemsAdder
return addon.isItemsAdder() && ItemsAdderHook.isInRegistry(key);
if (addon.isItemsAdder() && ItemsAdderHook.isInRegistry(key)) {
return true;
}
// Check CraftEngine — block IDs are already namespaced (e.g. "mynamespace:my_block")
return addon.isCraftEngine() && CraftEngineHook.exists(key);
}

private boolean isSpawner(String key) {
Expand Down
Loading