Solved Setblock Offline Player heads with Skript-mirror

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

MartinOdum

Member
Jan 26, 2017
112
13
18
Skript Version (do not put latest): Skript 2.3 beta 2
Skript Author: Bensku
Minecraft Version: 1.13.2

What I want to do:
My end goal is to make a top 10 wealthiest players head leaderboard, I have enough experience to do everything except actually placing the player heads in the world, as far as I know vanilla skript cannot do this in 1.13.2 but if I am wrong please let me know, the next option is addons, from what I have searched no addon can do this and either way if it is possible with skript-mirror I would prefer that over depending on various different addons that may lose support over time (I know that means fully depending on skript-mirror but whatever I'll put my chips on that)

What I have attempted:
code_language.skript:
command /headtest:
    trigger:
        set {_Material} to java class "org.bukkit.Material"
        set {_ItemStack} to java class "org.bukkit.inventory.ItemStack"
        set {_SkullType} to java class "org.bukkit.SkullType"
        set {_Bukkit} to the java class "org.bukkit.Bukkit"
        set {_UUID} to the java class "java.util.UUID"
        set {_skull} to new {_ItemStack}({_Material}.PLAYER_HEAD!)
        set {_meta} to {_skull}.getItemMeta()
        {_meta}.setOwningPlayer({_Bukkit}.getOfflinePlayer({_UUID}.fromString("69d6eeb5-1458-4a4e-8616-2e3c3b0638aa")))
        {_skull}.setItemMeta({_meta})
        give player {_skull}
        set block at location -507, 65, -215 in world "world" to {_skull}
I know i'm gonna catch shit for the way I import the classes as local variables but thats just how I do it when I'm testing, my results are that I will be given the player head with the texture if they player has previously joined the server and it will place on the wall without the skin texture, so I suppose I have two questions:
1) How can I get the player head with texture if the player has never joined the server?
2) How can I get it to place on the wall with the texture?
I have tried alot of things so this is kind of my last ditch effort to reach out for help because I couldn't figure it out on my own, there are many examples on how to do this with java but with versions before 1.13, it changed a bit on 1.13 and idk if that is affecting me or what it is that I am doing wrong, thanks for the help in advance
 
Skript Version (do not put latest): Skript 2.3 beta 2
Skript Author: Bensku
Minecraft Version: 1.13.2

What I want to do:
My end goal is to make a top 10 wealthiest players head leaderboard, I have enough experience to do everything except actually placing the player heads in the world, as far as I know vanilla skript cannot do this in 1.13.2 but if I am wrong please let me know, the next option is addons, from what I have searched no addon can do this and either way if it is possible with skript-mirror I would prefer that over depending on various different addons that may lose support over time (I know that means fully depending on skript-mirror but whatever I'll put my chips on that)

What I have attempted:
code_language.skript:
command /headtest:
    trigger:
        set {_Material} to java class "org.bukkit.Material"
        set {_ItemStack} to java class "org.bukkit.inventory.ItemStack"
        set {_SkullType} to java class "org.bukkit.SkullType"
        set {_Bukkit} to the java class "org.bukkit.Bukkit"
        set {_UUID} to the java class "java.util.UUID"
        set {_skull} to new {_ItemStack}({_Material}.PLAYER_HEAD!)
        set {_meta} to {_skull}.getItemMeta()
        {_meta}.setOwningPlayer({_Bukkit}.getOfflinePlayer({_UUID}.fromString("69d6eeb5-1458-4a4e-8616-2e3c3b0638aa")))
        {_skull}.setItemMeta({_meta})
        give player {_skull}
        set block at location -507, 65, -215 in world "world" to {_skull}
I know i'm gonna catch shit for the way I import the classes as local variables but thats just how I do it when I'm testing, my results are that I will be given the player head with the texture if they player has previously joined the server and it will place on the wall without the skin texture, so I suppose I have two questions:
1) How can I get the player head with texture if the player has never joined the server?
2) How can I get it to place on the wall with the texture?
I have tried alot of things so this is kind of my last ditch effort to reach out for help because I couldn't figure it out on my own, there are many examples on how to do this with java but with versions before 1.13, it changed a bit on 1.13 and idk if that is affecting me or what it is that I am doing wrong, thanks for the help in advance
As far as I know you can just use vanilla Skript (https://skriptlang.github.io/Skript/expressions.html#ExprSkull) for this.
EDIT:
Wouldn't it be easier to use import (https://skript-mirror.gitbook.io/docs/basics/importing-classes) for the classes?
 
As far as I know you can just use vanilla Skript (https://skriptlang.github.io/Skript/expressions.html#ExprSkull) for this.
EDIT:
Wouldn't it be easier to use import (https://skript-mirror.gitbook.io/docs/basics/importing-classes) for the classes?
The vanilla skript seems to be broken, running this simple code:
code_language.skript:
command /headtest2:
    trigger:
        give player's skull to the player
Gives this error:
[02:06:07] [Server thread/ERROR]: #!#! [Skript] Severe Error:
[02:06:07] [Server thread/ERROR]: #!#!
[02:06:07] [Server thread/ERROR]: #!#! Something went horribly wrong with Skript.
[02:06:07] [Server thread/ERROR]: #!#! This issue is NOT your fault! You probably can't fix it yourself, either.
[02:06:07] [Server thread/ERROR]: #!#! It looks like you are using some plugin(s) that alter how Skript works (addons).
[02:06:07] [Server thread/ERROR]: #!#! Here is full list of them:
[02:06:07] [Server thread/ERROR]: #!#! skRayFall (https://sk.rayfall.net/) skript-mirror (https://github.com/btk5h/skript-mirror) skUtilities (https://tim740.github.io/) MundoSK (https://forums.skunity.com/resources/mundosk.69/) Skellett (https://forums.skunity.com/resources/skellett-the-addon-with-a-beast-name.24/) skript-db
[02:06:07] [Server thread/ERROR]: #!#! We could not identify which of those are specially related, so this might also be Skript issue.
[02:06:07] [Server thread/ERROR]: #!#! You should try disabling those plugins one by one, trying to find which one causes it.
[02:06:07] [Server thread/ERROR]: #!#! If the error doesn't disappear even after disabling all listed plugins, it is probably Skript issue.
[02:06:07] [Server thread/ERROR]: #!#! In that case, you will be given instruction on how should you report it.
[02:06:07] [Server thread/ERROR]: #!#! On the other hand, if the error disappears when disabling some plugin, report it to author of that plugin.
[02:06:07] [Server thread/ERROR]: #!#! Only if the author tells you to do so, report it as Skript issue (url below)
[02:06:07] [Server thread/ERROR]: #!#! Issue tracker: https://github.com/SkriptLang/Skript/issues (only if you know what you're doing!)
[02:06:07] [Server thread/ERROR]: #!#!
[02:06:07] [Server thread/ERROR]: #!#! Stack trace:
[02:06:07] [Server thread/ERROR]: #!#! java.lang.UnsupportedOperationException: 1.13 update
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.expressions.ExprSkull.convert(ExprSkull.java:104)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.expressions.ExprSkull.convert(ExprSkull.java:1)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.registrations.Converters.convert(Converters.java:342)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.registrations.Converters.convertUnsafe(Converters.java:333)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.expressions.base.PropertyExpression.get(PropertyExpression.java:104)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.expressions.base.SimplePropertyExpression.get(SimplePropertyExpression.java:55)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.expressions.base.PropertyExpression.get(PropertyExpression.java:75)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.util.SimpleExpression.getArray(SimpleExpression.java:102)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.effects.EffChange.execute(EffChange.java:278)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.Effect.run(Effect.java:52)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:61)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:89)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.Trigger.execute(Trigger.java:57)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.command.ScriptCommand.execute2(ScriptCommand.java:286)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.command.ScriptCommand.execute(ScriptCommand.java:243)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.command.Commands.handleCommand(Commands.java:257)
[02:06:07] [Server thread/ERROR]: #!#! at ch.njol.skript.command.Commands$1.onPlayerCommand(Commands.java:172)
[02:06:07] [Server thread/ERROR]: #!#! at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[02:06:07] [Server thread/ERROR]: #!#! at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[02:06:07] [Server thread/ERROR]: #!#! at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[02:06:07] [Server thread/ERROR]: #!#! at java.base/java.lang.reflect.Method.invoke(Unknown Source)
[02:06:07] [Server thread/ERROR]: #!#! at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:304)
[02:06:07] [Server thread/ERROR]: #!#! at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
[02:06:07] [Server thread/ERROR]: #!#! at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500)
[02:06:07] [Server thread/ERROR]: #!#! at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485)
[02:06:07] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_13_R2.PlayerConnection.handleCommand(PlayerConnection.java:1640)
[02:06:07] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_13_R2.PlayerConnection.a(PlayerConnection.java:1483)
[02:06:07] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_13_R2.PacketPlayInChat.a(PacketPlayInChat.java:45)
[02:06:07] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_13_R2.PacketPlayInChat.a(PacketPlayInChat.java:1)
[02:06:07] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_13_R2.PlayerConnectionUtils.a(SourceFile:10)
[02:06:07] [Server thread/ERROR]: #!#! at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
[02:06:07] [Server thread/ERROR]: #!#! at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
[02:06:07] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_13_R2.SystemUtils.a(SourceFile:199)
[02:06:07] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_13_R2.MinecraftServer.b(MinecraftServer.java:900)
[02:06:07] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:417)
[02:06:07] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:835)
[02:06:07] [Server thread/ERROR]: #!#! at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:733)
[02:06:07] [Server thread/ERROR]: #!#! at java.base/java.lang.Thread.run(Unknown Source)
[02:06:07] [Server thread/ERROR]: #!#!
[02:06:07] [Server thread/ERROR]: #!#! Version Information:
[02:06:07] [Server thread/ERROR]: #!#! Skript: 2.3-beta2 (latest)
[02:06:07] [Server thread/ERROR]: #!#! Bukkit: 1.13.2-R0.1-SNAPSHOT
[02:06:07] [Server thread/ERROR]: #!#! Minecraft: 1.13.2
[02:06:07] [Server thread/ERROR]: #!#! Java: 10.0.2 (Java HotSpot(TM) 64-Bit Server VM 10.0.2+13)
[02:06:07] [Server thread/ERROR]: #!#! OS: Windows 10 amd64 10.0
[02:06:07] [Server thread/ERROR]: #!#!
[02:06:07] [Server thread/ERROR]: #!#! Server platform: Spigot
[02:06:07] [Server thread/ERROR]: #!#!
[02:06:07] [Server thread/ERROR]: #!#! Current node: null
[02:06:07] [Server thread/ERROR]: #!#! Current item: add the skull of the player to the player
[02:06:07] [Server thread/ERROR]: #!#! Current trigger: command /headtest2 (simple event) (newtest.sk, line -1)
[02:06:07] [Server thread/ERROR]: #!#!
[02:06:07] [Server thread/ERROR]: #!#! Thread: Server thread
[02:06:07] [Server thread/ERROR]: #!#!
[02:06:07] [Server thread/ERROR]: #!#! Language: english
[02:06:07] [Server thread/ERROR]: #!#! Link parse mode: DISABLED
[02:06:07] [Server thread/ERROR]: #!#!
[02:06:07] [Server thread/ERROR]: #!#! End of Error.
[02:06:07] [Server thread/ERROR]: #!#!
As for the imports:
I know i'm gonna catch shit for the way I import the classes as local variables but thats just how I do it when I'm testing
 
Seems like you should report it to Skript then
 
Seems like you should report it to Skript then
I probably will once I have time to confirm that its not an addon conflicting and that it is actually a vanilla skript bug, I would still love help with doing this with skript-mirror regardless as I am trying to get better with java and skript-mirror coding has helped quite alot. I've tried alot of variations of code and spent too damn long trying to figure it out to end up not knowing how to properly do it with java and use vanilla skript lol
 
code_language.skript:
import:
    org.bukkit.SkullType

effect place skull of %offlineplayer% at %location%:
    trigger:
        set {_block} to expression-2.getBlock()
        set block at {_block} to floor head
        set {_state} to {_block}.getState()
        minecraft version contains "1.8":
            {_state}.setOwner("%expression-1%")
        else:
            {_state}.setOwningPlayer("%expression-1%")
        {_state}.update()
 
code_language.skript:
import:
    org.bukkit.SkullType

effect place skull of %offlineplayer% at %location%:
    trigger:
        set {_block} to expression-2.getBlock()
        set block at {_block} to floor head
        set {_state} to {_block}.getState()
        minecraft version contains "1.8":
            {_state}.setOwner("%expression-1%")
        else:
            {_state}.setOwningPlayer("%expression-1%")
        {_state}.update()
Thank you! The code did not work from the get go for my version (1.13.2) but I modified it just a tad bit, here are my edits for anyone it may help provided with the code I used to test it:
code_language.skript:
import:
    org.bukkit.SkullType
    org.bukkit.Material
    org.bukkit.inventory.ItemStack
 
effect place skull of %offlineplayer% at %location%:
    trigger:
        set {_block} to expression-2.getBlock()
        set block at {_block} to new ItemStack(Material.PLAYER_WALL_HEAD!)
        set {_state} to {_block}.getState()
        minecraft version contains "1.8":
            {_state}.setOwner("%expression-1%")
        else:
            {_state}.setOwningPlayer(expression-1)
        {_state}.update()
on right click:
    set {_p} to "Drom" parsed as offline player
    place skull of {_p} at location of clicked block
The one thing I noticed again is that it will not texture the head if the player has not previously joined the server, I know this because I attempted random player names and the heads would not be textured, is there any way to get this to work with players who have never joined the server? I'm assuming the only way is through editing the nbt/using nms code right? Technically speaking I should never run into issues as anyone who may be in my top 10 leaderboard would obviously join the server but I'm just curious
 
Status
Not open for further replies.