Ir para conteúdo
  • 1

[Bukkit] ProgressBar


sadUKZ

Pergunta

Queria saber como posso fazer um progressbar


 


ex.. o player está com 20 de vida ira mostrar [||||||||||] se ele estiver com 15 de vida ira mostrar [||||||||||] e assim em diante

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0

Descubra quanto de vida cada caractere '|' irá representar, fazendo a divisão:

int amount = 10; // quantidade de caracteres na progress bar
double lifePerChar = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() / amount;
int lifeChars = (int) (p.getHealth() / lifePerChar);

String progressBar = "";

for (int i = 0; i < lifeChars; i++)
    progressBar += ChatColor.GREEN + '|';

if (lifeChars < amount)
    for (int i = lifeChars; i < amount; i++)
        progressBar += ChatColor.RED + '|';

// ta adaptado pra 1.12, se for inferior vai ser p.getMaxHealth() mesmo
// PS: nao testei
Editado por zDubsCrazy2
Link para o comentário
Compartilhar em outros sites

  • 0

 

Descubra quanto de vida cada caractere '|' irá representar, fazendo a divisão:

int amount = 10; // quantidade de caracteres na progress bar
double lifePerChar = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() / amount;
int lifeChars = (int) (p.getHealth() / lifePerChar);

String progressBar = "";

for (int i = 0; i < lifeChars; i++)
    progressBar += ChatColor.GREEN + '|';

if (lifeChars < amount)
    for (int i = lifeChars; i < amount; i++)
        progressBar += ChatColor.RED + '|';

// ta adaptado pra 1.12, se for inferior vai ser p.getMaxHealth() mesmo
// PS: nao testei

 

 

Descubra quanto de vida cada caractere '|' irá representar, fazendo a divisão:

int amount = 10; // quantidade de caracteres na progress bar
double lifePerChar = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() / amount;
int lifeChars = (int) (p.getHealth() / lifePerChar);

String progressBar = "";

for (int i = 0; i < lifeChars; i++)
    progressBar += ChatColor.GREEN + '|';

if (lifeChars < amount)
    for (int i = lifeChars; i < amount; i++)
        progressBar += ChatColor.RED + '|';

// ta adaptado pra 1.12, se for inferior vai ser p.getMaxHealth() mesmo
// PS: nao testei

 

 

Descubra quanto de vida cada caractere '|' irá representar, fazendo a divisão:

int amount = 10; // quantidade de caracteres na progress bar
double lifePerChar = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() / amount;
int lifeChars = (int) (p.getHealth() / lifePerChar);

String progressBar = "";

for (int i = 0; i < lifeChars; i++)
    progressBar += ChatColor.GREEN + '|';

if (lifeChars < amount)
    for (int i = lifeChars; i < amount; i++)
        progressBar += ChatColor.RED + '|';

// ta adaptado pra 1.12, se for inferior vai ser p.getMaxHealth() mesmo
// PS: nao testei

 

 

Descubra quanto de vida cada caractere '|' irá representar, fazendo a divisão:

int amount = 10; // quantidade de caracteres na progress bar
double lifePerChar = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() / amount;
int lifeChars = (int) (p.getHealth() / lifePerChar);

String progressBar = "";

for (int i = 0; i < lifeChars; i++)
    progressBar += ChatColor.GREEN + '|';

if (lifeChars < amount)
    for (int i = lifeChars; i < amount; i++)
        progressBar += ChatColor.RED + '|';

// ta adaptado pra 1.12, se for inferior vai ser p.getMaxHealth() mesmo
// PS: nao testei

 

Vlw mano deu certinho

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...