Heal plugin

Discussion in 'Plugin Development' started by demondking23, Feb 20, 2016.

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

    demondking23

    Hey! I need some help with a plugin, I am working on. I could find a playerkillevent so, I needed some help from some professionals, I am new and I know a little bit about coding, but If someone could help me that would be great! what I need is the code for heal. What I mean by that is , When someone kills someone , the killer gets free 3 hearts! ;)
     
  2. Online

    timtower Administrator Administrator Moderator

    Moved to plugin development.
     
  3. Offline

    SergeantBud

    Player k = e.getKiller();
    or e.getPlayer().getKiller(); idk
    And then k.setHealth(k.getHealth + 6) as 1 = half a heart
     
  4. Offline

    mine-care

    @SergeantBud Please put your code in [cοde] [/cοde] tags, and also explain it a bit more... Dont spoonfeed.
     
  5. Offline

    Zombie_Striker

  6. Offline

    pie_flavor

  7. Offline

    demondking23

    I know, I am trying to learn more, but right now, I am trying to do this :/ I need help with this. If you could, could you help me?

    What?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  8. Offline

    Evonoucono

  9. Offline

    Ethan Rocks 365

    @demondking23
    use this
    Code:
     @EventHandler
    public void onKill(PlayerDeathEvent e)
    {
    player p = e.getKiller();
    p.setHealth(p.getHealth + 6);
    }
    Be shure to register the event
    Code:
    public void onEnable{
    getServer().getPluginManager().registerEvents(this, this);
    }
    
    (plz like if this helped :))
     
  10. Offline

    Lightspeed

    e.getKiller() isn't a method. . .
     
  11. Offline

    Ethan Rocks 365

    o i thought it was
     
  12. Offline

    Gerov

    What you could do is use an EntityDamageEventEvent, check if both parties are Players, get the damage being dealt, and compare it with the player that is being hit's health, see if it would be equal to or lower than 0, if it is, give the person who killed them three hearts.
    @demondking23
     
    Lightspeed likes this.
  13. Offline

    demondking23

    Mind telling me the code? All I got is
     
  14. Offline

    Gerov

    @demondking23 Sorry, spoonfeeding isn't allowed on the forum, if I were to give you the code, then it might have been wrong, incompatible, or otherwise with your plugin. You should be able to translate what I said into your own code.
     
  15. Offline

    teej107

    Not so much allowed but just very frowned upon.
     
    mine-care likes this.
  16. Offline

    Gerov

  17. Offline

    Evonoucono

    @demondking23
    What's wrong with my method? Have you even tried it?
     
  18. Offline

    demondking23

    I dony seem to understand, because I'm new. It would be way easier, if someone gave me the code than I would understand
     
  19. Offline

    teej107

    No, you wouldn't understand. You need to understand on how to accomplish tasks with your own code! When you say you are new, are you new to programming in Java or the Bukkit API? If it's the former, then I suggest you read this: https://bukkit.org/threads/plugin-dev-sticky-learning-java-where-to-learn.395662/
     
  20. Offline

    Evonoucono

    @demondking23
    Post your code with your best attempt. Don't worry we won't laugh unless it's really funny :p
    Anyways, by doing this we will be able to tell you what you did wrong, so you can learn and reflect on it for next time. If we give you the code, you will rely on it and may not know how it works or how to alter it in the future. We want you to learn so bukkit will have more quality plugins, not trash. If you have not learned java, please do it first. Look at the link @teej107 sent you.
     
  21. Offline

    demondking23

    Already didd.....
    Alrwady

    https://bukkit.org/threads/playerdeathevent-not-working-3.408508/#post-3335099

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  22. Offline

    JoaoBM

    @demondking23 Since the code isn't in this post we won't guess your code is in the other thread.
    Now looking into the plugin:
    1. Don't name you main class Main. Also use Java Naming Conventions (http://www.oracle.com/technetwork/java/codeconventions-135099.html)
    2. Bukkit already logs messages in your console. The only thing that will use onEnable in you case will be registering the events
    3. No need for onDisable if it's not going to be used
    4. You are getting the Player's Max Health instead of setting it to max
    I just mentioned some of the things you can correct, since i'm in hurry. As for the code itself you should know the Basics of Java first before jumping into Bukkit API. It's like not knowing how to write and try to create an essay.
     
  23. Offline

    demondking23

    I am still learning both things, but I am trying to make a plugin because I'm trying to see what I have learned!
     
  24. Offline

    SergeantBud

    If there isn't a rule against something I'll do it okay ?
    I'll spoonfeed if I want to and I wont use [ code ] tags if I don't want to thanks bye
     
  25. Offline

    JoaoBM

    @SergeantBud By spoonfeeding him, he won't actually learn something you know?
     
    Zombie_Striker likes this.
  26. Offline

    Xerox262

    @SergeantBud Also helps if you post good code (not code that will throw errors if the killer has 7.5 hearts, or if the player dies by something that isn't a player), setting health greater than the player's max will throw an error.
     
  27. Offline

    Zombie_Striker

    @SergeantBud
    Yes. By you providing code and not showing him how he would figure this out for himself, you are creating more trouble for everyone around you (and for you if you answer any of his following questions).
     
    mine-care likes this.
  28. Offline

    Gerov

    @SergeantBud Think about it like this, if you had a problem and someone just gave you the cure-all answer for it, without any explanation or why it works or anything like that, what do you learn? What if you run into the same problem again down the road? You wouldn't be able to fix it. If someone actually puts the effort into making their own code from someone's explanation, then we are happy to walk them through whatever error or issue they have.
     
    mine-care, Zombie_Striker and JoaoBM like this.
  29. Offline

    mine-care

    I think you got an answer:
    Answers (open)


    Other than written rules, there are some 'rules' or -you may call it- conventions the majority of the comunity has decided upon. More or less how ethics and ethical values are in modern societies, which are decided upon from the society itself and not from an individual or a group of individuals with authority.
    Also since you decided to go by the book, spend some time reading the posting guidance, where it is clearly stated:
    And also,
    Lastly spend some time reading rule #2 of the forums which concerns your post in answer to me.

    Enough. Lets continue this argument in a discussion and go back on topic. Feel free to start one.
     
    Zombie_Striker and JoaoBM like this.
  30. Offline

    SergeantBud

    I'm not even going to bother replying to the other 4, lol. they were just unnecessary repeating eachother it feels like. Anyhow;
    - I won't get banned for not following or disagreeing with the community ?
    - Posting guidance means guidance meaning I don't have to so nty.
    - I don't call what I said personall attack or bullying lol, I wouldn't be offended fi I was you.


    and damn, im deffo not using bukkit again. Dang there's so many rules. Spoonfeeding on other websites is allg.
     
Thread Status:
Not open for further replies.

Share This Page