Search in sources :

Example 31 with Style

use of net.minecraft.util.text.Style in project BiomeTweaker by superckl.

the class CommandReloadScript method execute.

@Override
public void execute(final MinecraftServer server, final ICommandSender sender, final String[] args) throws CommandException {
    if (args.length != 1) {
        sender.sendMessage(new TextComponentTranslation("biometweaker.msg.reloadscript.usage.text").setStyle(new Style().setColor(TextFormatting.RED)));
        return;
    }
    try {
        final File operateIn = BiomeTweaker.getInstance().getConfig().getBtConfigFolder();
        final File scriptFile = new File(operateIn, args[0]);
        if (!scriptFile.exists() || !scriptFile.isFile()) {
            sender.sendMessage(new TextComponentTranslation("biometweaker.msg.reloadscript.nofile.text", scriptFile.getName()).setStyle(new Style().setColor(TextFormatting.RED)));
            return;
        }
        BiomeTweaker.getInstance().parseScript(scriptFile);
        sender.sendMessage(new TextComponentTranslation("biometweaker.msg.reloadscript.success.text", scriptFile.getName()).setStyle(new Style().setColor(TextFormatting.AQUA)));
    } catch (final Exception e) {
        sender.sendMessage(new TextComponentTranslation("biometweaker.msg.reloadscript.failure.text", args[0]).setStyle(new Style().setColor(TextFormatting.RED)));
        LogHelper.error(String.format("Failed to reload script %s!", args[0]));
        e.printStackTrace();
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Style(net.minecraft.util.text.Style) File(java.io.File) CommandException(net.minecraft.command.CommandException)

Example 32 with Style

use of net.minecraft.util.text.Style in project BiomeTweaker by superckl.

the class CommandReload method execute.

@Override
public void execute(final MinecraftServer server, final ICommandSender sender, final String[] args) throws CommandException {
    try {
        BiomeTweaker.getInstance().getConfig().loadValues();
        BiomeTweaker.getInstance().getCommandManager().reset();
        BiomeTweaker.getInstance().parseScripts();
        sender.sendMessage(new TextComponentTranslation("biometweaker.msg.reload.success.text").setStyle(new Style().setColor(TextFormatting.AQUA)));
    } catch (final Exception e) {
        sender.sendMessage(new TextComponentTranslation("biometweaker.msg.reload.failure.text").setStyle(new Style().setColor(TextFormatting.RED)));
        LogHelper.error("Failed to reload scripts!");
        e.printStackTrace();
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Style(net.minecraft.util.text.Style) CommandException(net.minecraft.command.CommandException)

Example 33 with Style

use of net.minecraft.util.text.Style in project BuildCraft by BuildCraft.

the class CommandVersion method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    ForgeVersion.CheckResult result = ForgeVersion.getResult(BCLib.MOD_CONTAINER);
    if (result.status == Status.FAILED) {
        sender.sendMessage(new TextComponentTranslation("command.buildcraft.version.failed"));
        return;
    }
    Style style = new Style();
    if (result.status == Status.OUTDATED) {
        style.setColor(TextFormatting.RED);
    } else {
        style.setColor(TextFormatting.GREEN);
    }
    BCLog.logger.info("[lib.command.version] Result status = " + result.status);
    BCLog.logger.info("[lib.command.version] Result url = " + result.url);
    BCLog.logger.info("[lib.command.version] Result target = " + result.target);
    BCLog.logger.info("[lib.command.version] Result changes = " + result.changes);
    String currentVersion = BCLib.VERSION;
    if (currentVersion.startsWith("$")) {
        currentVersion = "?.??.??";
        style.setColor(TextFormatting.GRAY);
    }
    Object[] textArgs = { currentVersion, ForgeVersion.mcVersion, result.target.toString() };
    sender.sendMessage(new TextComponentTranslation("command.buildcraft.version", textArgs).setStyle(style));
    if (currentVersion.contains("-pre")) {
        sender.sendMessage(new TextComponentTranslation("command.buildcraft.version.prerelease"));
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Style(net.minecraft.util.text.Style) ForgeVersion(net.minecraftforge.common.ForgeVersion)

Example 34 with Style

use of net.minecraft.util.text.Style in project HorsePower by GoryMoon.

the class Utils method sendSavedErrors.

public static void sendSavedErrors() {
    if (FMLCommonHandler.instance().getSide().isClient() && FMLClientHandler.instance().getClientPlayerEntity() != null && HPRecipes.ERRORS.size() > 0) {
        FMLClientHandler.instance().getClientPlayerEntity().sendMessage(new TextComponentString(TextFormatting.RED + "" + TextFormatting.BOLD + "HorsePower config errors"));
        FMLClientHandler.instance().getClientPlayerEntity().sendMessage(new TextComponentString(TextFormatting.RED + "" + TextFormatting.BOLD + "-----------------------------------------"));
        HPRecipes.ERRORS.forEach(s -> FMLClientHandler.instance().getClientPlayerEntity().sendMessage(new TextComponentString(TextFormatting.RED + s).setStyle(new Style().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, Loader.instance().getConfigDir() + "/horsepower.cfg")).setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Changed in in-game config or click to open the config file to fix this"))))));
        FMLClientHandler.instance().getClientPlayerEntity().sendMessage(new TextComponentString(TextFormatting.RED + "" + TextFormatting.BOLD + "-----------------------------------------"));
        HPRecipes.ERRORS.clear();
    }
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent) Style(net.minecraft.util.text.Style) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 35 with Style

use of net.minecraft.util.text.Style in project ForestryMC by ForestryMC.

the class CommandModeInfo method executeSubCommand.

@Override
public void executeSubCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length <= 0) {
        printHelp(sender);
        return;
    }
    String modeName = args[0];
    if (modeName == null) {
        CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.mode.info.error", args[0]);
        printHelp(sender);
        return;
    }
    Style green = new Style();
    green.setColor(TextFormatting.GREEN);
    CommandHelpers.sendLocalizedChatMessage(sender, green, modeName);
    for (String desc : modeHelper.getDescription(modeName)) {
        CommandHelpers.sendLocalizedChatMessage(sender, "for." + desc);
    }
}
Also used : Style(net.minecraft.util.text.Style)

Aggregations

Style (net.minecraft.util.text.Style)51 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)30 TextComponentString (net.minecraft.util.text.TextComponentString)21 ITextComponent (net.minecraft.util.text.ITextComponent)17 ClickEvent (net.minecraft.util.text.event.ClickEvent)10 BlockPos (net.minecraft.util.math.BlockPos)9 CommandException (net.minecraft.command.CommandException)7 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 ItemStack (net.minecraft.item.ItemStack)4 World (net.minecraft.world.World)4 Colony (com.minecolonies.coremod.colony.Colony)3 PlayerIdentifier (com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 GameProfile (com.mojang.authlib.GameProfile)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 HoverEvent (net.minecraft.util.text.event.HoverEvent)2 Biome (net.minecraft.world.biome.Biome)2 FluidStack (net.minecraftforge.fluids.FluidStack)2