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;
}
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;
}
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;
});
}
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));
}
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));
}
Aggregations