Search in sources :

Example 6 with Formatting

use of net.minecraft.util.Formatting in project EarthMCEssentials by EarthMC-Stats.

the class TownlessCommand method run.

private static int run(CommandContext<FabricClientCommandSource> c) {
    StringBuilder townlessString = new StringBuilder();
    Formatting townlessTextFormatting = Formatting.byName(instance().getConfig().commands.townlessTextColour.name());
    for (String townlessPlayer : instance().getTownless()) townlessString.append(townlessPlayer).append(", ");
    MsgUtils.sendPlayer("text_townless_header", false, townlessTextFormatting, false, instance().getTownless().size());
    if (instance().getTownless().size() > 0)
        MsgUtils.sendPlayer(townlessString.toString(), false, townlessTextFormatting, false);
    return 1;
}
Also used : Formatting(net.minecraft.util.Formatting)

Example 7 with Formatting

use of net.minecraft.util.Formatting in project Client by MatHax.

the class BetterTab method getPlayerName.

public Text getPlayerName(PlayerListEntry playerListEntry) {
    Text name;
    Color color = null;
    name = playerListEntry.getDisplayName();
    if (name == null) {
        /*if (mc.getSession().getUsername().equals("Matejko06"))
                name = new LiteralText("  " + playerListEntry.getProfile().getName());
            else*/
        name = new LiteralText(playerListEntry.getProfile().getName());
    }
    if (playerListEntry.getProfile().getId().toString().equals(mc.player.getGameProfile().getId().toString()) && self.get()) {
        color = selfColor.get();
    } else if (friends.get() && Friends.get().get(playerListEntry.getProfile().getName()) != null) {
        Friend friend = Friends.get().get(playerListEntry.getProfile().getName());
        if (friend != null)
            color = Friends.get().color;
    } else if (enemies.get() && Enemies.get().get(playerListEntry.getProfile().getName()) != null) {
        Enemy enemy = Enemies.get().get(playerListEntry.getProfile().getName());
        if (enemy != null)
            color = Enemies.get().color;
    }
    if (color != null) {
        String nameString = name.getString();
        for (Formatting format : Formatting.values()) {
            if (format.isColor())
                nameString = nameString.replace(format.toString(), "");
        }
        name = new LiteralText(nameString).setStyle(name.getStyle().withColor(new TextColor(color.getPacked())));
    }
    return name;
}
Also used : Friend(mathax.client.systems.friends.Friend) SettingColor(mathax.client.utils.render.color.SettingColor) TextColor(net.minecraft.text.TextColor) Color(mathax.client.utils.render.color.Color) Enemy(mathax.client.systems.enemies.Enemy) Formatting(net.minecraft.util.Formatting) LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) TextColor(net.minecraft.text.TextColor) LiteralText(net.minecraft.text.LiteralText)

Example 8 with Formatting

use of net.minecraft.util.Formatting in project Client by MatHax.

the class TPSCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.executes(context -> {
        float tps = TickRate.INSTANCE.getTickRate();
        Formatting color;
        if (tps > 16.0f)
            color = Formatting.GREEN;
        else if (tps > 12.0f)
            color = Formatting.YELLOW;
        else
            color = Formatting.RED;
        info("Current TPS: %s%.2f(default).", color, tps);
        return SINGLE_SUCCESS;
    });
}
Also used : Formatting(net.minecraft.util.Formatting)

Example 9 with Formatting

use of net.minecraft.util.Formatting in project EarthMCEssentials by EarthMC-Stats.

the class InfoCommands method sendNationInfo.

private static void sendNationInfo(JsonObject nationObject, FabricClientCommandSource source) {
    Formatting nationInfoTextColour = Formatting.byName(instance().getConfig().commands.nationInfoTextColour.name());
    source.sendFeedback(new TranslatableText("text_nationinfo_header", nationObject.get("name").getAsString()).formatted(nationInfoTextColour));
    source.sendFeedback(new TranslatableText("text_nationinfo_king", nationObject.get("king").getAsString()).formatted(nationInfoTextColour));
    source.sendFeedback(new TranslatableText("text_nationinfo_capital", nationObject.get("capitalName").getAsString()).formatted(nationInfoTextColour));
    source.sendFeedback(new TranslatableText("text_nationinfo_area", nationObject.get("area").getAsString()).formatted(nationInfoTextColour));
    source.sendFeedback(new TranslatableText("text_shared_residents", nationObject.get("residents").getAsJsonArray().size()).formatted(nationInfoTextColour));
    source.sendFeedback(new TranslatableText("text_nationinfo_towns", nationObject.get("towns").getAsJsonArray().size()).formatted(nationInfoTextColour));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Formatting(net.minecraft.util.Formatting)

Example 10 with Formatting

use of net.minecraft.util.Formatting in project EarthMCEssentials by EarthMC-Stats.

the class InfoCommands method sendTownInfo.

private static void sendTownInfo(JsonObject townObject, FabricClientCommandSource source) {
    Formatting townInfoTextColour = Formatting.byName(instance().getConfig().commands.townInfoTextColour.name());
    source.sendFeedback(new TranslatableText("text_towninfo_header", townObject.get("name").getAsString()).formatted(townInfoTextColour));
    source.sendFeedback(new TranslatableText("text_towninfo_mayor", townObject.get("mayor").getAsString()).formatted(townInfoTextColour));
    source.sendFeedback(new TranslatableText("text_towninfo_area", townObject.get("area").getAsString()).formatted(townInfoTextColour));
    source.sendFeedback(new TranslatableText("text_shared_residents", townObject.get("residents").getAsJsonArray().size()).formatted(townInfoTextColour));
    source.sendFeedback(new TranslatableText("text_towninfo_location", townObject.get("x").getAsString(), townObject.get("z").getAsString()).formatted(townInfoTextColour));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Formatting(net.minecraft.util.Formatting)

Aggregations

Formatting (net.minecraft.util.Formatting)10 LiteralText (net.minecraft.text.LiteralText)4 TranslatableText (net.minecraft.text.TranslatableText)4 Text (net.minecraft.text.Text)3 TextColor (net.minecraft.text.TextColor)3 MinecraftClient (net.minecraft.client.MinecraftClient)2 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 FluidText (io.github.darkkronicle.advancedchatcore.util.FluidText)1 SearchResult (io.github.darkkronicle.advancedchatcore.util.SearchResult)1 StringMatch (io.github.darkkronicle.advancedchatcore.util.StringMatch)1 Enemy (mathax.client.systems.enemies.Enemy)1 Friend (mathax.client.systems.friends.Friend)1 Color (mathax.client.utils.render.color.Color)1 SettingColor (mathax.client.utils.render.color.SettingColor)1 ConfigBuilder (me.shedaniel.clothconfig2.api.ConfigBuilder)1 ConfigCategory (me.shedaniel.clothconfig2.api.ConfigCategory)1 ConfigEntryBuilder (me.shedaniel.clothconfig2.api.ConfigEntryBuilder)1 Friend (meteordevelopment.meteorclient.systems.friends.Friend)1