We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在一个ConfiguredValue中获取Long值,可能会发生转换异常
配置内容
@HeaderComment("发送消息的冷却") public static final ConfiguredValue<Long> CHAT_COOLDOWN = ConfiguredValue.of(Long.class, 3000L);
配置文件内
# 发送消息的冷却 chat-cooldown: 3000
调用
@SuppressWarnings("ConstantConditions") long cd = Config.CHAT_COOLDOWN.getOrDefault();
报错
[14:24:37] [Async Chat Thread - #0/WARN]: java.lang.IllegalArgumentException: Cannot cast value to java.lang.Long [14:24:37] [Async Chat Thread - #0/WARN]: at online.flowerinsnow.chatrecord.shaded.cc.carm.lib.configuration.core.function.ConfigValueParser.lambda$castObject$5(ConfigValueParser.java:54) [14:24:37] [Async Chat Thread - #0/WARN]: at online.flowerinsnow.chatrecord.shaded.cc.carm.lib.configuration.core.function.ConfigValueParser.lambda$compose$1(ConfigValueParser.java:28) [14:24:37] [Async Chat Thread - #0/WARN]: at online.flowerinsnow.chatrecord.shaded.cc.carm.lib.configuration.core.value.type.ConfiguredValue.get(ConfiguredValue.java:60) [14:24:37] [Async Chat Thread - #0/WARN]: at online.flowerinsnow.chatrecord.shaded.cc.carm.lib.configuration.core.value.ConfigValue.getOptional(ConfigValue.java:91) [14:24:37] [Async Chat Thread - #0/WARN]: at online.flowerinsnow.chatrecord.shaded.cc.carm.lib.configuration.core.value.ConfigValue.getOrDefault(ConfigValue.java:77) [14:24:37] [Async Chat Thread - #0/WARN]: at online.flowerinsnow.chatrecord.listener.ChatListener.onChat(ChatListener.java:66) [14:24:37] [Async Chat Thread - #0/WARN]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [14:24:37] [Async Chat Thread - #0/WARN]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [14:24:37] [Async Chat Thread - #0/WARN]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [14:24:37] [Async Chat Thread - #0/WARN]: at java.lang.reflect.Method.invoke(Method.java:498) [14:24:37] [Async Chat Thread - #0/WARN]: at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) [14:24:37] [Async Chat Thread - #0/WARN]: at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:74) [14:24:37] [Async Chat Thread - #0/WARN]: at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) [14:24:37] [Async Chat Thread - #0/WARN]: at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:517) [14:24:37] [Async Chat Thread - #0/WARN]: at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:499) [14:24:37] [Async Chat Thread - #0/WARN]: at net.minecraft.server.v1_8_R3.PlayerConnection.chat(PlayerConnection.java:1111) [14:24:37] [Async Chat Thread - #0/WARN]: at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1026) [14:24:37] [Async Chat Thread - #0/WARN]: at net.minecraft.server.v1_8_R3.PacketPlayInChat$1.run(PacketPlayInChat.java:39) [14:24:37] [Async Chat Thread - #0/WARN]: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [14:24:37] [Async Chat Thread - #0/WARN]: at java.util.concurrent.FutureTask.run(FutureTask.java:266) [14:24:37] [Async Chat Thread - #0/WARN]: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [14:24:37] [Async Chat Thread - #0/WARN]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [14:24:37] [Async Chat Thread - #0/WARN]: at java.lang.Thread.run(Thread.java:853)
同样的环境下,将Long改为Integer即可避免报错 效果:我也不知道为什么,该异常抛出后,当前线程不会死亡,可以继续往下跑,但获取到的内容始终是默认值(例如3000L) 该异常不是偶然,是必定异常
Long
Integer
openjdk version "1.8.0_312" paper 1.8.8 445 Ubuntu 22.04.1 LTS
openjdk version "1.8.0_312"
paper 1.8.8 445
Ubuntu 22.04.1 LTS
The text was updated successfully, but these errors were encountered:
补充:环境依赖是cc.carm.lib:mineconfiguration-bukkit:2.1.0
cc.carm.lib:mineconfiguration-bukkit:2.1.0
Sorry, something went wrong.
这个问题我也发现很久了,但是一直以来没有思路修复,我再想想如何解决吧,也希望您能帮我看看。
好
请将本议题移向父项目EasyConfiguration。
6f97166
CarmJos
flowerinsnowdh
No branches or pull requests
问题简述
在一个ConfiguredValue中获取Long值,可能会发生转换异常
问题来源
配置内容
配置文件内
调用
报错
同样的环境下,将
Long
改为Integer
即可避免报错效果:我也不知道为什么,该异常抛出后,当前线程不会死亡,可以继续往下跑,但获取到的内容始终是默认值(例如3000L)
该异常不是偶然,是必定异常
环境
openjdk version "1.8.0_312"
paper 1.8.8 445
Ubuntu 22.04.1 LTS
The text was updated successfully, but these errors were encountered: