use of v1_8_9.net.minecraft.util.ChatComponentText in project SkyblockAddons by BiscuitDevelopment.
the class PlayerListener method onChatReceive.
/**
* Interprets the action bar to extract mana, health, and defence. Enables/disables mana/health prediction,
* and looks for mana usage messages in chat while predicting.
*/
@SubscribeEvent(priority = EventPriority.HIGH)
public void onChatReceive(ClientChatReceivedEvent e) {
String unformattedText = e.message.getUnformattedText();
// Type 2 means it's an action bar message.
if (e.type == 2) {
// Parse using ActionBarParser and display the rest message instead
String restMessage = actionBarParser.parseActionBar(unformattedText);
if (main.isUsingOofModv1() && restMessage.trim().length() == 0) {
e.setCanceled(true);
}
e.message = new ChatComponentText(restMessage);
} else {
String formattedText = e.message.getFormattedText();
Matcher matcher;
if (main.getRenderListener().isPredictMana() && unformattedText.startsWith("Used ") && unformattedText.endsWith("Mana)")) {
int manaLost = Integer.parseInt(unformattedText.split(Pattern.quote("! ("))[1].split(Pattern.quote(" Mana)"))[0]);
changeMana(-manaLost);
}
/* Resets all user input on dead as to not walk backwards or stafe into the portal
Might get trigger upon encountering a non named "You" though this chance is so
minimal it can be discarded as a bug. */
if (main.getConfigValues().isEnabled(Feature.PREVENT_MOVEMENT_ON_DEATH) && formattedText.startsWith("§r§c ☠ §r§7You ")) {
KeyBinding.unPressAllKeys();
} else if (main.getConfigValues().isEnabled(Feature.SUMMONING_EYE_ALERT) && formattedText.equals("§r§6§lRARE DROP! §r§5Summoning Eye§r")) {
// credits to tomotomo, thanks lol
main.getUtils().playLoudSound("random.orb", 0.5);
main.getRenderListener().setTitleFeature(Feature.SUMMONING_EYE_ALERT);
main.getScheduler().schedule(Scheduler.CommandType.RESET_TITLE_FEATURE, main.getConfigValues().getWarningSeconds());
} else if (formattedText.equals("§r§aA special §r§5Zealot §r§ahas spawned nearby!§r")) {
if (main.getConfigValues().isEnabled(Feature.SPECIAL_ZEALOT_ALERT)) {
main.getUtils().playLoudSound("random.orb", 0.5);
main.getRenderListener().setTitleFeature(Feature.SUMMONING_EYE_ALERT);
main.getRenderListener().setTitleFeature(Feature.SPECIAL_ZEALOT_ALERT);
main.getScheduler().schedule(Scheduler.CommandType.RESET_TITLE_FEATURE, main.getConfigValues().getWarningSeconds());
}
if (main.getConfigValues().isEnabled(Feature.ZEALOT_COUNTER)) {
// Edit the message to include counter.
e.message = new ChatComponentText(formattedText + ColorCode.GRAY + " (" + main.getPersistentValues().getKills() + ")");
}
main.getPersistentValues().addEyeResetKills();
} else if (main.getConfigValues().isEnabled(Feature.LEGENDARY_SEA_CREATURE_WARNING) && LEGENDARY_SEA_CREATURE_MESSAGES.contains(unformattedText)) {
main.getUtils().playLoudSound("random.orb", 0.5);
main.getRenderListener().setTitleFeature(Feature.LEGENDARY_SEA_CREATURE_WARNING);
main.getScheduler().schedule(Scheduler.CommandType.RESET_TITLE_FEATURE, main.getConfigValues().getWarningSeconds());
} else if (main.getConfigValues().isEnabled(Feature.DISABLE_MAGICAL_SOUP_MESSAGES) && SOUP_RANDOM_MESSAGES.contains(unformattedText)) {
e.setCanceled(true);
} else if (main.getConfigValues().isEnabled(Feature.DISABLE_TELEPORT_PAD_MESSAGES) && (formattedText.startsWith("§r§aWarped from ") || formattedText.equals("§r§cThis Teleport Pad does not have a destination set!§r"))) {
e.setCanceled(true);
} else if (formattedText.startsWith("§7Sending to server ")) {
lastSkyblockServerJoinAttempt = System.currentTimeMillis();
} else if (unformattedText.equals("You laid an egg!")) {
// Put the Chicken Head on cooldown for 20 seconds when the player lays an egg.
CooldownManager.put(InventoryUtils.CHICKEN_HEAD_DISPLAYNAME, 20000);
} else if (formattedText.startsWith("§r§eYou added a minute of rain!")) {
if (this.rainmakerTimeEnd == -1 || this.rainmakerTimeEnd < System.currentTimeMillis()) {
// Set the timer to a minute from now.
this.rainmakerTimeEnd = System.currentTimeMillis() + (1000 * 60);
} else {
// Extend the timer one minute.
this.rainmakerTimeEnd += (1000 * 60);
}
} else if (main.getConfigValues().isEnabled(Feature.SHOW_ENCHANTMENTS_REFORGES) && (matcher = ACCESSORY_BAG_REFORGE_PATTERN.matcher(unformattedText)).matches()) {
GuiChestHook.setLastAccessoryBagReforge(matcher.group("reforge"));
}
if (main.getConfigValues().isEnabled(Feature.NO_ARROWS_LEFT_ALERT)) {
if (NO_ARROWS_LEFT_PATTERN.matcher(formattedText).matches()) {
main.getUtils().playLoudSound("random.orb", 0.5);
main.getRenderListener().setSubtitleFeature(Feature.NO_ARROWS_LEFT_ALERT);
main.getRenderListener().setArrowsLeft(-1);
main.getScheduler().schedule(Scheduler.CommandType.RESET_SUBTITLE_FEATURE, main.getConfigValues().getWarningSeconds());
} else if ((matcher = ONLY_HAVE_ARROWS_LEFT_PATTERN.matcher(formattedText)).matches()) {
int arrowsLeft = Integer.parseInt(matcher.group("arrows"));
main.getUtils().playLoudSound("random.orb", 0.5);
main.getRenderListener().setSubtitleFeature(Feature.NO_ARROWS_LEFT_ALERT);
main.getRenderListener().setArrowsLeft(arrowsLeft);
main.getScheduler().schedule(Scheduler.CommandType.RESET_SUBTITLE_FEATURE, main.getConfigValues().getWarningSeconds());
}
}
matcher = ABILITY_CHAT_PATTERN.matcher(formattedText);
if (matcher.matches()) {
CooldownManager.put(Minecraft.getMinecraft().thePlayer.getHeldItem());
} else {
matcher = PROFILE_CHAT_PATTERN.matcher(formattedText);
if (matcher.matches()) {
main.getUtils().setProfileName(matcher.group(1));
} else {
matcher = SWITCH_PROFILE_CHAT_PATTERN.matcher(formattedText);
if (matcher.matches()) {
main.getUtils().setProfileName(matcher.group(1));
}
}
}
}
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project SkyblockAddons by BiscuitDevelopment.
the class Updater method sendUpdateMessage.
public void sendUpdateMessage() {
if (sentUpdateMessage)
return;
if (main.getOnlineData().getVideoLink() == null)
return;
String newestVersion = main.getOnlineData().getLatestVersion();
if (newestVersion == null)
return;
sentUpdateMessage = true;
main.getUtils().sendMessage("§7§m------------§7[§b§l SkyblockAddons §7]§7§m------------", false);
ChatComponentText newUpdate = new ChatComponentText("§b" + Message.MESSAGE_NEW_UPDATE.getMessage(newestVersion) + "\n");
main.getUtils().sendMessage(newUpdate, false);
ChatComponentText buttonsMessage = new ChatComponentText("§b§l[" + Message.MESSAGE_DOWNLOAD_LINK.getMessage(newestVersion) + "]");
buttonsMessage.setChatStyle(buttonsMessage.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, main.getOnlineData().getVideoLink())).setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("§7" + Message.MESSAGE_CLICK_TO_OPEN_LINK.getMessage()))));
buttonsMessage.appendSibling(new ChatComponentText(" "));
if (isPatch && main.getOnlineData().getDirectDownload() != null) {
ChatComponentText openModsFolder = new ChatComponentText("§c§l[" + Message.MESSAGE_DIRECT_DOWNLOAD.getMessage(newestVersion) + "]");
openModsFolder.setChatStyle(openModsFolder.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, main.getOnlineData().getDirectDownload())).setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("§7" + Message.MESSAGE_CLICK_TO_OPEN_LINK.getMessage()))));
openModsFolder.appendSibling(new ChatComponentText(" "));
buttonsMessage.appendSibling(openModsFolder);
}
ChatComponentText openModsFolder = new ChatComponentText("§e§l[" + Message.MESSAGE_OPEN_MODS_FOLDER.getMessage(newestVersion) + "]");
openModsFolder.setChatStyle(openModsFolder.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/sba folder")).setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("§7" + Message.MESSAGE_CLICK_TO_OPEN_FOLDER.getMessage()))));
buttonsMessage.appendSibling(openModsFolder);
main.getUtils().sendMessage(buttonsMessage, false);
ChatComponentText discord = new ChatComponentText("§b" + Message.MESSAGE_VIEW_PATCH_NOTES.getMessage() + " §9§l[" + Message.MESSAGE_JOIN_DISCORD.getMessage() + "]");
discord.setChatStyle(discord.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://discord.gg/biscuit")).setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("§7" + Message.MESSAGE_CLICK_TO_OPEN_LINK.getMessage()))));
main.getUtils().sendMessage(discord, false);
main.getUtils().sendMessage("§7§m----------------------------------------------", false);
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project SkyblockAddons by BiscuitDevelopment.
the class Utils method sendMessage.
public void sendMessage(ChatComponentText text, boolean prefix) {
if (prefix) {
// Add the prefix in front.
ChatComponentText newText = new ChatComponentText(MESSAGE_PREFIX);
newText.appendSibling(text);
text = newText;
}
ClientChatReceivedEvent event = new ClientChatReceivedEvent((byte) 1, text);
// Let other mods pick up the new message
MinecraftForge.EVENT_BUS.post(event);
if (!event.isCanceled()) {
// Just for logs
Minecraft.getMinecraft().thePlayer.addChatMessage(event.message);
}
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Hbm-s-Nuclear-Tech-GIT by HbmMods.
the class BlockGraphiteFuel method onScrew.
@Override
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
if (!world.isRemote) {
if (tool == ToolType.SCREWDRIVER) {
int meta = world.getBlockMetadata(x, y, z) & 3;
if (side == meta * 2 || side == meta * 2 + 1) {
world.setBlock(x, y, z, ModBlocks.block_graphite_drilled, meta, 3);
this.ejectItem(world, x, y, z, ForgeDirection.getOrientation(side), new ItemStack(ModItems.pile_rod_uranium));
}
}
if (tool == ToolType.HAND_DRILL) {
TileEntityPileFuel pile = (TileEntityPileFuel) world.getTileEntity(x, y, z);
player.addChatComponentMessage(new ChatComponentText("CP1 FUEL ASSEMBLY " + x + " " + y + " " + z).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD)));
player.addChatComponentMessage(new ChatComponentText("HEAT: " + pile.heat + "/" + pile.maxHeat).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)));
player.addChatComponentMessage(new ChatComponentText("DEPLETION: " + pile.progress + "/" + pile.maxProgress).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)));
player.addChatComponentMessage(new ChatComponentText("FLUX: " + pile.lastNeutrons).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)));
}
}
return true;
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Hbm-s-Nuclear-Tech-GIT by HbmMods.
the class ItemRTGPellet method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (!world.isRemote && this == ModItems.pellet_rtg) {
player.addChatComponentMessage(new ChatComponentText(facts[world.rand.nextInt(facts.length)]).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)));
world.playSoundAtEntity(player, "random.orb", 1.0F, 1.0F);
}
return stack;
}
Aggregations