|
43 | 43 | import net.minecraft.client.audio.SoundCategory; |
44 | 44 | import net.minecraft.client.entity.EntityOtherPlayerMP; |
45 | 45 | import net.minecraft.client.entity.EntityPlayerSP; |
| 46 | +import net.minecraft.client.gui.GuiPlayerTabOverlay; |
46 | 47 | import net.minecraft.client.gui.inventory.GuiChest; |
| 48 | +import net.minecraft.client.network.NetHandlerPlayClient; |
| 49 | +import net.minecraft.client.network.NetworkPlayerInfo; |
47 | 50 | import net.minecraft.client.settings.KeyBinding; |
48 | 51 | import net.minecraft.entity.Entity; |
49 | 52 | import net.minecraft.entity.item.EntityArmorStand; |
|
61 | 64 | import net.minecraft.item.EnumDyeColor; |
62 | 65 | import net.minecraft.item.ItemStack; |
63 | 66 | import net.minecraft.nbt.NBTTagCompound; |
| 67 | +import net.minecraft.scoreboard.ScorePlayerTeam; |
64 | 68 | import net.minecraft.util.*; |
| 69 | +import net.minecraft.world.WorldSettings; |
65 | 70 | import net.minecraftforge.client.event.ClientChatReceivedEvent; |
66 | 71 | import net.minecraftforge.client.event.GuiScreenEvent; |
67 | 72 | import net.minecraftforge.client.event.sound.PlaySoundEvent; |
@@ -372,20 +377,34 @@ public void onChatReceive(ClientChatReceivedEvent e) { |
372 | 377 | !fetchur.hasFetchedToday() && unformattedText.contains(fetchur.getFetchurAlreadyDidTaskPhrase())) { |
373 | 378 | FetchurManager.getInstance().saveLastTimeFetched(); |
374 | 379 | } |
375 | | - // Tries to check if a message is from a player to add the player profile icon |
376 | | - } else if (main.getConfigValues().isEnabled(Feature.PROFILE_TYPE_IN_CHAT) && |
| 380 | + // Tries to check if a message is from a player to add the player profile icon |
| 381 | + } else if (main.getConfigValues().isEnabled(Feature.PLAYER_SYMBOLS_IN_CHAT) && |
377 | 382 | unformattedText.contains(":")) { |
378 | | - String username = unformattedText.split(":")[0].replaceAll("§.",""); |
379 | | - // Remove rank prefix if exists |
380 | | - if (username.contains("]")) |
381 | | - username = username.split("] ")[1]; |
| 383 | + // For some reason guild chat messages still contain color codes in the unformatted text |
| 384 | + String username = TextUtils.stripColor(unformattedText.split(":")[0]); |
| 385 | + // Remove rank prefix and guild rank suffix if exists |
| 386 | + String[] splitted = username.split("\\[[^\\[\\]]*\\]"); |
| 387 | + if (splitted.length>1) { |
| 388 | + username = TextUtils.trimWhitespaceAndResets(splitted[1]); |
| 389 | + logger.info(username); |
| 390 | + } |
382 | 391 | // Check if stripped username is a real username or the player |
383 | 392 | if (TextUtils.isUsername(username) || username.equals("**MINECRAFTUSERNAME**")) { |
384 | 393 | EntityPlayer chattingPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(username); |
385 | 394 | // Put player in cache if found nearby |
386 | 395 | if(chattingPlayer != null) { |
387 | 396 | namesWithType.put(username, chattingPlayer.getDisplayName().getSiblings().get(0).getUnformattedText()); |
388 | 397 | } |
| 398 | + // Otherwise search in tablist |
| 399 | + else { |
| 400 | + Collection<NetworkPlayerInfo> networkPlayerInfos = Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap(); |
| 401 | + String finalUsername = username; |
| 402 | + Optional<NetworkPlayerInfo> result = networkPlayerInfos.stream().filter(npi -> npi.getDisplayName() != null).filter(npi -> TextUtils.stripUsername(npi.getDisplayName().getUnformattedText()).equals(finalUsername)).findAny(); |
| 403 | + // Put in cache if found |
| 404 | + if(result.isPresent()){ |
| 405 | + namesWithType.put(username, result.get().getDisplayName().getFormattedText()); |
| 406 | + } |
| 407 | + } |
389 | 408 | // Check cache regardless if found nearby |
390 | 409 | if(namesWithType.containsKey(username)){ |
391 | 410 | IChatComponent oldMessage = e.message; |
@@ -827,26 +846,26 @@ public void onEntitySpawn(EntityEvent.EnteringChunk e) { |
827 | 846 | } |
828 | 847 | } |
829 | 848 | if (main.getUtils().isOnSkyblock()) { |
830 | | - Minecraft mc = Minecraft.getMinecraft(); |
831 | | - for (Entity cubes : mc.theWorld.loadedEntityList) { |
832 | | - if (main.getConfigValues().isEnabled(Feature.BAL_BOSS_ALERT) && main.getUtils().isOnSkyblock() && LocationUtils.isInCrystalHollows(main.getUtils().getLocation().getScoreboardName())) { |
833 | | - if (cubes instanceof EntityMagmaCube) { |
834 | | - EntitySlime magma = (EntitySlime) cubes; |
835 | | - if (magma.getSlimeSize() > 10) { // Find a big bal boss |
836 | | - if ((lastBal == -1 || System.currentTimeMillis() - lastBal > 240000)) { |
837 | | - lastBal = System.currentTimeMillis(); |
838 | | - main.getRenderListener().setTitleFeature(Feature.BAL_BOSS_ALERT); // Enable warning and disable again in four seconds. |
839 | | - balTick = 16; // so the sound plays instantly |
840 | | - main.getScheduler().schedule(Scheduler.CommandType.RESET_TITLE_FEATURE, main.getConfigValues().getWarningSeconds()); |
841 | | - } |
842 | | - if (main.getRenderListener().getTitleFeature() == Feature.BAL_BOSS_ALERT && balTick % 4 == 0) { // Play sound every 4 ticks or 1/5 second. |
843 | | - main.getUtils().playLoudSound("random.orb", 0.5); |
| 849 | + Minecraft mc = Minecraft.getMinecraft(); |
| 850 | + for (Entity cubes : mc.theWorld.loadedEntityList) { |
| 851 | + if (main.getConfigValues().isEnabled(Feature.BAL_BOSS_ALERT) && main.getUtils().isOnSkyblock() && LocationUtils.isInCrystalHollows(main.getUtils().getLocation().getScoreboardName())) { |
| 852 | + if (cubes instanceof EntityMagmaCube) { |
| 853 | + EntitySlime magma = (EntitySlime) cubes; |
| 854 | + if (magma.getSlimeSize() > 10) { // Find a big bal boss |
| 855 | + if ((lastBal == -1 || System.currentTimeMillis() - lastBal > 240000)) { |
| 856 | + lastBal = System.currentTimeMillis(); |
| 857 | + main.getRenderListener().setTitleFeature(Feature.BAL_BOSS_ALERT); // Enable warning and disable again in four seconds. |
| 858 | + balTick = 16; // so the sound plays instantly |
| 859 | + main.getScheduler().schedule(Scheduler.CommandType.RESET_TITLE_FEATURE, main.getConfigValues().getWarningSeconds()); |
| 860 | + } |
| 861 | + if (main.getRenderListener().getTitleFeature() == Feature.BAL_BOSS_ALERT && balTick % 4 == 0) { // Play sound every 4 ticks or 1/5 second. |
| 862 | + main.getUtils().playLoudSound("random.orb", 0.5); |
| 863 | + } |
844 | 864 | } |
845 | 865 | } |
846 | 866 | } |
847 | 867 | } |
848 | 868 | } |
849 | | - } |
850 | 869 |
|
851 | 870 | if (main.getUtils().isOnSkyblock() && main.getConfigValues().isEnabled(Feature.ZEALOT_COUNTER_EXPLOSIVE_BOW_SUPPORT) && entity instanceof EntityArrow) { |
852 | 871 | EntityArrow arrow = (EntityArrow) entity; |
|
0 commit comments