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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Addon skript-mirror 0.19.1

Natural reflection utilities for Skript

  1. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    159
    btk5h submitted a new resource:

    skript-mirror - Natural reflection utilities for Skript

    Read more about this resource...
     
  2. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    btk5h updated skript-mirror with a new update entry:

    skript-mirror 0.2.0

    Read the rest of this update entry...
     
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    I already shut down someone else's computer with this addon. Thank you so much for this power. I might now make a JavaFX application in Skript.
    (Courtesy of Snow-Pyon):
    [​IMG]

    Code (Skript):
    1. #Shuts down the computer
    2. import "java.lang.System"
    3. import "java.lang.Runtime"
    4. set {_os} to {System}.getProperty("os.name")
    5. if {_os} contains "windows":
    6.     set {_command} to "shutdown -s"
    7. else:
    8.     set {_command} to "shutdown"
    9. {Runtime}.getRuntime().exec({_command});
    --- Double Post Merged, Jun 25, 2017, Original Post Date: Jun 25, 2017 ---
    Now we just need a way to load classes in dynamically. (Oh wait, I can try to load a library with lots of hacky methods with ClassLoader which will allow me to load in new classes)
     
  8. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    In addition to the above post, text to speech for windows users:

    Code (Skript):
    1.  
    2. on script load:
    3.  
    4.     import "java.io.File"
    5.     import "java.io.FileWriter"
    6.     import "java.lang.System"
    7.     import "java.lang.Runtime"
    8.  
    9. function textToSpeech(text: text):
    10.  
    11.     set {_new-line} to {System}.getProperty("line.separator")
    12.     set {_vbsFile} to {File}.createTempFile("text2speech" and ".vbs")
    13.     set {_vbsFileWriter} to new {FileWriter}({_vbsFile})
    14.     set {_vbsCode} to "dim speechobject%{_new-line}%set speechobject=createobject(""sapi.spvoice"")%{_new-line}%speechobject.speak ""%{_text}%"""
    15.  
    16.     {_vbsFileWriter}.write({_vbsCode});
    17.     {_vbsFileWriter}.close();
    18.  
    19.     {Runtime}.getRuntime().exec("wscript %{_vbsFile}.getPath()%");
    20.  
    21.     wait 2 ticks
    22.  
    23.     {_vbsFile}.delete();
     
    #8 ShaneBee, Jun 25, 2017
    Last edited by a moderator: Jun 25, 2017
  9. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
  10. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    com.btk5h.skriptmirror
    skript
    EffImport.class
    Code (Java):
    1.  
    2.  
    3. package com.btk5h.skriptmirror.skript;
    4.  
    5. import ch.njol.skript.Skript;
    6. import ch.njol.skript.classes.Changer.ChangeMode;
    7. import ch.njol.skript.lang.Effect;
    8. import ch.njol.skript.lang.Expression;
    9. import ch.njol.skript.lang.SkriptParser.ParseResult;
    10. import ch.njol.skript.lang.Variable;
    11. import ch.njol.skript.variables.Variables;
    12. import ch.njol.util.Kleenean;
    13. import com.btk5h.skriptmirror.JavaType;
    14. import org.bukkit.event.Event;
    15.  
    16. public class EffImport
    17.  extends Effect
    18. {
    19.   private Expression<String> className;
    20.   private Variable var;
    21.  
    22.   static
    23.   {
    24.     Skript.registerEffect(EffImport.class, new String[] { "import %string% [(as|to) [[the] var[iable]] %-object%]" });
    25.   }
    26.  
    27.   protected void execute(Event e)
    28.   {
    29.     String cls = (String)this.className.getSingle(e);
    30.     if (cls == null) {
    31.       return;
    32.     }
    33.     try
    34.     {
    35.       javaType = new JavaType(Class.forName(cls));
    36.     }
    37.     catch (ClassNotFoundException ex)
    38.     {
    39.       JavaType javaType;
    40.       Skript.warning(cls + " refers to a non-existent class."); return;
    41.     }
    42.     JavaType javaType;
    43.     if (this.var == null) {
    44.       Variables.setVariable(javaType.getJavaClass().getSimpleName().toLowerCase(), javaType, e, false);
    45.     } else {
    46.       this.var.change(e, new Object[] { javaType }, Changer.ChangeMode.SET);
    47.     }
    48.   }
    49.  
    50.   public String toString(Event e, boolean debug)
    51.   {
    52.     return "import";
    53.   }
    54.  
    55.   public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult)
    56.   {
    57.     this.className = exprs[0];
    58.     if (exprs[1] != null)
    59.     {
    60.       if (!(exprs[1] instanceof Variable)) {
    61.         return false;
    62.       }
    63.       this.var = ((Variable)exprs[1]);
    64.     }
    65.     return true;
    66.   }
    67. }
    68.  
    --- Double Post Merged, Jun 27, 2017, Original Post Date: Jun 27, 2017 ---
    EffTerminatedLine.class
    Code (Java):
    1.  
    2. package com.btk5h.skriptmirror.skript;
    3.  
    4. import ch.njol.skript.Skript;
    5. import ch.njol.skript.lang.Effect;
    6. import ch.njol.skript.lang.Expression;
    7. import ch.njol.skript.lang.SkriptParser.ParseResult;
    8. import ch.njol.skript.lang.UnparsedLiteral;
    9. import ch.njol.util.Kleenean;
    10. import org.bukkit.event.Event;
    11.  
    12. public class EffTerminatedLine
    13.   extends Effect
    14. {
    15.   private Expression<Object> arg;
    16.  
    17.   static
    18.   {
    19.     Skript.registerEffect(EffTerminatedLine.class, new String[] { "%objects%;" });
    20.   }
    21.  
    22.   protected void execute(Event e)
    23.   {
    24.     this.arg.getAll(e);
    25.   }
    26.  
    27.   public String toString(Event e, boolean debug)
    28.   {
    29.     return this.arg.toString(e, debug);
    30.   }
    31.  
    32.   public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult)
    33.   {
    34.     this.arg = exprs[0];
    35.    
    36.     return !(this.arg instanceof UnparsedLiteral);
    37.   }
    38. }
    39.  
    40.  
    41.  
    --- Double Post Merged, Jun 27, 2017 ---
    I have ( ͡° ͜ʖ ͡°) Power
     
  11. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Hey anyone know how to i get island owner in askyblock api?
    API Link: http://tastybento.github.io/askyblock/
    I tried this (Result: <none>):
    Code (Skript):
    1. on script load:
    2.     import "java.util.UUID"
    3.  
    4.     import "com.wasteofplastic.askyblock.Island"
    5.  
    6. command /heys:
    7.     trigger:
    8.         set {_x} to player.getOwner()
    9.         send "%{_x}%"
     
  12. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    @bertek41 that isn't how it works. Here is an example of usage:
    Code (Skript):
    1. on script load:
    2.     import "com.wasteofplastic.askyblock.ASkyBlockAPI"
    3.  
    4. command /heys:
    5.     trigger:
    6.         set {_island} to {ASkyBlockAPI}.getInstace().getIslandAt(player's location)
    7.         set {_owner} to {_island}.getOwner().toString() #Owner's uuid
     
    bertek41 likes this.
  13. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Hello,
    My skript don't work for me :/

    Code (Java):
    1. on script load:
    2.     import "org.dynmap.DynmapCommonAPI"
    3.  
    4. command /test:
    5.     trigger:
    6.        
    7.         {DynmapCommonAPI}.assertPlayerInvisibility(name of player, false, "MyPlugin");
     
  14. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    DynmapCommonAPI is an interface. You need an instance of an object that implements DynmapCommonAPI. You're looking for this class (more specifically, this field).
     
  15. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Ok, I think I understand, is it possible with skript-mirror? And how used the event priority with skript-mirror?
     
  16. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Code (Skript):
    1. on "some.event.package.EventClass" with priority 3:
    2. #0 = low priority.
    3. #1 = lowest priority.
    4. #2 = high priority.
    5. #3 = highest priority.
    6. #5 = normal priority.
    7.  
     
    #16 ShaneBee, Jul 16, 2017
    Last edited by a moderator: Jul 16, 2017
    Spartan9802 likes this.
  17. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Awesome !
    Really nice job, it's great to mix skript and java :3
    Do you have an example for my dynmap?
    --- Double Post Merged, Jul 18, 2017, Original Post Date: Jul 16, 2017 ---
    Hello,
    Plz help me for this ..

    Code (Java):
    1. on "org.bukkit.event.player.PlayerMoveEvent" with priority 5:
    2.     set {_player} to event.getPlayer()
    3.     if {_player} = "Spartan9802":
    4.         set {_from} to event.getFrom()
    5.         set {_to} to event.getTo()
    6.                //getRegion at {_from} in jskript-mirror
     
  18. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    What exactly is the problem?
     
  19. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Well I tried to do as in java, but I think not yet very well understood how skript-mirror works ^^
    Code (Java):
    1. set {_region} to getWorldGuard().getRegionManager({_to}.getWorld()).getApplicableRegions({_to}).iterator()
     
  20. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    You need to call getWorldGuard on an object. If it's a a static method, you need the class. If I had to guess, it would probably be located in WorldGuard's main class.
     

Share This Page

Loading...