Search in sources :

Example 26 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Galacticraft by micdoodle8.

the class CommandSpaceStationRemoveOwner method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    String var3 = null;
    EntityPlayerMP playerBase = null;
    if (args.length > 0) {
        var3 = args[0];
        try {
            playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), false);
            if (playerBase != null) {
                GCPlayerStats stats = GCPlayerStats.get(playerBase);
                if (stats.getSpaceStationDimensionData().isEmpty()) {
                    throw new WrongUsageException(GCCoreUtil.translate("commands.ssinvite.not_found"), new Object[0]);
                } else {
                    for (Map.Entry<Integer, Integer> e : stats.getSpaceStationDimensionData().entrySet()) {
                        final SpaceStationWorldData data = SpaceStationWorldData.getStationData(playerBase.worldObj, e.getValue(), playerBase);
                        String str = null;
                        for (String name : data.getAllowedPlayers()) {
                            if (name.equalsIgnoreCase(var3)) {
                                str = name;
                                break;
                            }
                        }
                        if (str != null) {
                            data.getAllowedPlayers().remove(str);
                            data.markDirty();
                        } else {
                            throw new CommandException(GCCoreUtil.translateWithFormat("commands.ssuninvite.no_player", "\"" + var3 + "\""), new Object[0]);
                        }
                    }
                }
            }
        } catch (final Exception var6) {
            throw new CommandException(var6.getMessage(), new Object[0]);
        }
    } else {
        throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.ssinvite.wrong_usage", this.getCommandUsage(sender)), new Object[0]);
    }
    if (playerBase != null) {
        playerBase.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("gui.spacestation.removesuccess", var3)));
    }
}
Also used : SpaceStationWorldData(micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData) WrongUsageException(net.minecraft.command.WrongUsageException) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) CommandException(net.minecraft.command.CommandException) ChatComponentText(net.minecraft.util.ChatComponentText) CommandException(net.minecraft.command.CommandException) WrongUsageException(net.minecraft.command.WrongUsageException)

Example 27 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Galacticraft by micdoodle8.

the class EntityBuggy method interactFirst.

@Override
public boolean interactFirst(EntityPlayer var1) {
    if (this.worldObj.isRemote) {
        if (this.riddenByEntity == null) {
            var1.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.leftKey.getKeyCode()) + " / " + GameSettings.getKeyDisplayString(KeyHandlerClient.rightKey.getKeyCode()) + "  - " + GCCoreUtil.translate("gui.buggy.turn.name")));
            var1.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.accelerateKey.getKeyCode()) + "       - " + GCCoreUtil.translate("gui.buggy.accel.name")));
            var1.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.decelerateKey.getKeyCode()) + "       - " + GCCoreUtil.translate("gui.buggy.decel.name")));
            var1.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.openFuelGui.getKeyCode()) + "       - " + GCCoreUtil.translate("gui.buggy.inv.name")));
        }
        return true;
    } else {
        if (this.riddenByEntity != null) {
            if (this.riddenByEntity == var1)
                var1.mountEntity(null);
            return true;
        } else {
            var1.mountEntity(this);
            return true;
        }
    }
}
Also used : ChatComponentText(net.minecraft.util.ChatComponentText)

Example 28 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Galacticraft by micdoodle8.

the class ThreadVersionCheck method run.

@Override
public void run() {
    final Side sideToCheck = FMLCommonHandler.instance().getSide();
    if (sideToCheck == null || ConfigManagerCore.disableUpdateCheck) {
        return;
    }
    while (this.count < 3 && remotePatchVer == -1) {
        BufferedReader in = null;
        try {
            final URL url = new URL("https://micdoodle8.com/galacticraft/version.html");
            final HttpURLConnection http = (HttpURLConnection) url.openConnection();
            http.addRequestProperty("User-Agent", "Mozilla/4.76");
            InputStreamReader streamReader = new InputStreamReader(http.getInputStream());
            in = new BufferedReader(streamReader);
            String str;
            String[] str2 = null;
            while ((str = in.readLine()) != null) {
                if (str.contains("Version")) {
                    str = str.replace("Version=", "");
                    str2 = str.split("#");
                    if (str2.length >= 3) {
                        remoteMajVer = Integer.parseInt(str2[0]);
                        remoteMinVer = Integer.parseInt(str2[1]);
                        remotePatchVer = Integer.parseInt(str2[2]);
                    }
                    if (remoteMajVer == Constants.LOCALMAJVERSION && (remoteMinVer > Constants.LOCALMINVERSION || (remoteMinVer == Constants.LOCALMINVERSION && remotePatchVer > Constants.LOCALPATCHVERSION))) {
                        Thread.sleep(5000);
                        if (sideToCheck.equals(Side.CLIENT)) {
                            FMLClientHandler.instance().getClient().thePlayer.addChatMessage(new ChatComponentText(EnumColor.GREY + "New " + EnumColor.DARK_AQUA + Constants.MOD_NAME_SIMPLE + EnumColor.GREY + " version available! v" + String.valueOf(remoteMajVer) + "." + String.valueOf(remoteMinVer) + "." + String.valueOf(remotePatchVer) + ".xxx" + EnumColor.DARK_BLUE + " http://micdoodle8.com/"));
                        } else if (sideToCheck.equals(Side.SERVER)) {
                            GCLog.severe("New Galacticraft version available! v" + String.valueOf(remoteMajVer) + "." + String.valueOf(remoteMinVer) + "." + String.valueOf(remotePatchVer) + ".xxx" + " http://micdoodle8.com/");
                        }
                    }
                    break;
                }
            }
            in.close();
            streamReader.close();
        } catch (final Exception e) {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }
        if (remotePatchVer == -1) {
            try {
                GCLog.severe(GCCoreUtil.translate("newversion.failed.name"));
                Thread.sleep(15000);
            } catch (final InterruptedException e) {
            }
        } else {
            GCLog.info(GCCoreUtil.translate("newversion.success.name") + " " + remoteMajVer + "." + remoteMinVer + "." + remotePatchVer);
        }
        this.count++;
    }
}
Also used : Side(net.minecraftforge.fml.relauncher.Side) HttpURLConnection(java.net.HttpURLConnection) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) ChatComponentText(net.minecraft.util.ChatComponentText) URL(java.net.URL) IOException(java.io.IOException)

Example 29 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Galacticraft by micdoodle8.

the class BlockShortRangeTelepad method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
    TileEntity tile = worldIn.getTileEntity(pos);
    boolean validSpot = true;
    for (int x = -1; x <= 1; x++) {
        for (int y = 0; y < 3; y += 2) {
            for (int z = -1; z <= 1; z++) {
                if (!(x == 0 && y == 0 && z == 0)) {
                    Block blockAt = worldIn.getBlockState(pos.add(x, y, z)).getBlock();
                    if (!blockAt.getMaterial().isReplaceable()) {
                        validSpot = false;
                    }
                }
            }
        }
    }
    if (!validSpot) {
        worldIn.setBlockToAir(pos);
        if (placer instanceof EntityPlayer) {
            if (!worldIn.isRemote) {
                ((EntityPlayer) placer).addChatMessage(new ChatComponentText(EnumColor.RED + GCCoreUtil.translate("gui.warning.noroom")));
            }
            ((EntityPlayer) placer).inventory.addItemStackToInventory(new ItemStack(Item.getItemFromBlock(this), 1, 0));
        }
        return;
    }
    if (tile instanceof TileEntityShortRangeTelepad) {
        ((TileEntityShortRangeTelepad) tile).onCreate(worldIn, pos);
        ((TileEntityShortRangeTelepad) tile).setOwner(PlayerUtil.getName(((EntityPlayer) placer)));
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityShortRangeTelepad(micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad) Block(net.minecraft.block.Block) IMultiBlock(micdoodle8.mods.galacticraft.core.tile.IMultiBlock) EnumSortCategoryBlock(micdoodle8.mods.galacticraft.core.util.EnumSortCategoryBlock) ISortableBlock(micdoodle8.mods.galacticraft.core.blocks.ISortableBlock) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 30 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Armourers-Workshop by RiskyKen.

the class ModClientFMLEventHandler method onPlayerTickEndEvent.

public void onPlayerTickEndEvent() {
    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    if (!shownUpdateInfo && UpdateCheck.updateFound) {
        shownUpdateInfo = true;
        ChatComponentText updateMessage = new ChatComponentText(TranslateUtils.translate("chat.armourersworkshop:updateAvailable", UpdateCheck.remoteModVersion) + " ");
        ChatComponentText updateURL = new ChatComponentText(TranslateUtils.translate("chat.armourersworkshop:updateDownload"));
        updateURL.getChatStyle().setUnderlined(true);
        updateURL.getChatStyle().setColor(EnumChatFormatting.BLUE);
        updateURL.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(TranslateUtils.translate("chat.armourersworkshop:updateDownloadRollover"))));
        updateURL.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, LibModInfo.DOWNLOAD_URL));
        updateMessage.appendSibling(updateURL);
        player.addChatMessage(updateMessage);
    }
    if (!showmDevWarning && LibModInfo.DEVELOPMENT_VERSION) {
        ChatComponentText devWarning = new ChatComponentText(TranslateUtils.translate("chat.armourersworkshop:devWarning"));
        devWarning.getChatStyle().setColor(EnumChatFormatting.RED);
        player.addChatMessage(devWarning);
        showmDevWarning = true;
    }
}
Also used : HoverEvent(net.minecraft.event.HoverEvent) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) ClickEvent(net.minecraft.event.ClickEvent) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

ChatComponentText (net.minecraft.util.ChatComponentText)164 ItemStack (net.minecraft.item.ItemStack)27 EntityPlayer (net.minecraft.entity.player.EntityPlayer)24 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)16 TileEntity (net.minecraft.tileentity.TileEntity)13 Entity (net.minecraft.entity.Entity)12 ClickEvent (net.minecraft.event.ClickEvent)10 IChatComponent (net.minecraft.util.IChatComponent)10 ArrayList (java.util.ArrayList)9 ChatStyle (net.minecraft.util.ChatStyle)9 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)8 Block (net.minecraft.block.Block)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)8 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)7 File (java.io.File)7 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)7 WrongUsageException (net.minecraft.command.WrongUsageException)7 World (net.minecraft.world.World)6 AccessGroup (com.builtbroken.mc.lib.access.AccessGroup)5 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)5