Add a chat replacement helper
This commit is contained in:
parent
902cca2f42
commit
5c70fb1291
3 changed files with 21 additions and 2 deletions
|
@ -5,5 +5,5 @@ org.gradle.daemon=false
|
|||
|
||||
mc_version=1.18.2
|
||||
forge_version=40.2.1
|
||||
myversion=1.0.5.0228230829
|
||||
myversion=1.0.5.0228230925
|
||||
parchment_version=2022.11.06
|
|
@ -3,6 +3,7 @@ package dev.zontreck.libzontreck.util;
|
|||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
@ -72,4 +73,22 @@ public class ChatHelpers {
|
|||
{
|
||||
broadcastTo(ID.getUUID(), message, server, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the output with colors applied, and chat entries replaced using [number] as the format
|
||||
* @param input
|
||||
* @param inputs Entries to replace with in input
|
||||
* @return
|
||||
*/
|
||||
public static String macroize(String input, String... inputs)
|
||||
{
|
||||
String output = input;
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
String inp = inputs[i];
|
||||
|
||||
output = output.replaceAll("\\["+String.valueOf(i)+"]", inp);
|
||||
}
|
||||
|
||||
return ChatColor.doColors(output);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ modId="libzontreck" #mandatory
|
|||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
|
||||
# see the associated build.gradle script for how to populate this completely automatically during a build
|
||||
version="1.0.5.0228230829" #mandatory
|
||||
version="1.0.5.0228230925" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="LibZontreck" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
|
||||
|
|
Reference in a new issue