Skip to content
Merged
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
75 changes: 59 additions & 16 deletions src/main/java/world/bentobox/level/PlaceholderManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@
import org.bukkit.persistence.PersistentDataType;
import org.eclipse.jdt.annotation.Nullable;

import com.nexomc.nexo.api.NexoBlocks;
import com.nexomc.nexo.api.NexoItems;
import com.nexomc.nexo.mechanics.custom_block.CustomBlockMechanic;

import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.hooks.ItemsAdderHook;
import world.bentobox.bentobox.hooks.OraxenHook;
import world.bentobox.bentobox.managers.PlaceholdersManager;
import world.bentobox.bentobox.managers.RanksManager;
import world.bentobox.level.objects.IslandLevels;
Expand Down Expand Up @@ -394,6 +399,30 @@ private Object getBlockIdentifier(@Nullable Block block) {
return Material.SPAWNER; // Return generic spawner material if state invalid
}

// Check Oraxen custom blocks (noteblock/stringblock/chorusblock mechanics)
if (BentoBox.getInstance().getHooks().getHook("Oraxen").isPresent()) {
String oraxenId = OraxenHook.getOraxenBlockID(block.getLocation());
if (oraxenId != null) {
return "oraxen:" + oraxenId;
}
}

// Check Nexo custom blocks
if (addon.isNexo()) {
CustomBlockMechanic nexoMechanic = NexoBlocks.customBlockMechanic(block.getLocation());
if (nexoMechanic != null) {
return "nexo:" + nexoMechanic.getItemID();
}
}

// Check ItemsAdder custom blocks
if (addon.isItemsAdder()) {
String iaId = ItemsAdderHook.getInCustomRegion(block.getLocation());
if (iaId != null) {
return iaId;
}
}

// Fallback to the Material for regular blocks
return type;
}
Expand Down Expand Up @@ -474,15 +503,31 @@ private Object getItemIdentifier(@Nullable ItemStack itemStack) {
} // End of Spawner handling

// 2. Handle potential custom items (e.g., ItemsAdder)
if (addon.isItemsAdder()) {
Optional<String> customId = ItemsAdderHook.getNamespacedId(itemStack);
if (customId.isPresent()) {
return customId.get(); // Return the String ID from ItemsAdder
}
}

// 3. Fallback to Material for regular items that represent blocks
return type.isBlock() ? type : null;
if (addon.isItemsAdder()) {
Optional<String> customId = ItemsAdderHook.getNamespacedId(itemStack);
if (customId.isPresent()) {
return customId.get(); // Return the String ID from ItemsAdder
}
}

// 3. Handle Oraxen custom items
if (BentoBox.getInstance().getHooks().getHook("Oraxen").isPresent()) {
Optional<String> oraxenId = OraxenHook.getNamespacedId(itemStack);
if (oraxenId.isPresent()) {
return "oraxen:" + oraxenId.get();
}
}

// 4. Handle Nexo custom items
if (addon.isNexo()) {
String nexoId = NexoItems.idFromItem(itemStack);
if (nexoId != null) {
return "nexo:" + nexoId;
}
}

// 5. Fallback to Material for regular items that represent blocks
return type.isBlock() ? type : null;
}

/**
Expand Down Expand Up @@ -538,16 +583,14 @@ private Object getObjectFromConfigKey(String configKey) {
return material;
}

// Assume it's a custom String key (e.g., ItemsAdder) if not resolved yet
if (addon.isItemsAdder() && ItemsAdderHook.isInRegistry(configKey)) { // Use original case key for lookup?
return configKey;
}

// Final check: maybe it's the generic "spawner" key from config?
if(lowerCaseKey.equals("spawner")) {
if (lowerCaseKey.equals("spawner")) {
return Material.SPAWNER;
}
return null;

// Return the key as-is for custom blocks (ItemsAdder, Oraxen, Nexo).
// These are stored as String keys in mdCount/uwCount.
return configKey;
}

/**
Expand Down