From d690ed6ac61351733a330286dfceeb303dd36252 Mon Sep 17 00:00:00 2001 From: Waiting Idly <25394029+WaitingIdly@users.noreply.github.com> Date: Fri, 8 Nov 2024 12:35:32 -0800 Subject: [PATCH] StyleConstant creation (#259) * move code generation colors to constant values * extract to StyleConstant, apply to many places * fix minor mistakes * change nbt key coloration * color nbt tag string properly * adjust blockstate appearance * change color for mapper and string, improve javadoc * fix JEI tab not working based on stack size * make NBT letters be lowercase * convert mapper color to be method color * convert style to methods * make copy text be colored * adjust mekanism info commands * act as if colored is always true for info parsers * adjust javadoc * update nbt parser and extract constants * restore using colored parameter --- .../groovyscript/GroovyScript.java | 19 ++-- .../api/infocommand/InfoParser.java | 7 +- .../groovyscript/command/BaseInfoCommand.java | 9 +- .../groovyscript/command/GSCommand.java | 37 +++---- .../command/GSMekanismCommand.java | 10 +- .../groovyscript/command/TextCopyable.java | 25 ++--- .../compat/mods/jei/InfoParserTab.java | 7 +- .../command/infoparser/GenericInfoParser.java | 11 +- .../command/infoparser/InfoParserNBT.java | 29 ++--- .../command/infoparser/InfoParserOreDict.java | 2 +- .../infoparser/InfoParserTranslationKey.java | 4 +- .../groovyscript/helper/StyleConstant.java | 102 ++++++++++++++++++ .../ingredient/GroovyScriptCodeConverter.java | 83 ++++++++------ .../helper/ingredient/NbtHelper.java | 77 +++++++------ .../network/StartLanguageServerPacket.java | 6 +- .../assets/groovyscript/lang/en_us.lang | 2 +- 16 files changed, 283 insertions(+), 147 deletions(-) create mode 100644 src/main/java/com/cleanroommc/groovyscript/helper/StyleConstant.java diff --git a/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java b/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java index f972817b1..1a0e2f2d0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java +++ b/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java @@ -14,6 +14,7 @@ import com.cleanroommc.groovyscript.documentation.linkgenerator.LinkGeneratorHooks; import com.cleanroommc.groovyscript.event.EventHandler; import com.cleanroommc.groovyscript.helper.JsonHelper; +import com.cleanroommc.groovyscript.helper.StyleConstant; import com.cleanroommc.groovyscript.mapper.ObjectMapper; import com.cleanroommc.groovyscript.mapper.ObjectMapperManager; import com.cleanroommc.groovyscript.network.CReload; @@ -181,10 +182,10 @@ public static long runGroovyScriptsInLoader(LoadStage loadStage) { public void onPostInit(FMLPostInitializationEvent event) { CustomClickAction.registerAction("copy", value -> { GuiScreen.setClipboardString(value); - Minecraft.getMinecraft().player.sendMessage( - new TextComponentTranslation("groovyscript.command.copy.copied_start") - .appendSibling(new TextComponentString(value).setStyle(new Style().setColor(TextFormatting.GOLD))) - .appendSibling(new TextComponentTranslation("groovyscript.command.copy.copied_end"))); + var message = new TextComponentTranslation("groovyscript.command.copy.copied_start").setStyle(StyleConstant.getEmphasisStyle()) + .appendSibling(new TextComponentString(value).setStyle(new Style().setColor(TextFormatting.RESET))) + .appendSibling(new TextComponentTranslation("groovyscript.command.copy.copied_end").setStyle(StyleConstant.getEmphasisStyle())); + Minecraft.getMinecraft().player.sendMessage(message); }); } @@ -279,21 +280,21 @@ public static void postScriptRunResult(ICommandSender sender, boolean onlyLogFai if (!onlyLogFails) { if (running) { String s = packmode ? "changes packmode" : "reloaded scripts"; - sender.sendMessage(new TextComponentString(TextFormatting.GREEN + "Successfully " + s + TextFormatting.WHITE + " in " + time + "ms")); + sender.sendMessage(new TextComponentString("Successfully " + s).setStyle(StyleConstant.getSuccessStyle()).appendSibling(new TextComponentString(" in " + time + "ms"))); } else { - sender.sendMessage(new TextComponentString(TextFormatting.GREEN + "No syntax errors found :)")); + sender.sendMessage(new TextComponentString("No syntax errors found :)").setStyle(StyleConstant.getSuccessStyle())); } } } else { String executing = running ? "running" : "checking"; - sender.sendMessage(new TextComponentString(TextFormatting.RED + "Found " + errors.size() + " errors while " + executing + " scripts")); + sender.sendMessage(new TextComponentString("Found " + errors.size() + " errors while " + executing + " scripts").setStyle(StyleConstant.getErrorStyle())); int n = errors.size(); if (errors.size() >= 10) { - sender.sendMessage(new TextComponentString("Displaying the first 7 errors:")); + sender.sendMessage(new TextComponentString("Displaying the first 7 errors:").setStyle(StyleConstant.getTitleStyle())); n = 7; } for (int i = 0; i < n; i++) { - sender.sendMessage(new TextComponentString(TextFormatting.RED + errors.get(i))); + sender.sendMessage(new TextComponentString(errors.get(i)).setStyle(StyleConstant.getErrorStyle())); } GSCommand.postLogFiles(sender); } diff --git a/src/main/java/com/cleanroommc/groovyscript/api/infocommand/InfoParser.java b/src/main/java/com/cleanroommc/groovyscript/api/infocommand/InfoParser.java index ea9da3bfc..b6726a896 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/infocommand/InfoParser.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/infocommand/InfoParser.java @@ -1,14 +1,17 @@ package com.cleanroommc.groovyscript.api.infocommand; +import com.cleanroommc.groovyscript.helper.StyleConstant; import net.minecraft.util.text.Style; -import net.minecraft.util.text.TextFormatting; public interface InfoParser { /** * The style for any parser header - bold and light purple. + * + * @deprecated use {@link com.cleanroommc.groovyscript.helper.StyleConstant#getTitleStyle()} */ - Style headerStyle = new Style().setColor(TextFormatting.WHITE).setBold(true); + @Deprecated + Style headerStyle = StyleConstant.getTitleStyle(); /** * Priority of the parser for determining the order they are logged in chat, diff --git a/src/main/java/com/cleanroommc/groovyscript/command/BaseInfoCommand.java b/src/main/java/com/cleanroommc/groovyscript/command/BaseInfoCommand.java index 6b0d0185e..25843eb1f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/command/BaseInfoCommand.java +++ b/src/main/java/com/cleanroommc/groovyscript/command/BaseInfoCommand.java @@ -3,6 +3,7 @@ import com.cleanroommc.groovyscript.api.infocommand.InfoParserPackage; import com.cleanroommc.groovyscript.api.infocommand.InfoParserRegistry; import com.cleanroommc.groovyscript.event.GsHandEvent; +import com.cleanroommc.groovyscript.helper.StyleConstant; import com.google.common.base.Predicates; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; @@ -15,9 +16,7 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.Style; import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; import net.minecraftforge.common.MinecraftForge; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -112,14 +111,14 @@ public int getRequiredPermissionLevel() { protected void print(EntityPlayer player, List messages, List argList) { if (messages.isEmpty()) { if (argList.isEmpty()) { - player.sendMessage(new TextComponentString(String.format("Couldn't find %s!", targetDescription())).setStyle(new Style().setColor(TextFormatting.RED))); + player.sendMessage(new TextComponentString(String.format("Couldn't find %s!", targetDescription())).setStyle(StyleConstant.getErrorStyle())); } else { - player.sendMessage(new TextComponentString(String.format("Couldn't find %s matching the given arguments!", targetDescription())).setStyle(new Style().setColor(TextFormatting.RED))); + player.sendMessage(new TextComponentString(String.format("Couldn't find %s matching the given arguments!", targetDescription())).setStyle(StyleConstant.getErrorStyle())); player.sendMessage(new TextComponentString("The following arguments were provided: " + String.join(", ", argList))); } } else { // have a horizontal bar to improve readability when running multiple consecutive info commands - player.sendMessage(new TextComponentString("================================").setStyle(new Style().setColor(TextFormatting.GOLD))); + player.sendMessage(new TextComponentString("================================").setStyle(StyleConstant.getEmphasisStyle())); messages.forEach(player::sendMessage); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/command/GSCommand.java b/src/main/java/com/cleanroommc/groovyscript/command/GSCommand.java index a73933e03..3b3022ee3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/command/GSCommand.java +++ b/src/main/java/com/cleanroommc/groovyscript/command/GSCommand.java @@ -5,6 +5,7 @@ import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.compat.mods.jei.JeiPlugin; import com.cleanroommc.groovyscript.documentation.Documentation; +import com.cleanroommc.groovyscript.helper.StyleConstant; import com.cleanroommc.groovyscript.network.NetworkHandler; import com.cleanroommc.groovyscript.network.SReloadScripts; import com.cleanroommc.groovyscript.network.StartLanguageServerPacket; @@ -15,9 +16,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.Style; import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.event.ClickEvent; import net.minecraft.util.text.event.HoverEvent; import net.minecraftforge.server.command.CommandTreeBase; @@ -59,17 +58,8 @@ public GSCommand() { addSubcommand(new InfoLookingCommand()); addSubcommand(new InfoSelfCommand()); - addSubcommand( - new SimpleCommand( - "wiki", - (server, sender, args) -> sender.sendMessage( - new TextComponentString("GroovyScript wiki").setStyle( - new Style().setColor(TextFormatting.GOLD) - .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Click to open wiki in browser"))) - .setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://cleanroommc.com/groovy-script/")))), - "doc", - "docs", - "documentation")); + + addSubcommand(new SimpleCommand("wiki", (server, sender, args) -> sender.sendMessage(getTextForUrl("GroovyScript wiki", "Click to open wiki in browser", new TextComponentString("https://cleanroommc.com/groovy-script/"))), "doc", "docs", "documentation")); addSubcommand(new SimpleCommand("generateWiki", (server, sender, args) -> { Documentation.generateWiki(); @@ -106,9 +96,9 @@ public GSCommand() { addSubcommand(new SimpleCommand("deleteScriptCache", (server, sender, args) -> { if (GroovyScript.getSandbox().deleteScriptCache()) { - sender.sendMessage(new TextComponentString(TextFormatting.GREEN + "Deleted groovy script cache")); + sender.sendMessage(new TextComponentString("Deleted groovy script cache").setStyle(StyleConstant.getSuccessStyle())); } else { - sender.sendMessage(new TextComponentString(TextFormatting.RED + "An error occurred while deleting groovy script cache")); + sender.sendMessage(new TextComponentString("An error occurred while deleting groovy script cache").setStyle(StyleConstant.getErrorStyle())); } })); @@ -120,7 +110,7 @@ public GSCommand() { addSubcommand(new SimpleCommand("cleanLog", (server, sender, args) -> { GroovyLogImpl.LOG.cleanLog(); - sender.sendMessage(new TextComponentString(TextFormatting.GREEN + "Cleaned Groovy log")); + sender.sendMessage(new TextComponentString("Cleaned Groovy log").setStyle(StyleConstant.getSuccessStyle())); })); if (ModSupport.MEKANISM.isLoaded()) { @@ -148,8 +138,19 @@ public static void postLogFiles(ICommandSender sender) { } public static ITextComponent getTextForFile(String name, String path, ITextComponent hoverText) { - return new TextComponentString(TextFormatting.UNDERLINE + (TextFormatting.GOLD + name)) - .setStyle(new Style().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, path)).setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText))); + return getTextForClickEvent(name, new ClickEvent(ClickEvent.Action.OPEN_FILE, path), hoverText); + } + + public static ITextComponent getTextForUrl(String name, String url, ITextComponent hoverText) { + return getTextForClickEvent(name, new ClickEvent(ClickEvent.Action.OPEN_URL, url), hoverText); + } + + public static ITextComponent getTextForClickEvent(String name, ClickEvent clickEvent, ITextComponent hoverText) { + return new TextComponentString(name).setStyle( + StyleConstant.getEmphasisStyle() + .setUnderlined(true) + .setClickEvent(clickEvent) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText))); } public static boolean hasArgument(String[] args, String arg) { diff --git a/src/main/java/com/cleanroommc/groovyscript/command/GSMekanismCommand.java b/src/main/java/com/cleanroommc/groovyscript/command/GSMekanismCommand.java index 11b82fe6e..54a31e393 100644 --- a/src/main/java/com/cleanroommc/groovyscript/command/GSMekanismCommand.java +++ b/src/main/java/com/cleanroommc/groovyscript/command/GSMekanismCommand.java @@ -2,6 +2,7 @@ import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.compat.mods.mekanism.Mekanism; +import com.cleanroommc.groovyscript.helper.StyleConstant; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.infuse.InfuseRegistry; @@ -10,7 +11,6 @@ import net.minecraft.command.ICommandSender; import net.minecraft.server.MinecraftServer; import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; import net.minecraftforge.server.command.CommandTreeBase; import org.jetbrains.annotations.NotNull; @@ -24,14 +24,14 @@ public GSMekanismCommand() { sender.sendMessage(new TextComponentString("Mekanism gases:")); for (Gas gas : GasRegistry.getRegisteredGasses()) { String copyText = Mekanism.asGroovyCode(gas, true); - sender.sendMessage(TextCopyable.string(copyText, " - " + gas.getName()).build()); + sender.sendMessage(TextCopyable.string(copyText, " - " + copyText).build()); } }, "gases")); addSubcommand(new SimpleCommand("infusionTypes", (server, sender, args) -> { sender.sendMessage(new TextComponentString("Mekanism infusion types:")); for (InfuseType infuseType : InfuseRegistry.getInfuseMap().values()) { - String copyText = "'" + infuseType.name + "'"; - sender.sendMessage(TextCopyable.string(copyText, " - " + infuseType.name).build()); + String copyText = Mekanism.asGroovyCode(infuseType, true); + sender.sendMessage(TextCopyable.string(copyText, " - " + copyText).build()); } })); } @@ -39,7 +39,7 @@ public GSMekanismCommand() { @Override public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sender, String @NotNull [] args) throws CommandException { if (!ModSupport.MEKANISM.isLoaded()) { - sender.sendMessage(new TextComponentString(TextFormatting.RED + "Mekanism is not loaded!")); + sender.sendMessage(new TextComponentString("Mekanism is not loaded!").setStyle(StyleConstant.getErrorStyle())); return; } super.execute(server, sender, args); diff --git a/src/main/java/com/cleanroommc/groovyscript/command/TextCopyable.java b/src/main/java/com/cleanroommc/groovyscript/command/TextCopyable.java index 9ee1d124a..8eec7a575 100644 --- a/src/main/java/com/cleanroommc/groovyscript/command/TextCopyable.java +++ b/src/main/java/com/cleanroommc/groovyscript/command/TextCopyable.java @@ -1,27 +1,28 @@ package com.cleanroommc.groovyscript.command; +import com.cleanroommc.groovyscript.helper.StyleConstant; import net.minecraft.util.text.*; import net.minecraft.util.text.event.HoverEvent; public class TextCopyable { - public static Builder string(java.lang.String copyText, java.lang.String msg) { + public static Builder string(String copyText, String msg) { return new Builder(copyText, msg); } - public static Builder translation(java.lang.String copyText, java.lang.String msg, Object... args) { + public static Builder translation(String copyText, String msg, Object... args) { return new Builder(copyText, msg).translate(args); } public static class Builder { - private final java.lang.String copyText; - private final java.lang.String msg; + private final String copyText; + private final String msg; private Object[] args; private ITextComponent hoverMsg; - public Builder(java.lang.String copyText, java.lang.String msg) { - this.copyText = TextFormatting.getTextWithoutFormattingCodes(copyText); + public Builder(String copyText, String msg) { + this.copyText = copyText; this.msg = msg; } @@ -33,16 +34,12 @@ public Builder translate(Object... args) { public ITextComponent build() { Style style = new Style(); if (hoverMsg == null) { - hoverMsg = new TextComponentTranslation("groovyscript.command.copy.hover") - .appendSibling(new TextComponentString(" " + copyText).setStyle(new Style().setColor(TextFormatting.GOLD))); + hoverMsg = new TextComponentTranslation("groovyscript.command.copy.hover").setStyle(StyleConstant.getEmphasisStyle()) + .appendSibling(new TextComponentString(" " + copyText)); } style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverMsg)); - style.setClickEvent(CustomClickAction.makeCopyEvent(copyText)); - ITextComponent textComponent; - if (args == null) - textComponent = new TextComponentString(msg); - else - textComponent = new TextComponentTranslation(msg, args); + style.setClickEvent(CustomClickAction.makeCopyEvent(TextFormatting.getTextWithoutFormattingCodes(copyText))); + ITextComponent textComponent = args == null ? new TextComponentString(msg) : new TextComponentTranslation(msg, args); textComponent.setStyle(style); return textComponent; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/InfoParserTab.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/InfoParserTab.java index b24a9e567..a51232375 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/InfoParserTab.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/InfoParserTab.java @@ -3,9 +3,10 @@ import com.cleanroommc.groovyscript.api.infocommand.InfoParserPackage; import com.cleanroommc.groovyscript.compat.vanilla.command.infoparser.GenericInfoParser; import com.cleanroommc.groovyscript.core.mixin.jei.ModRegistryAccessor; +import com.cleanroommc.groovyscript.helper.StyleConstant; import mezz.jei.api.recipe.IRecipeCategory; import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.oredict.OreDictionary; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -29,7 +30,7 @@ public String name() { @Override public String text(@NotNull IRecipeCategory entry, boolean colored, boolean prettyNbt) { - return colored ? TextFormatting.YELLOW + entry.getUid() : entry.getUid(); + return colored ? StyleConstant.STRING + entry.getUid() : entry.getUid(); } @Override @@ -41,7 +42,7 @@ public void parse(InfoParserPackage info) { List allowed = ((ModRegistryAccessor) JeiPlugin.modRegistry).getRecipeCatalysts() .entrySet() .stream() - .filter(entry -> entry.getValue().stream().anyMatch(x -> x instanceof ItemStack stack && ItemStack.areItemStacksEqual(stack, info.getStack()))) + .filter(entry -> entry.getValue().stream().anyMatch(x -> x instanceof ItemStack stack && OreDictionary.itemMatches(stack, info.getStack(), false))) .map(Map.Entry::getKey) .collect(Collectors.toList()); List list = JeiPlugin.recipeRegistry.getRecipeCategories(allowed); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/GenericInfoParser.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/GenericInfoParser.java index 73d050566..813785272 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/GenericInfoParser.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/GenericInfoParser.java @@ -3,6 +3,7 @@ import com.cleanroommc.groovyscript.api.infocommand.InfoParser; import com.cleanroommc.groovyscript.api.infocommand.InfoParserPackage; import com.cleanroommc.groovyscript.command.TextCopyable; +import com.cleanroommc.groovyscript.helper.StyleConstant; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.Style; import net.minecraft.util.text.TextComponentString; @@ -63,14 +64,14 @@ public ITextComponent hoverTitle() { } /** - * The formatted header of the parser. Uses the {@link #headerStyle}, with hover text from {@link #hoverTitle()}. + * The formatted header of the parser. Uses the {@link StyleConstant#getTitleStyle()}, with hover text from {@link #hoverTitle()}. * * @param plural if the name should be in {@link #plural()} or singular {@link #name()} form. * @return the header for the parser */ public ITextComponent header(boolean plural) { String name = plural ? plural() : name(); - Style style = headerStyle.createShallowCopy().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverTitle())); + Style style = StyleConstant.getTitleStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverTitle())); return new TextComponentString(name + ":").setStyle(style); } @@ -95,7 +96,7 @@ public void header(List messages, boolean plural) { /** * The text that will display in chat. - * The primary difference from {@link #copyText} is containing formatting codes. + * This may be different from {@link #copyText} for instances in which too much text would be added to chat. * Typically valid GroovyScript code. * * @param entry the entry to be parsed @@ -108,7 +109,7 @@ public String msg(@NotNull T entry, boolean prettyNbt) { /** * The text that will be copied when the entry is clicked on. - * The primary difference from {@link #msg} is lacking formatting codes. + * This may be different from {@link #msg} when it would be trimmed due to being too long. * Typically valid GroovyScript code. * * @param entry the entry to be parsed @@ -116,7 +117,7 @@ public String msg(@NotNull T entry, boolean prettyNbt) { * @return the text that is copied when clicking on the message */ public String copyText(@NotNull T entry, boolean prettyNbt) { - return text(entry, false, prettyNbt); + return text(entry, true, prettyNbt); } /** diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/InfoParserNBT.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/InfoParserNBT.java index 84076f9a2..659d76775 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/InfoParserNBT.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/InfoParserNBT.java @@ -1,11 +1,11 @@ package com.cleanroommc.groovyscript.compat.vanilla.command.infoparser; import com.cleanroommc.groovyscript.api.infocommand.InfoParserPackage; +import com.cleanroommc.groovyscript.helper.StyleConstant; import com.cleanroommc.groovyscript.helper.ingredient.NbtHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextFormatting; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; @@ -13,6 +13,9 @@ public class InfoParserNBT extends GenericInfoParser { public static final InfoParserNBT instance = new InfoParserNBT(); + private static final int MAXIMUM_LENGTH_BEFORE_TRIM = 300; + private static final int MAXIMUM_LINES_BEFORE_TRIM = 8; + @Override public int priority() { return 500; @@ -34,7 +37,12 @@ public String plural() { } private String trimText() { - return TextFormatting.RED + "(trimmed)"; + return StyleConstant.ERROR + "(trimmed)"; + } + + @Override + public String text(@NotNull NBTTagCompound entry, boolean colored, boolean prettyNbt) { + return NbtHelper.toGroovyCode(entry, prettyNbt, colored); } /** @@ -45,21 +53,16 @@ private String trimText() { * if the cut happens just after a section sign it would break the formatting of {@link #trimText}. */ @Override - public String text(@NotNull NBTTagCompound entry, boolean colored, boolean prettyNbt) { - String msg = NbtHelper.toGroovyCode(entry, prettyNbt, true); - if (msg.length() > 300) { - int endIndex = StringUtils.indexOf(msg, " ", 300); - return endIndex == -1 ? msg : msg.substring(0, StringUtils.indexOf(msg, " ", 300)) + trimText(); + public String msg(@NotNull NBTTagCompound entry, boolean prettyNbt) { + String msg = text(entry, true, prettyNbt); + if (msg.length() > MAXIMUM_LENGTH_BEFORE_TRIM) { + int endIndex = StringUtils.indexOf(msg, " ", MAXIMUM_LENGTH_BEFORE_TRIM); + return endIndex == -1 ? msg : msg.substring(0, StringUtils.indexOf(msg, " ", MAXIMUM_LENGTH_BEFORE_TRIM)) + trimText(); } - int trimLocation = StringUtils.ordinalIndexOf(msg, "\n", 8); + int trimLocation = StringUtils.ordinalIndexOf(msg, "\n", MAXIMUM_LINES_BEFORE_TRIM); return trimLocation == -1 ? msg : msg.substring(0, trimLocation) + "\n" + trimText(); } - @Override - public String copyText(@NotNull NBTTagCompound entry, boolean prettyNbt) { - return NbtHelper.toGroovyCode(entry, prettyNbt, false); - } - @Override public ITextComponent information(@NotNull NBTTagCompound entry, boolean prettyNbt) { return information(copyText(entry, prettyNbt), msg(entry, prettyNbt)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/InfoParserOreDict.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/InfoParserOreDict.java index f5a26b6a1..efa07a5b4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/InfoParserOreDict.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/InfoParserOreDict.java @@ -30,7 +30,7 @@ public String plural() { @Override public String text(@NotNull String entry, boolean colored, boolean prettyNbt) { - return colored ? GroovyScriptCodeConverter.asGroovyCode(entry, true) : entry; + return GroovyScriptCodeConverter.asGroovyCode(entry, colored); } @Override diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/InfoParserTranslationKey.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/InfoParserTranslationKey.java index 1a7298e34..c14a3154e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/InfoParserTranslationKey.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/command/infoparser/InfoParserTranslationKey.java @@ -1,7 +1,7 @@ package com.cleanroommc.groovyscript.compat.vanilla.command.infoparser; import com.cleanroommc.groovyscript.api.infocommand.InfoParserPackage; -import net.minecraft.util.text.TextFormatting; +import com.cleanroommc.groovyscript.helper.StyleConstant; import org.jetbrains.annotations.NotNull; public class InfoParserTranslationKey extends GenericInfoParser { @@ -20,7 +20,7 @@ public String name() { @Override public String text(@NotNull String entry, boolean colored, boolean prettyNbt) { - return colored ? TextFormatting.YELLOW + entry : entry; + return colored ? StyleConstant.STRING + entry : entry; } @Override diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/StyleConstant.java b/src/main/java/com/cleanroommc/groovyscript/helper/StyleConstant.java new file mode 100644 index 000000000..ec5871576 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/helper/StyleConstant.java @@ -0,0 +1,102 @@ +package com.cleanroommc.groovyscript.helper; + +import net.minecraft.util.text.Style; +import net.minecraft.util.text.TextFormatting; + +/** + * Constant values for formatting colors for the Minecraft chat. + *

+ * Primarily used to format the object mappers into valid code fragments via + * {@link com.cleanroommc.groovyscript.helper.ingredient.GroovyScriptCodeConverter GroovyScriptCodeConverter} + */ +public class StyleConstant { + + /** + * Used for any text that should not be a different color: + * the default text color + */ + public static final TextFormatting BASE = TextFormatting.GRAY; + + /** + * Used for the digits of numbers: + * 0xFF00FF, 5.0f, 347 + */ + public static final TextFormatting NUMBER = TextFormatting.YELLOW; + + /** + * Used for text within strings: + * 'hello', "world" + */ + public static final TextFormatting STRING = TextFormatting.GREEN; + + /** + * Used for method names, most commonly the object mapper name: + * call(), item('minecraft:clay'), fluid('water') + */ + public static final TextFormatting METHOD = TextFormatting.AQUA; + + /** + * Used for creating a new object: + * new Object(), key=value + */ + public static final TextFormatting NEW = TextFormatting.LIGHT_PURPLE; + + /** + * Used for class types, casts, and declarations: + * (byte), new Object(), 1.5F + */ + public static final TextFormatting CLASS = TextFormatting.GOLD; + + /** + * Used for the text of a state where a different outcome could be a warning or an error, + * but this evaluation was not and has succeeded. + */ + public static final TextFormatting SUCCESS = TextFormatting.GREEN; + + /** + * Used for the text of warnings + */ + public static final TextFormatting WARNING = TextFormatting.YELLOW; + + /** + * Used for the text of errors + */ + public static final TextFormatting ERROR = TextFormatting.RED; + + /** + * Used for titles to make them emphasised and keep them distinct from the surrounding text + */ + public static Style getTitleStyle() { + return new Style().setColor(TextFormatting.WHITE).setBold(true); + } + + /** + * Used to distinguish text from surrounding text. + * Often used for borders or for critical information. + */ + public static Style getEmphasisStyle() { + return new Style().setColor(TextFormatting.GOLD); + } + + /** + * Used for the text of a state where the other outcome could be a warning or an error, + * but this evaluation was not, and works as expected. + */ + public static Style getSuccessStyle() { + return new Style().setColor(SUCCESS); + } + + /** + * Used for the text of warnings + */ + public static Style getWarningStyle() { + return new Style().setColor(WARNING); + } + + /** + * Used for the text of errors + */ + public static Style getErrorStyle() { + return new Style().setColor(ERROR); + } +} diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/GroovyScriptCodeConverter.java b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/GroovyScriptCodeConverter.java index a6dd9079d..ea2d6fd15 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/GroovyScriptCodeConverter.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/GroovyScriptCodeConverter.java @@ -1,6 +1,7 @@ package com.cleanroommc.groovyscript.helper.ingredient; import com.cleanroommc.groovyscript.core.mixin.CreativeTabsAccessor; +import com.cleanroommc.groovyscript.helper.StyleConstant; import com.google.common.collect.Lists; import net.minecraft.block.Block; import net.minecraft.block.properties.IProperty; @@ -14,7 +15,6 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextFormatting; import net.minecraft.world.DimensionType; import net.minecraft.world.biome.Biome; import net.minecraftforge.fluids.FluidStack; @@ -28,44 +28,54 @@ public class GroovyScriptCodeConverter { public static String formatNumber(int number, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.YELLOW); + if (colored) builder.append(StyleConstant.NUMBER); builder.append(number); return builder.toString(); } + public static String formatString(String target, boolean colored) { + StringBuilder builder = new StringBuilder(); + if (colored) builder.append(StyleConstant.BASE); + builder.append("'"); + if (colored) builder.append(StyleConstant.STRING); + builder.append(target); + if (colored) builder.append(StyleConstant.BASE); + builder.append("'"); + return builder.toString(); + } + public static String formatGenericHandler(String handler, String target, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.DARK_GREEN); + if (colored) builder.append(StyleConstant.METHOD); builder.append(handler); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append("('"); - if (colored) builder.append(TextFormatting.AQUA); + if (colored) builder.append(StyleConstant.STRING); builder.append(target); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append("')"); return builder.toString(); } public static String formatMultiple(int amount, boolean colored) { + if (amount <= 1) return ""; StringBuilder builder = new StringBuilder(); - if (amount > 1) { - if (colored) builder.append(TextFormatting.GRAY); - builder.append(" * "); - builder.append(formatNumber(amount, colored)); - } + if (colored) builder.append(StyleConstant.BASE); + builder.append(" * "); + builder.append(formatNumber(amount, colored)); return builder.toString(); } public static String formatInstantiation(String clazz, List params, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.LIGHT_PURPLE); + if (colored) builder.append(StyleConstant.NEW); builder.append("new "); - if (colored) builder.append(TextFormatting.GOLD); + if (colored) builder.append(StyleConstant.CLASS); builder.append(clazz); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append("("); - builder.append(String.join((colored ? TextFormatting.GRAY.toString() : "") + ", ", params)); - if (colored) builder.append(TextFormatting.GRAY); + builder.append(String.join(colored ? StyleConstant.BASE + ", " : ", ", params)); + if (colored) builder.append(StyleConstant.BASE); builder.append(")"); return builder.toString(); } @@ -82,9 +92,14 @@ public static String formatForgeRegistryImpl(String handler, IForgeRegistryEntry public static String formatNBTTag(NBTTagCompound tag, boolean colored, boolean prettyNbt) { StringBuilder builder = new StringBuilder(); if (tag != null) { - builder.append(".withNbt("); + if (colored) builder.append(StyleConstant.BASE); + builder.append("."); + if (colored) builder.append(StyleConstant.METHOD); + builder.append("withNbt"); + if (colored) builder.append(StyleConstant.BASE); + builder.append("("); builder.append(NbtHelper.toGroovyCode(tag, prettyNbt, colored)); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append(")"); } return builder.toString(); @@ -92,27 +107,27 @@ public static String formatNBTTag(NBTTagCompound tag, boolean colored, boolean p private static String getSingleItemStack(ItemStack itemStack, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.DARK_GREEN); + if (colored) builder.append(StyleConstant.METHOD); builder.append("item"); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append("('"); - if (colored) builder.append(TextFormatting.AQUA); + if (colored) builder.append(StyleConstant.STRING); builder.append(itemStack.getItem().getRegistryName()); // code is more complex than strictly needed here to allow using the wildcard if (itemStack.getMetadata() == Short.MAX_VALUE) { builder.append(":"); builder.append("*"); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append("'"); } else if (itemStack.getMetadata() == 0) { - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append("'"); } else { - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append("'"); builder.append(", "); builder.append(formatNumber(itemStack.getMetadata(), colored)); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); } builder.append(")"); return builder.toString(); @@ -187,26 +202,26 @@ public static String asGroovyCode(Block state, boolean colored) { @SuppressWarnings("all") public static String asGroovyCode(IBlockState state, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.DARK_GREEN); + if (colored) builder.append(StyleConstant.METHOD); builder.append("blockstate"); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append("('"); - if (colored) builder.append(TextFormatting.AQUA); + if (colored) builder.append(StyleConstant.STRING); builder.append(state.getBlock().getRegistryName()); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append("'"); if (!state.getProperties().isEmpty()) { for (Map.Entry, Comparable> entry : state.getProperties().entrySet()) { IProperty property = entry.getKey(); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append(", ").append("'"); - if (colored) builder.append(TextFormatting.YELLOW); + if (colored) builder.append(StyleConstant.NEW); builder.append(property.getName()); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append("="); - if (colored) builder.append(TextFormatting.YELLOW); + if (colored) builder.append(StyleConstant.CLASS); builder.append(property.getName(entry.getValue())); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append("'"); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/NbtHelper.java b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/NbtHelper.java index 11fa22791..f2a6787ac 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/NbtHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/NbtHelper.java @@ -1,9 +1,9 @@ package com.cleanroommc.groovyscript.helper.ingredient; +import com.cleanroommc.groovyscript.helper.StyleConstant; import com.cleanroommc.groovyscript.sandbox.expand.LambdaClosure; import groovy.lang.Closure; import net.minecraft.nbt.*; -import net.minecraft.util.text.TextFormatting; import net.minecraftforge.common.util.Constants; import java.util.List; @@ -81,67 +81,73 @@ public static NBTBase toNbt(Object o) { public static String toGroovyCode(NBTTagByte nbt, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.CLASS); builder.append("(byte) "); - if (colored) builder.append(TextFormatting.GOLD); + if (colored) builder.append(StyleConstant.NUMBER); builder.append(nbt.getByte()); return builder.toString(); } public static String toGroovyCode(NBTTagShort nbt, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.CLASS); builder.append("(short) "); - if (colored) builder.append(TextFormatting.GOLD); + if (colored) builder.append(StyleConstant.NUMBER); builder.append(nbt.getShort()); return builder.toString(); } public static String toGroovyCode(NBTTagInt nbt, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.GREEN); + if (colored) builder.append(StyleConstant.NUMBER); builder.append(nbt.getInt()); return builder.toString(); } public static String toGroovyCode(NBTTagLong nbt, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.GREEN); - builder.append(nbt.getLong()).append("L"); + if (colored) builder.append(StyleConstant.NUMBER); + builder.append(nbt.getLong()); + if (colored) builder.append(StyleConstant.CLASS); + builder.append("l"); return builder.toString(); } public static String toGroovyCode(NBTTagFloat nbt, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.GREEN); - builder.append(nbt.getFloat()).append("F"); + if (colored) builder.append(StyleConstant.NUMBER); + builder.append(nbt.getFloat()); + if (colored) builder.append(StyleConstant.CLASS); + builder.append("f"); return builder.toString(); } public static String toGroovyCode(NBTTagDouble nbt, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.GREEN); - builder.append(nbt.getDouble()).append("D"); + if (colored) builder.append(StyleConstant.NUMBER); + builder.append(nbt.getDouble()); + if (colored) builder.append(StyleConstant.CLASS); + builder.append("d"); return builder.toString(); } public static String toGroovyCode(NBTTagByteArray nbt, int indent, boolean pretty, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append('['); if (!nbt.isEmpty()) { newLine(builder, indent, pretty); for (byte value : nbt.getByteArray()) { - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.CLASS); builder.append("(byte) "); - if (colored) builder.append(TextFormatting.GOLD); + if (colored) builder.append(StyleConstant.NUMBER); builder.append(value); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append(", "); } builder.delete(builder.length() - 2, builder.length()); newLine(builder, indent, pretty); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); } builder.append(']'); return builder.toString(); @@ -149,26 +155,30 @@ public static String toGroovyCode(NBTTagByteArray nbt, int indent, boolean prett public static String toGroovyCode(NBTTagString nbt, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.GREEN); - builder.append('\'').append(nbt.getString()).append('\''); + if (colored) builder.append(StyleConstant.BASE); + builder.append("'"); + if (colored) builder.append(StyleConstant.STRING); + builder.append(nbt.getString()); + if (colored) builder.append(StyleConstant.BASE); + builder.append("'"); return builder.toString(); } public static String toGroovyCode(NBTTagList nbt, int indent, boolean pretty, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append('['); if (!nbt.isEmpty()) { int internalIndent = indent + 1; for (NBTBase nbtBase : nbt) { newLine(builder, internalIndent, pretty); builder.append(toGroovyCode(nbtBase, internalIndent, pretty, colored)); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append(", "); } builder.delete(builder.length() - 2, builder.length()); newLine(builder, indent, pretty); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); } builder.append(']'); return builder.toString(); @@ -180,23 +190,26 @@ public static String toGroovyCode(NBTTagCompound nbt, boolean pretty, boolean co public static String toGroovyCode(NBTTagCompound nbt, int indent, boolean pretty, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append('['); if (!nbt.isEmpty()) { int internalIndent = indent + 1; for (String key : nbt.getKeySet()) { newLine(builder, internalIndent, pretty); - if (colored) builder.append(TextFormatting.GREEN); - builder.append('\'').append(key).append('\''); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); + builder.append("'"); + if (colored) builder.append(StyleConstant.STRING); + builder.append(key); + if (colored) builder.append(StyleConstant.BASE); + builder.append("'"); builder.append(": "); builder.append(toGroovyCode(nbt.getTag(key), internalIndent, pretty, colored)); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append(", "); } builder.delete(builder.length() - 2, builder.length()); newLine(builder, indent, pretty); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); } builder.append(']'); return builder.toString(); @@ -204,19 +217,19 @@ public static String toGroovyCode(NBTTagCompound nbt, int indent, boolean pretty public static String toGroovyCode(NBTTagIntArray nbt, int indent, boolean pretty, boolean colored) { StringBuilder builder = new StringBuilder(); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append('['); if (!nbt.isEmpty()) { newLine(builder, indent, pretty); for (int value : nbt.getIntArray()) { - if (colored) builder.append(TextFormatting.GOLD); + if (colored) builder.append(StyleConstant.NUMBER); builder.append(value); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); builder.append(", "); } builder.delete(builder.length() - 2, builder.length()); newLine(builder, indent, pretty); - if (colored) builder.append(TextFormatting.GRAY); + if (colored) builder.append(StyleConstant.BASE); } builder.append(']'); return builder.toString(); diff --git a/src/main/java/com/cleanroommc/groovyscript/network/StartLanguageServerPacket.java b/src/main/java/com/cleanroommc/groovyscript/network/StartLanguageServerPacket.java index fe6dfb5a5..35fdcb4f4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/network/StartLanguageServerPacket.java +++ b/src/main/java/com/cleanroommc/groovyscript/network/StartLanguageServerPacket.java @@ -1,11 +1,11 @@ package com.cleanroommc.groovyscript.network; import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.helper.StyleConstant; import net.minecraft.client.Minecraft; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.network.PacketBuffer; import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; public class StartLanguageServerPacket implements IPacket { @@ -18,9 +18,9 @@ public void decode(PacketBuffer buf) {} @Override public IPacket executeClient(NetHandlerPlayClient handler) { if (GroovyScript.runLanguageServer()) { - Minecraft.getMinecraft().player.sendMessage(new TextComponentString(TextFormatting.GREEN + "Starting language server")); + Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Starting language server").setStyle(StyleConstant.getSuccessStyle())); } else { - Minecraft.getMinecraft().player.sendMessage(new TextComponentString(TextFormatting.YELLOW + "Language server is already running")); + Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Language server is already running").setStyle(StyleConstant.getWarningStyle())); } return null; } diff --git a/src/main/resources/assets/groovyscript/lang/en_us.lang b/src/main/resources/assets/groovyscript/lang/en_us.lang index 01882f94e..42d32fc42 100644 --- a/src/main/resources/assets/groovyscript/lang/en_us.lang +++ b/src/main/resources/assets/groovyscript/lang/en_us.lang @@ -1,4 +1,4 @@ -groovyscript.command.copy.hover=Click to copy +groovyscript.command.copy.hover=Click to copy: groovyscript.command.copy.copied_start=Copied [ groovyscript.command.copy.copied_end=] to the clipboard