|
4 | 4 |
|
5 | 5 | import java.util.Collection; |
6 | 6 | import java.util.EnumSet; |
| 7 | +import java.util.HashMap; |
| 8 | +import java.util.Map; |
7 | 9 | import java.util.Optional; |
8 | 10 | import java.util.Set; |
9 | 11 | import java.util.UUID; |
|
17 | 19 | import org.bukkit.OfflinePlayer; |
18 | 20 | import org.bukkit.Particle; |
19 | 21 | import org.bukkit.World; |
20 | | -import org.bukkit.Registry.SimpleRegistry; |
21 | 22 | import org.bukkit.block.Block; |
22 | 23 | import org.bukkit.block.data.BlockData; |
23 | 24 | import org.bukkit.craftbukkit.v1_20_R4.CraftParticle; |
24 | | -import org.bukkit.craftbukkit.v1_20_R4.util.CraftNamespacedKey; |
25 | 25 | import org.bukkit.enchantments.Enchantment; |
26 | 26 | import org.bukkit.entity.EntityType; |
27 | 27 | import org.bukkit.entity.Player; |
28 | 28 | import org.bukkit.inventory.ItemStack; |
29 | 29 | import org.bukkit.inventory.Recipe; |
30 | 30 | import org.bukkit.loot.LootTable; |
31 | | -import org.bukkit.potion.PotionEffectType; |
32 | 31 | import org.bukkit.scoreboard.Objective; |
33 | 32 | import org.bukkit.scoreboard.Team; |
34 | 33 | import org.mockito.MockedStatic; |
|
67 | 66 | import net.minecraft.core.HolderLookup; |
68 | 67 | import net.minecraft.core.HolderOwner; |
69 | 68 | import net.minecraft.core.Registry; |
| 69 | +import net.minecraft.core.particles.ParticleOptions; |
70 | 70 | import net.minecraft.core.particles.ParticleType; |
71 | 71 | import net.minecraft.core.registries.BuiltInRegistries; |
72 | 72 | import net.minecraft.core.registries.Registries; |
@@ -542,25 +542,253 @@ public OfflinePlayer getOfflinePlayer(CommandContext cmdCtx, String key) throws |
542 | 542 |
|
543 | 543 | @Override |
544 | 544 | public ParticleData<?> getParticle(CommandContext cmdCtx, String key) { |
545 | | - |
546 | 545 | final ParticleData<?> result; |
547 | | - |
548 | 546 | try (MockedStatic<CraftParticle> craftParticle = Mockito.mockStatic(CraftParticle.class)) { |
549 | 547 | craftParticle.when(() -> CraftParticle.minecraftToBukkit(any())) |
550 | 548 | .thenAnswer(args -> { |
551 | 549 | ParticleType minecraft = args.getArgument(0, ParticleType.class); |
552 | 550 |
|
553 | 551 |
|
554 | 552 | Registry<ParticleType<?>> registry = BuiltInRegistries.PARTICLE_TYPE; //CraftRegistry.getMinecraftRegistry(Registries.PARTICLE_TYPE); |
555 | | - org.bukkit.Registry.PARTICLE_TYPE |
556 | | - // new SimpleRegistry(Particle.class, (par) -> par.register); |
| 553 | +// org.bukkit.Registry.PARTICLE_TYPE |
| 554 | +// // new SimpleRegistry(Particle.class, (par) -> par.register); |
| 555 | +// |
| 556 | + // We can't actually implement this until we have MockBukkit |
| 557 | + // linked against 1.20.5, which is super annoying... |
| 558 | + |
| 559 | + // Do we wait for MockBukkit to update its paper dependencies, |
| 560 | + // or do we just fork MockBukkit at this point? |
| 561 | +// |
| 562 | +// Particle bukkit = (Particle) org.bukkit.Registry.PARTICLE_TYPE.get(CraftNamespacedKey |
| 563 | +// .fromMinecraft(((ResourceKey) registry.getResourceKey(minecraft).orElseThrow()).location())); |
| 564 | + |
| 565 | + |
| 566 | + |
| 567 | + return Particle.CRIT; |
557 | 568 |
|
558 | | - Particle bukkit = (Particle) org.bukkit.Registry.PARTICLE_TYPE.get(CraftNamespacedKey |
559 | | - .fromMinecraft(((ResourceKey) registry.getResourceKey(minecraft).orElseThrow()).location())); |
560 | | - return bukkit; |
| 569 | + // return bukkit; |
561 | 570 | }); |
562 | 571 |
|
563 | | - result = baseNMS.getParticle(cmdCtx, key); |
| 572 | + Map<String, Particle> map = new HashMap<>(); |
| 573 | +// map.put("poof", Particle.POOF); |
| 574 | +// map.put("explosion", Particle.EXPLOSION); |
| 575 | +// map.put("explosion_emitter", Particle.EXPLOSION_EMITTER); |
| 576 | +// map.put("firework", Particle.FIREWORK); |
| 577 | +// map.put("bubble", Particle.BUBBLE); |
| 578 | +// map.put("splash", Particle.SPLASH); |
| 579 | +// map.put("fishing", Particle.FISHING); |
| 580 | +// map.put("underwater", Particle.UNDERWATER); |
| 581 | +// map.put("crit", Particle.CRIT); |
| 582 | +// map.put("enchanted_hit", Particle.ENCHANTED_HIT); |
| 583 | +// map.put("smoke", Particle.SMOKE); |
| 584 | +// map.put("large_smoke", Particle.LARGE_SMOKE); |
| 585 | +// map.put("effect", Particle.EFFECT); |
| 586 | +// map.put("instant_effect", Particle.INSTANT_EFFECT); |
| 587 | +// map.put("entity_effect", Particle.ENTITY_EFFECT); |
| 588 | +// map.put("witch", Particle.WITCH); |
| 589 | +// map.put("dripping_water", Particle.DRIPPING_WATER); |
| 590 | +// map.put("dripping_lava", Particle.DRIPPING_LAVA); |
| 591 | +// map.put("angry_villager", Particle.ANGRY_VILLAGER); |
| 592 | +// map.put("happy_villager", Particle.HAPPY_VILLAGER); |
| 593 | +// map.put("mycelium", Particle.MYCELIUM); |
| 594 | +// map.put("note", Particle.NOTE); |
| 595 | +// map.put("portal", Particle.PORTAL); |
| 596 | +// map.put("enchant", Particle.ENCHANT); |
| 597 | +// map.put("flame", Particle.FLAME); |
| 598 | +// map.put("lava", Particle.LAVA); |
| 599 | +// map.put("cloud", Particle.CLOUD); |
| 600 | +// map.put("dust", Particle.DUST); |
| 601 | +// map.put("item_snowball", Particle.ITEM_SNOWBALL); |
| 602 | +// map.put("item_slime", Particle.ITEM_SLIME); |
| 603 | +// map.put("heart", Particle.HEART); |
| 604 | +// map.put("item", Particle.ITEM); |
| 605 | +// map.put("block", Particle.BLOCK); |
| 606 | +// map.put("rain", Particle.RAIN); |
| 607 | +// map.put("elder_guardian", Particle.ELDER_GUARDIAN); |
| 608 | +// map.put("dragon_breath", Particle.DRAGON_BREATH); |
| 609 | +// map.put("end_rod", Particle.END_ROD); |
| 610 | +// map.put("damage_indicator", Particle.DAMAGE_INDICATOR); |
| 611 | +// map.put("sweep_attack", Particle.SWEEP_ATTACK); |
| 612 | +// map.put("falling_dust", Particle.FALLING_DUST); |
| 613 | +// map.put("totem_of_undying", Particle.TOTEM_OF_UNDYING); |
| 614 | +// map.put("spit", Particle.SPIT); |
| 615 | +// map.put("squid_ink", Particle.SQUID_INK); |
| 616 | +// map.put("bubble_pop", Particle.BUBBLE_POP); |
| 617 | +// map.put("current_down", Particle.CURRENT_DOWN); |
| 618 | +// map.put("bubble_column_up", Particle.BUBBLE_COLUMN_UP); |
| 619 | +// map.put("nautilus", Particle.NAUTILUS); |
| 620 | +// map.put("dolphin", Particle.DOLPHIN); |
| 621 | +// map.put("sneeze", Particle.SNEEZE); |
| 622 | +// map.put("campfire_cosy_smoke", Particle.CAMPFIRE_COSY_SMOKE); |
| 623 | +// map.put("campfire_signal_smoke", Particle.CAMPFIRE_SIGNAL_SMOKE); |
| 624 | +// map.put("composter", Particle.COMPOSTER); |
| 625 | +// map.put("flash", Particle.FLASH); |
| 626 | +// map.put("falling_lava", Particle.FALLING_LAVA); |
| 627 | +// map.put("landing_lava", Particle.LANDING_LAVA); |
| 628 | +// map.put("falling_water", Particle.FALLING_WATER); |
| 629 | +// map.put("dripping_honey", Particle.DRIPPING_HONEY); |
| 630 | +// map.put("falling_honey", Particle.FALLING_HONEY); |
| 631 | +// map.put("landing_honey", Particle.LANDING_HONEY); |
| 632 | +// map.put("falling_nectar", Particle.FALLING_NECTAR); |
| 633 | +// map.put("soul_fire_flame", Particle.SOUL_FIRE_FLAME); |
| 634 | +// map.put("ash", Particle.ASH); |
| 635 | +// map.put("crimson_spore", Particle.CRIMSON_SPORE); |
| 636 | +// map.put("warped_spore", Particle.WARPED_SPORE); |
| 637 | +// map.put("soul", Particle.SOUL); |
| 638 | +// map.put("dripping_obsidian_tear", Particle.DRIPPING_OBSIDIAN_TEAR); |
| 639 | +// map.put("falling_obsidian_tear", Particle.FALLING_OBSIDIAN_TEAR); |
| 640 | +// map.put("landing_obsidian_tear", Particle.LANDING_OBSIDIAN_TEAR); |
| 641 | +// map.put("reverse_portal", Particle.REVERSE_PORTAL); |
| 642 | +// map.put("white_ash", Particle.WHITE_ASH); |
| 643 | +// map.put("dust_color_transition", Particle.DUST_COLOR_TRANSITION); |
| 644 | +// map.put("vibration", Particle.VIBRATION); |
| 645 | +// map.put("falling_spore_blossom", Particle.FALLING_SPORE_BLOSSOM); |
| 646 | +// map.put("spore_blossom_air", Particle.SPORE_BLOSSOM_AIR); |
| 647 | +// map.put("small_flame", Particle.SMALL_FLAME); |
| 648 | +// map.put("snowflake", Particle.SNOWFLAKE); |
| 649 | +// map.put("dripping_dripstone_lava", Particle.DRIPPING_DRIPSTONE_LAVA); |
| 650 | +// map.put("falling_dripstone_lava", Particle.FALLING_DRIPSTONE_LAVA); |
| 651 | +// map.put("dripping_dripstone_water", Particle.DRIPPING_DRIPSTONE_WATER); |
| 652 | +// map.put("falling_dripstone_water", Particle.FALLING_DRIPSTONE_WATER); |
| 653 | +// map.put("glow_squid_ink", Particle.GLOW_SQUID_INK); |
| 654 | +// map.put("glow", Particle.GLOW); |
| 655 | +// map.put("wax_on", Particle.WAX_ON); |
| 656 | +// map.put("wax_off", Particle.WAX_OFF); |
| 657 | +// map.put("electric_spark", Particle.ELECTRIC_SPARK); |
| 658 | +// map.put("scrape", Particle.SCRAPE); |
| 659 | +// map.put("sonic_boom", Particle.SONIC_BOOM); |
| 660 | +// map.put("sculk_soul", Particle.SCULK_SOUL); |
| 661 | +// map.put("sculk_charge", Particle.SCULK_CHARGE); |
| 662 | +// map.put("sculk_charge_pop", Particle.SCULK_CHARGE_POP); |
| 663 | +// map.put("shriek", Particle.SHRIEK); |
| 664 | +// map.put("cherry_leaves", Particle.CHERRY_LEAVES); |
| 665 | +// map.put("egg_crack", Particle.EGG_CRACK); |
| 666 | +// map.put("dust_plume", Particle.DUST_PLUME); |
| 667 | +// map.put("white_smoke", Particle.WHITE_SMOKE); |
| 668 | +// map.put("gust", Particle.GUST); |
| 669 | +// map.put("small_gust", Particle.SMALL_GUST); |
| 670 | +// map.put("gust_emitter_large", Particle.GUST_EMITTER_LARGE); |
| 671 | +// map.put("gust_emitter_small", Particle.GUST_EMITTER_SMALL); |
| 672 | +// map.put("trial_spawner_detection", Particle.TRIAL_SPAWNER_DETECTION); |
| 673 | +// map.put("trial_spawner_detection_ominous", Particle.TRIAL_SPAWNER_DETECTION_OMINOUS); |
| 674 | +// map.put("vault_connection", Particle.VAULT_CONNECTION); |
| 675 | +// map.put("infested", Particle.INFESTED); |
| 676 | +// map.put("item_cobweb", Particle.ITEM_COBWEB); |
| 677 | +// map.put("dust_pillar", Particle.DUST_PILLAR); |
| 678 | +// map.put("ominous_spawning", Particle.OMINOUS_SPAWNING); |
| 679 | +// map.put("raid_omen", Particle.RAID_OMEN); |
| 680 | +// map.put("trial_omen", Particle.TRIAL_OMEN); |
| 681 | +// map.put("block_marker", Particle.BLOCK_MARKER); |
| 682 | + |
| 683 | + map.put("poof", Particle.valueOf("EXPLOSION_NORMAL")); |
| 684 | + map.put("explosion", Particle.valueOf("EXPLOSION_LARGE")); |
| 685 | + map.put("explosion_emitter", Particle.valueOf("EXPLOSION_HUGE")); |
| 686 | + map.put("firework", Particle.valueOf("FIREWORKS_SPARK")); |
| 687 | + map.put("bubble", Particle.valueOf("WATER_BUBBLE")); |
| 688 | + map.put("splash", Particle.valueOf("WATER_SPLASH")); |
| 689 | + map.put("fishing", Particle.valueOf("WATER_WAKE")); |
| 690 | + map.put("underwater", Particle.valueOf("SUSPENDED")); |
| 691 | + // map.put("???", Particle.valueOf("SUSPENDED_DEPTH")); |
| 692 | + map.put("crit", Particle.valueOf("CRIT")); |
| 693 | + map.put("enchanted_hit", Particle.valueOf("CRIT_MAGIC")); |
| 694 | + map.put("smoke", Particle.valueOf("SMOKE_NORMAL")); |
| 695 | + map.put("large_smoke", Particle.valueOf("SMOKE_LARGE")); |
| 696 | + map.put("effect", Particle.valueOf("SPELL")); |
| 697 | + map.put("instant_effect", Particle.valueOf("SPELL_INSTANT")); |
| 698 | + map.put("entity_effect", Particle.valueOf("SPELL_MOB")); |
| 699 | + // map.put("???", Particle.valueOf("SPELL_MOB_AMBIENT")); |
| 700 | + map.put("witch", Particle.valueOf("SPELL_WITCH")); |
| 701 | + map.put("dripping_water", Particle.valueOf("DRIP_WATER")); |
| 702 | + map.put("dripping_lava", Particle.valueOf("DRIP_LAVA")); |
| 703 | + map.put("angry_villager", Particle.valueOf("VILLAGER_ANGRY")); |
| 704 | + map.put("happy_villager", Particle.valueOf("VILLAGER_HAPPY")); |
| 705 | + map.put("mycelium", Particle.valueOf("TOWN_AURA")); |
| 706 | + map.put("note", Particle.valueOf("NOTE")); |
| 707 | + map.put("portal", Particle.valueOf("PORTAL")); |
| 708 | + map.put("enchant", Particle.valueOf("ENCHANTMENT_TABLE")); |
| 709 | + map.put("flame", Particle.valueOf("FLAME")); |
| 710 | + map.put("lava", Particle.valueOf("LAVA")); |
| 711 | + map.put("cloud", Particle.valueOf("CLOUD")); |
| 712 | + map.put("dust", Particle.valueOf("REDSTONE")); |
| 713 | + map.put("item_snowball", Particle.valueOf("SNOWBALL")); |
| 714 | + map.put("item_slime", Particle.valueOf("SNOW_SHOVEL")); |
| 715 | + // map.put("???", Particle.valueOf("SLIME")); |
| 716 | + map.put("heart", Particle.valueOf("HEART")); |
| 717 | + map.put("item", Particle.valueOf("ITEM_CRACK")); |
| 718 | + map.put("block", Particle.valueOf("BLOCK_CRACK")); |
| 719 | + map.put("rain", Particle.valueOf("BLOCK_DUST")); |
| 720 | + // map.put("???", Particle.valueOf("WATER_DROP")); |
| 721 | + map.put("elder_guardian", Particle.valueOf("MOB_APPEARANCE")); |
| 722 | + map.put("dragon_breath", Particle.valueOf("DRAGON_BREATH")); |
| 723 | + map.put("end_rod", Particle.valueOf("END_ROD")); |
| 724 | + map.put("damage_indicator", Particle.valueOf("DAMAGE_INDICATOR")); |
| 725 | + map.put("sweep_attack", Particle.valueOf("SWEEP_ATTACK")); |
| 726 | + map.put("falling_dust", Particle.valueOf("FALLING_DUST")); |
| 727 | + map.put("totem_of_undying", Particle.valueOf("TOTEM")); |
| 728 | + map.put("spit", Particle.valueOf("SPIT")); |
| 729 | + map.put("squid_ink", Particle.valueOf("SQUID_INK")); |
| 730 | + map.put("bubble_pop", Particle.valueOf("BUBBLE_POP")); |
| 731 | + map.put("current_down", Particle.valueOf("CURRENT_DOWN")); |
| 732 | + map.put("bubble_column_up", Particle.valueOf("BUBBLE_COLUMN_UP")); |
| 733 | + map.put("nautilus", Particle.valueOf("NAUTILUS")); |
| 734 | + map.put("dolphin", Particle.valueOf("DOLPHIN")); |
| 735 | + map.put("sneeze", Particle.valueOf("SNEEZE")); |
| 736 | + map.put("campfire_cosy_smoke", Particle.valueOf("CAMPFIRE_COSY_SMOKE")); |
| 737 | + map.put("campfire_signal_smoke", Particle.valueOf("CAMPFIRE_SIGNAL_SMOKE")); |
| 738 | + map.put("composter", Particle.valueOf("COMPOSTER")); |
| 739 | + map.put("flash", Particle.valueOf("FLASH")); |
| 740 | + map.put("falling_lava", Particle.valueOf("FALLING_LAVA")); |
| 741 | + map.put("landing_lava", Particle.valueOf("LANDING_LAVA")); |
| 742 | + map.put("falling_water", Particle.valueOf("FALLING_WATER")); |
| 743 | + map.put("dripping_honey", Particle.valueOf("DRIPPING_HONEY")); |
| 744 | + map.put("falling_honey", Particle.valueOf("FALLING_HONEY")); |
| 745 | + map.put("landing_honey", Particle.valueOf("LANDING_HONEY")); |
| 746 | + map.put("falling_nectar", Particle.valueOf("FALLING_NECTAR")); |
| 747 | + map.put("soul_fire_flame", Particle.valueOf("SOUL_FIRE_FLAME")); |
| 748 | + map.put("ash", Particle.valueOf("ASH")); |
| 749 | + map.put("crimson_spore", Particle.valueOf("CRIMSON_SPORE")); |
| 750 | + map.put("warped_spore", Particle.valueOf("WARPED_SPORE")); |
| 751 | + map.put("soul", Particle.valueOf("SOUL")); |
| 752 | + map.put("dripping_obsidian_tear", Particle.valueOf("DRIPPING_OBSIDIAN_TEAR")); |
| 753 | + map.put("falling_obsidian_tear", Particle.valueOf("FALLING_OBSIDIAN_TEAR")); |
| 754 | + map.put("landing_obsidian_tear", Particle.valueOf("LANDING_OBSIDIAN_TEAR")); |
| 755 | + map.put("reverse_portal", Particle.valueOf("REVERSE_PORTAL")); |
| 756 | + map.put("white_ash", Particle.valueOf("WHITE_ASH")); |
| 757 | + map.put("dust_color_transition", Particle.valueOf("DUST_COLOR_TRANSITION")); |
| 758 | + map.put("vibration", Particle.valueOf("VIBRATION")); |
| 759 | + map.put("falling_spore_blossom", Particle.valueOf("FALLING_SPORE_BLOSSOM")); |
| 760 | + map.put("spore_blossom_air", Particle.valueOf("SPORE_BLOSSOM_AIR")); |
| 761 | + map.put("small_flame", Particle.valueOf("SMALL_FLAME")); |
| 762 | + map.put("snowflake", Particle.valueOf("SNOWFLAKE")); |
| 763 | + map.put("dripping_dripstone_lava", Particle.valueOf("DRIPPING_DRIPSTONE_LAVA")); |
| 764 | + map.put("falling_dripstone_lava", Particle.valueOf("FALLING_DRIPSTONE_LAVA")); |
| 765 | + map.put("dripping_dripstone_water", Particle.valueOf("DRIPPING_DRIPSTONE_WATER")); |
| 766 | + map.put("falling_dripstone_water", Particle.valueOf("FALLING_DRIPSTONE_WATER")); |
| 767 | + map.put("glow_squid_ink", Particle.valueOf("GLOW_SQUID_INK")); |
| 768 | + map.put("glow", Particle.valueOf("GLOW")); |
| 769 | + map.put("wax_on", Particle.valueOf("WAX_ON")); |
| 770 | + map.put("wax_off", Particle.valueOf("WAX_OFF")); |
| 771 | + map.put("electric_spark", Particle.valueOf("ELECTRIC_SPARK")); |
| 772 | + map.put("scrape", Particle.valueOf("SCRAPE")); |
| 773 | + map.put("sonic_boom", Particle.valueOf("SONIC_BOOM")); |
| 774 | + map.put("sculk_soul", Particle.valueOf("SCULK_SOUL")); |
| 775 | + map.put("sculk_charge", Particle.valueOf("SCULK_CHARGE")); |
| 776 | + map.put("sculk_charge_pop", Particle.valueOf("SCULK_CHARGE_POP")); |
| 777 | + map.put("shriek", Particle.valueOf("SHRIEK")); |
| 778 | + map.put("cherry_leaves", Particle.valueOf("CHERRY_LEAVES")); |
| 779 | + map.put("egg_crack", Particle.valueOf("EGG_CRACK")); |
| 780 | + map.put("dust_plume", Particle.valueOf("BLOCK_MARKER")); |
| 781 | + |
| 782 | + Registry<ParticleType<?>> registry = BuiltInRegistries.PARTICLE_TYPE; //CraftRegistry.getMinecraftRegistry(Registries.PARTICLE_TYPE); |
| 783 | + |
| 784 | + final ParticleOptions particleOptions = ParticleArgument.getParticle(cmdCtx, key); |
| 785 | + |
| 786 | +// registry.getResourceKey(particleOptions.getType()).get(). |
| 787 | + // registry.asLookup(). |
| 788 | + |
| 789 | + String nmsKey = registry.getResourceKey(particleOptions.getType()).get().location().getPath(); |
| 790 | + System.out.println("Trying to find " + nmsKey + " but got " + map.get(nmsKey)); |
| 791 | + result = new ParticleData(map.get(nmsKey), null); //baseNMS.getParticle(cmdCtx, key); |
564 | 792 | } |
565 | 793 |
|
566 | 794 | return result; |
|
0 commit comments