Solved My Plugin isn't working...

Discussion in 'Plugin Development' started by RAFA_GATO_FOFO, Apr 6, 2014.

Thread Status:
Not open for further replies.
  1. Hey guys,

    Absolutelly nothing happens and I'm confused... Can someone please help?
    All I'm supposed to have so far is the following:
    • Player gets randomly placed on either Alien or Predator Team.
    • Player received a book to change teams.
    • Command to check which team player is placed on.
    Here's the code:



    I know it's a lot of code but if someone took the time to read through it to find whatever it is I did wrong, many many thanks to you!

    Cheers.
     
  2. Offline

    EnderTroll68

    Add debugging code, such as
    Bukkit.broadcastMessage("1")
    to figure out where your server breaks
     
  3. Offline

    BillyBobJoe168

    add @EventHandler over your public void part.
     
  4. Alright so I forgot to add @EventHandler before onPlayerJoin. Thanks, that debugging thing helps a lot!

    So now the only thing not working is the Book Part.

    I received the Book and Team upon login but when I click the book it doesn't change teams, there's probably an error there since it doesn't break.
    Also the /whatteam command isn't working, this error shows up:
    Code:
    [01:24:16 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'what
    team' in plugin AVP v1.0
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[cra
    ftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:17
    5) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServe
    r.java:683) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerCon
    nection.java:952) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java
    :814) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java
    :28) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat
    .java:47) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    tbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    55) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    Caused by: java.lang.NullPointerException
            at me.rafagatofofo.AVP.AVPMain.onCommand(AVPMain.java:114) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[cra
    ftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            ... 13 more
    >
    [01:25:23 INFO]: Unknown command. Type "help" for help.
    >
     
  5. Offline

    SainttX

    RAFA_GATO_FOFO
    Code:java
    1. Team.getTeamType(((Player) sender))

    is returning null for you, so when you call .name on that null value it throws the NPE.
     
  6. SainttX
    When I connect it shows in chat that I've joined either of the teams, so I'm guessing the assigning is done correctly. Why is it returning null then?
     
  7. Offline

    Zethariel

    I'll start off by saying that storing players ANYWHERE is bad practice - it can cause errors and memory leaks. Use player names or UUID's exclusively.
     
  8. Zethariel

    I'm adding player.getName(); not the full data.

    EDIT:

    The command is working now, there was a small error in the getTeamType command.
    My only problem now lies in this part of the code. If the player joins Team Alien, when he clicks the Book he gets placed on the Alien Team again instead of the Predator Team.

    If the player gets placed on Team Predator on join he can join Team Alien though.




    Solved. Thanks for those who helped.
     
Thread Status:
Not open for further replies.

Share This Page