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!

btk5h

Addon Developer
Jan 25, 2017
154
159
0
Pyongyang, North Korea
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):
image.png


code_language.skript:
#Shuts down the computer
import "java.lang.System"
import "java.lang.Runtime"
set {_os} to {System}.getProperty("os.name")
if {_os} contains "windows":
    set {_command} to "shutdown -s"
else:
    set {_command} to "shutdown"
{Runtime}.getRuntime().exec({_command});
[doublepost=1498356908,1498356673][/doublepost]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)
 
In addition to the above post, text to speech for windows users:

code_language.skript:
on script load:

    import "java.io.File"
    import "java.io.FileWriter"
    import "java.lang.System"
    import "java.lang.Runtime"

function textToSpeech(text: text):

    set {_new-line} to {System}.getProperty("line.separator")
    set {_vbsFile} to {File}.createTempFile("text2speech" and ".vbs")
    set {_vbsFileWriter} to new {FileWriter}({_vbsFile})
    set {_vbsCode} to "dim speechobject%{_new-line}%set speechobject=createobject(""sapi.spvoice"")%{_new-line}%speechobject.speak ""%{_text}%"""

    {_vbsFileWriter}.write({_vbsCode});
    {_vbsFileWriter}.close();

    {Runtime}.getRuntime().exec("wscript %{_vbsFile}.getPath()%");

    wait 2 ticks

    {_vbsFile}.delete();
 
Last edited by a moderator:
com.btk5h.skriptmirror
skript
EffImport.class
Java:
package com.btk5h.skriptmirror.skript;

import ch.njol.skript.Skript;
import ch.njol.skript.classes.Changer.ChangeMode;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.Variable;
import ch.njol.skript.variables.Variables;
import ch.njol.util.Kleenean;
import com.btk5h.skriptmirror.JavaType;
import org.bukkit.event.Event;

public class EffImport
  extends Effect
{
  private Expression<String> className;
  private Variable var;
 
  static
  {
    Skript.registerEffect(EffImport.class, new String[] { "import %string% [(as|to) [[the] var[iable]] %-object%]" });
  }
 
  protected void execute(Event e)
  {
    String cls = (String)this.className.getSingle(e);
    if (cls == null) {
      return;
    }
    try
    {
      javaType = new JavaType(Class.forName(cls));
    }
    catch (ClassNotFoundException ex)
    {
      JavaType javaType;
      Skript.warning(cls + " refers to a non-existent class."); return;
    }
    JavaType javaType;
    if (this.var == null) {
      Variables.setVariable(javaType.getJavaClass().getSimpleName().toLowerCase(), javaType, e, false);
    } else {
      this.var.change(e, new Object[] { javaType }, Changer.ChangeMode.SET);
    }
  }
 
  public String toString(Event e, boolean debug)
  {
    return "import";
  }
 
  public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult)
  {
    this.className = exprs[0];
    if (exprs[1] != null)
    {
      if (!(exprs[1] instanceof Variable)) {
        return false;
      }
      this.var = ((Variable)exprs[1]);
    }
    return true;
  }
}
[doublepost=1498536472,1498536426][/doublepost]EffTerminatedLine.class
Java:
package com.btk5h.skriptmirror.skript;

import ch.njol.skript.Skript;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.UnparsedLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;

public class EffTerminatedLine
  extends Effect
{
  private Expression<Object> arg;
 
  static
  {
    Skript.registerEffect(EffTerminatedLine.class, new String[] { "%objects%;" });
  }
 
  protected void execute(Event e)
  {
    this.arg.getAll(e);
  }
 
  public String toString(Event e, boolean debug)
  {
    return this.arg.toString(e, debug);
  }
 
  public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult)
  {
    this.arg = exprs[0];
   
    return !(this.arg instanceof UnparsedLiteral);
  }
}
[doublepost=1498536509][/doublepost]I have ( ͡° ͜ʖ ͡°) Power
 
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_language.skript:
on script load:
    import "java.util.UUID"

    import "com.wasteofplastic.askyblock.Island"

command /heys:
    trigger:
        set {_x} to player.getOwner()
        send "%{_x}%"
 
@bertek41 that isn't how it works. Here is an example of usage:
code_language.skript:
on script load:
    import "com.wasteofplastic.askyblock.ASkyBlockAPI"

command /heys:
    trigger:
        set {_island} to {ASkyBlockAPI}.getInstace().getIslandAt(player's location)
        set {_owner} to {_island}.getOwner().toString() #Owner's uuid
 
  • Like
Reactions: bertek41
Hello,
My skript don't work for me :/

Java:
on script load:
    import "org.dynmap.DynmapCommonAPI"

command /test:
    trigger:
        
        {DynmapCommonAPI}.assertPlayerInvisibility(name of player, false, "MyPlugin");
 
Hello,
My skript don't work for me :/

Java:
on script load:
    import "org.dynmap.DynmapCommonAPI"

command /test:
    trigger:
       
        {DynmapCommonAPI}.assertPlayerInvisibility(name of player, false, "MyPlugin");
DynmapCommonAPI is an interface. You need an instance of an object that implements DynmapCommonAPI. You're looking for this class (more specifically, this field).
 
Ok, I think I understand, is it possible with skript-mirror? And how used the event priority with skript-mirror?
 
Ok, I think I understand, is it possible with skript-mirror? And how used the event priority with skript-mirror?
code_language.skript:
on "some.event.package.EventClass" with priority 3: 
#0 = low priority.
#1 = lowest priority.
#2 = high priority.
#3 = highest priority.
#5 = normal priority.
 
Last edited by a moderator:
  • Like
Reactions: Spartan9802
Awesome !
Really nice job, it's great to mix skript and java :3
Do you have an example for my dynmap?
[doublepost=1500398012,1500234900][/doublepost]Hello,
Plz help me for this ..

Java:
on "org.bukkit.event.player.PlayerMoveEvent" with priority 5:
    set {_player} to event.getPlayer()
    if {_player} = "Spartan9802":
        set {_from} to event.getFrom()
        set {_to} to event.getTo()
               //getRegion at {_from} in jskript-mirror
 
Hello,
Plz help me for this ..

Java:
on "org.bukkit.event.player.PlayerMoveEvent" with priority 5:
    set {_player} to event.getPlayer()
    if {_player} = "Spartan9802":
        set {_from} to event.getFrom()
        set {_to} to event.getTo()
               //getRegion at {_from} in jskript-mirror
What exactly is the problem?
 
Well I tried to do as in java, but I think not yet very well understood how skript-mirror works ^^
Java:
set {_region} to getWorldGuard().getRegionManager({_to}.getWorld()).getApplicableRegions({_to}).iterator()
 
Well I tried to do as in java, but I think not yet very well understood how skript-mirror works ^^
Java:
set {_region} to getWorldGuard().getRegionManager({_to}.getWorld()).getApplicableRegions({_to}).iterator()
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.