Solved Getting ArmorStand

Discussion in 'Plugin Development' started by KarimAKL, Jun 20, 2018.

Thread Status:
Not open for further replies.
  1. Online

    KarimAKL

    @CommonSenze I edited the post saying that i feel like an idiot. :p
     
  2. Offline

    CommonSenze

    @KarimAKL
    Oh that's simple.
    Use the boolean to check as shown below:
    Code:java
    1.  
    2. public void createStand() {
    3. if (!isAFK()) {
    4. ArmorStand stand = p.getWorld().spawn(p.getLocation().add(0, +1, 0), ArmorStand.class);
    5. stand.setGravity(false);
    6. stand.setVisible(false);
    7. Item barrier = (Item) p.getWorld().dropItem(p.getLocation().add(0, +2, 0), new ItemStack(Material.BARRIER));
    8. barrier.setPickupDelay(Integer.MAX_VALUE);
    9. stand.setPassenger(barrier);
    10. this.stand = stand;
    11. this.barrier = barrier;
    12. }
    13. this.afk = true;
    14. }
    15.  

    That way it only does it one time and when it removes it will set back to false and allow you to do it again.
     
  3. Online

    KarimAKL

    @CommonSenze Oh, i see. Thanks for the help. :D
    When i tried this and joined the server the first time it came with this error:
    Error (open)
    Code:
    [22:58:45 ERROR]: Could not pass event PlayerMoveEvent to AFK v0.1
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:270) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:126) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PacketPlayInFlying$PacketPlayInPosition.a(SourceFile:57) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_161]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_161]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_161]
    Caused by: java.lang.NullPointerException
            at me.karim.afk.listeners.PlayerMove.onMove(PlayerMove.java:23) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_161]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_161]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            ... 15 more
    
    But after leaving and joining again it didn't come with the error, should i just continue on or try solving it even though the error doesn't seem to pop up anymore?
    Anyway it works as i want it now, thanks for all the help! :D I also learned some new things from this. :)
    EDIT: Btw line 23 on PlayerMove is this:
    Code:Java
    1.  
    2. if (plugin.getAfk(p.getUniqueId()) >= 60*5 && plugin.getAFKManager().isAFK(p)) {
    3.  
     
  4. Offline

    CommonSenze

    @KarimAKL
    If the error comes again send it to me along with the class. Until then you can make this as solve.
     
  5. Online

    KarimAKL

    @CommonSenze Will do, thanks again for all the help. :) Solved.
     
Thread Status:
Not open for further replies.

Share This Page