use of v1_8_9.net.minecraft.util.ChatComponentText in project Hyperium by HyperiumClient.
the class LevelheadChatRenderer method chat.
@InvokeEvent
public void chat(ServerChatEvent event) {
if (!levelhead.getDisplayManager().getMasterConfig().isEnabled())
return;
LevelheadDisplay chat = Levelhead.getInstance().getDisplayManager().getChat();
if (chat == null || !levelhead.getLevelheadPurchaseStates().isChat() || !chat.getConfig().isEnabled())
return;
List<IChatComponent> siblings = event.getChat().getSiblings();
if (siblings.size() == 0)
return;
IChatComponent chatComponent = siblings.get(0);
if (chatComponent instanceof ChatComponentText) {
ChatStyle style = chatComponent.getChatStyle();
ClickEvent clickEvent = style.getChatClickEvent();
if (clickEvent != null && clickEvent.getAction() == ClickEvent.Action.RUN_COMMAND) {
String value = clickEvent.getValue();
HoverEvent hoverEvent = style.getChatHoverEvent();
if (hoverEvent != null && hoverEvent.getAction() == HoverEvent.Action.SHOW_TEXT) {
String[] split = value.split(" ");
if (split.length == 2) {
String uuid = split[1];
UUID key = UUID.fromString(uuid);
String tag = chat.getTrueValueCache().get(key);
if (tag != null) {
event.setChat(modifyChat(event.getChat(), tag, chat.getConfig()));
} else if (!(chat.getCache().get(key) instanceof NullLevelheadTag)) {
levelhead.fetch(key, chat, false);
}
}
}
}
}
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Hyperium by HyperiumClient.
the class ToggleChatEvents method onChatReceive.
// We use the high priority to grab things first
@InvokeEvent(priority = Priority.HIGH)
public void onChatReceive(ServerChatEvent event) {
// Strip the message of any colors for improved detectability
String unformattedText = ChatColor.stripColor(event.getChat().getUnformattedText());
// The formatted message for a few of the custom toggles
String formattedText = event.getChat().getFormattedText();
try {
// Loop through all the toggles
for (ToggleBase type : mod.getToggleHandler().getToggles().values()) {
// The chat its looking for shouldn't be toggled, move to next one!
if (type.isEnabled())
continue;
// the whole toggle system crashing down in flames.
try {
// The text we want to input into the shouldToggle method.
String input = type.useFormattedMessage() ? formattedText : unformattedText;
// don't send the message to the player & stop looping
if (type.shouldToggle(input)) {
if (type instanceof TypeMessageSeparator) {
// Attempt to keep the formatting
ChatStyle style = event.getChat().getChatStyle();
String edited = ((TypeMessageSeparator) type).editMessage(formattedText);
// Don't bother sending the message if its empty
if (!input.equals(edited) && edited.isEmpty()) {
event.setCancelled(true);
} else {
event.setChat(new ChatComponentText(edited).setChatStyle(style));
}
} else {
event.setCancelled(true);
}
break;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Hyperium by HyperiumClient.
the class MyPosition method sendMyPosCommand.
private void sendMyPosCommand() {
Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(ChatColor.RED.toString() + ChatColor.BOLD + "------| Auto MyPosition |------"));
Minecraft.getMinecraft().thePlayer.sendChatMessage("/myposition");
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project SimplyJetpacks by Tonius.
the class PackBase method toggleState.
protected void toggleState(boolean on, ItemStack stack, String type, String tag, EntityPlayer player, boolean showInChat) {
stack.stackTagCompound.setBoolean(tag, !on);
if (player != null && showInChat) {
String color = on ? StringHelper.LIGHT_RED : StringHelper.BRIGHT_GREEN;
type = type != null && !type.equals("") ? "chat." + this.name + "." + type + ".on" : "chat." + this.name + ".on";
String msg = SJStringHelper.localize(type) + " " + color + SJStringHelper.localize("chat." + (on ? "disabled" : "enabled"));
player.addChatMessage(new ChatComponentText(msg));
}
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Charset by CharsetMC.
the class ItemDramaInABottle method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
if (!worldIn.isRemote) {
if (itemStackIn.hasTagCompound() && itemStackIn.getTagCompound().hasKey("drama")) {
playerIn.addChatComponentMessage(new ChatComponentText(itemStackIn.getTagCompound().getString("drama")));
} else {
itemStackIn.setTagCompound(new NBTTagCompound());
itemStackIn.getTagCompound().setString("drama", DramaGenerator.INSTANCE.createDrama());
playerIn.addChatComponentMessage(new ChatComponentText(itemStackIn.getTagCompound().getString("drama")));
}
}
return itemStackIn;
}
Aggregations