SkriptLang / Skript

Skript is a Spigot plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
https://docs.skriptlang.org
GNU General Public License v3.0
1.08k stars 373 forks source link

EntryContainer methods throw NullPointerException #6193

Closed erenkarakal closed 1 year ago

erenkarakal commented 1 year ago

Skript/Server Version

[Skript] Server Version: git-Paper-241 (MC: 1.20.2)
 [Skript] Skript Version: 2.7.2 (skriptlang-github)
 [Skript] Installed Skript Addons: 
 [Skript]  - skript-reflect v2.4-dev1 (https://github.com/SkriptLang/skript-reflect)
 [Skript]  - SkCheese v1.0-SNAPSHOT
 [Skript]  - Hippo v1.1.1-PRERELEASE
 [Skript]  - SkBee v2.18.3 (https://github.com/ShaneBeee/SkBee)
 [Skript] Installed dependencies: 
 [Skript]  - Vault v1.7.3-b131

Bug Description

EntryContainer methods don't check if the current events of the parser instance are set, causing NullPointerException if used in the walk() method

Expected Behavior

The exception shouldn't be thrown

Steps to Reproduce

Use any EntryContainer method inside the walk method Example code: https://hastebin.skyra.pw/obiheruroh.pgsql - remove line 54 to reproduce it (this is not the final product, the syntax doesn't work properly yet and lots of stuff was changed, this is just an example)

function add(first: int, second: int, message: string) :: string:
  return "%{_first}% + %{_second}% %{_message}% %{_first} + {_second}%"

function test():
  execute function add and store it in {var}:
    first: 1
    second: 2
    message: "a"
  broadcast {var}

Errors or Screenshots

https://hastebin.skyra.pw/ehabupasop.md

Other

No response

Agreement

UnderscoreTud commented 1 year ago

You're trying to parse expressions at runtime where the parser instance isn't active. You need to use the entry container at parse time instead. This is intended, there's nothing wrong with the behavior