Need Help with Plugin: Stamina bar

Discussion in 'Plugin Development' started by Aplenator, May 6, 2014.

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

    Aplenator

    I need some help creating a plugin, what I'm trying to do is to replace the exp bar with a stamina bar so I will need it to slowly deplete when sprinting, sneaking, combat(using swords etc.), so when depleted you cant run, combat or sneak only walk until the bar starts to regain.
    as I am new here I may not know much and I am still learning however this is what I've come up with so far:
    Code:java
    1. package plugin.main;
    2.  
    3. import java.util.HashMap;
    4. import java.util.UUID;
    5.  
    6. import org.bukkit.Bukkit;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.event.EventHandler;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.event.player.PlayerJoinEvent;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. /**
    14. * @author ioncann0ns
    15. */
    16. public class PluginMain extends JavaPlugin implements Listener{
    17.  
    18. HashMap<UUID, String> mobChallengeList = new HashMap<UUID, String>();
    19.  
    20. @Override
    21. public void onEnable() {
    22. Bukkit.getPluginManager().registerEvents(new LoginListener(), this);
    23. getLogger().info("Looking good so far!");
    24. }
    25.  
    26. public void onDisable() {
    27. getLogger().info("Bye Administrator");
    28. }
    29. private class LoginListener implements Listener
    30. {
    31. @EventHandler
    32. public void onLogin(PlayerJoinEvent event)
    33. {
    34. Player player = event.getPlayer();
    35. player.getWalkSpeed();
    36. player.setWalkSpeed((float).07);{
    37. player.setSneaking(false);
    38. player.setSprinting(false);
    39. for (int counter=0;counter<=18;counter++)
    40. player.giveExp(1);
    41. System.out.println("[Plugin] Player " + player.getName() + " walk speed now: " + player.getWalkSpeed() + "; sneaking: " + player.isSneaking());
    42. }
    43.  
    44. }
    45. }
    46. }[/syntax]
    47.  
    48. i heard someone used fake enderdragons for the xp
    49.  
    50. EDIT by Moderator: merged posts, please use the edit button instead of double posting.[/Plugin]
     
    Last edited by a moderator: Jun 8, 2016
  2. Offline

    RawCode

    learn java first.
     
  3. Offline

    Aplenator

  4. Offline

    Epixpenguin

    You probably don't want to try and spawn in enderdragons but I think there is a method in the player class to give xp. So if you create a for loop so that the player is given enough xp.
     
Thread Status:
Not open for further replies.

Share This Page