yLR111 Postado Junho 20, 2017 Denunciar Compartilhar Postado Junho 20, 2017 A Scoreboard so atualiza quando eu saio e entro no servidor, queria que atualiza na hora https://pastebin.com/4VUKn0vR Link para o comentário Compartilhar em outros sites More sharing options...
Viiict0r Postado Junho 20, 2017 Denunciar Compartilhar Postado Junho 20, 2017 https://pastebin.com/fbsm9kPq private String getMoney(Player p) { DecimalFormat numberFormat = new DecimalFormat("###,###.##"); String d = numberFormat.format(econ.getBalance(p)); if (d.equalsIgnoreCase(".00")) { d = "0.0"; } return d.replace(".", ","); } Link para o comentário Compartilhar em outros sites More sharing options...
Viiict0r Postado Junho 20, 2017 Denunciar Compartilhar Postado Junho 20, 2017 public class Main extends JavaPlugin implements Listener { public static Economy econ = null; public boolean setupEconomy() { RegisteredServiceProvider<Economy> ec = getServer().getServicesManager().getRegistration(Economy.class); if (ec != null) { econ = (Economy) ec.getProvider(); } return econ != null; } public void onEnable() { getServer().getPluginManager().registerEvents(this, this); setupEconomy(); new BukkitRunnable() { @Override public void run() { for (Player p : Bukkit.getOnlinePlayers()){ Scoreboard sb = p.getScoreboard(); if (sb.getTeam("coins") != null){ Team t = sb.getTeam("coins"); long coins = (long) econ.getBalance(p); t.setSuffix(NumberFormat.getInstance().format(coins)); } } } }.runTaskTimerAsynchronously(this, 0, 20L); } public void setScore(Player p) { long coins = (long) econ.getBalance(p); Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); Objective objetivo = board.registerNewObjective("test", "dummy"); objetivo.setDisplaySlot(DisplaySlot.SIDEBAR); objetivo.setDisplayName("§4Titulo"); Team money = board.registerNewTeam("coins"); OfflinePlayer off = Bukkit.getOfflinePlayer(" §aCoins: §f"); money.addPlayer(off); money.setSuffix(NumberFormat.getInstance().format(coins)); objetivo.getScore(off.getName()).setScore(1); p.setScoreboard(board); } @EventHandler public void onJoin(PlayerJoinEvent e) { Player p = e.getPlayer(); setScore(p); } } Link para o comentário Compartilhar em outros sites More sharing options...
Hard Postado Junho 20, 2017 Denunciar Compartilhar Postado Junho 20, 2017 (editado) public static void run() { new BukkitRunnable() { public void run() { for (Player p : Bukkit.getOnlinePlayers()) setScore(p); } }.runTaskTimer(this, 0, 3); } Editado Junho 20, 2017 por Hard Link para o comentário Compartilhar em outros sites More sharing options...
yLR111 Postado Junho 20, 2017 Autor Denunciar Compartilhar Postado Junho 20, 2017 public class Main extends JavaPlugin implements Listener { public static Economy econ = null; public boolean setupEconomy() { RegisteredServiceProvider<Economy> ec = getServer().getServicesManager().getRegistration(Economy.class); if (ec != null) { econ = (Economy) ec.getProvider(); } return econ != null; } public void onEnable() { getServer().getPluginManager().registerEvents(this, this); setupEconomy(); new BukkitRunnable() { @Override public void run() { for (Player p : Bukkit.getOnlinePlayers()){ Scoreboard sb = p.getScoreboard(); if (sb.getTeam("coins") != null){ Team t = sb.getTeam("coins"); long coins = (long) econ.getBalance(p); t.setSuffix(NumberFormat.getInstance().format(coins)); } } } }.runTaskTimerAsynchronously(this, 0, 20L); } public void setScore(Player p) { long coins = (long) econ.getBalance(p); Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); Objective objetivo = board.registerNewObjective("test", "dummy"); objetivo.setDisplaySlot(DisplaySlot.SIDEBAR); objetivo.setDisplayName("§4Titulo"); Team money = board.registerNewTeam("coins"); OfflinePlayer off = Bukkit.getOfflinePlayer(" §aCoins: §f"); money.addPlayer(off); money.setSuffix(NumberFormat.getInstance().format(coins)); objetivo.getScore(off.getName()).setScore(1); p.setScoreboard(board); } @EventHandler public void onJoin(PlayerJoinEvent e) { Player p = e.getPlayer(); setScore(p); } } Vlw, outra coisa tem como deixar os "." por ","? Link para o comentário Compartilhar em outros sites More sharing options...
Viiict0r Postado Junho 20, 2017 Denunciar Compartilhar Postado Junho 20, 2017 Vlw, outra coisa tem como deixar os "." por ","? public class Main extends JavaPlugin implements Listener { public static Economy econ = null; public boolean setupEconomy() { RegisteredServiceProvider<Economy> ec = getServer().getServicesManager().getRegistration(Economy.class); if (ec != null) { econ = (Economy) ec.getProvider(); } return econ != null; } public void onEnable() { getServer().getPluginManager().registerEvents(this, this); setupEconomy(); new BukkitRunnable() { @Override public void run() { for (Player p : Bukkit.getOnlinePlayers()) { Scoreboard sb = p.getScoreboard(); if (sb.getTeam("coins") != null) { Team t = sb.getTeam("coins"); t.setSuffix(getMoney(p)); } } } }.runTaskTimerAsynchronously(this, 0, 20L); } public void setScore(Player p) { Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); Objective objetivo = board.registerNewObjective("test", "dummy"); objetivo.setDisplaySlot(DisplaySlot.SIDEBAR); objetivo.setDisplayName("§4Titulo"); Team money = board.registerNewTeam("coins"); OfflinePlayer off = Bukkit.getOfflinePlayer(" §aCoins: §f"); money.addPlayer(off); money.setSuffix(getMoney(p)); objetivo.getScore(off.getName()).setScore(1); p.setScoreboard(board); } private String getMoney(Player p) { DecimalFormat numberFormat = new DecimalFormat("###,###.##"); String d = numberFormat.format(econ.getBalance(p)); if (d.equalsIgnoreCase(".00")) { d = "0.0"; } return d; } @EventHandler public void onJoin(PlayerJoinEvent e) { Player p = e.getPlayer(); setScore(p); } } Link para o comentário Compartilhar em outros sites More sharing options...
yLR111 Postado Junho 20, 2017 Autor Denunciar Compartilhar Postado Junho 20, 2017 public class Main extends JavaPlugin implements Listener { public static Economy econ = null; public boolean setupEconomy() { RegisteredServiceProvider<Economy> ec = getServer().getServicesManager().getRegistration(Economy.class); if (ec != null) { econ = (Economy) ec.getProvider(); } return econ != null; } public void onEnable() { getServer().getPluginManager().registerEvents(this, this); setupEconomy(); new BukkitRunnable() { @Override public void run() { for (Player p : Bukkit.getOnlinePlayers()) { Scoreboard sb = p.getScoreboard(); if (sb.getTeam("coins") != null) { Team t = sb.getTeam("coins"); t.setSuffix(getMoney(p)); } } } }.runTaskTimerAsynchronously(this, 0, 20L); } public void setScore(Player p) { Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); Objective objetivo = board.registerNewObjective("test", "dummy"); objetivo.setDisplaySlot(DisplaySlot.SIDEBAR); objetivo.setDisplayName("§4Titulo"); Team money = board.registerNewTeam("coins"); OfflinePlayer off = Bukkit.getOfflinePlayer(" §aCoins: §f"); money.addPlayer(off); money.setSuffix(getMoney(p)); objetivo.getScore(off.getName()).setScore(1); p.setScoreboard(board); } private String getMoney(Player p) { DecimalFormat numberFormat = new DecimalFormat("###,###.##"); String d = numberFormat.format(econ.getBalance(p)); if (d.equalsIgnoreCase(".00")) { d = "0.0"; } return d; } @EventHandler public void onJoin(PlayerJoinEvent e) { Player p = e.getPlayer(); setScore(p); } } Não funcionou, precisa de alguma dependencia? Link para o comentário Compartilhar em outros sites More sharing options...
Viiict0r Postado Junho 20, 2017 Denunciar Compartilhar Postado Junho 20, 2017 Não funcionou, precisa de alguma dependencia? Qual o erro? Link para o comentário Compartilhar em outros sites More sharing options...
yLR111 Postado Junho 20, 2017 Autor Denunciar Compartilhar Postado Junho 20, 2017 Qual o erro? Nenhum erro, tipo coloquei tudo la, salvei o plugin fui testar continua com "." Link para o comentário Compartilhar em outros sites More sharing options...
Viiict0r Postado Junho 20, 2017 Denunciar Compartilhar Postado Junho 20, 2017 Nenhum erro, tipo coloquei tudo la, salvei o plugin fui testar continua com "." Giva uma quantidade alta de coins, se quiser que fique somente com "." Altere a linha "DecimalFormat numberFormat = new DecimalFormat("###,###.##");" para "DecimalFormat numberFormat = new DecimalFormat("###,###,##");" Link para o comentário Compartilhar em outros sites More sharing options...
yLR111 Postado Junho 20, 2017 Autor Denunciar Compartilhar Postado Junho 20, 2017 Giva uma quantidade alta de coins, se quiser que fique somente com "." Altere a linha "DecimalFormat numberFormat = new DecimalFormat("###,###.##");" para "DecimalFormat numberFormat = new DecimalFormat("###,###,##");" https://pastebin.com/fbsm9kPq Link para o comentário Compartilhar em outros sites More sharing options...
yLR111 Postado Junho 20, 2017 Autor Denunciar Compartilhar Postado Junho 20, 2017 private String getMoney(Player p) { DecimalFormat numberFormat = new DecimalFormat("###,###.##"); String d = numberFormat.format(econ.getBalance(p)); if (d.equalsIgnoreCase(".00")) { d = "0.0"; } return d.replace(".", ","); } Muito Obrigado Link para o comentário Compartilhar em outros sites More sharing options...
Viiict0r Postado Junho 20, 2017 Denunciar Compartilhar Postado Junho 20, 2017 Muito Obrigado Deixa o like ae xD 1 Link para o comentário Compartilhar em outros sites More sharing options...
Skin Postado Junho 20, 2017 Denunciar Compartilhar Postado Junho 20, 2017 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
yLR111
A Scoreboard so atualiza quando eu saio e entro no servidor, queria que atualiza na hora
https://pastebin.com/4VUKn0vR
Link para o comentário
Compartilhar em outros sites
13 respostass a esta questão
Posts Recomendados