public static ArrayList<String> onlineInList(ArrayList<String> playersToFind) { ArrayList<String> returnPlayers = new ArrayList<String>(); List<GuiPlayerInfo> onlinePlayers = mc.thePlayer.sendQueue.playerInfoList; // Cycle through every player that's online. for (GuiPlayerInfo player : onlinePlayers) { String playerName = player.name.replaceAll("\u00A7.", ""); // Cycle through all the players in the specified list (friends). for (String friend : playersToFind) { // Use startsWith because names are sometimes cut off in tab. if (friend.startsWith(playerName)) { // Add the whole friend's name instead of the potentiall cut-off version. returnPlayers.add(friend); } } } return returnPlayers; }
public static String getColorPrefix(String playerName) { // Cycle through each online player. for (GuiPlayerInfo player : getPlayersGui()) { if (player.name.startsWith("\u00A7")) { String realName = player.name.replaceAll("\u00A7.(.*)", "$1"); if (playerName.startsWith(realName)) return player.name.replaceAll("\u00A7(.).*", "$1"); } if (player.name.endsWith(playerName) && player.name.startsWith("\u00A7")) { return player.name.replaceAll("\u00A7(.).*", "$1"); } } return " "; }
protected boolean isOnline(String user) { if (Minecraft.getMinecraft().getNetHandler() == null || Minecraft.getMinecraft().getNetHandler().playerInfoList == null) return false; Iterator iter = Minecraft.getMinecraft().getNetHandler().playerInfoList.iterator(); while (iter.hasNext()) { if (user.equals(((GuiPlayerInfo)iter.next()).name)) return true; } return false; }
public static int getTeamsLeft() { ArrayList<String> found = new ArrayList<String>(); for (GuiPlayerInfo info : ServerHelper.getPlayersGui()) { String prefix = ServerHelper.getColorPrefix(info.name); if (AllTeam.getTeamFromColor(prefix.charAt(0)) == AllTeam.NONE || AllTeam.getTeamFromColor(prefix.charAt(0)) == AllTeam.GRAY) continue; if (!found.contains(ServerHelper.getColorPrefix(info.name))) { found.add(ServerHelper.getColorPrefix(info.name)); } } return found.size(); }
public static ArrayList<String> onlineInListOnTeam(ArrayList checkPlayers, TeamCTF team) { ArrayList<String> returnPlayers = new ArrayList<String>(); List<GuiPlayerInfo> onlinePlayers = mc.thePlayer.sendQueue.playerInfoList; for (GuiPlayerInfo player : onlinePlayers) { String playerName = player.name.replaceAll("\u00A7.", ""); if (checkPlayers.contains(playerName) && TeamCTF.getTeam(playerName).equals(team)) { returnPlayers.add(playerName); } } return returnPlayers; }
/** * @return A list of all player's as EntityPlayers. The list of players * is identical to what is showing in tab. */ public static List<EntityPlayer> getPlayers() { List<EntityPlayer> players = new ArrayList<EntityPlayer>(); for (GuiPlayerInfo player : getPlayersGui()) { players.add(Main.mc.theWorld.getPlayerEntityByName(player.name)); } return players; }
@SuppressWarnings("unchecked") protected void renderPlayerList(int width, int height) { ScoreObjective scoreobjective = this.field_73839_d.field_71441_e.func_96441_U().func_96539_a(0); NetHandlerPlayClient handler = field_73839_d.field_71439_g.field_71174_a; if (field_73839_d.field_71474_y.field_74321_H.func_151470_d() && (!field_73839_d.func_71387_A() || handler.field_147303_b.size() > 1 || scoreobjective != null)) { if (pre(PLAYER_LIST)) return; this.field_73839_d.field_71424_I.func_76320_a("playerList"); List<GuiPlayerInfo> players = (List<GuiPlayerInfo>)handler.field_147303_b; int maxPlayers = handler.field_147304_c; int rows = maxPlayers; int columns = 1; for (columns = 1; rows > 20; rows = (maxPlayers + columns - 1) / columns) { columns++; } int columnWidth = 300 / columns; if (columnWidth > 150) { columnWidth = 150; } int left = (width - columns * columnWidth) / 2; byte border = 10; func_73734_a(left - 1, border - 1, left + columnWidth * columns, border + 9 * rows, Integer.MIN_VALUE); for (int i = 0; i < maxPlayers; i++) { int xPos = left + i % columns * columnWidth; int yPos = border + i / columns * 9; func_73734_a(xPos, yPos, xPos + columnWidth - 1, yPos + 8, 553648127); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_ALPHA_TEST); if (i < players.size()) { GuiPlayerInfo player = (GuiPlayerInfo)players.get(i); ScorePlayerTeam team = field_73839_d.field_71441_e.func_96441_U().func_96509_i(player.field_78831_a); String displayName = ScorePlayerTeam.func_96667_a(team, player.field_78831_a); fontrenderer.func_78261_a(displayName, xPos, yPos, 16777215); if (scoreobjective != null) { int endX = xPos + fontrenderer.func_78256_a(displayName) + 5; int maxX = xPos + columnWidth - 12 - 5; if (maxX - endX > 5) { Score score = scoreobjective.func_96682_a().func_96529_a(player.field_78831_a, scoreobjective); String scoreDisplay = EnumChatFormatting.YELLOW + "" + score.func_96652_c(); fontrenderer.func_78261_a(scoreDisplay, maxX - fontrenderer.func_78256_a(scoreDisplay), yPos, 16777215); } } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); field_73839_d.func_110434_K().func_110577_a(Gui.field_110324_m); int pingIndex = 4; int ping = player.field_78829_b; if (ping < 0) pingIndex = 5; else if (ping < 150) pingIndex = 0; else if (ping < 300) pingIndex = 1; else if (ping < 600) pingIndex = 2; else if (ping < 1000) pingIndex = 3; field_73735_i += 100.0F; func_73729_b(xPos + columnWidth - 12, yPos, 0, 176 + pingIndex * 8, 10, 8); field_73735_i -= 100.0F; } } post(PLAYER_LIST); } }
@SuppressWarnings("unchecked") protected void renderPlayerList(int width, int height) { ScoreObjective scoreobjective = this.mc.theWorld.getScoreboard().func_96539_a(0); NetHandlerPlayClient handler = mc.thePlayer.sendQueue; if (mc.gameSettings.keyBindPlayerList.getIsKeyPressed() && (!mc.isIntegratedServerRunning() || handler.playerInfoList.size() > 1 || scoreobjective != null)) { if (pre(PLAYER_LIST)) return; this.mc.mcProfiler.startSection("playerList"); List<GuiPlayerInfo> players = (List<GuiPlayerInfo>)handler.playerInfoList; int maxPlayers = handler.currentServerMaxPlayers; int rows = maxPlayers; int columns = 1; for (columns = 1; rows > 20; rows = (maxPlayers + columns - 1) / columns) { columns++; } int columnWidth = 300 / columns; if (columnWidth > 150) { columnWidth = 150; } int left = (width - columns * columnWidth) / 2; byte border = 10; drawRect(left - 1, border - 1, left + columnWidth * columns, border + 9 * rows, Integer.MIN_VALUE); for (int i = 0; i < maxPlayers; i++) { int xPos = left + i % columns * columnWidth; int yPos = border + i / columns * 9; drawRect(xPos, yPos, xPos + columnWidth - 1, yPos + 8, 553648127); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_ALPHA_TEST); if (i < players.size()) { GuiPlayerInfo player = (GuiPlayerInfo)players.get(i); ScorePlayerTeam team = mc.theWorld.getScoreboard().getPlayersTeam(player.name); String displayName = ScorePlayerTeam.formatPlayerName(team, player.name); fontrenderer.drawStringWithShadow(displayName, xPos, yPos, 16777215); if (scoreobjective != null) { int endX = xPos + fontrenderer.getStringWidth(displayName) + 5; int maxX = xPos + columnWidth - 12 - 5; if (maxX - endX > 5) { Score score = scoreobjective.getScoreboard().func_96529_a(player.name, scoreobjective); String scoreDisplay = EnumChatFormatting.YELLOW + "" + score.getScorePoints(); fontrenderer.drawStringWithShadow(scoreDisplay, maxX - fontrenderer.getStringWidth(scoreDisplay), yPos, 16777215); } } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.getTextureManager().bindTexture(Gui.icons); int pingIndex = 4; int ping = player.responseTime; if (ping < 0) pingIndex = 5; else if (ping < 150) pingIndex = 0; else if (ping < 300) pingIndex = 1; else if (ping < 600) pingIndex = 2; else if (ping < 1000) pingIndex = 3; zLevel += 100.0F; drawTexturedModalRect(xPos + columnWidth - 12, yPos, 0, 176 + pingIndex * 8, 10, 8); zLevel -= 100.0F; } } post(PLAYER_LIST); } }
/** * @return A list of all player's GuiInfo. The list of players * is identical to what is showing in tab. */ public static List<GuiPlayerInfo> getPlayersGui() { if (Main.mc.thePlayer == null) return new ArrayList<GuiPlayerInfo>(); return Main.mc.thePlayer.sendQueue.playerInfoList; }
protected void renderPlayerList(int width, int height) { ScoreObjective scoreobjective = this.mc.theWorld.getScoreboard().func_96539_a(0); NetClientHandler handler = mc.thePlayer.sendQueue; if (mc.gameSettings.keyBindPlayerList.pressed && (!mc.isIntegratedServerRunning() || handler.playerInfoList.size() > 1 || scoreobjective != null)) { if (pre(PLAYER_LIST)) return; this.mc.mcProfiler.startSection("playerList"); List players = handler.playerInfoList; int maxPlayers = handler.currentServerMaxPlayers; int rows = maxPlayers; int columns = 1; for (columns = 1; rows > 20; rows = (maxPlayers + columns - 1) / columns) { columns++; } int columnWidth = 300 / columns; if (columnWidth > 150) { columnWidth = 150; } int left = (width - columns * columnWidth) / 2; byte border = 10; drawRect(left - 1, border - 1, left + columnWidth * columns, border + 9 * rows, Integer.MIN_VALUE); for (int i = 0; i < maxPlayers; i++) { int xPos = left + i % columns * columnWidth; int yPos = border + i / columns * 9; drawRect(xPos, yPos, xPos + columnWidth - 1, yPos + 8, 553648127); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_ALPHA_TEST); if (i < players.size()) { GuiPlayerInfo player = (GuiPlayerInfo)players.get(i); ScorePlayerTeam team = mc.theWorld.getScoreboard().getPlayersTeam(player.name); String displayName = ScorePlayerTeam.formatPlayerName(team, player.name); fontrenderer.drawStringWithShadow(displayName, xPos, yPos, 16777215); if (scoreobjective != null) { int endX = xPos + fontrenderer.getStringWidth(displayName) + 5; int maxX = xPos + columnWidth - 12 - 5; if (maxX - endX > 5) { Score score = scoreobjective.getScoreboard().func_96529_a(player.name, scoreobjective); String scoreDisplay = EnumChatFormatting.YELLOW + "" + score.getScorePoints(); fontrenderer.drawStringWithShadow(scoreDisplay, maxX - fontrenderer.getStringWidth(scoreDisplay), yPos, 16777215); } } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.getTextureManager().bindTexture(Gui.icons); int pingIndex = 4; int ping = player.responseTime; if (ping < 0) pingIndex = 5; else if (ping < 150) pingIndex = 0; else if (ping < 300) pingIndex = 1; else if (ping < 600) pingIndex = 2; else if (ping < 1000) pingIndex = 3; zLevel += 100.0F; drawTexturedModalRect(xPos + columnWidth - 12, yPos, 0, 176 + pingIndex * 8, 10, 8); zLevel -= 100.0F; } } post(PLAYER_LIST); } }
@Override @SuppressWarnings("rawtypes") protected void renderPlayerList(int width, int height) { ScoreObjective scoreobjective = this.mc.theWorld.getScoreboard().func_96539_a(0); NetClientHandler handler = mc.thePlayer.sendQueue; if (mc.gameSettings.keyBindPlayerList.pressed && (!mc.isIntegratedServerRunning() || handler.playerInfoList.size() > 1 || scoreobjective != null)) { this.mc.mcProfiler.startSection("playerList"); List players = handler.playerInfoList; int maxPlayers = handler.currentServerMaxPlayers; int rows = maxPlayers; int columns = 1; for (columns = 1; rows > 20; rows = (maxPlayers + columns - 1) / columns) { columns++; } int columnWidth = 300 / columns; if (columnWidth > 150) { columnWidth = 150; } int left = (width - columns * columnWidth) / 2; byte border = 10; drawRect(left - 1, border - 1, left + columnWidth * columns, border + 9 * rows, Integer.MIN_VALUE); for (int i = 0; i < maxPlayers; i++) { int xPos = left + i % columns * columnWidth; int yPos = border + i / columns * 9; drawRect(xPos, yPos, xPos + columnWidth - 1, yPos + 8, 553648127); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_ALPHA_TEST); if (i < players.size()) { GuiPlayerInfo player = (GuiPlayerInfo)players.get(i); ScorePlayerTeam team = mc.theWorld.getScoreboard().getPlayersTeam(player.name); String displayName = ScorePlayerTeam.formatPlayerName(team, player.name); fontrenderer.drawStringWithShadow(displayName, xPos, yPos, 16777215); if (scoreobjective != null) { int endX = xPos + fontrenderer.getStringWidth(displayName) + 5; int maxX = xPos + columnWidth - 12 - 5; if (maxX - endX > 5) { Score score = scoreobjective.getScoreboard().func_96529_a(player.name, scoreobjective); String scoreDisplay = EnumChatFormatting.YELLOW + "" + score.getScorePoints(); fontrenderer.drawStringWithShadow(scoreDisplay, maxX - fontrenderer.getStringWidth(scoreDisplay), yPos, 16777215); } } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.func_110434_K().func_110577_a(Gui.field_110324_m); int pingIndex = 4; int ping = player.responseTime; if (ping < 0) pingIndex = 5; else if (ping < 150) pingIndex = 0; else if (ping < 300) pingIndex = 1; else if (ping < 600) pingIndex = 2; else if (ping < 1000) pingIndex = 3; zLevel += 100.0F; drawTexturedModalRect(xPos + columnWidth - 12, yPos, 0, 176 + pingIndex * 8, 10, 8); zLevel -= 100.0F; } } } }
@Override public void render(Minecraft mc, ScaledResolution res, float partialTicks, HPHud hud) { super.render(mc, res, partialTicks, hud); ScoreObjective scoreobjective = mc.theWorld.getScoreboard().func_96539_a(0); NetClientHandler handler = mc.thePlayer.sendQueue; if (handler.playerInfoList.size() > 1 || scoreobjective != null) { @SuppressWarnings("rawtypes") List players = handler.playerInfoList; int maxPlayers = handler.currentServerMaxPlayers; int rows = maxPlayers; int columns = 1; for (columns = 1; rows > 20; rows = (maxPlayers + columns - 1) / columns) { columns++; } int columnWidth = 300 / columns; if (columnWidth > 150) { columnWidth = 150; } int left = (width - columns * columnWidth) / 2; byte border = 10; Gui.drawRect(left - 1, border - 1, left + columnWidth * columns, border + 9 * rows, Integer.MIN_VALUE); for (int i = 0; i < maxPlayers; i++) { int xPos = left + i % columns * columnWidth; int yPos = border + i / columns * 9; Gui.drawRect(xPos, yPos, xPos + columnWidth - 1, yPos + 8, 553648127); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_ALPHA_TEST); if (i < players.size()) { FontRenderer fr = hud.fontrenderer; GuiPlayerInfo player = (GuiPlayerInfo)players.get(i); ScorePlayerTeam team = mc.theWorld.getScoreboard().getPlayersTeam(player.name); String displayName = ScorePlayerTeam.formatPlayerName(team, player.name); fr.drawStringWithShadow(displayName, xPos, yPos, 16777215); if (scoreobjective != null) { int endX = xPos + fr.getStringWidth(displayName) + 5; int maxX = xPos + columnWidth - 12 - 5; if (maxX - endX > 5) { Score score = scoreobjective.getScoreboard().func_96529_a(player.name, scoreobjective); String scoreDisplay = EnumChatFormatting.YELLOW + "" + score.getScorePoints(); fr.drawStringWithShadow(scoreDisplay, maxX - fr.getStringWidth(scoreDisplay), yPos, 16777215); } } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.func_110434_K().func_110577_a(Gui.field_110324_m); int pingIndex = 4; int ping = player.responseTime; if (ping < 0) pingIndex = 5; else if (ping < 150) pingIndex = 0; else if (ping < 300) pingIndex = 1; else if (ping < 600) pingIndex = 2; else if (ping < 1000) pingIndex = 3; //hud.zLevel += 100.0F; hud.drawTexturedModalRect(xPos + columnWidth - 12, yPos, 0, 176 + pingIndex * 8, 10, 8); //hud.zLevel -= 100.0F; } } } }
@Override protected void renderPlayerList(int width, int height) { mc.mcProfiler.startSection("playerList"); ScoreObjective scoreobjective = mc.theWorld.getScoreboard().func_96539_a(0); NetHandlerPlayClient handler = mc.thePlayer.sendQueue; if (mc.gameSettings.keyBindPlayerList.isPressed() && (!mc.isIntegratedServerRunning() || handler.playerInfoList.size() > 1 || scoreobjective != null)) { List<?> players = handler.playerInfoList; int maxPlayers = handler.currentServerMaxPlayers; int rows = maxPlayers; int columns; for (columns = 1; rows > 20; rows = (maxPlayers + columns - 1) / columns) { columns++; } int columnWidth = 300 / columns; if (columnWidth > 150) { columnWidth = 150; } int left = (width - columns * columnWidth) / 2; byte border = 10; drawRect(left - 1, border - 1, left + columnWidth * columns, border + 9 * rows, Integer.MIN_VALUE); for (int i = 0; i < maxPlayers; i++) { int xPos = left + i % columns * columnWidth; int yPos = border + i / columns * 9; drawRect(xPos, yPos, xPos + columnWidth - 1, yPos + 8, 553648127); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_ALPHA_TEST); if (i < players.size()) { GuiPlayerInfo player = (GuiPlayerInfo) players.get(i); ScorePlayerTeam team = mc.theWorld.getScoreboard().getPlayersTeam(player.name); String displayName = ScorePlayerTeam.formatPlayerName(team, player.name); mc.fontRenderer.drawStringWithShadow(displayName, xPos, yPos, 16777215); if (scoreobjective != null) { int endX = xPos + mc.fontRenderer.getStringWidth(displayName) + 5; int maxX = xPos + columnWidth - 12 - 5; if (maxX - endX > 5) { Score score = scoreobjective.getScoreboard().func_96529_a(player.name, scoreobjective); String scoreDisplay = EnumChatFormatting.YELLOW + "" + score.getScorePoints(); mc.fontRenderer.drawStringWithShadow(scoreDisplay, maxX - mc.fontRenderer.getStringWidth(scoreDisplay), yPos, 16777215); } } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); RenderAssist.bindTexture(Gui.icons); int pingIndex = 4; int ping = player.responseTime; if (ping < 0) { pingIndex = 5; } else if (ping < 150) { pingIndex = 0; } else if (ping < 300) { pingIndex = 1; } else if (ping < 600) { pingIndex = 2; } else if (ping < 1000) { pingIndex = 3; } zLevel += 100.0F; drawTexturedModalRect(xPos + columnWidth - 12, yPos, 0, 176 + pingIndex * 8, 10, 8); zLevel -= 100.0F; } } } mc.mcProfiler.endSection(); }