Xp countdown?

Discussion in 'Plugin Development' started by PizzaPixel, Mar 24, 2014.

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

    PizzaPixel

    How would i Make a countdown on the xp bar. And when it hits 0 it does something
     
  2. Offline

    MCPvPCraft

    Code:java
    1. final int ID;
    2.  
    3. p.setExp(1);
    4. ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
    5. public void run() {
    6. p.setExp(p.getExp() - 0.1);
    7. if (p.getExp() == 0) {
    8. p.setVelocity(new Vector(0, 1, 0)); // just some fun code
    9. Bukkit.getScheduler().cancelTask(ID);
    10. }
    11. }
    12. }, 0, 2)


    or something like that and then just set the players xp to 0.1 less
     
  3. Offline

    PizzaPixel

  4. Offline

    MCPvPCraft

    PizzaPixel Well first we set the players xp to 1. Then we start a repeating timer and assign it id. every 2 ticks the players xp bar will be set to 0.1 xp less and if the xp of the player is 0 we cancel the task and then do some stuff with the player. Note sure if the code works though, i havent tested it yet :p

    oh, and btw you need to define the ID variable in the top of your class
     
  5. Offline

    PizzaPixel

    MCPvPCraft kk

    MCPvPCraft What does p equal???

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

    MCPvPCraft

  7. Offline

    PizzaPixel

    Player p = //What do i put here
     
  8. Offline

    MCPvPCraft

  9. Offline

    PizzaPixel

  10. Offline

    AoH_Ruthless

    PizzaPixel
    What you are defining as p depends on the method.
     
  11. Offline

    PizzaPixel

    AoH_Ruthless I know im just tired and Bored and i cant think
     
  12. Offline

    MCPvPCraft

    PizzaPixel well it doesn't looks like you know how to, because you just asked me what a player is and how to define it lol
     
  13. Offline

    PizzaPixel

    MCPvPCraft I didnt ask what a player is and how to define it I think your confused
     
  14. Offline

    AoH_Ruthless

    MCPvPCraft
    I think he was asking in the specific code you gave him, what can be used as a representation of p. But I completely agree :p

    PizzaPixel
    If you are bored and aren't thinking, stop coding. You need an open-mind: We can't (and won't) just spell everything out.
     
    MCPvPCraft likes this.
  15. Offline

    PizzaPixel

    AoH_Ruthless Lol I dont even remember what my plugin is about
     
  16. Offline

    AoH_Ruthless

    PizzaPixel
    Yeah, I suggest you stop now and take a break.
     
  17. Offline

    PizzaPixel

    AoH_Ruthless Lol
    Im just gonna go eat so Bye

    AoH_Ruthless Crap I have nothing left in my fridge what should i do

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

    AoH_Ruthless

    PizzaPixel
    Not go farther and farther off-topic from what the purpose of this thread was (imo worse than just saying bump)!
     
  19. Offline

    PizzaPixel

  20. Offline

    Hellborn5456

    PizzaPixel
    Code:
    public static void expTimer(int time){
        for(Player p : Bukkit.getOnlinePlayers){
            p.setLevel(time);
        } 
    }
     
  21. Offline

    Wizehh

    You should eat some pizza.
     
    PizzaPixel and Venexor like this.
Thread Status:
Not open for further replies.

Share This Page