Need Help with my First Plugin!

Discussion in 'Plugin Development' started by ZaynTheGreat, Dec 15, 2013.

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

    ZaynTheGreat

    http://pastebin.com/0hmHrYAK

    The plugin is meant to see if the player is blocking, and heal them.
    For some reason, it doesn't. Please help!
     
  2. ZaynTheGreat
    You put your isBlocking() if statement in your onCommand method, yet you don't have anything referencing a command. Hope that makes sense.
     
  3. Offline

    MarinD99

    You need to set p.setHealth(20), not 2.0 and deprecate it(hover the mouse over it and click deprecate ).
     
  4. Offline

    ZaynTheGreat

    So, what do I do to fix it?
     
  5. Offline

    user_90854156

    Remove your onCommand method.
    And your if statement should be like this:
    Code:java
    1. if(player.isBlocking()){
    2. player.setHealth(20);
    3. player.sendMessage("You have been healed!");
    4. }

    Since blocking isn't a command, there is no need for the onCommand method. You would need to use a Listener for the code. Not sure how to do it myself :I
     
  6. Offline

    Developing

    ZaynTheGreat You should not use the onCommand method because thats for commands and instead use a listener listening for the PlayerInteractEvent. Also, you should just set the player's health to his max health.

    Code:java
    1. @EventHandler
    2. public void onPlayerBlock(PlayerInteractEvent e){
    3. Player p = e.getPlayer();
    4. if(player.isBlocking()){
    5. player.setHealth(player.getMaxHealth());
    6. player.sendMessage("You have been healed!");
    7. }
     
  7. Offline

    mattrick

    Why would you deprecate it? Why wouldn't you give it support for when Bukkit updates and breaks plugins with ints?
     
  8. Offline

    ZaynTheGreat

    Can you show me where to add that?

    How do I define the player?

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

    HyrulesLegend

  10. Offline

    ZaynTheGreat

    Look, I'm new, I have no idea in regards to this stuff. Instead of just sighing and moving on, can you just help me please?
     
  11. Offline

    AoH_Ruthless

  12. Offline

    MarinD99

    I personally prefer deprecating. It's quicker and better.
     
  13. Offline

    AoH_Ruthless

    I am sorry for being rude, but that statement contains extremely little logic.
     
  14. Offline

    MarinD99

    It's quite alright. I'm at my cousins currently and I'm not thinking straight. I'll reply when I get home.
     
Thread Status:
Not open for further replies.

Share This Page