PikaMug / Quests

Easy-to-use, open-source plugin for the creation and execution of quests on Minecraft servers.
https://modrinth.com/plugin/quests.classic
MIT License
141 stars 104 forks source link

Error with items-to-enchant and item delivery with enchants #2178

Closed ghost closed 5 months ago

ghost commented 5 months ago

What is your Quests version / build number (do not say "latest")?

5.0.0-rc.4-b${env.BUILD_NUMBER} (manually build from github source code)

Describe the problem and how to replicate it.

Make a quest with a items-to-enchant stage followed by delivering this item to a npc stage (not required both stages have the same issue) Just a sidenote these quests were made using QuestsGUI not sure if that helps

Any console errors to share?

[07:19:26 ERROR]: [Quests] An error has occurred with Quests. Please report on Github with info below
[07:19:26 WARN]: [Quests] quest = custom230
[07:19:26 WARN]: [Quests] index = 0
[07:19:26 WARN]: [Quests] location = Location{world=CraftWorld{name=Spawn},x=-6.409359174839241,y=66.41999998688698,z=6.09499651127319,pitch=26.250088,yaw=-261.30243}
[07:19:26 WARN]: [Quests] locationsToReach = 0
[07:19:26 WARN]: [Quests] locationsReached = 1
[07:19:26 WARN]: [Quests] hasReached = 1
[07:19:26 WARN]: java.lang.StringIndexOutOfBoundsException: begin 27, end -1, length 43
[07:19:26 WARN]:        at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4606)
[07:19:26 WARN]:        at java.base/java.lang.String.substring(String.java:2709)
[07:19:26 WARN]:        at Quests-5.0.0-rc.4.jar//me.pikamug.quests.libs.localelib.LocaleManager.queryEnchantments(LocaleManager.java:464)
[07:19:26 WARN]:        at Quests-5.0.0-rc.4.jar//me.pikamug.quests.libs.localelib.LocaleManager.sendMessage(LocaleManager.java:168)
[07:19:26 WARN]:        at Quests-5.0.0-rc.4.jar//me.pikamug.quests.libs.localelib.LocaleManager.sendMessage(LocaleManager.java:132)
[07:19:26 WARN]:        at Quests-5.0.0-rc.4.jar//me.pikamug.quests.player.BukkitQuester.showCurrentObjectives(BukkitQuester.java:1731)
[07:19:26 WARN]:        at Quests-5.0.0-rc.4.jar//me.pikamug.quests.quests.BukkitQuest.setStage(BukkitQuest.java:363)
[07:19:26 WARN]:        at Quests-5.0.0-rc.4.jar//me.pikamug.quests.quests.BukkitQuest.doNextStage(BukkitQuest.java:304)
[07:19:26 WARN]:        at Quests-5.0.0-rc.4.jar//me.pikamug.quests.quests.BukkitQuest.nextStage(BukkitQuest.java:283)
[07:19:26 WARN]:        at Quests-5.0.0-rc.4.jar//me.pikamug.quests.player.BukkitQuester.finishObjective(BukkitQuester.java:3777)
[07:19:26 WARN]:        at Quests-5.0.0-rc.4.jar//me.pikamug.quests.player.BukkitQuester.reachLocation(BukkitQuester.java:3191)
[07:19:26 WARN]:        at Quests-5.0.0-rc.4.jar//me.pikamug.quests.listeners.BukkitPlayerListener.lambda$playerMove$10(BukkitPlayerListener.java:998)
[07:19:26 WARN]:        at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftTask.run(CraftTask.java:101)
[07:19:26 WARN]:        at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480)
[07:19:26 WARN]:        at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1641)
[07:19:26 WARN]:        at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:449)
[07:19:26 WARN]:        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1520)
[07:19:26 WARN]:        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1216)
[07:19:26 WARN]:        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:323)
[07:19:26 WARN]:        at java.base/java.lang.Thread.run(Thread.java:840)

If applicable, can you provide an example quest from quests.yml?

This is a stripped quest format to instantly get the error so doesn't match some details from the console error above.  
  '000002':
    name: Error
    ask-message: Challenge objectives!
    finish-message: Well done!
    stages:
      ordered:
        '1':
          items-to-enchant:
          - ==: org.bukkit.inventory.ItemStack
            v: 3700
            type: NETHERITE_SWORD
            meta:
              ==: ItemMeta
              meta-type: UNSPECIFIC
              enchants:
                VANISHING_CURSE: 1
        '2':
          items-to-deliver:
          - ==: org.bukkit.inventory.ItemStack
            v: 3700
            type: NETHERITE_SWORD
            meta:
              ==: ItemMeta
              meta-type: UNSPECIFIC
              enchants:
                VANISHING_CURSE: 1
              repair-cost: 1
          npc-delivery-uuids:
          - ca6e5f24-0ec3-4878-a2f8-a0bf077a7036
          delivery-messages:
          - Thank you. Only <amount> more to go!
ghost commented 5 months ago

Seems it's related to one of the dependencies: https://github.com/PikaMug/LocaleLib/blob/master/src/main/java/me/pikamug/localelib/LocaleManager.java#L464 the second one should be str.indexOf("]")

Hope that helps Graycat

PikaMug commented 5 months ago

Seems it's related to one of the dependencies: https://github.com/PikaMug/LocaleLib/blob/master/src/main/java/me/pikamug/localelib/LocaleManager.java#L464 the second one should be str.indexOf("]")

Hope that helps Graycat

That line is referring to Minecraft strings as they appear within the internal en_us.json file, i.e. "enchantment.minecraft.fortune": "Fortune", where the last character is , not ].

I'll find time to test this, but based on the error it's possible I may need the entire, non-stripped quest to replicate.

ghost commented 5 months ago

Seems it's related to one of the dependencies: https://github.com/PikaMug/LocaleLib/blob/master/src/main/java/me/pikamug/localelib/LocaleManager.java#L464 the second one should be str.indexOf("]") Hope that helps Graycat

That line is referring to Minecraft strings as they appear within the internal en_us.json file, i.e. "enchantment.minecraft.fortune": "Fortune", where the last character is , not ].

I'll find time to test this, but based on the error it's possible I may need the entire, non-stripped quest to replicate.

Let's say that I added some debug messages and it doesn't contain a , anymore I know the enchantments have been changed in one of the 1.20.X version this may be why but when I recoded the plugin to use ] it all worked without issues.

and the quest provided is enough to recreate it.

PikaMug commented 5 months ago

Let's say that I added some debug messages

Did you actually, or is this theoretical? If you've done so, let me know which version of 1.20 has changed the strings (or at least which you tested on - it's either 1.20.3 or 1.20.4 based on error). Otherwise, even if ] happened to work, it could be masking an underlying issue.

and the quest provided is enough to recreate it.

The index numbers will almost certainly vary, but as long as an out of bounds exception is thrown that's fine.

ghost commented 5 months ago

Let's say that I added some debug messages

Did you actually, or is this theoretical? If you've done so, let me know which version of 1.20 has changed the strings (or at least which you tested on - it's either 1.20.3 or 1.20.4 based on error). Otherwise, even if ] happened to work, it could be masking an underlying issue.

and the quest provided is enough to recreate it.

The index numbers will almost certainly vary, but as long as an out of bounds exception is thrown that's fine.

Yes I did test it the server is currently running find with that modification running and is going smooth. I'm not 100% sure which mc version is the cause though as I updated from 1.20.2 to 1.20.4

PikaMug commented 5 months ago

I was incorrect in determining that line referred to the internal string. It was actually referring to a String representation of the Enchantment, which at some point became:

Enchantment[minecraft:vanishing_curse]

Previously, it would have appeared as such (as tested on 1.17.1):

Enchantment[minecraft:vanishing_curse, VANISHING_CURSE]

Unfortunately, replacing , with ] passes on current version, but would break older ones. I hope to have a solution ready soon.

PikaMug commented 5 months ago

https://ci.codemc.io/job/PikaMug/job/Quests/447/