Skip to content

Conversation

@AxDevv
Copy link

@AxDevv AxDevv commented Nov 6, 2025

📋 Description

Added regex pattern support for world names in NPCs and holograms.
This allows creating a single NPC/hologram that will automatically appear in multiple worlds matching a pattern (e.g., instance_* for instance_1, instance_2, etc.).

✅ Checklist

  • My code follows the project's coding style and guidelines
  • I have tested my changes locally and they work as expected
  • I have added necessary documentation (if applicable)
  • I have linked related issues using Fixes #issue_number or Closes #issue_number
  • I have rebased/merged with the latest main branch

🔍 Changes

Please provide a brief summary of the changes made in this PR.

FancyNPCs:

  • Added regex pattern support for the world field in NPC configuration
  • Automatically detects patterns (*, ?, [, {)
  • Creates a separate NPC per matching world with unique ID (npcId_worldName)
  • Preserves all properties (skin, equipment, actions, attributes) across instances

FancyHolograms:

  • Added worldPattern field to HologramData
  • Implemented matchesWorld() method for dynamic world validation
  • Pattern is saved/loaded in configuration
  • Hologram automatically displays in all matching worlds

Modified files:

  • plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/NpcManagerImpl.java
  • plugins/fancyholograms-v2/api/src/main/java/de/oliver/fancyholograms/api/data/HologramData.java
  • plugins/fancyholograms-v2/api/src/main/java/de/oliver/fancyholograms/api/hologram/Hologram.java
  • plugins/fancyholograms-v2/src/main/java/de/oliver/fancyholograms/hologram/version/HologramImpl.java

🧪 How to Test

Please describe how to manually test the changes made in this PR.

For NPCs:

  1. Create multiple worlds with a common pattern (e.g., instance_1, instance_2, instance_3)
  2. In npcs.yml, configure an NPC with location.world: "instance_*"
  3. Reload the plugin with /npc reload
  4. Verify the NPC appears in all instance_* worlds at the same coordinates
  5. Check that each NPC has a unique ID in logs/console

For Holograms:

  1. Create multiple worlds with a common pattern
  2. In holograms.yml, configure a hologram with location.world: "instance_*"
  3. Reload the plugin
  4. Teleport to each instance_* world and verify the hologram appears
  5. Verify the hologram doesn't appear in worlds that don't match the pattern

Supported patterns:

  • instance_* → matches instance_1, instance_2, etc.
  • world_? → matches world_1, world_a, etc. (single character)
  • lobby* → matches lobby, lobby1, lobby_pvp, etc.

@Grabsky
Copy link
Contributor

Grabsky commented Nov 25, 2025

Could you please explain why this is needed and who is going to benefit from these changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants