TeamVK / PAPI-Enchantment

0 stars 0 forks source link

[Bug] Placeholder Parsing #2

Open KhrysAK47 opened 2 months ago

KhrysAK47 commented 2 months ago

If you hold a Nether Star, and do /papi parse me %enchantment_<any enchant>_level%

It will display this error:

[09:44:56 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'papi' in plugin PlaceholderAPI v2.11.2
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R3.CraftServer.dispatchCommand(CraftServer.java:999) ~[paper-1.20.4.jar:git-Paper-435]
        at org.bukkit.craftbukkit.v1_20_R3.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.20.4.jar:git-Paper-435]
        at com.mojang.brigadier.context.ContextChain.runExecutable(ContextChain.java:73) ~[brigadier-1.2.9.jar:?]
        at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:32) ~[paper-1.20.4.jar:git-Paper-435]
        at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:19) ~[paper-1.20.4.jar:git-Paper-435]
        at net.minecraft.commands.execution.UnboundEntryAction.lambda$bind$0(UnboundEntryAction.java:8) ~[paper-1.20.4.jar:git-Paper-435]
        at net.minecraft.commands.execution.CommandQueueEntry.a(CommandQueueEntry.java:5) ~[paper-1.20.4.jar:git-Paper-435]
        at net.minecraft.commands.execution.ExecutionContext.runCommandQueue(ExecutionContext.java:101) ~[paper-1.20.4.jar:git-Paper-435]
        at net.minecraft.commands.Commands.executeCommandInContext(Commands.java:434) ~[?:?]
        at net.minecraft.commands.Commands.performCommand(Commands.java:336) ~[?:?]
        at net.minecraft.commands.Commands.performCommand(Commands.java:323) ~[?:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2230) ~[?:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$14(ServerGamePacketListenerImpl.java:2190) ~[?:?]
        at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
        at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) ~[?:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.20.4.jar:git-Paper-435]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1455) ~[paper-1.20.4.jar:git-Paper-435]
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:194) ~[paper-1.20.4.jar:git-Paper-435]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1432) ~[paper-1.20.4.jar:git-Paper-435]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1355) ~[paper-1.20.4.jar:git-Paper-435]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
        at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1333) ~[paper-1.20.4.jar:git-Paper-435]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1222) ~[paper-1.20.4.jar:git-Paper-435]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[paper-1.20.4.jar:git-Paper-435]
        at java.lang.Thread.run(Unknown Source) ~[?:?]
Caused by: java.lang.UnsupportedOperationException
        at com.google.common.collect.ImmutableCollection.removeIf(ImmutableCollection.java:324) ~[guava-32.1.2-jre.jar:?]
        at com.vk2gpz.papi.enchantment.i.I.W.getEnchantments(W.java:697) ~[?:?]
        at com.vk2gpz.papi.enchantment.EnchantmentExpansion.onRequest(EnchantmentExpansion.java:73) ~[?:?]
        at me.clip.placeholderapi.replacer.CharsReplacer.apply(CharsReplacer.java:119) ~[PlaceholderAPI.jar:?]
        at me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(PlaceholderAPI.java:71) ~[PlaceholderAPI.jar:?]
        at me.clip.placeholderapi.commands.impl.local.CommandParse.evaluateParseSingular(CommandParse.java:118) ~[PlaceholderAPI.jar:?]
        at me.clip.placeholderapi.commands.impl.local.CommandParse.evaluate(CommandParse.java:58) ~[PlaceholderAPI.jar:?]
        at me.clip.placeholderapi.commands.PlaceholderCommandRouter.onCommand(PlaceholderCommandRouter.java:114) ~[PlaceholderAPI.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        ... 29 more
KhrysAK47 commented 2 months ago

It appears to break on every custom item or that has custom name with basic color codes.

vk2gpz commented 1 month ago

try the new version.

KhrysAK47 commented 1 month ago

try the new version.

The issue still persists. https://pastebin.com/LiEBtmfB

vk2gpz commented 1 month ago

it works on all our tester servers. Does this happen with other Java? (rather than guava you're using?)

KhrysAK47 commented 1 month ago

Yes, I tried 17 and 21 and both have same problem.

vk2gpz commented 1 month ago

we've tested on all LTS versions and they all worked fine and we could not replicate the error you presented.

vk2gpz commented 1 month ago

this is what we typically gets. The image shows the placeholder showing (returning) the string "1" in response to "/papi parse me %enchantment_FORTUNE_level%".

image
KhrysAK47 commented 1 month ago

Did you test with a renamed nether star? With it in hand or equipped? What Java are you running? I will perform one last test in the morning.

vk2gpz commented 1 month ago

Here is the same result with a nether_star with FORTUNE enchant on it and holding it in my hand:

image
vk2gpz commented 1 month ago

an immutable map object holding the enchantment information, is first copied into a mutable map object before executing the remove operation.

KhrysAK47 commented 1 month ago

Do you mind sharing your Java version? 17?

vk2gpz commented 1 month ago

we tested with 4 LTS versions java 8, java 11, java 17 and java 21.

KhrysAK47 commented 1 month ago

It didn't work for me on any of the testings. :( Even blank server

vk2gpz commented 1 month ago

where did you get your java?

KhrysAK47 commented 1 month ago

I use a hosting provider (SparkedHost) and they add it on server installation.

KhrysAK47 commented 1 month ago

Can I somehow further debug?

vk2gpz commented 1 month ago

well, your issue is coming from your java and cannot be debugged in the placeholder expansion. The expansion "copies" the map object which stores the enchantments into "mutable" object so that elements can be removed. However, your java implementation seems to be keep using immutable map object.

vk2gpz commented 1 month ago

we confirm the working with the official implementation of Java

vk2gpz commented 1 month ago

BTW, which version of PAPI-Enchantment are you using?

vk2gpz commented 1 month ago

It appears to break on every custom item or that has custom name with basic color codes.

BTW, this expansion is nothing to do with such custom name (including color codes). The exception you encounter is nothing to do with custom names.