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.

Solved Skull Owner

Discussion in 'Java' started by Uzumaki, Jul 16, 2018.

  1. Uzumaki

    Uzumaki Well-Known Member

    Joined:
    Feb 20, 2017
    Messages:
    307
    Likes Received:
    10
    This is the skellet skull owner expression, I will really appreciate if anybody could fix it


    Code:

    Code (Java):
    1. package com.gmail.thelimeglass.Expressions;
    2.  
    3. import javax.annotation.Nullable;
    4.  
    5. import org.bukkit.OfflinePlayer;
    6. import org.bukkit.block.Block;
    7. import org.bukkit.block.BlockState;
    8. import org.bukkit.block.Skull;
    9. import org.bukkit.event.Event;
    10.  
    11. import com.gmail.thelimeglass.Utils.Annotations.Config;
    12. import com.gmail.thelimeglass.Utils.Annotations.PropertyType;
    13. import com.gmail.thelimeglass.Utils.Annotations.Syntax;
    14.  
    15. import ch.njol.skript.classes.Changer;
    16. import ch.njol.skript.classes.Changer.ChangeMode;
    17. import ch.njol.skript.lang.Expression;
    18. import ch.njol.skript.lang.ExpressionType;
    19. import ch.njol.skript.lang.SkriptParser.ParseResult;
    20. import ch.njol.skript.lang.util.SimpleExpression;
    21. import ch.njol.util.Kleenean;
    22. import ch.njol.util.coll.CollectionUtils;
    23.  
    24. @Syntax({"[the] [skellett] skull[ ]owner of [skull] %block%", "[skellett] [skull] %block%'s skull[ ]owner"})
    25. @Config("SkullOwner")
    26. @PropertyType(ExpressionType.COMBINED)
    27. public class ExprSkullBlockOwner extends SimpleExpression<OfflinePlayer>{
    28.    
    29.     private Expression<Block> skull;
    30.     @Override
    31.     public Class<? extends OfflinePlayer> getReturnType() {
    32.         return OfflinePlayer.class;
    33.     }
    34.     @Override
    35.     public boolean isSingle() {
    36.         return true;
    37.     }
    38.     @SuppressWarnings("unchecked")
    39.     @Override
    40.     public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
    41.         skull = (Expression<Block>) e[0];
    42.         return true;
    43.     }
    44.     @Override
    45.     public String toString(@Nullable Event e, boolean arg1) {
    46.         return "[the] skull[ ]owner of [skull] %block%";
    47.     }
    48.     @Override
    49.     @Nullable
    50.     protected OfflinePlayer[] get(Event e) {
    51.         BlockState state = skull.getSingle(e).getState();
    52.         if (state instanceof Skull) {
    53.             Skull skull = (Skull) state;
    54.             return new OfflinePlayer[]{skull.getOwningPlayer()};
    55.         }
    56.         return null;
    57.     }
    58.     @Override
    59.     public void change(Event e, Object[] delta, Changer.ChangeMode mode){
    60.         if (mode == ChangeMode.SET) {
    61.             BlockState state = skull.getSingle(e).getState();
    62.             if (state instanceof Skull) {
    63.                 Skull skull = (Skull) state;
    64.                 skull.setOwningPlayer((OfflinePlayer)delta[0]);
    65.                 skull.update();
    66.             }
    67.         }
    68.     }
    69.     @Override
    70.     public Class<?>[] acceptChange(final Changer.ChangeMode mode) {
    71.         if (mode == ChangeMode.SET) {
    72.             return CollectionUtils.array(OfflinePlayer.class);
    73.         }
    74.         return null;
    75.     }
    76. }
    Error:

    Code (Skript):
    1. [18:34:41 ERROR]: Could not pass event PlayerCommandPreprocessEvent to Skript v2.2-dev27
    2. org.bukkit.event.EventException
    3.         at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot.jar:git-Spigot-21fe707-e1ebe52]
    4.         at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-21fe707-e1ebe52]
    5.         at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    6.         at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    7.         at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1154) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    8.         at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    9.         at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    10.         at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    11.         at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    12.         at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_171]
    13.         at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_171]
    14.         at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    15.         at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    16.         at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    17.         at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    18.         at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    19.         at java.lang.Thread.run(Unknown Source) [?:1.8.0_171]
    20. Caused by: java.lang.NoSuchMethodError: org.bukkit.block.Skull.setOwningPlayer(Lorg/bukkit/OfflinePlayer;)V
    21.         at com.gmail.thelimeglass.Expressions.ExprSkullBlockOwner.change(ExprSkullBlockOwner.java:59) ~[?:?]
    22.         at ch.njol.skript.effects.EffChange.execute(EffChange.java:271) ~[?:?]
    23.         at ch.njol.skript.lang.Effect.run(Effect.java:52) ~[?:?]
    24.         at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:61) ~[?:?]
    25.         at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:89) ~[?:?]
    26.         at ch.njol.skript.lang.Trigger.execute(Trigger.java:55) ~[?:?]
    27.         at ch.njol.skript.command.ScriptCommand.execute2(ScriptCommand.java:220) ~[?:?]
    28.         at ch.njol.skript.command.ScriptCommand.execute(ScriptCommand.java:182) ~[?:?]
    29.         at ch.njol.skript.command.Commands.handleCommand(Commands.java:268) ~[?:?]
    30.         at ch.njol.skript.command.Commands$1.onPlayerCommand(Commands.java:163) ~[?:?]
    31.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_171]
    32.         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
    33.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
    34.         at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_171]
    35.         at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-21fe707-e1ebe52]
    36.         ... 16 more
    37. [18:34:41 ERROR]: null
    38. org.bukkit.command.CommandException: Unhandled exception executing command 'test' in plugin Skript v2.2-dev27
    39.         at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-21fe707-e1ebe52]
    40.         at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-21fe707-e1ebe52]
    41.         at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot.jar:git-Spigot-21fe707-e1ebe52]
    42.         at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    43.         at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    44.         at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    45.         at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    46.         at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    47.         at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_171]
    48.         at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_171]
    49.         at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    50.         at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    51.         at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    52.         at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    53.         at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-21fe707-e1ebe52]
    54.         at java.lang.Thread.run(Unknown Source) [?:1.8.0_171]
    55. Caused by: java.lang.NoSuchMethodError: org.bukkit.block.Skull.setOwningPlayer(Lorg/bukkit/OfflinePlayer;)V
    56.         at com.gmail.thelimeglass.Expressions.ExprSkullBlockOwner.change(ExprSkullBlockOwner.java:59) ~[?:?]
    57.         at ch.njol.skript.effects.EffChange.execute(EffChange.java:271) ~[?:?]
    58.         at ch.njol.skript.lang.Effect.run(Effect.java:52) ~[?:?]
    59.         at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:61) ~[?:?]
    60.         at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:89) ~[?:?]
    61.         at ch.njol.skript.lang.Trigger.execute(Trigger.java:55) ~[?:?]
    62.         at ch.njol.skript.command.ScriptCommand.execute2(ScriptCommand.java:220) ~[?:?]
    63.         at ch.njol.skript.command.ScriptCommand.execute(ScriptCommand.java:182) ~[?:?]
    64.         at ch.njol.skript.command.ScriptCommand.onCommand(ScriptCommand.java:159) ~[?:?]
    65.         at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-21fe707-e1ebe52]
    66.         ... 15 more
    67. >
    --- Double Post Merged, Jul 16, 2018, Original Post Date: Jul 16, 2018 ---
    nvm, found that you can update skull using nbt.
     

Share This Page

Loading...