[SOLVED] Need Help with first plugin

Discussion in 'Plugin Development' started by kvartz, Jul 20, 2011.

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

    kvartz

    Hi,

    I need help with my first plugin.
    My plugin is quite simple, i want a message to be displayed every time player dies.
    now i was trying to make message to be displayed on respawn.

    I would really appreciate some help, and if possible some comment on changes.

    https://github.com/kvartz/deathnotify



    PS I would also appreciate if someone could explain how is this "ignore" thing is working with github app for mac os x

    Server is not showing message correctly, it shows error

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  2. Offline

    Nitnelave

    What error? paste the log
     
  3. Offline

    kvartz

    i just checked there is no error in server side,
    i just was killing myself with /kill it caused an "unknown command" message in chat window
     
  4. Offline

    Nitnelave

    Did you die? it most probably is caused by the /kill command. I believe it's not included in the vanilla bukkit server. You have to use a plugin, like AdminCmd to use it.
     
  5. Offline

    kvartz

    Anyway even if i die normal way like in fire. msg is not displayed.
    so I'm sure I just have something missing in the code.

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  6. Offline

    Hretsam

    Your using the player respawn event, you need the onEntityDeath event i think.

    Anyway, the code that is in the first post is correct as far as i can see. So it would supposed to give you a message when you respawn, not when you die.
     
  7. Offline

    Nitnelave

    Isn't it because it's broadcasting the message after he dies, but before he respawns? therefore he wouldn't be counted as an online player, and would not receive the message? Just a thought.
     
  8. Offline

    Crash

    You registered the event in onEnable for an instance of Listener not deathnotifyEntityListener.
    Change this.entityListener to this.EntityListener when you register the event.
     
  9. Offline

    Nitnelave

    Oh, yeah, didn't notice the capital. Keen eye you have! In any case, I don't think you need that Listener, if you use a deathnotifyEntityListener.
     
  10. Offline

    kvartz

    thnx I'll change, and write here if it is all right

    now I'm getting this error
    Code:
    [SEVERE] Could not pass event ENTITY_DEATH to deathnotify
    java.lang.Error: Unresolved compilation problem:
        player cannot be resolved
    
        at me.kvartz.deathnotify.deathnotifyEntityListener.onEntityDeath(deathnotifyEntityListener.java:18)
        at org.bukkit.plugin.java.JavaPluginLoader$56.execute(JavaPluginLoader.java:635)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:321)
        at net.minecraft.server.EntityLiving.q(EntityLiving.java:467)
        at net.minecraft.server.EntityLiving.die(EntityLiving.java:447)
        at net.minecraft.server.EntityCreeper.die(EntityCreeper.java:87)
        at net.minecraft.server.EntityLiving.damageEntity(EntityLiving.java:391)
        at net.minecraft.server.EntityMonster.damageEntity(EntityMonster.java:43)
        at net.minecraft.server.Entity.ab(Entity.java:309)
        at net.minecraft.server.Entity.R(Entity.java:280)
        at net.minecraft.server.EntityLiving.R(EntityLiving.java:113)
        at net.minecraft.server.Entity.m_(Entity.java:201)
        at net.minecraft.server.EntityLiving.m_(EntityLiving.java:217)
        at net.minecraft.server.EntityMonster.m_(EntityMonster.java:30)
        at net.minecraft.server.EntityCreeper.m_(EntityCreeper.java:68)
        at net.minecraft.server.World.entityJoinedWorld(World.java:1190)
        at net.minecraft.server.WorldServer.entityJoinedWorld(WorldServer.java:48)
        at net.minecraft.server.World.playerJoinedWorld(World.java:1172)
        at net.minecraft.server.World.cleanUp(World.java:1102)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:447)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  11. Offline

    Vynlar

    I think someone already pointed this out, but in your line where you register the entity death event, you need to change: this.entityListener To: EntityListener

    And you only need to have one logger. There area a few cases where the "this." isn't necessary and might even be causing problems. When I get on my computer (ipad right now) I'll look at the code and help you clean it up and maybe fix your problem.

    Thanks,
    Vynlar
     
  12. Offline

    kvartz

    thnx, looking forward to it.
     
  13. Offline

    Crash

    Looks like your
    Code:
    if(event.getEntity() instanceof Player){
    Player player = (Player)event.getEntity();
    lines got removed from the onEntityDeath method, just add it back in
     
  14. Offline

    kvartz

    added it back, still not working

    plugin.getServer().broadcastMessage(ChatColor.RED + player.getName() + "test");
    I'm getting warning message: player cannot be resolved

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  15. Offline

    nisovin

    That's because that variable doesn't exist. Add that to the line above:
    Code:
    Player player = (Player)event.getEntity();
     
    kvartz likes this.
  16. Offline

    kvartz

    awesome! it is working, thanks a lot :)
    so every time I use player variable, I need to define it in this class, right?

    Solved!
    thank you guys for helping it's been great.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  17. Offline

    Vynlar

    I fixed it like 1 hour ago, but I've been trying to get my github working. Finally did and you solved it >.<
     
Thread Status:
Not open for further replies.

Share This Page