skript-mirror

Addon skript-mirror 0.19.1

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Initializing a datawatcher constructor through the skript-mirror null syntax seems to give off this error:
Code:
constructor DataWatcher#<init> called with (null (Null)) threw a ClassCastException: Cannot cast com.btk5h.skriptmirror.Null to net.minecraft.server.v1_8_R3.Entity
Code:
import "net.minecraft.server.v1_8_R3.DataWatcher"
set {_datawatcher} to new {DataWatcher}(null object)

There are spigot posts that have been able to initialize it without an entity, am I doing something wrong?
 
Initializing a datawatcher constructor through the skript-mirror null syntax seems to give off this error:
Code:
constructor DataWatcher#<init> called with (null (Null)) threw a ClassCastException: Cannot cast com.btk5h.skriptmirror.Null to net.minecraft.server.v1_8_R3.Entity
Code:
import "net.minecraft.server.v1_8_R3.DataWatcher"
set {_datawatcher} to new {DataWatcher}(null object)

There are spigot posts that have been able to initialize it without an entity, am I doing something wrong?
That's a strange issue. I'll look into it and see if it can be fixed in one or two versions.
 
  • Like
Reactions: Decalers
Hello @btk5h can you help me to create event every change player's balance?
Code:
on "org.appledash.saneeconomy.event.SaneEconomyTransactionEvent" with priority 5:
  set {_players::*} to event.getHandlers().toArray()
  loop {_players::*}:
    broadcast "%loop-value%"
 
Last edited by a moderator:
Hello @btk5h can you help me to create event every change player's balance?
Code:
on "org.appledash.saneeconomy.event.SaneEconomyTransactionEvent" with priority 5:
  set {_players::*} to event.getHandlers().toArray()
  loop {_players::*}:
    broadcast "%loop-value%"
you have to use the array spread expression to convert an array of objects to a skript list. It should be like this:
code_language.skript:
set {_players::*} to ...(event.getHandlers())

I surrounded the event.getHandlers() just to be sure it'll be parsed correctly.
 
Last edited by a moderator:

Attachments

  • Zrzut ekranu 2017-08-02 o 21.35.41.png
    Zrzut ekranu 2017-08-02 o 21.35.41.png
    36.5 KB · Views: 322
Well, the handlers aren't what you're thinking. You should do the following for get the players involved on the transaction.
code_language.skript:
set {_transaction} to event.getTransaction() #gets the Transaction object from this event.
#https://github.com/AppleDash/SaneEconomy/blob/master/SaneEconomyCore/src/main/java/org/appledash/saneeconomy/economy/transaction/Transaction.java

set {_sender} to {_transaction}.getSender() #gets who sends the money from the transaction object.
set {_receiver} to {_transaction}.getReceiver() #gets who receives the money from the transaction object.
#both returns an Economable object:
#https://github.com/AppleDash/SaneEconomy/blob/master/SaneEconomyCore/src/main/java/org/appledash/saneeconomy/economy/economable/Economable.java
 
http://imgur.com/a/xaZjA
How can I convert this to player's name?
Change {_transaction}.getSender() and {_transaction}.getReceiver() to {_transaction}.getSender().handle! and {_transaction}.getReceiver().handle!

Keep in mind, your code will only work assuming transactions only occur between players. If a transaction occurs with a non-player (the console, a faction, etc.), your code will break unless you make the appropriate checks.

Also, don't set an event priority unless you really need to. Event priorities are changing in 0.7.0, so the best way to stay compatible is to avoid using them.
 
Change {_transaction}.getSender() and {_transaction}.getReceiver() to {_transaction}.getSender().handle! and {_transaction}.getReceiver().handle!

Keep in mind, your code will only work assuming transactions only occur between players. If a transaction occurs with a non-player (the console, a faction, etc.), your code will break unless you make the appropriate checks.

Also, don't set a priority unless you really need to. Event priorities are changing in 0.7.0, so the best way to stay compatible is to avoid using them.

Code:
[21:52:49 ERROR]: Can't understand this expression: '{_transaction}..getSender().handle!' (gui.sk, line 25: set {_sender} to {_transaction}..getSender().handle!')

[21:52:49 ERROR]: Can't understand this expression: '{_transaction}..getReceiver().handle!' (gui.sk, line 26: set {_receiver} to {_transaction}..getReceiver().handle!')

There is two errors.
 
Code:
[21:52:49 ERROR]: Can't understand this expression: '{_transaction}..getSender().handle!' (gui.sk, line 25: set {_sender} to {_transaction}..getSender().handle!')

[21:52:49 ERROR]: Can't understand this expression: '{_transaction}..getReceiver().handle!' (gui.sk, line 26: set {_receiver} to {_transaction}..getReceiver().handle!')

There is two errors.
Small copy-paste typo. I fixed it in an edit a few seconds before you replied.
 
A syntax for creating an array of a specific type would be really useful.
There is an expression for casting objects

code_language.skript:
%objects% (as|converted to) %classinfo/javatype%

Which can be used like

code_language.skript:
[{test::*} as string]
 
There is an expression for casting objects

code_language.skript:
%objects% (as|converted to) %classinfo/javatype%

Which can be used like

code_language.skript:
[{test::*} as string]
It only seems to work for JavaTypes and not imported classes. For example, creating a URL array.
 
Last edited by a moderator:
Dang, I was so close. This would be amazing if it were possible.

Code:
command /load:
    trigger:
        import "java.io.File"
        import "java.net.URLClassLoader"
        import "java.net.URL"
        set {_url} to [new {File}("c:/twitter4j-core-4.0.4.jar").toURL() converted to java type "java.net.URL"]
        set {_classloader} to new {URLClassLoader}({_url})
        set {_twitter4j} to {_classloader}.loadClass("twitter4j.TwitterFactory").newInstance() //Calling any method or constructor fails.

https://hastebin.com/raw/etemewobol.bash
 
Last edited by a moderator:
Dang, I was so close. This would be amazing if it were possible.

Code:
command /load:
    trigger:
        import "java.io.File"
        import "java.net.URLClassLoader"
        import "java.net.URL"
        set {_url} to [new {File}("c:/twitter4j-core-4.0.4.jar").toURL() converted to java type "java.net.URL"]
        set {_classloader} to new {URLClassLoader}({_url})
        set {_twitter4j} to {_classloader}.loadClass("twitter4j.TwitterFactory").newInstance() //Calling any method or constructor fails.

https://hastebin.com/raw/etemewobol.bash
From the error you've posted, it looks like skript-mirror is failing in the error handler, causing it to swallow the original exception and throw a misleading one (which is not very helpful). It looks like a version mismatch with your version of Skript.

As for your issue, you should be able to specify the classpath when you launch your server.
 
As for your issue, you should be able to specify the classpath when you launch your server.
What does this mean

Are you referring to this?
Code:
java -Xmx2048M -jar spigot_1.8.8_latest.jar -o true -cp twitter4j-core-4.0.4.jar
Although that is helpful, when it comes to shared hosting you generally cannot change your server startup parameters. Also, just overall dynamic class loading would be pretty cool.
 
Last edited by a moderator:
What does this mean

Are you referring to this?
Code:
java -Xmx2048M -jar spigot_1.8.8_latest.jar -o true -cp twitter4j-core-4.0.4.jar
Although that is helpful, when it comes to shared hosting you generally cannot change your server startup parameters. Also, just overall dynamic class loading would be pretty cool.
I'll look into loading additional library jars.
 
  • Like
Reactions: Decalers