Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public enum Feature {
SHOW_SKYBLOCK_ITEM_ID(213, "settings.showSkyblockItemId", null, true),
RESET_SALVAGED_ESSENCES_AFTER_LEAVING_MENU(214, "settings.resetSalvagedEssencesAfterLeavingMenu", null, false),
CHANGE_DUNGEON_MAP_ZOOM_WITH_KEYBOARD(215, "settings.changeDungeonMapZoomWithKeyboard", null, false),
PROFILE_TYPE_IN_CHAT(216, "settings.showProfileTypeInChat", null, true),
PLAYER_SYMBOLS_IN_CHAT(216, "settings.showPlayerSymbolsInChat", null, false),
CRIMSON_ARMOR_ABILITY_STACKS(217, "settings.crimsonArmorAbilityStacks", new GuiFeatureData(EnumUtils.DrawType.TEXT, ColorCode.GOLD), false),
HIDE_TRUE_DEFENSE(218, "settings.hideTrueDefense", new GuiFeatureData(ColorCode.RED), false),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static void render() {
int savedX = middleX;

if (tabLine.getType() == TabStringType.PLAYER) {
NetworkPlayerInfo networkPlayerInfo = mc.getNetHandler().getPlayerInfo(TextUtils.stripColor(tabLine.getText()));
NetworkPlayerInfo networkPlayerInfo = mc.getNetHandler().getPlayerInfo(TextUtils.stripUsername(tabLine.getText()));
if (networkPlayerInfo != null) {
EntityPlayer entityPlayer = mc.theWorld.getPlayerEntityByUUID(networkPlayerInfo.getGameProfile().getId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ public enum TabStringType {
PLAYER;

public static TabStringType fromLine(String line) {
String strippedLine = TextUtils.stripColor(line);

String strippedLine = TextUtils.stripUsername(line);
if (strippedLine.startsWith(" ")) {
return TEXT;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
import net.minecraft.client.audio.SoundCategory;
import net.minecraft.client.entity.EntityOtherPlayerMP;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.GuiPlayerTabOverlay;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.client.network.NetworkPlayerInfo;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityArmorStand;
Expand All @@ -61,7 +64,9 @@
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.scoreboard.ScorePlayerTeam;
import net.minecraft.util.*;
import net.minecraft.world.WorldSettings;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.sound.PlaySoundEvent;
Expand Down Expand Up @@ -372,20 +377,34 @@ public void onChatReceive(ClientChatReceivedEvent e) {
!fetchur.hasFetchedToday() && unformattedText.contains(fetchur.getFetchurAlreadyDidTaskPhrase())) {
FetchurManager.getInstance().saveLastTimeFetched();
}
// Tries to check if a message is from a player to add the player profile icon
} else if (main.getConfigValues().isEnabled(Feature.PROFILE_TYPE_IN_CHAT) &&
// Tries to check if a message is from a player to add the player profile icon
} else if (main.getConfigValues().isEnabled(Feature.PLAYER_SYMBOLS_IN_CHAT) &&
unformattedText.contains(":")) {
String username = unformattedText.split(":")[0].replaceAll("§.","");
// Remove rank prefix if exists
if (username.contains("]"))
username = username.split("] ")[1];
// For some reason guild chat messages still contain color codes in the unformatted text
String username = TextUtils.stripColor(unformattedText.split(":")[0]);
// Remove rank prefix and guild rank suffix if exists
String[] splitted = username.split("\\[[^\\[\\]]*\\]");
if (splitted.length>1) {
username = TextUtils.trimWhitespaceAndResets(splitted[1]);
logger.info(username);
}
// Check if stripped username is a real username or the player
if (TextUtils.isUsername(username) || username.equals("**MINECRAFTUSERNAME**")) {
EntityPlayer chattingPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(username);
// Put player in cache if found nearby
if(chattingPlayer != null) {
namesWithType.put(username, chattingPlayer.getDisplayName().getSiblings().get(0).getUnformattedText());
}
// Otherwise search in tablist
else {
Collection<NetworkPlayerInfo> networkPlayerInfos = Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap();
String finalUsername = username;
Optional<NetworkPlayerInfo> result = networkPlayerInfos.stream().filter(npi -> npi.getDisplayName() != null).filter(npi -> TextUtils.stripUsername(npi.getDisplayName().getUnformattedText()).equals(finalUsername)).findAny();
// Put in cache if found
if(result.isPresent()){
namesWithType.put(username, result.get().getDisplayName().getFormattedText());
}
}
// Check cache regardless if found nearby
if(namesWithType.containsKey(username)){
IChatComponent oldMessage = e.message;
Expand Down Expand Up @@ -827,26 +846,26 @@ public void onEntitySpawn(EntityEvent.EnteringChunk e) {
}
}
if (main.getUtils().isOnSkyblock()) {
Minecraft mc = Minecraft.getMinecraft();
for (Entity cubes : mc.theWorld.loadedEntityList) {
if (main.getConfigValues().isEnabled(Feature.BAL_BOSS_ALERT) && main.getUtils().isOnSkyblock() && LocationUtils.isInCrystalHollows(main.getUtils().getLocation().getScoreboardName())) {
if (cubes instanceof EntityMagmaCube) {
EntitySlime magma = (EntitySlime) cubes;
if (magma.getSlimeSize() > 10) { // Find a big bal boss
if ((lastBal == -1 || System.currentTimeMillis() - lastBal > 240000)) {
lastBal = System.currentTimeMillis();
main.getRenderListener().setTitleFeature(Feature.BAL_BOSS_ALERT); // Enable warning and disable again in four seconds.
balTick = 16; // so the sound plays instantly
main.getScheduler().schedule(Scheduler.CommandType.RESET_TITLE_FEATURE, main.getConfigValues().getWarningSeconds());
}
if (main.getRenderListener().getTitleFeature() == Feature.BAL_BOSS_ALERT && balTick % 4 == 0) { // Play sound every 4 ticks or 1/5 second.
main.getUtils().playLoudSound("random.orb", 0.5);
Minecraft mc = Minecraft.getMinecraft();
for (Entity cubes : mc.theWorld.loadedEntityList) {
if (main.getConfigValues().isEnabled(Feature.BAL_BOSS_ALERT) && main.getUtils().isOnSkyblock() && LocationUtils.isInCrystalHollows(main.getUtils().getLocation().getScoreboardName())) {
if (cubes instanceof EntityMagmaCube) {
EntitySlime magma = (EntitySlime) cubes;
if (magma.getSlimeSize() > 10) { // Find a big bal boss
if ((lastBal == -1 || System.currentTimeMillis() - lastBal > 240000)) {
lastBal = System.currentTimeMillis();
main.getRenderListener().setTitleFeature(Feature.BAL_BOSS_ALERT); // Enable warning and disable again in four seconds.
balTick = 16; // so the sound plays instantly
main.getScheduler().schedule(Scheduler.CommandType.RESET_TITLE_FEATURE, main.getConfigValues().getWarningSeconds());
}
if (main.getRenderListener().getTitleFeature() == Feature.BAL_BOSS_ALERT && balTick % 4 == 0) { // Play sound every 4 ticks or 1/5 second.
main.getUtils().playLoudSound("random.orb", 0.5);
}
}
}
}
}
}
}

if (main.getUtils().isOnSkyblock() && main.getConfigValues().isEnabled(Feature.ZEALOT_COUNTER_EXPLOSIVE_BOW_SUPPORT) && entity instanceof EntityArrow) {
EntityArrow arrow = (EntityArrow) entity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,9 @@ public enum FeatureCredit {
SKYCATMINEPOKIE("skycatminepokie", "github.com/skycatminepokie", Feature.OUTBID_ALERT_SOUND),
TIMOLOB("TimoLob", "github.com/TimoLob", Feature.BROOD_MOTHER_ALERT),
NOPOTHEGAMER("NopoTheGamer", "twitch.tv/nopothegamer", Feature.BAL_BOSS_ALERT),
CATFACE("CatFace","github.com/CattoFace",Feature.PROFILE_TYPE_IN_CHAT),
CATFACE("CatFace","github.com/CattoFace",Feature.PLAYER_SYMBOLS_IN_CHAT),
HANNIBAL2("Hannibal2", "github.com/hannibal00212", Feature.CRIMSON_ARMOR_ABILITY_STACKS, Feature.HIDE_TRUE_DEFENSE);


private final Set<Feature> features;
private final String author;
private final String url;
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/codes/biscuit/skyblockaddons/utils/TextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class TextUtils {
public static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance(Locale.US);

private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)§[0-9A-FK-ORZ]");
private static final Pattern STRIP_ICONS_PATTERN = Pattern.compile("[♲Ⓑ⚒ቾ]+");
private static final Pattern REPEATED_COLOR_PATTERN = Pattern.compile("(?i)(§[0-9A-FK-ORZ])+");
private static final Pattern NUMBERS_SLASHES = Pattern.compile("[^0-9 /]");
private static final Pattern SCOREBOARD_CHARACTERS = Pattern.compile("[^a-z A-Z:0-9_/'.!§\\[\\]❤]");
Expand Down Expand Up @@ -59,6 +60,24 @@ public static String stripColor(final String input) {
return STRIP_COLOR_PATTERN.matcher(input).replaceAll("");
}

/**
* Strips icons from player names
* @param input Text to strip icons from
* @return Text without icons
*/
public static String stripIcons(String input) {
return STRIP_ICONS_PATTERN.matcher(input).replaceAll("");
}

/**
* Strips icons and colors and trims spaces from a potential username
* @param input Text to strip from
* @return Stripped Text
*/
public static String stripUsername(String input) {
return trimWhitespaceAndResets(stripIcons(stripColor((input))));
}

/**
* Computationally efficient way to test if a given string has a rendered length of 0
* @param input string to test
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
"showFeatureNamesOnHover": "Show Feature Names on Hover",
"resetSalvagedEssencesAfterLeavingMenu": "Reset Salvaged Essence Counter After Closing Menu",
"changeDungeonMapZoomWithKeyboard": "Adjust zoom with +/- keys",
"showProfileTypeInChat": "Show Profile Type In Chat",
"showPlayerSymbolsInChat": "Show Player Symbols In Chat",
"crimsonArmorAbilityStacks": "Show Crimson Armor Stacks",
"hideTrueDefense": "Hide True Defense"
},
Expand Down