Code Monkey home page Code Monkey logo

skript-reflect's Introduction

skript-reflect

This fork of skript-mirror aims to fix multiple issues that I believe have been present for too long, and implement some long-wanted features.

Documentation: https://tpgamesnl.gitbook.io/skript-reflect

Source code: https://github.com/TPGamesNL/skript-reflect

Downloads: releases or actions (not stable)

Discord: https://discord.gg/jDW8UbD

What's been changed in this fork:

  • Added custom events
  • Support for more Java versions (Java 13+, OpenJ9)
  • Support for listening to asynchronous events
  • Class proxy fixes + documentation
  • Fixed multiple issues with local variables
  • + much more

skript-reflect's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

skript-reflect's Issues

classes with methods / fields that reference unfound classes can't be used in mirror

SkriptLang/Skript#3051

find out what Java standards are on this, because I probably won't support it if is deemed bad practice.

[13:55:42] [Server thread/WARN]: [Skript] Task #38 for Skript v2.5-alpha3 generated an exception
java.lang.NoClassDefFoundError: com/sucy/skill/SkillAPI
	at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:?]
	at java.lang.Class.privateGetDeclaredMethods(Class.java:3166) ~[?:?]
	at java.lang.Class.privateGetPublicMethods(Class.java:3191) ~[?:?]
	at java.lang.Class.getMethods(Class.java:1904) ~[?:?]
	at com.btk5h.skriptmirror.util.JavaUtil.methods(JavaUtil.java:53) ~[?:?]
	at com.btk5h.skriptmirror.skript.reflect.ExprJavaCall.createCallSite(ExprJavaCall.java:386) ~[?:?]
	at java.util.HashMap.computeIfAbsent(HashMap.java:1133) ~[?:?]
	at com.btk5h.skriptmirror.skript.reflect.ExprJavaCall.getCallSite(ExprJavaCall.java:346) ~[?:?]
	at com.btk5h.skriptmirror.skript.reflect.ExprJavaCall.findCompatibleMethod(ExprJavaCall.java:524) ~[?:?]
	at com.btk5h.skriptmirror.skript.reflect.ExprJavaCall.invoke(ExprJavaCall.java:435) ~[?:?]
	at com.btk5h.skriptmirror.skript.reflect.ExprJavaCall.getSingle(ExprJavaCall.java:137) ~[?:?]
	at com.btk5h.skriptmirror.skript.reflect.ExprJavaCall.getArray(ExprJavaCall.java:143) ~[?:?]
	at ch.njol.skript.effects.EffChange.execute(EffChange.java:278) ~[?:?]
	at ch.njol.skript.lang.Effect.run(Effect.java:52) ~[?:?]
	at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:61) ~[?:?]
	at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:89) ~[?:?]
	at ch.njol.skript.lang.Trigger.execute(Trigger.java:57) ~[?:?]
	at ch.njol.skript.events.EvtScript.register(EvtScript.java:61) ~[?:?]
	at ch.njol.skript.ScriptLoader$3.call(ScriptLoader.java:753) ~[?:?]
	at ch.njol.skript.ScriptLoader$3.call(ScriptLoader.java:1) ~[?:?]
	at ch.njol.skript.ScriptLoader.loadScript(ScriptLoader.java:772) ~[?:?]
	at ch.njol.skript.ScriptLoader.lambda$1(ScriptLoader.java:410) ~[?:?]
	at ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:429) ~[?:?]
	at ch.njol.skript.ScriptLoader.lambda$0(ScriptLoader.java:348) ~[?:?]
	at ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:381) ~[?:?]
	at ch.njol.skript.Skript$2.run(Skript.java:592) ~[?:?]
	at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:64) ~[server.jar:git-Paper-33d42c8e]
	at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:423) ~[server.jar:git-Paper-33d42c8e]
	at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:852) ~[server.jar:git-Paper-33d42c8e]
	at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:423) ~[server.jar:git-Paper-33d42c8e]
	at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:786) ~[server.jar:git-Paper-33d42c8e]
	at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:678) ~[server.jar:git-Paper-33d42c8e]
	at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.ClassNotFoundException: com.sucy.skill.SkillAPI
	at java.net.URLClassLoader.findClass(URLClassLoader.java:471) ~[?:?]
	at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:156) ~[server.jar:git-Paper-33d42c8e]
	at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:104) ~[server.jar:git-Paper-33d42c8e]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:588) ~[?:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
	... 33 more

error is because mirror uses getMethods() instead of getMethod(String name)

Custom classes

Be able to extend classes as well as implement them (maybe both at the same time).
Resources:
http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/sun/misc/ProxyGenerator.java
https://marschall.github.io/2017/07/11/java-proxy-anatomy.html (see this one to save generated files)
Also experiment if ClassLoader#defineClass can be used properly (link)
Idea for syntax:

class extends AbstractMap:
# class [extends %javatype%] [implements %javatypes%]
	
	# access modifier: [(public|private|protected)]
	# %access modifier% %javatype% %identifier%
	public Integer testField
	
	# %access modifier% (%javatype%|void) %identifier%([parameters])
	# %identifier%: %javatype%
	public void doMethod(a: Integer, b: String):
		broadcast "HEY"

# note: %identifier% and %access modifier% aren't actual types, just to make it easy to read the syntax here

# look into:
	# class name
	# primitive types
	# syntax for varargs

EDIT: probably name this custom classes

Integers and number stuff

effect test %number%:
	trigger:
		broadcast "int %expr-1%"

expression test expr:
	get:
		return 1

command /bug:
	trigger:
		test test expr

works, %number% -> %integer% doesn't

Event priority error

Describe the bug
Gives error when you try to use event priority with imported event.

To reproduce
You can use the given example on the wiki:

import:
  org.bukkit.event.entity.EnderDragonChangePhaseEvent

on EnderDragonChangePhaseEvent with priority highest:
  # your code

Expected behavior
no errors

Screenshots
image

Server information

  • skript-reflect: 2.3
  • Skript: 2.6.1
  • Bukkit: 1.18.2 (Purpur)
  • Minecraft: 1.18.2
  • Java: 17
  • OS: Centos 7

Custom Syntax bug

Describe the bug
There seems to be a problem when using %itemstack% in Custom Syntax.
It worked normally in version 2.1.0, but a problem occurred after updating to version 2.2.0.

To reproduce
[Normal case-A]

expression test expression %itemstack%:
	get:
		broadcast "%expr-1%"
		return "Done."
on inventory click:
	set {_inv} to player' current inventory
	set {_test} to test expression slot 0 of {_inv}

[Normal case-B]

expression %itemstack% test expression:
	get:
		broadcast "%expr-1%"
		return "Done."
on inventory click:
	set {_test} to slot 0 of player' current inventory test expression

[Bug case]

expression %itemstack% test expression:
	get:
		broadcast "%expr-1%"
		return "Done."
on inventory click:
	set {_inv} to player' current inventory
	set {_test} to slot 0 of {_inv} test expression

Expected behavior
In both cases, the item in the 0 slot of the player's inventory is displayed normally. However, in the bug case, is displayed.

Screenshots
If applicable, add screenshots to help explain your problem.

Server information

  • skript-reflect: 2.2.0
  • Skript: 2.5.3
  • Bukkit: Paper-1.16.4-b416
  • Minecraft: Minecaft 1.16.4
  • Java: Java "11.0.10" 2021-01-09 LTS
  • OS: Windows Server 2016 Standard

Additional context
Add any other context about the problem here.

Imports no longer work in effect commands

Describe the bug
In the last version of skript-mirror, you could run import from effect commands. This functionality seems to have been lost at some point in skript-reflect.

To reproduce
Try running import com.whatever.Class in an effect command. It will error.

Expected behavior
Importing is possible via effect commands. This enables quick tests.

Additional context
It seems this may have been removed intentionally by 272078c, but I'm not sure

BlockBreakEvent not working correctly

Describe the bug
I have a BlockBreakEvent that should add to a variable everytime the block is broken and the person is in a town. However, sometimes it adds two to the variable despite only breaking the block once. Some ores don't even work at all.

Code: https://hastebin.com/uracawofut.sql

To reproduce

  1. Install skript-reflect and Skript
  2. Write the event pasted above
  3. Some ores add to the variable twice, some not at all.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
image
Iron ore does it twice, lapis does it once (which is how they should all function) and gold ore does not even function whatsoever.

Server information

  • skript-reflect: 2.1.0
  • Skript: 2.5.3
  • Bukkit: 1.16.4
  • Minecraft: 1.16.4
  • Java: 8
  • OS: ?

Additional context
Add any other context about the problem here.

Parsing not implemented (remember to override parse method)

Describe the bug
I don't know why but between version 2.2.2 and 2.2.3 my skript doesn't work anymore and I am 100% sure that the error comes from SK-REFLECT

To reproduce
The skript is as follows:

on chat: set {roleicachat.%player%} to group of player if {tchatskycdica.%player%} is not set: set {_messmot::*} to {messagenew.%player%} split at " " loop {_messmot::*}: if loop-value contain "<chat=": remove "%{_messmot::%loop-index%}%" from {_messmot::*} loop {_messmot::*}: if loop-index = "1": set {messagenew2.%player%} to "%{_messmot::1}%" else: set {messagenew2.%player%} to "%{messagenew2.%player%}% %{_messmot::%loop-index%}%" if {messagenew.%player%} is not set: send "**[%{roleicachat.%player%}%] %player% **➜ %message%" to channel with id "510293782944808970" else: if {messagenew2.%player%} contain "@here" or "@everyone": replace all "@here" with "@ here" in {messagenew2.%player%} replace all "@everyone" with "@ everyone" in {messagenew2.%player%} send "**[%{roleicachat.%player%}%] %player% **➜ %{messagenew2.%player%}%" to channel with id "510293782944808970" else: send "**[%{roleicachat.%player%}%] %player% **➜ %{messagenew2.%player%}%" to channel with id "510293782944808970" set {tchatskycdica.%player%} to 1 wait 2 tick delete {tchatskycdica.%player%} delete {messagenew2.%player%}

Server information
image
Java 16
Spigot : 1.16.5

Additional context
Log error :
https://pastebin.com/SnhNWwPD
Error is with Sk-reflect 2.2.3 now when i use 2.2.2 no error :\

Can not parse Java Array correctly

Describe the bug
Java Array can not parse as Skript Array correctly
It will have the only one element

To reproduce
set {_array::"all"} to [{_javaArray}]
send "%size of {_array::"all"}%" to console
//It will be always 1
//
loop {_array::"all"}:
send "%loop-value%" to console
//It will be "[%all elements to string%]"
//Do not care about the "all", because "*" will be recognized as an special mark

Expected behavior
No

Screenshots
No

Server information

  • skript-reflect: 2.2.3
  • Skript: 2.5.3
  • Bukkit: Spigot-1.16.5
  • Minecraft: 1.16.5
  • Java: 1.8.0-292
  • OS: Windows10

Additional context
No

listenening to Bukkit events (`EvtByReflection`) and ignoring cancelled

ignoring cancelled events was inverted, that's fixed in next commit.
also, listeners aren't unregistered, so you can only change ignoreCancelled by using a different priority or by restarting the server.
can be fixed by implementing ignoreCancelled in the same way priority is done.

Suggestion: Class Cast

For example, in Java:
int a = 1;
Long b = (Long) a;

Can the provider be implemented in skript-reflect?
Thanks a lot.

return won't work

When I try the

option nms:
    get: 
        set {_nmsversion} to Bukkit.getServer().getClass().getPackage().getName().split("\.")[3]
        return {_nmsversion}

It consoles output a error when I reload the skript

15:50:08 ERROR: #!#! [Skript] Severe Error:
15:50:08 ERROR: #!#! Could not load GPClaimInteg.sk
15:50:08 ERROR: #!#!
15:50:08 ERROR: #!#! Something went horribly wrong with Skript.
15:50:08 ERROR: #!#! This issue is NOT your fault! You probably can't fix it yourself, either.
15:50:08 ERROR: #!#! It looks like you are using some plugin(s) that alter how Skript works (addons).
15:50:08 ERROR: #!#! Here is full list of them:
15:50:08 ERROR: #!#! skript-placeholders v1.5.2 (https://github.com/APickledWalrus/skript-placeholders) skript-reflect v2.3 (https://github.com/TPGamesNL/skript-reflect) skript-gui v1.2.2 (https://github.com/APickledWalrus/skript-gui) SkBee v1.15.2 (https://github.com/ShaneBeee/SkBee) skript-yaml v1.4 AuctionMaster v4.0 (https://discord.gg/nchk86TKMT)
15:50:08 ERROR: #!#! We could not identify which of those are specially related, so this might also be Skript issue.
15:50:08 ERROR: #!#! You should try disabling those plugins one by one, trying to find which one causes it.
15:50:08 ERROR: #!#! If the error doesn't disappear even after disabling all listed plugins, it is probably Skript issue.
15:50:08 ERROR: #!#! In that case, you will be given instruction on how should you report it.
15:50:08 ERROR: #!#! On the other hand, if the error disappears when disabling some plugin, report it to author of that plugin.
15:50:08 ERROR: #!#! Only if the author tells you to do so, report it to Skript's issue tracker.
15:50:08 ERROR: #!#!
15:50:08 ERROR: #!#! Stack trace:
15:50:08 ERROR: #!#! java.lang.RuntimeException: pattern compiling exception, element class: io.github.apickledwalrus.skriptgui.elements.effects.EffCancelGUIClose
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:228)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:179)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.Statement.parse(Statement.java:61)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.loadItems(ScriptLoader.java:1113)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.util.SkriptUtil.getItemsFromNode(SkriptUtil.java:88)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.expression.CustomConstantSection.lambda$init$2(CustomConstantSection.java:66)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.CustomSyntaxSection.handleEntriesAndSections(CustomSyntaxSection.java:253)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.expression.CustomConstantSection.init(CustomConstantSection.java:58)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.CustomSyntaxSection.init(CustomSyntaxSection.java:214)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.CustomSyntaxSection.init(CustomSyntaxSection.java:182)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parseEvent(SkriptParser.java:1101)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parseEvent(SkriptParser.java:1067)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.loadScript(ScriptLoader.java:739)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.lambda$loadScripts$4(ScriptLoader.java:525)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.lambda$makeFuture$2(ScriptLoader.java:417)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.makeFuture(ScriptLoader.java:433)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:524)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:468)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.Skript$1.run(Skript.java:778)
15:50:08 ERROR: #!#! at org.bukkit.craftbukkit.v1_18_R1.scheduler.CraftTask.run(CraftTask.java:101)
15:50:08 ERROR: #!#! at org.bukkit.craftbukkit.v1_18_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483)
15:50:08 ERROR: #!#! at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1227)
15:50:08 ERROR: #!#! at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:322)
15:50:08 ERROR: #!#! at java.base/java.lang.Thread.run(Thread.java:833)
15:50:08 ERROR: #!#! Caused by: ch.njol.skript.patterns.MalformedPatternException: invalid parse mark at 9 [pattern: cancel|1¦uncancel]
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.patterns.PatternCompiler.compile(PatternCompiler.java:114)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.patterns.PatternCompiler.compile(PatternCompiler.java:83)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.patterns.PatternCompiler.compile(PatternCompiler.java:48)
15:50:08 ERROR: #!#! at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parse_i(SkriptParser.java:1301)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:226)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:179)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.Statement.parse(Statement.java:61)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.loadItems(ScriptLoader.java:1113)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.util.SkriptUtil.getItemsFromNode(SkriptUtil.java:88)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.expression.CustomConstantSection.lambda$init$2(CustomConstantSection.java:66)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.CustomSyntaxSection.handleEntriesAndSections(CustomSyntaxSection.java:253)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.expression.CustomConstantSection.init(CustomConstantSection.java:58)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.CustomSyntaxSection.init(CustomSyntaxSection.java:214)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.CustomSyntaxSection.init(CustomSyntaxSection.java:182)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parseEvent(SkriptParser.java:1101)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parseEvent(SkriptParser.java:1067)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.loadScript(ScriptLoader.java:739)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.lambda$loadScripts$4(ScriptLoader.java:525)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.lambda$makeFuture$2(ScriptLoader.java:417)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.makeFuture(ScriptLoader.java:433)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:524)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:468)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.Skript$1.run(Skript.java:778)
15:50:08 ERROR: #!#! at org.bukkit.craftbukkit.v1_18_R1.scheduler.CraftTask.run(CraftTask.java:101)
15:50:08 ERROR: #!#! at org.bukkit.craftbukkit.v1_18_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483)
15:50:08 ERROR: #!#! at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1227)
15:50:08 ERROR: #!#! at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:322)
15:50:08 ERROR: #!#! at java.base/java.lang.Thread.run(Thread.java:833)
15:50:08 ERROR: #!#! Caused by: java.lang.NumberFormatException: For input string: "1Â"
15:50:08 ERROR: #!#! at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
15:50:08 ERROR: #!#! at java.base/java.lang.Integer.parseInt(Integer.java:668)
15:50:08 ERROR: #!#! at java.base/java.lang.Integer.parseInt(Integer.java:786)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.patterns.PatternCompiler.compile(PatternCompiler.java:112)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.patterns.PatternCompiler.compile(PatternCompiler.java:83)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.patterns.PatternCompiler.compile(PatternCompiler.java:48)
15:50:08 ERROR: #!#! at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parse_i(SkriptParser.java:1301)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:226)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:179)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.Statement.parse(Statement.java:61)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.loadItems(ScriptLoader.java:1113)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.util.SkriptUtil.getItemsFromNode(SkriptUtil.java:88)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.expression.CustomConstantSection.lambda$init$2(CustomConstantSection.java:66)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.CustomSyntaxSection.handleEntriesAndSections(CustomSyntaxSection.java:253)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.expression.CustomConstantSection.init(CustomConstantSection.java:58)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.CustomSyntaxSection.init(CustomSyntaxSection.java:214)
15:50:08 ERROR: #!#! at skript-reflect.jar//com.btk5h.skriptmirror.skript.custom.CustomSyntaxSection.init(CustomSyntaxSection.java:182)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parseEvent(SkriptParser.java:1101)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.lang.SkriptParser.parseEvent(SkriptParser.java:1067)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.loadScript(ScriptLoader.java:739)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.lambda$loadScripts$4(ScriptLoader.java:525)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.lambda$makeFuture$2(ScriptLoader.java:417)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.makeFuture(ScriptLoader.java:433)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:524)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:468)
15:50:08 ERROR: #!#! at Skript.jar//ch.njol.skript.Skript$1.run(Skript.java:778)
15:50:08 ERROR: #!#! at org.bukkit.craftbukkit.v1_18_R1.scheduler.CraftTask.run(CraftTask.java:101)
15:50:08 ERROR: #!#! at org.bukkit.craftbukkit.v1_18_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483)
15:50:08 ERROR: #!#! at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1227)
15:50:08 ERROR: #!#! at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:322)
15:50:08 ERROR: #!#! at java.base/java.lang.Thread.run(Thread.java:833)
15:50:08 ERROR: #!#!
15:50:08 ERROR: #!#! Version Information:
15:50:08 ERROR: #!#! Skript: 2.6.1 (latest)
15:50:08 ERROR: #!#! Flavor: skriptlang-github
15:50:08 ERROR: #!#! Date: 22:18:42.554713200
15:50:08 ERROR: #!#! Bukkit: 1.18.1-R0.1-SNAPSHOT
15:50:08 ERROR: #!#! Minecraft: 1.18.1
15:50:08 ERROR: #!#! Java: 17.0.3 (OpenJDK 64-Bit Server VM 17.0.3+7)
15:50:08 ERROR: #!#! OS: Windows 11 amd64 10.0
15:50:08 ERROR: #!#!
15:50:08 ERROR: #!#! Server platform: Paper
15:50:08 ERROR: #!#!
15:50:08 ERROR: #!#! Current node: return {_nmsversion} (GPClaimInteg.sk, line 12)
15:50:08 ERROR: #!#! Current item: null
15:50:08 ERROR: #!#!
15:50:08 ERROR: #!#! Thread: Server thread
15:50:08 ERROR: #!#!
15:50:08 ERROR: #!#! Language: english
15:50:08 ERROR: #!#! Link parse mode: DISABLED
15:50:08 ERROR: #!#!
15:50:08 ERROR: #!#! End of Error.
15:50:08 ERROR: #!#!

Async section returns <none>

Describe the bug
Async section returns

To reproduce
Copy paste this code (it's example from gitbook with command trigger)

command /testy:
	trigger:
		set {_i} to 2
		create new section with {_x} stored in {_section}:
			return {_x} * {_i}
		run section {_section} async with 3 and store result in {_result} and wait
		broadcast "Result: %{_result}%"

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.
screenshot
Server information

  • skript-reflect:2.2.1
  • Skript:2.5.3
  • Bukkit:git-Paper-505
  • Minecraft:1.16.5
  • Java:1.8.0_271
  • OS:Windows

Additional context
Add any other context about the problem here.

Skript-reflect not working on 1.17?

I was told on the skript github that this is a skript-flect issue.
SkriptLang/Skript#4130

Description

Skript-reflect not working on 1.17? :/

Steps to Reproduce

Not sure how exactly to reproduce this as i'm not sure the cause of it.

Expected Behavior

That it worked? xD

Errors / Screenshots

https://mclo.gs/5ON1Y0Y

Server Information

  • Server version/platform: Purpur1206
  • Skript version: Skript-alpha1 (I've also tried latest "Action" builds
  • Skript-reflect: latest stable release version 2.2.1

Additional Context

Async reflection can be delayed

Because of https://github.com/TPGamesNL/skript-reflect/blob/2.x/src/main/java/com/btk5h/skriptmirror/skript/EffExpressionStatement.java#L27 the maximum number of simultaneously running reflection calls is limited by the return value of above method. Example:

import:
	java.lang.Thread
	java.lang.Runnable
	java.lang.System
	java.lang.Runtime

function test(proxy: object):
	await {_proxy}.run()

command /test:
	trigger:
		broadcast "availableProcessors: %Runtime.getRuntime().availableProcessors()%"
		set {_start} to now
		loop 5 times:
			set {_i} to loop-value
			create section stored in {_f::run}:
				broadcast "[%{_i}%] started @ %difference between {_start} and now%"
				Thread.sleep(1000)
			set {_proxy::%{_i}%} to proxy of Runnable from {_f::*}
		loop 5 times:
			test({_proxy::%loop-value%})

output:

availableProcessors: 4
[3] started @ 0.001 seconds
[1] started @ 0.001 seconds
[4] started @ 0.001 seconds
[2] started @ 0.002 seconds
[5] started @ 1.002 seconds

IllegalPluginAccessException when using EvtByReflection for non-event classes

Describe the bug
As the title says, an IPAE is thrown when a class that doesn't implement Event is used as input.

To reproduce

import:
  java.util.function.Consumer


on Consumer:
  broadcast "%event%"

Expected behavior
I would expect the addon to do type-checking before casting or passing around the input, and throw an error if applicable.

Usage of imported classes in effect commands

Is your feature request related to a problem? Please describe.
Title is explaining almost everything. That would be awesome if we can use imported classes in skript's effect commands.

Describe the solution you'd like
!send Bukkit.getServer()
!send SomePluginAPI.chargeXYZ(1, 5, -9)

This event doesn't support event priority

Describe the bug
The events with priority doesn't work:
(imports: org.bukkit.event.block.BlockBreakEvent and org.bukkit.event.block.BlockPlaceEvent)
on BlockBreakEvent with priority monitor:
on all BlockPlaceEvent with priority monitor:
The errors:
[Skript] Line 257: (drop.sk)
This event doesn't support event priority
Line: §7on BlockBreakEvent with priority monitor:

[22:51:46 ERROR]: [Skript] Line 5: (preventjump.sk)
This event doesn't support event priority
Line: on all BlockPlaceEvent with priority monitor:

Server information

  • skript-reflect: 2.3
  • Skript: 2.6.1
  • Bukkit: Purpur
  • Minecraft: 1.16.5
  • Java: 17
  • OS: Linux

1.17 Stack trace when using a non-existent event

Describe the bug
Having an event that doesn't exist (such as "on test:") in a Skript print a stack trace (skript severe error, can be found here https://pastebin.com/b6smGqL5). I found out that the same issue occurs when trying to use an event from skript-packet (on packet event %packettype%:) which is a huge problem for me but I don't know if it happens with other addons

To reproduce
Start a new paper 1.17 server with Skript 2.6 b1, create a new skript with an event that doesn't exist, such as "on test:", reload it and see the stack trace

Expected behavior
Shouldn't print a stack trace but should print the errors found in the script (and it shouldn't print it when trying to use an event from skript-packet too)

Screenshots
Not needed here, but can provide if you really need some

Server information

  • skript-reflect: 2.2.1
  • Skript: 2.6-beta1
  • Bukkit: git-Paper-68
  • Minecraft: 1.17
  • Java: Java 16 (OpenJDK 64-Bit Server VM 16.0.1+9)
  • OS: Windows 10
    Tested with no scripts (just the 2 lines one to make it print the stack trace) and no other plugins

Additional context
I have no idea how addons are made, but maybe this occurs with skript-packet because every event are not registered (because of the number of packets), but this is pure dumb speculation from me.
Sorry if my english isn't perfect, it isn't my main language but I tried my best haha

Sk reload all gives errors but reloading the skripts separately works

Describe the bug
A clear and concise description of what the bug is.

When I execute /sk reload all when applying a custom public expression to a Skript, Skript doesn't recognize it. This is the bug because normally, Skript would recognize the expression.

Expected behavior
A clear and concise description of what you expected to happen.

I expected the skript to give no errors when reloading all the Skripts with /sk reload all. Instead, the Skript gave errors but when the Skripts were reloaded separately they suddenly worked. I ended up having to make a bunch of on skript events with "make console execute command "/sk reload duel" etc. so that the skripts could be reloaded separately.

Screenshots
If applicable, add screenshots to help explain your problem.
https://user-images.githubusercontent.com/63815615/103445671-640d9c00-4c45-11eb-8826-8e66ef90aa30.mp4

Server information

  • skript-reflect: 2.2alpha2 (tried in 2.1.0 as well)
  • Skungee: 2.0.0
  • Skript - 2.5.3
  • This server is running Paper version git-Paper-337 (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT)

I need you to support 1.18 version.

I cannot run skript-reflect on 1.18 version.

[16:03:53 INFO]: [skript-reflect] Enabling skript-reflect v2.2.3
[16:03:53 WARN]: [skript-reflect] Loaded class ch.njol.skript.Skript from Skript v2.6 which is not a depend, softdepend or loadbefore of this plugin.
[16:03:53 ERROR]: Error occurred while enabling skript-reflect v2.2.3 (Is it up to date?)
ch.njol.skript.SkriptAPIException: Registering is disabled after initialisation!
at ch.njol.skript.Skript.checkAcceptRegistrations(Skript.java:1174) ~[Skript.jar:?]
at ch.njol.skript.Skript.registerAddon(Skript.java:1196) ~[Skript.jar:?]
at com.btk5h.skriptmirror.SkriptMirror.getAddonInstance(SkriptMirror.java:95) ~[skript-reflect-2.2.3 (2).jar:?]
at com.btk5h.skriptmirror.SkriptMirror.onEnable(SkriptMirror.java:39) ~[skript-reflect-2.2.3 (2).jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at com.rylinaux.plugman.util.PluginUtil.load(PluginUtil.java:366) ~[PlugMan.jar:?]
at com.rylinaux.plugman.command.LoadCommand.execute(LoadCommand.java:114) ~[PlugMan.jar:?]
at com.rylinaux.plugman.PlugManCommandHandler.onCommand(PlugManCommandHandler.java:95) ~[PlugMan.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.dispatchCommand(CraftServer.java:876) ~[paper-1.18.1.jar:git-Paper-68]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCommand(ServerGamePacketListenerImpl.java:2268) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2079) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2060) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:46) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundChatPacket.a(ServerboundChatPacket.java:6) ~[?:?]
at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:56) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.18.1.jar:git-Paper-68]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:149) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[?:?]
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1413) ~[paper-1.18.1.jar:git-Paper-68]
at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:189) ~[paper-1.18.1.jar:git-Paper-68]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1391) ~[paper-1.18.1.jar:git-Paper-68]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1384) ~[paper-1.18.1.jar:git-Paper-68]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132) ~[?:?]
at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1362) ~[paper-1.18.1.jar:git-Paper-68]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1268) ~[paper-1.18.1.jar:git-Paper-68]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-68]
at java.lang.Thread.run(Thread.java:833) ~[?:?]

Could not load the plugin

Could not load 'plugins\skript-reflect-2.1.0 (1).jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Unsupported API version 1.15
        at org.bukkit.craftbukkit.v1_13_R2.util.CraftMagicNumbers.checkSupported(CraftMagicNumbers.java:226) ~[patched_1.13.2.jar:git-Paper-655]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:130) ~[patched_1.13.2.jar:git-Paper-655]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:334) ~[patched_1.13.2.jar:git-Paper-655]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:255) ~[patched_1.13.2.jar:git-Paper-655]
        at org.bukkit.craftbukkit.v1_13_R2.CraftServer.loadPlugins(CraftServer.java:331) ~[patched_1.13.2.jar:git-Paper-655]
        at net.minecraft.server.v1_13_R2.DedicatedServer.init(DedicatedServer.java:235) ~[patched_1.13.2.jar:git-Paper-655]
        at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:787) ~[patched_1.13.2.jar:git-Paper-655]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_261]

Server information

  • skript-reflect: 2.1.0
  • Skript: 2.5-beta2
  • Paper: git-Paper-655
  • Minecraft: 1.13.2
  • Java: 1.8.0_261
  • OS: Windows 10

Looks like event priorities don't work

Priorities when listening an event don't work, i listen to the BlockBreak event like this: https://gyazo.com/5080559a7ce06ad80d7919513816522a
Normally the broadcast of skript-mirror should be after that of skript? because the priority is highest and skript is normal: https://gyazo.com/63d0e6c4a051514d5aab5e01ab1d1e56

Same with worldguard, when the event is cancelled and it use a priority less than highest but the broadcast is before skript-mirror: https://gyazo.com/e22b5ce5e01d8c646f7ef547fa464368

better syntax for custom event selection

Currently, custom events require a name entry to be used for calling the event, but this doesn't look great. An idea would be to base it off the syntax, but that won't be a good solution when your syntax becomes more complex.
Any suggestions are welcome

Consider adding api-version 1.13

Is your feature request related to a problem? Please describe.

[04:46:16 WARN]: Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
[04:46:27 WARN]: Legacy plugin skript-reflect v2.2.1 does not specify an api-version.

Describe the solution you'd like
Add api-version: 1.13 to plugin.yml of the plugin.

Describe alternatives you've considered
Leave it as-is, but not future proof. Future versions may refuse to load plugins with no api-version, however that is also the case with api-version 1.13 - a future version may require a higher api version to load or not give warnings. Basically, adding api-version hops you into Spigot's decisions, but not adding it is not a solution.

Additional context
Adding this will disable legacy plugin bytecode rewrite made by Spigot. This may throw NoSuchFieldError's on runtime even though it compiles fine if the code uses Material enum values, or such that Spigot rewrites. However this not the case mostly since Skript has aliases and Skript had api-version for a long time.

Note: Adding this to plugin.yml will not affect < 1.13. In < 1.13, the entry will just be ignored. This will only have an effect on 1.13+, so adding this will not make the plugin incompatible with < 1.13, however, if you use another value, such as, api-version: 1.14, then it will not work on 1.13.

There is an import bug...?

Describe the bug
When I reload the skript, the exception happened

To reproduce
Execute Skript reload command, then it happened

These are my codes:

import:
	com.meowj.langutils.lang.LanguageHelper
on swap items:
	if player is sneaking:
		set {_p} to player
		set {_b} to target block of {_p}
		set {_type} to {_b}.getType()
		set {_localeType} to LanguageHelper.getMaterialName({_type}, {_p})
		send action bar "&a你看向的方块是:&f %{_localeType}%" to {_p}

Expected behavior
Reload normally

Screenshots
No

Server information

  • skript-reflect: 2.2.3
  • Skript: 2.6
  • Bukkit: 1.18.1-R0.1-SNAPSHOT
  • Minecraft: 1.18.1
  • Java: 17.0.1 (Java HotSpot(TM) 64-Bit Server VM 17.0.1+12-LTS-39)
  • OS: Linux amd64 3.10.0-1160.25.1.el7.x86_64

Additional context
This is error log: https://paste.ubuntu.com/p/v2TCwnbbB9/

section API

for features such as:
try catch sections (#17)
await sections
suppressed section (surpresses parse messages)
switch case

feel free to suggest other stuff

Testers needed

I want to release the first version of this fork soon, but before I can do that, I want it to be properly tested. Because I spent a lot of time developing it, I don't have all that much time to test it. Therefore, I'm looking for people with some time on their hands to test it, with the additional benefits of having earlier access to versions and having a say in the project.

Please DM me on Discord to get involved: TPGamesNL#0880

memory leak

probably because of recent changes to variable transfer

No matching method with this fork

I've try your fork because you fixed a lot of bugs but i have an error when i use a method from FactionsX plugin (i don't try other plugins), which I don't have with the latest version of btk5h https://github.com/btk5h/skript-mirror/releases/tag/v1.0.0

Script: https://gyazo.com/d05a2e93af26fffc017a294c3602aeb5
Error (i try 5-6 versions https://github.com/TPGamesNL/skript-mirror/actions) (the latest and other): https://gyazo.com/c3bfb9f1e9500344c4815b89c43b68c0
With btk5h skript-mirror 1.0, i have no error: https://gyazo.com/7f959a91756c7a10b3a7077cfd8d430d
There is no error on startup

  • Skript: 2.2-dev36
  • Bukkit: PaperSpigot 1.8.8
  • Java: 8
  • OS: Ubuntu 18.04

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.