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!

code_language.skript:
import:
   org.bukkit.event.player.PlayerItemBreakEvent
on PlayerItemBreakEvent:
   broadcast "test"



> [23:49:40 ERROR]: #!#! Stack trace:
> [23:49:40 ERROR]: #!#! java.lang.NullPointerException
> [23:49:40 ERROR]: #!#! at org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack.addUnsafeEnchantment(CraftItemStack.java:189)
> [23:49:40 ERROR]: #!#! at ch.njol.skript.effects.EffEnchant.execute(EffEnchant.java:83)
> [23:49:40 ERROR]: #!#! at ch.njol.skript.lang.Effect.run(Effect.java:52)
> [23:49:40 ERROR]: #!#! at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:61)
> [23:49:40 ERROR]: #!#! at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:89)
> [23:49:40 ERROR]: #!#! at ch.njol.skript.lang.Trigger.execute(Trigger.java:55)
> [23:49:40 ERROR]: #!#! at ch.njol.skript.SkriptEventHandler.check(SkriptEventHandler.ja
 
Hi @btk5h ,
I have a strange error with the new API version of the GPS plugin, here is my code it returns me an "internal error" there is also an error in the console
Java:
import:
    com.live.bemmamin.gps.api.GPSAPI
    ch.njol.skript.Skript
    
on load:
    set {GPSAPI} to new GPSAPI(Skript.getInstance())
    
command /test:
    trigger:
        send "%{GPSAPI}.getClass()%"

My Console Error:
https://pastebin.com/TZvuegZB
 
can you make so we can suppress errors from imports
code_language.skript:
import:
    try com.wasteofplastic.askyblock.ASkyBlockAPI
thanks
 
  • Like
Reactions: BaeFell
I want to do both.
But I don't know Java syntax and can only use skript
Can you help me?
@Uzumaki @Pikachu
Code:
import com.intellectualcrafters.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.SubCommand;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.flag.Flags;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.util.BukkitUtil;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

/**
* Get all plots for the player.
*
* @param world The world to retrieve plots from
* @param player The player to search for
* @param justOwner should we just search for owner? Or with rights?
* @return An array of plots for the player
*/
@Deprecated
public Plot[] getPlots(World world, Player player, boolean justOwner) {
ArrayList<Plot> pPlots = new ArrayList<>();
UUID uuid = BukkitUtil.getPlayer(player).getUUID();
for (Plot plot : PS.get().getPlots(world.getName())) {
if (justOwner) {
if (plot.hasOwner() && plot.isOwner(uuid)) {
pPlots.add(plot);
}
} else if (plot.isAdded(uuid)) {
pPlots.add(plot);
}
}
return pPlots.toArray(new Plot[0]);
}

/**
* Get home location.
*
* @param plot Plot that you want to get the location for
*
* @return plot bottom location
*
* @see Plot
*/
public Location getHomeLocation(Plot plot) {
return BukkitUtil.getLocation(plot.getHome());
}
[code/]
[doublepost=1560674337,1558809926][/doublepost]0.16.1 update to 0.19.1 error


Code:
on "lk.vexview.event.KeyBoardPressEvent" with priority high:
    set {_ki} to event.getKey()

[16:16:20 INFO]: [Skript] Reloading 1.sk...
[16:16:21 ERROR]: can't understand this event: 'on "lk.vexview.event.KeyBoardPressEvent" with priority high' (1.sk, line 99: on "lk.vexview.event.KeyBoardPressEvent" with priority high:')
[16:16:21 INFO]: [Skript] Encountered 1 error while reloading 1.sk!
 
0.16.1 update to 0.19.1 error


Code:
on "lk.vexview.event.KeyBoardPressEvent" with priority high:
    set {_ki} to event.getKey()

[16:16:20 INFO]: [Skript] Reloading 1.sk...
[16:16:21 ERROR]: can't understand this event: 'on "lk.vexview.event.KeyBoardPressEvent" with priority high' (1.sk, line 99: on "lk.vexview.event.KeyBoardPressEvent" with priority high:')
[16:16:21 INFO]: [Skript] Encountered 1 error while reloading 1.sk!
Take a look at https://skript-mirror.gitbook.io/docs/basics/handling-events
 
Thank you, I have learned the operation of the event.
But there is a question, when placing the armor frame, can be access to player information?
Like who put the armor rack
Yes, you have to use methods from the event expression.
 
Hey so i tried to switch to skript-mirror 2.0.0 due to the log handler issue but it breaks so many of my skripts and i cant find any documentation about it

code_language.skript:
on load:
        set {mcoin} to new ItemStack(Material.EMERALD!)
        set {_meta} to {mcoin}.getItemMeta()
        set {_lore} to new ArrayList()
        {_lore}.add("&a&oMelville Currency")
        {_meta}.setLore({_lore})
        {_meta}.setDisplayName("&e✪ MCoin ✪")
        {_meta}.setUnbreakable(true)
        {_meta}.addEnchant(Enchantment.LUCK!, 10, true)
        {_meta}.addItemFlags([ItemFlag.HIDE_ENCHANTS!, ItemFlag.HIDE_UNBREAKABLE!])
        {mcoin}.setItemMeta({_meta})

on EntityTargetLivingEntityEvent:
        event.getEntityType() is EntityType.PHANTOM!
        set {_p} to event.getTarget()
        {_p} is instance of Player
        {_p}.hasPotionEffect(PotionEffectType.NIGHT_VISION!) is true
        {_p}.getStatistic(Statistic.TIME_SINCE_REST!) < 72000
        cancel event

on PlayerInteractEntityEvent:
        set {_p} to event.getPlayer()
        event.getHand() is EquipmentSlot.HAND!
        "%lore of {_p}'s tool%" contains "adult":
                event.setCancelled(true)
                if {_p} can build at location at {_p}:
                        set {_e} to event.getRightClicked()
                        if {_e} is instance of Ageable:
                                set {_s} to {_p}.getWorld().spawnEntity({_e}.getLocation(), {_e}.getType())
                                {_s}.setBaby()
                                set {_t} to {_p}'s tool
                                remove 1 of {_t} from {_p}


[16:24:33 ERROR]: The function 'ItemStack' does not exist. (vote.sk, line 13: set {mcoin} to new ItemStack(Material.EMERALD!)')
[16:24:33 ERROR]: LUCK!, 10, true is not a valid descriptor. (vote.sk, line 20: {_meta}.addEnchant(Enchantment.LUCK!, 10, true)#Enchantments have Fields and thus require the "!"')
[16:24:33 ERROR]: Can't understand this condition/effect: {_meta}.addItemFlags([ItemFlag.HIDE_ENCHANTS!, ItemFlag.HIDE_UNBREAKABLE!]) (vote.sk, line 21: {_meta}.addItemFlags([ItemFlag.HIDE_ENCHANTS!, ItemFlag.HIDE_UNBREAKABLE!])#an array is simply made by [%value% and %value2% etc]')
[16:24:33 ERROR]: The function 'ItemStack' does not exist. (vote.sk, line 27: set {mgrand} to new ItemStack(Material.EMERALD_BLOCK!)')
[16:24:33 ERROR]: LUCK!, 10, true is not a valid descriptor. (vote.sk, line 34: {_meta}.addEnchant(Enchantment.LUCK!, 10, true)#Enchantments have Fields and thus require the "!"')
[16:24:33 ERROR]: Can't understand this condition/effect: {_meta}.addItemFlags([ItemFlag.HIDE_ENCHANTS!, ItemFlag.HIDE_UNBREAKABLE!]) (vote.sk, line 35: {_meta}.addItemFlags([ItemFlag.HIDE_ENCHANTS!, ItemFlag.HIDE_UNBREAKABLE!])#an array is simply made by [%value% and %value2% etc]')
[16:24:42 ERROR]: Can't understand this condition/effect: event.getEntityType() is EntityType.PHANTOM! (shopitems.sk, line 33: event.getEntityType() is EntityType.PHANTOM!')
[16:24:42 ERROR]: Can't understand this condition/effect: {_p}.hasPotionEffect(PotionEffectType.NIGHT_VISION!) is true (shopitems.sk, line 36: {_p}.hasPotionEffect(PotionEffectType.NIGHT_VISION!) is true')
[16:24:42 ERROR]: Can't compare '{_p}.getStatistic(Statistic.TIME_SINCE_REST!)' with an integer (shopitems.sk, line 37: {_p}.getStatistic(Statistic.TIME_SINCE_REST!) < 72000')
[16:24:42 ERROR]: Can't understand this condition/effect: event.getHand() is EquipmentSlot.HAND! (shopitems.sk, line 43: event.getHand() is EquipmentSlot.HAND!')
[16:24:42 WARN]: List is missing 'and' or 'or', defaulting to 'and': {_e}.getLocation(), {_e}.getType() (shopitems.sk, line 49: set {_s} to {_p}.getWorld().spawnEntity({_e}.getLocation(), {_e}.getType())')
[16:24:42 ERROR]: TIME_SINCE_REST!, 0 is not a valid descriptor. (shopitems.sk, line 63: {_p}.setStatistic(Statistic.TIME_SINCE_REST!, 0)')
[16:24:42 WARN]: List is missing 'and' or 'or', defaulting to 'and': {_m}.getType(), 1 (shopitems.sk, line 82: event.setResult(new ItemStack({_m}.getType(), 1))')
[16:24:42 ERROR]: Can't understand this condition/effect: arg-1.hasPotionEffect(PotionEffectType.NIGHT_VISION!) is true (shopitems.sk, line 93: arg-1.hasPotionEffect(PotionEffectType.NIGHT_VISION!) is true')
[16:24:42 ERROR]: Can't understand this expression: arg-1.getStatistic(Statistic.TIME_SINCE_REST!) (shopitems.sk, line 99: send  "%arg-1.getStatistic(Statistic.TIME_SINCE_REST!)%"')

should i just go back to the "stable" version here or is there any documentation available?
 
Last edited:
You need to remove the !
ex:
Code:
{_meta}.addItemFlags([ItemFlag.HIDE_ENCHANTS!, ItemFlag.HIDE_UNBREAKABLE!])
should be
code_language.skript:
{_meta}.addItemFlags([ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_UNBREAKABLE])
 
Playing around with mirror stuff and citizens.

Why does this return <none> ?

Code:
import:
    net.citizensnpcs.npc.CitizensNPCRegistry as NPCRegistry
    
command /example [<text>] [<text>]:
    trigger:
        set {_npc} to NPCRegistry.getById(1)
        send "%{_npc}%"
 
Playing around with mirror stuff and citizens.

Why does this return <none> ?

Code:
import:
    net.citizensnpcs.npc.CitizensNPCRegistry as NPCRegistry
   
command /example [<text>] [<text>]:
    trigger:
        set {_npc} to NPCRegistry.getById(1)
        send "%{_npc}%"
because that method is not a static method, so you need to get an instance fo that class.
 
Is there a way to override the factions EntityDamageByEntityEvent ? i want to uncancel this event for players in same factions in a region
My code :
Code:
on all EntityDamageEvent and EntityDamageByEntityEvent with priority HIGHEST:
  broadcast "e"
  uncancel event
But it don't work and there is no broadcast.
I tried on all EntityDamageEvent with priority HIGHEST:
and on all EntityDamageByEntityEvent with priority HIGHEST:
but nothing change
My faction plugin is SaberFactions and it's code :
5d7a46a752e10ea52e60eaa7ab7c3579.png
 
Is there a way to override the factions EntityDamageByEntityEvent ? i want to uncancel this event for players in same factions in a region
My code :
Code:
on all EntityDamageEvent and EntityDamageByEntityEvent with priority HIGHEST:
  broadcast "e"
  uncancel event
But it don't work and there is no broadcast.
I tried on all EntityDamageEvent with priority HIGHEST:
and on all EntityDamageByEntityEvent with priority HIGHEST:
but nothing change
My faction plugin is SaberFactions and it's code :
5d7a46a752e10ea52e60eaa7ab7c3579.png

Due to how mirror/skript parses its events try exact the same code but with a restart. If u register a event its put at that syntax and won't update with a skreload:

Prioritys do update with a skreload the all expression not.

The second thing bc ur events go trough skript skript>skript-mirror. so if skript decides to stop an event u won't recieve it with mirror even with prio highest and all. Now what u can do is get the responsible event so on damage: and uncancel that event. now the other events in mirror should continue working.
 
Due to how mirror/skript parses its events try exact the same code but with a restart. If u register a event its put at that syntax and won't update with a skreload:

Prioritys do update with a skreload the all expression not.

The second thing bc ur events go trough skript skript>skript-mirror. so if skript decides to stop an event u won't recieve it with mirror even with prio highest and all. Now what u can do is get the responsible event so on damage: and uncancel that event. now the other events in mirror should continue working.
Hey thanks for your help ! I tried to restart the server and add "on damage: uncancel event" but nothing change
Code:
import:
  org.bukkit.event.entity.EntityDamageEvent
  org.bukkit.event.entity.EntityDamageByEntityEvent

on damage:
  uncancel event

# on all EntityDamageEvent with priority highest:                   # It didn't work so i tried this but nothing change, no broadcast
#   broadcast "e"
# 
# on all EntityDamageByEntityEvent with priority highest:
#   broadcast "f"

on all EntityDamageEvent and EntityDamageByEntityEvent with priority highest:
  broadcast "both"
 
Hey thanks for your help ! I tried to restart the server and add "on damage: uncancel event" but nothing change
Code:
import:
  org.bukkit.event.entity.EntityDamageEvent
  org.bukkit.event.entity.EntityDamageByEntityEvent

on damage:
  uncancel event

# on all EntityDamageEvent with priority highest:                   # It didn't work so i tried this but nothing change, no broadcast
#   broadcast "e"
#
# on all EntityDamageByEntityEvent with priority highest:
#   broadcast "f"

on all EntityDamageEvent and EntityDamageByEntityEvent with priority highest:
  broadcast "both"

Can u try this + restart.

Code:
import:
  org.bukkit.event.entity.EntityDamageEvent
  org.bukkit.event.entity.EntityDamageByEntityEvent

on damage:
  uncancel event

on EntityDamageEvent with priority highest:
   broadcast "e"

on EntityDamageByEntityEvent with priority highest:
   broadcast "f"