|
23 | 23 | import org.bukkit.persistence.PersistentDataType; |
24 | 24 | import org.eclipse.jdt.annotation.Nullable; |
25 | 25 |
|
| 26 | +import com.nexomc.nexo.api.NexoBlocks; |
| 27 | +import com.nexomc.nexo.api.NexoItems; |
| 28 | +import com.nexomc.nexo.mechanics.custom_block.CustomBlockMechanic; |
| 29 | + |
26 | 30 | import world.bentobox.bentobox.BentoBox; |
27 | 31 | import world.bentobox.bentobox.api.addons.GameModeAddon; |
28 | 32 | import world.bentobox.bentobox.api.user.User; |
29 | 33 | import world.bentobox.bentobox.database.objects.Island; |
30 | 34 | import world.bentobox.bentobox.hooks.ItemsAdderHook; |
| 35 | +import world.bentobox.bentobox.hooks.OraxenHook; |
31 | 36 | import world.bentobox.bentobox.managers.PlaceholdersManager; |
32 | 37 | import world.bentobox.bentobox.managers.RanksManager; |
33 | 38 | import world.bentobox.level.objects.IslandLevels; |
@@ -394,6 +399,30 @@ private Object getBlockIdentifier(@Nullable Block block) { |
394 | 399 | return Material.SPAWNER; // Return generic spawner material if state invalid |
395 | 400 | } |
396 | 401 |
|
| 402 | + // Check Oraxen custom blocks (noteblock/stringblock/chorusblock mechanics) |
| 403 | + if (BentoBox.getInstance().getHooks().getHook("Oraxen").isPresent()) { |
| 404 | + String oraxenId = OraxenHook.getOraxenBlockID(block.getLocation()); |
| 405 | + if (oraxenId != null) { |
| 406 | + return "oraxen:" + oraxenId; |
| 407 | + } |
| 408 | + } |
| 409 | + |
| 410 | + // Check Nexo custom blocks |
| 411 | + if (addon.isNexo()) { |
| 412 | + CustomBlockMechanic nexoMechanic = NexoBlocks.customBlockMechanic(block.getLocation()); |
| 413 | + if (nexoMechanic != null) { |
| 414 | + return "nexo:" + nexoMechanic.getItemID(); |
| 415 | + } |
| 416 | + } |
| 417 | + |
| 418 | + // Check ItemsAdder custom blocks |
| 419 | + if (addon.isItemsAdder()) { |
| 420 | + String iaId = ItemsAdderHook.getInCustomRegion(block.getLocation()); |
| 421 | + if (iaId != null) { |
| 422 | + return iaId; |
| 423 | + } |
| 424 | + } |
| 425 | + |
397 | 426 | // Fallback to the Material for regular blocks |
398 | 427 | return type; |
399 | 428 | } |
@@ -474,15 +503,31 @@ private Object getItemIdentifier(@Nullable ItemStack itemStack) { |
474 | 503 | } // End of Spawner handling |
475 | 504 |
|
476 | 505 | // 2. Handle potential custom items (e.g., ItemsAdder) |
477 | | - if (addon.isItemsAdder()) { |
478 | | - Optional<String> customId = ItemsAdderHook.getNamespacedId(itemStack); |
479 | | - if (customId.isPresent()) { |
480 | | - return customId.get(); // Return the String ID from ItemsAdder |
481 | | - } |
482 | | - } |
483 | | - |
484 | | - // 3. Fallback to Material for regular items that represent blocks |
485 | | - return type.isBlock() ? type : null; |
| 506 | + if (addon.isItemsAdder()) { |
| 507 | + Optional<String> customId = ItemsAdderHook.getNamespacedId(itemStack); |
| 508 | + if (customId.isPresent()) { |
| 509 | + return customId.get(); // Return the String ID from ItemsAdder |
| 510 | + } |
| 511 | + } |
| 512 | + |
| 513 | + // 3. Handle Oraxen custom items |
| 514 | + if (BentoBox.getInstance().getHooks().getHook("Oraxen").isPresent()) { |
| 515 | + Optional<String> oraxenId = OraxenHook.getNamespacedId(itemStack); |
| 516 | + if (oraxenId.isPresent()) { |
| 517 | + return "oraxen:" + oraxenId.get(); |
| 518 | + } |
| 519 | + } |
| 520 | + |
| 521 | + // 4. Handle Nexo custom items |
| 522 | + if (addon.isNexo()) { |
| 523 | + String nexoId = NexoItems.idFromItem(itemStack); |
| 524 | + if (nexoId != null) { |
| 525 | + return "nexo:" + nexoId; |
| 526 | + } |
| 527 | + } |
| 528 | + |
| 529 | + // 5. Fallback to Material for regular items that represent blocks |
| 530 | + return type.isBlock() ? type : null; |
486 | 531 | } |
487 | 532 |
|
488 | 533 | /** |
@@ -538,16 +583,14 @@ private Object getObjectFromConfigKey(String configKey) { |
538 | 583 | return material; |
539 | 584 | } |
540 | 585 |
|
541 | | - // Assume it's a custom String key (e.g., ItemsAdder) if not resolved yet |
542 | | - if (addon.isItemsAdder() && ItemsAdderHook.isInRegistry(configKey)) { // Use original case key for lookup? |
543 | | - return configKey; |
544 | | - } |
545 | | - |
546 | 586 | // Final check: maybe it's the generic "spawner" key from config? |
547 | | - if(lowerCaseKey.equals("spawner")) { |
| 587 | + if (lowerCaseKey.equals("spawner")) { |
548 | 588 | return Material.SPAWNER; |
549 | 589 | } |
550 | | - return null; |
| 590 | + |
| 591 | + // Return the key as-is for custom blocks (ItemsAdder, Oraxen, Nexo). |
| 592 | + // These are stored as String keys in mdCount/uwCount. |
| 593 | + return configKey; |
551 | 594 | } |
552 | 595 |
|
553 | 596 | /** |
|
0 commit comments