Matocolotoe / Skript-1.8

The Skript plugin made for Minecraft 1.8.x only. Releases will follow the original repository, except for some bug fixes. Please read the README before updating to Skript-1.8 !
https://discord.gg/yh3Z98m
GNU General Public License v3.0
49 stars 4 forks source link

Error with if else statement after else #29

Closed MinecraftMan1013number2 closed 3 years ago

MinecraftMan1013number2 commented 3 years ago

Hello, I have discovered that if you put and if else statement after an else statement, Skript errors out with this.

[09:12:33 ERROR]: #!#!
[09:12:33 ERROR]: #!#! [Skript] Severe Error:
[09:12:33 ERROR]: #!#! Could not load CustomEnchants.sk
[09:12:33 ERROR]: #!#!
[09:12:33 ERROR]: #!#! Something went horribly wrong with Skript.
[09:12:33 ERROR]: #!#! This issue is NOT your fault! You probably can't fix it yourself, either.
[09:12:33 ERROR]: #!#! You should report it at https://github.com/SkriptLang/Skript/issues. Please copy paste this report there (or use paste service).
[09:12:33 ERROR]: #!#! This ensures that your issue is noticed and will be fixed as soon as possible.
[09:12:33 ERROR]: #!#! If you believe this is related to this fork in particular (for example if the issue didn't occur
[09:12:33 ERROR]: #!#! with the latest SkriptLang release), please report it here : https://github.com/Matocolotoe/Skript-1.8/issues
[09:12:33 ERROR]: #!#!
[09:12:33 ERROR]: #!#! Stack trace:
[09:12:33 ERROR]: #!#! java.lang.ClassCastException: class ch.njol.skript.lang.Conditional$1 cannot be cast to class ch.njol.skript.lang.Conditional (ch.njol.skript.lang.Conditional$1 and ch.njol.skript.lang.Conditional are in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @64af3397)
[09:12:33 ERROR]: #!#!     at ch.njol.skript.lang.Conditional.loadElseIf(Conditional.java:90)
[09:12:33 ERROR]: #!#!     at ch.njol.skript.lang.Conditional.loadElseIf(Conditional.java:90)
[09:12:33 ERROR]: #!#!     at ch.njol.skript.ScriptLoader.loadItems(ScriptLoader.java:1105)
[09:12:33 ERROR]: #!#!     at ch.njol.skript.command.Commands.loadCommand(Commands.java:486)
[09:12:33 ERROR]: #!#!     at ch.njol.skript.ScriptLoader.loadScript(ScriptLoader.java:636)
[09:12:33 ERROR]: #!#!     at ch.njol.skript.ScriptLoader.lambda$4(ScriptLoader.java:401)
[09:12:33 ERROR]: #!#!     at ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:420)
[09:12:33 ERROR]: #!#!     at ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:464)
[09:12:33 ERROR]: #!#!     at ch.njol.skript.ScriptLoader.reloadScript(ScriptLoader.java:976)
[09:12:33 ERROR]: #!#!     at ch.njol.skript.SkriptCommand.onCommand(SkriptCommand.java:185)
[09:12:33 ERROR]: #!#!     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[09:12:33 ERROR]: #!#!     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:146)
[09:12:33 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:666)
[09:12:33 ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1189)
[09:12:33 ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1001)
[09:12:33 ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45)
[09:12:33 ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1)
[09:12:33 ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13)
[09:12:33 ERROR]: #!#!     at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[09:12:33 ERROR]: #!#!     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[09:12:33 ERROR]: #!#!     at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44)
[09:12:33 ERROR]: #!#!     at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:774)
[09:12:33 ERROR]: #!#!     at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378)
[09:12:33 ERROR]: #!#!     at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713)
[09:12:33 ERROR]: #!#!     at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616)
[09:12:33 ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:834)
[09:12:33 ERROR]: #!#!
[09:12:33 ERROR]: #!#! Version Information:
[09:12:33 ERROR]: #!#!   Skript: 2.5.3 (latest)
[09:12:33 ERROR]: #!#!     Flavor: github-matocolotoe-1.8
[09:12:33 ERROR]: #!#!     Date: 2020-12-22
[09:12:33 ERROR]: #!#!   Bukkit: 1.8.8-R0.1-SNAPSHOT
[09:12:33 ERROR]: #!#!   Minecraft: 1.8.8
[09:12:33 ERROR]: #!#!   Java: 11.0.10 (Java HotSpot(TM) 64-Bit Server VM 11.0.10+8-LTS-162)
[09:12:33 ERROR]: #!#!   OS: Windows 10 amd64 10.0
[09:12:33 ERROR]: #!#!
[09:12:33 ERROR]: #!#! Server platform: Paper
[09:12:33 ERROR]: #!#!
[09:12:33 ERROR]: #!#! Current node: else if arg-1 is "remove": (CustomEnchants.sk, line 374)
[09:12:33 ERROR]: #!#! Current item: null
[09:12:33 ERROR]: #!#!
[09:12:33 ERROR]: #!#! Thread: Server thread
[09:12:33 ERROR]: #!#!
[09:12:33 ERROR]: #!#! Language: english
[09:12:33 ERROR]: #!#! Link parse mode: DISABLED
[09:12:33 ERROR]: #!#!
[09:12:33 ERROR]: #!#! End of Error.
[09:12:33 ERROR]: #!#!

What I mean is something like this (pretend there is tabs/spaces)

command /hello <text>:
    trigger:
        if arg-1 is "hi":
            send "hi"
        else:
            send "bye"
        else if arg-1 is "hello":
            send "this errors"
Romitou commented 3 years ago

Duplicate of https://github.com/SkriptLang/Skript/issues/3840. You cannot have two else sections on the same level. Your script should look like this:

command /hello <text>:
    trigger:
        if arg-1 is "hi":
            send "hi"
        else if arg-1 is "hello":
            send "this errors"
        else:
            send "bye"
MinecraftMan1013number2 commented 3 years ago

Duplicate of SkriptLang/Skript#3840. You cannot have two else sections on the same level. Your script should look like this:

command /hello <text>:
    trigger:
        if arg-1 is "hi":
            send "hi"
        else if arg-1 is "hello":
            send "this errors"
        else:
            send "bye"

Maybe you could find a way to add a reload error (something like "You have an if else after an else! You can't do this!") instead of that console error?

Romitou commented 3 years ago

I would recommend opening an issue on the official SkriptLang repository for that.

Romitou commented 3 years ago

Closing as it is not related to this fork.