@Override public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) { if (Minecraft.getMinecraft().thePlayer == null || VolatileSettings.isBlocked(e.getAuthor().getId())) return; String message; EntityPlayer player = Minecraft.getMinecraft().thePlayer; // Highlighting mentions message = MCHelper.buildInteractiveMessage( e.getAuthor().getUsername() , null , e.getAuthor().getId() , null , null , DiscordUtil.resolveMentions(e.getMessage().getRawContent()) , Config.directLayout , e.getMessage()); Minecraft .getMinecraft() .thePlayer .addChatComponentMessage(TextComponentBase.Serializer.jsonToComponent(message)); }
@SubscribeEvent @SideOnly(Side.CLIENT) public void onPlayerDeathImage(GuiOpenEvent e) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; if (!(e.getGui() instanceof GuiGameOver) || !Config.demiseImage || player == null || player.getHealth() <= 0F) return; // Getting discord and minecraft user try { User me = DiscordCE.client.getUserById(DiscordCE.client.getSelfInfo().getId()); Minecraft mc = Minecraft.getMinecraft(); ITextComponent t = ScreenShotHelper.saveScreenshot(mc.mcDataDir, mc.displayWidth, mc.displayHeight, mc.getFramebuffer()); String fileName = new JSONObject(TextComponentBase.Serializer.componentToJson(t)).getJSONArray("with") .getJSONObject(0).getJSONObject("clickEvent").getString("value"); File file = new File(fileName); TextChannel c = DiscordCE.client.getTextChannelById(Preferences.i.usingChannel); // Doing checks if (c == null || !c.checkPermission(me, Permission.MESSAGE_ATTACH_FILES)) return; //Sending file c.sendFileAsync(file, null, m -> file.delete()); } catch (Exception e1) { e1.printStackTrace(); } }
@Override public void onGuildMessageReceived(GuildMessageReceivedEvent e) { if (Minecraft.getMinecraft().thePlayer == null || VolatileSettings.isBlocked(e.getAuthor().getId()) || Preferences.i.mutedChannels.contains(e.getChannel().getId()) || Preferences.i.mutedGuilds.contains(e.getGuild().getId()) || (Preferences.i.focus && !Preferences.i.usingChannel.equals(e.getChannel().getId()))) return; String message; EntityPlayer player = Minecraft.getMinecraft().thePlayer; // Formatting message message = MCHelper.buildInteractiveMessage( e.getAuthor().getUsername() , e.getAuthorNick() , e.getAuthor().getId() , e.getGuild() , e.getChannel() , DiscordUtil.resolveMentions(e.getMessage().getRawContent()) , Config.serverLayout , e.getMessage()); Minecraft .getMinecraft() .thePlayer .addChatComponentMessage(TextComponentBase.Serializer.jsonToComponent(message)); }
/** * Sends an interactive message to the user * * @param message The message to set the user */ public static void sendRawMessage(JSONArray message) { if (Minecraft.getMinecraft() == null || Minecraft.getMinecraft().thePlayer == null) return; ITextComponent component = TextComponentBase.Serializer.jsonToComponent(message.toString()); Minecraft.getMinecraft().thePlayer.addChatMessage(component); }
@Override public void sendMessage(String msg) { for (String part : msg.split("\n")) { part = BBC.color(part); TextComponentBase text = new TextComponentString(part); this.parent.addChatMessage(text); } }
@Override public TextComponentBase getDisplayName() { if (this.hasCustomName()) { return new TextComponentString(this.getName()); } return new TextComponentTranslation(this.getName(), new Object[0]); }
@Override public TextComponentBase getDisplayName() { return null; }