-
-
Notifications
You must be signed in to change notification settings - Fork 376
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
Can't find difference between Date and Timespan #575
Comments
2018 Edit: It's not a small fix lol |
This class has been modified since the date this was posted. Someone should test to see if this still occurs. |
I'll test it later, thanks for the heads up @TheLimeGlass. |
Seems fine
|
@TheLimeGlass did you try comparing a date with a timespan/timeperiod too? |
Like that?
I'm not LimeGlass :c |
Wellll
Edit: sorry I sent this from my phone lol |
The stacktraces are due to variables (The Difference expression handles Variables differently) and when they're not variables it states that Skript can't get the difference between the two, which leads to the stacktraces within the variables due to no Arithmetic setup for Date to Timespan and vice versa. I attempted to fix this issue but the main problem is being the Arithmetic of the Date/Timespans. They only accept the first generic of the Arithmetic to be converted with itself (Meaning compare Date with Date but returns the secondary generic) and the main problem is that the system would have to be heavily modified to be able to support multiple Arithmetics. Due to this I didn't want to finalize a fix for this. You can make a cheesy fix in this section https://github.com/bensku/Skript/blob/master/src/main/java/ch/njol/skript/expressions/ExprDifference.java#L123-L142 But the main point of Alternatives could include making a dual Arithmetic, making an Arithmetic that checks the difference between the first and second generic and returns the type that the Arithmetic is associated with, or utilizing a Comparator to convert a Timespan to Date and vice versa while finding the difference. This expression has since been released https://github.com/bensku/Skript/blob/master/src/main/java/ch/njol/skript/expressions/ExprDateAgoLater.java Which will help you achieve what you're attempting to do in this issue. @bensku I'm interested in your thoughts about this fix, because there should definitely be a system to be able to check multiple Arithmetics. Some types can contain more than one difference between two objects (just like in this case), especially for addon developers. And to anyone reading this with permissions, can the title be changed to something like "Can't find difference between Date and Timespan" |
We should probably attempt to convert Dates to Timespans or the other way around. I'm not exactly sure how that would be best implemented, though... |
I don't know the best way either but I know of several ways, and the conversion already exists in the date class.
|
There are like 3-4 issues about this now, some duplicates. |
So I am trying to make some scripts but I keep running into errors and it fails to load anything.
[01:19:46] [Server thread/ERROR]: #!#!
[01:19:46] [Server thread/ERROR]: #!#! [Skript] Severe Error:
[01:19:46] [Server thread/ERROR]: #!#! Could not load Smash.sk
[01:19:46] [Server thread/ERROR]: #!#!
[01:19:46] [Server thread/ERROR]: #!#! If you're developing an add-on for Skript this likely means that you have done something wrong.
[01:19:46] [Server thread/ERROR]: #!#! If you're a server admin however please go to https://github.com/bensku/Skript/issues/
[01:19:46] [Server thread/ERROR]: #!#! and check whether this error has already been reported.
[01:19:46] [Server thread/ERROR]: #!#! If not please create a new ticket with a meaningful title, copy & paste this whole error into it (or use paste service),
[01:19:46] [Server thread/ERROR]: #!#! and describe what you did before it happened and/or what you think caused the error.
[01:19:46] [Server thread/ERROR]: #!#! If you think that it's a trigger that's causing the error please post the trigger as well.
[01:19:46] [Server thread/ERROR]: #!#! By following this guide fixing the error should be easy and done fast.
[01:19:46] [Server thread/ERROR]: #!#!
[01:19:46] [Server thread/ERROR]: #!#! Stack trace:
[01:19:46] [Server thread/ERROR]: #!#! java.lang.NullPointerException
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.expressions.ExprDifference.init(ExprDifference.java:104)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:247)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:174)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.SkriptParser.parseSingleExpr(SkriptParser.java:319)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.SkriptParser.parseExpression(SkriptParser.java:445)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.SkriptParser.parse_i(SkriptParser.java:1159)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.SkriptParser.parse_i(SkriptParser.java:1150)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:219)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:174)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.Statement.parse(Statement.java:59)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.ScriptLoader.loadItems(ScriptLoader.java:753)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.TriggerSection.(TriggerSection.java:54)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.Conditional.(Conditional.java:44)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.ScriptLoader.loadItems(ScriptLoader.java:839)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.ScriptLoader.loadScript(ScriptLoader.java:510)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:245)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:199)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.Skript.reload(Skript.java:722)
[01:19:46] [Server thread/ERROR]: #!#! at ch.njol.skript.SkriptCommand.onCommand(SkriptCommand.java:159)
[01:19:46] [Server thread/ERROR]: #!#! at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
[01:19:46] [Server thread/ERROR]: #!#! at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
[01:19:46] [Server thread/ERROR]: #!#! at org.bukkit.craftbukkit.v1_11_R1.CraftServer.dispatchCommand(CraftServer.java:650)
[01:19:46] [Server thread/ERROR]: #!#! at org.bukkit.craftbukkit.v1_11_R1.CraftServer.dispatchServerCommand(CraftServer.java:636)
[01:19:46] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_11_R1.DedicatedServer.aM(DedicatedServer.java:437)
[01:19:46] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:400)
[01:19:46] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678)
[01:19:46] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576)
[01:19:46] [Server thread/ERROR]: #!#! at java.lang.Thread.run(Thread.java:745)
[01:19:46] [Server thread/ERROR]: #!#!
[01:19:46] [Server thread/ERROR]: #!#! Version Information:
[01:19:46] [Server thread/ERROR]: #!#! Skript: 2.2-dev27
[01:19:46] [Server thread/ERROR]: #!#! Bukkit: 1.11.2-R0.1-SNAPSHOT
[01:19:46] [Server thread/ERROR]: #!#! Minecraft: 1.11.2
[01:19:46] [Server thread/ERROR]: #!#! Java: 1.8.0_74 (Java HotSpot(TM) 64-Bit Server VM 25.74-b02)
[01:19:46] [Server thread/ERROR]: #!#! OS: Linux amd64 3.10.23-xxxx-std-ipv6-64
[01:19:46] [Server thread/ERROR]: #!#!
[01:19:46] [Server thread/ERROR]: #!#! Running CraftBukkit: false
[01:19:46] [Server thread/ERROR]: #!#!
[01:19:46] [Server thread/ERROR]: #!#! Current node: set {_dash} to difference between {dash.%player%} and now (Smash.sk, line 3)
[01:19:46] [Server thread/ERROR]: #!#! Current item: null
[01:19:46] [Server thread/ERROR]: #!#!
[01:19:46] [Server thread/ERROR]: #!#! Thread: Server thread
[01:19:46] [Server thread/ERROR]: #!#!
[01:19:46] [Server thread/ERROR]: #!#! End of Error.
[01:19:46] [Server thread/ERROR]: #!#!
Is there anything that I am doing wrong that I just don't know of?
The text was updated successfully, but these errors were encountered: