Skip to content
New issue

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

Pre-set cooldown storage variable causes ClassCastException #5935

Closed
1 task done
sovdeeth opened this issue Aug 24, 2023 · 0 comments
Closed
1 task done

Pre-set cooldown storage variable causes ClassCastException #5935

sovdeeth opened this issue Aug 24, 2023 · 0 comments
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update. priority: low Issues that are not harmful to the experience but are related to useful changes or additions.

Comments

@sovdeeth
Copy link
Member

sovdeeth commented Aug 24, 2023

Skript/Server Version

[09:52:00 INFO]: [Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[09:52:00 INFO]: [Skript] Skript's documentation can be found here: https://docs.skriptlang.org/
[09:52:00 INFO]: [Skript] Skript's tutorials can be found here: https://docs.skriptlang.org/tutorials
[09:52:00 INFO]: [Skript] Server Version: git-Paper-100 (MC: 1.20.1)
[09:52:00 INFO]: [Skript] Skript Version: 2.7.0-beta3 (skriptlang-github)
[09:52:00 INFO]: [Skript] Installed Skript Addons:
[09:52:00 INFO]: [Skript]  - skript-reflect v2.3.1-for-skript-beta (https://github.com/TPGamesNL/skript-reflect)
[09:52:00 INFO]: [Skript]  - SkBee v2.14.1 (https://github.com/ShaneBeee/SkBee)
[09:52:00 INFO]: [Skript] Installed dependencies:
[09:52:00 INFO]: [Skript]  - WorldGuard v7.0.9+5934e49

Bug Description

When using a variable for cooldown storage, if the variable is already set to anything that is not a date, running the command will cause getLastUsage() to throw a ClassCastException.

Due to unchecked cast on line 477 of ScriptCommand:

			return (Date) Variables.getVariable(name, null, false);

Expected Behavior

getLastUsage() should interpret any non-dates as if they did not exist, aka as not having been used before.

Steps to Reproduce

on load:
    set {cooldown} to 123

command /example:
    cooldown: 12 hours
    cooldown storage: {cooldown}
    trigger:
        broadcast "cooldown: %{cooldown}%"

Errors or Screenshots

[09:55:26 INFO]: Sahvde [69e37026-2c7d-4255-ac76-9b13a5fe8f74]: /example
[09:55:26 ERROR]: Could not pass event PlayerCommandPreprocessEvent to Skript v2.7.0-beta3
java.lang.ClassCastException: class java.lang.Long cannot be cast to class ch.njol.skript.util.Date (java.lang.Long is in module java.base of loader 'bootstrap'; ch.njol.skript.util.Date is in unnamed module of loader 'Skript-2.7.0-beta3.jar' @71fd3442)
        at ch.njol.skript.command.ScriptCommand.getLastUsage(ScriptCommand.java:477) ~[Skript-2.7.0-beta3.jar:?]
        at ch.njol.skript.command.ScriptCommand.execute(ScriptCommand.java:262) ~[Skript-2.7.0-beta3.jar:?]
        at ch.njol.skript.command.Commands.handleCommand(Commands.java:193) ~[Skript-2.7.0-beta3.jar:?]
        at ch.njol.skript.command.Commands$1.onPlayerCommand(Commands.java:152) ~[Skript-2.7.0-beta3.jar:?]
        at com.destroystokyo.paper.event.executor.MethodHandleEventExecutor.execute(MethodHandleEventExecutor.java:40) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:81) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:git-Paper-100]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-1.20.1.jar:git-Paper-100]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[paper-1.20.1.jar:git-Paper-100]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:615) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2275) ~[?:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2259) ~[?:?]
        at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
        at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.20.1.jar:git-Paper-100]
        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:1339) ~[paper-1.20.1.jar:git-Paper-100]
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.20.1.jar:git-Paper-100]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1316) ~[paper-1.20.1.jar:git-Paper-100]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1309) ~[paper-1.20.1.jar:git-Paper-100]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
        at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1287) ~[paper-1.20.1.jar:git-Paper-100]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1175) ~[paper-1.20.1.jar:git-Paper-100]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[paper-1.20.1.jar:git-Paper-100]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
[09:55:26 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'example' in plugin Skript v2.7.0-beta3
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R1.CraftServer.dispatchCommand(CraftServer.java:1006) ~[paper-1.20.1.jar:git-Paper-100]
        at org.bukkit.craftbukkit.v1_20_R1.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.20.1.jar:git-Paper-100]
        at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:265) ~[paper-1.20.1.jar:?]
        at net.minecraft.commands.Commands.performCommand(Commands.java:324) ~[?:?]
        at net.minecraft.commands.Commands.performCommand(Commands.java:308) ~[?:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2299) ~[?:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2259) ~[?:?]
        at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
        at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.20.1.jar:git-Paper-100]
        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:1339) ~[paper-1.20.1.jar:git-Paper-100]
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.20.1.jar:git-Paper-100]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1316) ~[paper-1.20.1.jar:git-Paper-100]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1309) ~[paper-1.20.1.jar:git-Paper-100]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
        at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1287) ~[paper-1.20.1.jar:git-Paper-100]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1175) ~[paper-1.20.1.jar:git-Paper-100]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[paper-1.20.1.jar:git-Paper-100]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ClassCastException: class java.lang.Long cannot be cast to class ch.njol.skript.util.Date (java.lang.Long is in module java.base of loader 'bootstrap'; ch.njol.skript.util.Date is in unnamed module of loader 'Skript-2.7.0-beta3.jar' @71fd3442)
        at ch.njol.skript.command.ScriptCommand.getLastUsage(ScriptCommand.java:477) ~[Skript-2.7.0-beta3.jar:?]
        at ch.njol.skript.command.ScriptCommand.execute(ScriptCommand.java:262) ~[Skript-2.7.0-beta3.jar:?]
        at ch.njol.skript.command.ScriptCommand.onCommand(ScriptCommand.java:221) ~[Skript-2.7.0-beta3.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        ... 23 more

Other

No response

Agreement

  • I have read the guidelines above and affirm I am following them with this report.
@sovdeeth sovdeeth added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. priority: low Issues that are not harmful to the experience but are related to useful changes or additions. good first issue An issue that would be good for a first-time contributor to make a PR for labels Aug 24, 2023
@TheLimeGlass TheLimeGlass added PR available Issues which have a yet-to-be merged PR resolving it and removed good first issue An issue that would be good for a first-time contributor to make a PR for labels Aug 27, 2023
@sovdeeth sovdeeth added completed The issue has been fully resolved and the change will be in the next Skript update. and removed PR available Issues which have a yet-to-be merged PR resolving it labels Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update. priority: low Issues that are not harmful to the experience but are related to useful changes or additions.
Projects
None yet
Development

No branches or pull requests

3 participants