sadUKZ Postado Maio 21, 2018 Denunciar Compartilhar Postado Maio 21, 2018 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 More sharing options...
0 zDubsCrazy2 Postado Maio 21, 2018 Denunciar Compartilhar Postado Maio 21, 2018 (editado) 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 Maio 21, 2018 por zDubsCrazy2 Link para o comentário Compartilhar em outros sites More sharing options...
0 sadUKZ Postado Maio 21, 2018 Autor Denunciar Compartilhar Postado Maio 21, 2018 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 More sharing options...
0 nOthing Postado Maio 21, 2018 Denunciar Compartilhar Postado Maio 21, 2018 Sua dúvida foi marcada como [Resolvido] e movido à área de dúvidas resolvidas. Atenciosamente, Gamer's Board Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
sadUKZ
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