Search in sources :

Example 46 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project RFToolsDimensions by McJty.

the class CmdSetOwner method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension and player parameters are missing!"));
        return;
    } else if (args.length > 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    String playerName = fetchString(sender, args, 2, null);
    World world = sender.getEntityWorld();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    if (dimensionManager.getDimensionDescriptor(dim) == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    for (Object o : MinecraftServer.getServer().getConfigurationManager().playerEntityList) {
        EntityPlayerMP entityPlayerMP = (EntityPlayerMP) o;
        if (playerName.equals(entityPlayerMP.getDisplayName())) {
            DimensionInformation information = dimensionManager.getDimensionInformation(dim);
            information.setOwner(playerName, entityPlayerMP.getGameProfile().getId());
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Owner of dimension changed!"));
            dimensionManager.save(world);
            return;
        }
    }
    sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Could not find player!"));
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

Example 47 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Hyperium by HyperiumClient.

the class NetworkHandler method handleChat.

@Override
public void handleChat(String s) {
    if (s.toLowerCase().contains("reconnecting hyperium connection"))
        return;
    Hyperium.LOGGER.debug("Chat: {}", s);
    s = s.replace("&", C.COLOR_CODE_SYMBOL);
    IChatComponent chatComponent = new ChatComponentText("");
    Arrays.stream(s.split(" ")).forEach(s1 -> {
        ChatComponentText iChatComponents = new ChatComponentText(s1 + " ");
        if (s1.contains(".") && !s1.startsWith(".") && !s1.endsWith(".")) {
            ChatStyle chatStyle = new ChatStyle();
            chatStyle.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, s1.startsWith("http") ? s1 : "http://" + s1));
            iChatComponents.setChatStyle(chatStyle);
        }
        chatComponent.appendSibling(iChatComponents);
    });
    GeneralChatHandler.instance().sendMessage(chatComponent);
}
Also used : ChatStyle(net.minecraft.util.ChatStyle) ClickEvent(net.minecraft.event.ClickEvent) IChatComponent(net.minecraft.util.IChatComponent) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 48 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Hyperium by HyperiumClient.

the class HyperiumScreenshotHelper method saveScreenshot.

public static IChatComponent saveScreenshot(int width, int height, Framebuffer buffer, IntBuffer pixelBuffer, int[] pixelValues) {
    final File file1 = new File(Minecraft.getMinecraft().mcDataDir, "screenshots");
    file1.mkdir();
    if (OpenGlHelper.isFramebufferEnabled()) {
        width = buffer.framebufferTextureWidth;
        height = buffer.framebufferTextureHeight;
    }
    final int i = width * height;
    if (pixelBuffer == null || pixelBuffer.capacity() < i) {
        pixelBuffer = BufferUtils.createIntBuffer(i);
        pixelValues = new int[i];
    }
    GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
    pixelBuffer.clear();
    if (OpenGlHelper.isFramebufferEnabled()) {
        GlStateManager.bindTexture(buffer.framebufferTexture);
        GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
    } else {
        GL11.glReadPixels(0, 0, width, height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
    }
    boolean upload = true;
    pixelBuffer.get(pixelValues);
    if (!Settings.DEFAULT_UPLOAD_SS) {
        HyperiumBind uploadBind = Hyperium.INSTANCE.getHandlers().getKeybindHandler().getBinding("Upload Screenshot");
        int keyCode = uploadBind.getKeyCode();
        upload = keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode);
    }
    new Thread(new AsyncScreenshotSaver(width, height, pixelValues, Minecraft.getMinecraft().getFramebuffer(), new File(Minecraft.getMinecraft().mcDataDir, "screenshots"), upload)).start();
    if (!upload) {
        return Settings.HYPERIUM_CHAT_PREFIX ? new ChatComponentText(ChatColor.RED + "[Hyperium] " + ChatColor.WHITE + "Capturing...") : new ChatComponentText(ChatColor.WHITE + "Capturing...");
    }
    return Settings.HYPERIUM_CHAT_PREFIX ? new ChatComponentText(ChatColor.RED + "[Hyperium] " + ChatColor.WHITE + "Uploading...") : new ChatComponentText(ChatColor.WHITE + "Uploading...");
}
Also used : HyperiumBind(cc.hyperium.handlers.handlers.keybinds.HyperiumBind) AsyncScreenshotSaver(cc.hyperium.utils.mods.AsyncScreenshotSaver) File(java.io.File) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 49 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Hyperium by HyperiumClient.

the class HyperiumEntityPlayer method getDisplayName.

public IChatComponent getDisplayName() {
    if (cachedName == null || System.currentTimeMillis() - lastChangeTime > 50L) {
        IChatComponent ichatcomponent = new ChatComponentText(ScorePlayerTeam.formatPlayerName(parent.getTeam(), displayName));
        ichatcomponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + parent.getName() + " "));
        // Unneeded for client
        if (Minecraft.getMinecraft().isIntegratedServerRunning()) {
            ichatcomponent.getChatStyle().setChatHoverEvent(((IMixinEntity) parent).callGetHoverEvent());
        }
        ichatcomponent.getChatStyle().setInsertion(parent.getName());
        cachedName = ichatcomponent;
    }
    return cachedName;
}
Also used : ClickEvent(net.minecraft.event.ClickEvent) IChatComponent(net.minecraft.util.IChatComponent) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 50 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Hyperium by HyperiumClient.

the class UpdateChecker method serverJoinEvent.

@InvokeEvent
public void serverJoinEvent(ServerJoinEvent event) {
    // If they were already asked, don't even make the new thread.
    if (asked)
        return;
    UpdateUtils updateUtils = new UpdateUtils();
    Multithreading.runAsync(() -> {
        boolean latest = updateUtils.isAbsoluteLatest();
        boolean beta = updateUtils.isBeta();
        int version = Metadata.getVersionID();
        Hyperium.LOGGER.info("version is: " + version);
        // dont alert beta users
        if (beta)
            return;
        // If they're on the latest version, I don't want to mess with them.
        if (latest)
            return;
        Hyperium.INSTANCE.getNotification().display("You have an update pending.", "Click here to be sent to the installer.", 10f, null, () -> {
            try {
                Desktop.getDesktop().browse(new URI("https://hyperium.cc/downloads"));
            } catch (IOException | URISyntaxException e) {
                IChatComponent urlComponent = new ChatComponentText(ChatColor.RED + "[Hyperium] " + ChatColor.GRAY + "Click to be sent to update Hyperium");
                urlComponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://hyperium.cc/downloads"));
                Hyperium.INSTANCE.getHandlers().getGeneralChatHandler().sendMessage(urlComponent);
            }
        }, new Color(200, 150, 50));
        asked = true;
    });
}
Also used : UpdateUtils(cc.hyperium.utils.UpdateUtils) ClickEvent(net.minecraft.event.ClickEvent) ChatColor(cc.hyperium.utils.ChatColor) IChatComponent(net.minecraft.util.IChatComponent) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) ChatComponentText(net.minecraft.util.ChatComponentText) InvokeEvent(cc.hyperium.event.InvokeEvent)

Aggregations

ChatComponentText (net.minecraft.util.ChatComponentText)383 IChatComponent (net.minecraft.util.IChatComponent)55 EntityPlayer (net.minecraft.entity.player.EntityPlayer)43 ChatStyle (net.minecraft.util.ChatStyle)39 ItemStack (net.minecraft.item.ItemStack)36 ClickEvent (net.minecraft.event.ClickEvent)31 World (net.minecraft.world.World)28 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)26 TileEntity (net.minecraft.tileentity.TileEntity)25 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)25 HoverEvent (net.minecraft.event.HoverEvent)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)21 ArrayList (java.util.ArrayList)17 RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)16 Block (net.minecraft.block.Block)15 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)15 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)14 Entity (net.minecraft.entity.Entity)14 DimensionInformation (mcjty.rftools.dimension.DimensionInformation)13 File (java.io.File)12