[Historical] Committing for changes. Added colored chat in game + fleshed out more note commands

Merge conflict paste error resolution

[issue/note-commands] Fleshed out modifynote + documentation
This commit is contained in:
Jkibbels 2024-08-10 15:19:42 -04:00
parent 14ebf3062e
commit f295c028d4
5 changed files with 404 additions and 76 deletions

View File

@ -1,12 +1,8 @@
package jesse.keeblarcraft.Commands; package jesse.keeblarcraft.Commands;
import java.util.UUID;
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.context.CommandContext;
import com.mojang.datafixers.Products.P1;
import jesse.keeblarcraft.ConfigMgr.ConfigManager; import jesse.keeblarcraft.ConfigMgr.ConfigManager;
import jesse.keeblarcraft.JsonClassObjects.PlayerNote; import jesse.keeblarcraft.JsonClassObjects.PlayerNote;
@ -19,13 +15,16 @@ import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
public class NoteCommands { public class NoteCommands {
/// Class Variables
// IMPORTANT NOTE:
//
// Each player will retain their own private file of notes inside a "notes" directory inside the overall mod config directory
ConfigManager notesConfig = new ConfigManager(); ConfigManager notesConfig = new ConfigManager();
String NOTES_GLOBAL_DIRECTORY = "notes"; // The overall "notes" dir inside cfg folder String NOTES_GLOBAL_DIRECTORY = "notes"; // The overall "notes" dir inside cfg folder
/////////////////////////////////////////////////////////////////////////////
/// @fn NoteCommands
///
/// @brief This classes non-trivial constructor. Ensures creation
// of notes directory exists before commands can be ran
/////////////////////////////////////////////////////////////////////////////
public NoteCommands() { public NoteCommands() {
// Check if directory exists // Check if directory exists
if (notesConfig.DoesDirectoryExist(NOTES_GLOBAL_DIRECTORY) == false) { if (notesConfig.DoesDirectoryExist(NOTES_GLOBAL_DIRECTORY) == false) {
@ -44,6 +43,11 @@ public class NoteCommands {
} }
} }
/////////////////////////////////////////////////////////////////////////////
/// @fn RegisterNoteCommands
///
/// @brief Registers all the commands for this class
/////////////////////////////////////////////////////////////////////////////
public void RegisterNoteCommands() { public void RegisterNoteCommands() {
// Command: "/addnote note goes here" // Command: "/addnote note goes here"
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> { CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
@ -62,15 +66,21 @@ public class NoteCommands {
// Command: "/purgenotes" // Command: "/purgenotes"
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> { CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
dispatcher.register(CommandManager.literal("purgenotes") dispatcher.register(CommandManager.literal("purgenotes")
.then(CommandManager.argument("value", StringArgumentType.greedyString()) .executes(context -> PurgeAllNotes(context)));
.executes(context -> PurgeAllNotes(StringArgumentType.getString(context, "value"), context))));
}); });
// Command: "/modifynote noteIdHere" // Command: "/modifynote noteIdHere new_note_string_here"
// Alises: "/editnote"
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> { CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
dispatcher.register(CommandManager.literal("editnote") final var mNote = dispatcher.register(CommandManager.literal("editnote")
.then(CommandManager.argument("value", IntegerArgumentType.integer()) .then(CommandManager.argument("note_id", IntegerArgumentType.integer())
.executes(context -> ModifyNote(IntegerArgumentType.getInteger(context, "value"), context)))); .then(CommandManager.argument("new_note", StringArgumentType.string())
.executes(context -> ModifyNote(
IntegerArgumentType.getInteger(context, "note_id"),
StringArgumentType.getString(context, "new_note"),
context)))));
dispatcher.register(CommandManager.literal("editnote").redirect(mNote));
}); });
// Command Root: "/delnote noteIdHere" // Command Root: "/delnote noteIdHere"
@ -84,14 +94,39 @@ public class NoteCommands {
dispatcher.register(CommandManager.literal("rmnote").redirect(rootDeleteCmd)); dispatcher.register(CommandManager.literal("rmnote").redirect(rootDeleteCmd));
dispatcher.register(CommandManager.literal("deletenote").redirect(rootDeleteCmd)); dispatcher.register(CommandManager.literal("deletenote").redirect(rootDeleteCmd));
}); });
// Command Root: "/notegui"
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
dispatcher.register(CommandManager.literal("notegui")
.executes(context -> { OpenNoteGui(context);
return 0;
}));
});
// Command Root: "/notelist"
// Aliases: "/listnotes"
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
final var rootListNotes = dispatcher.register(CommandManager.literal("notelist")
.executes(context -> { ListNotes(context);
return 0;
}));
dispatcher.register(CommandManager.literal("listnotes").redirect(rootListNotes));
});
} }
/// COMMAND HANDLERS BELOW /////////////////////////////////////////////////////////////////////////////
/// @fn AddNote
// AddNote ///
// /// @brief Adds a new note to the players notebook
// Adds a new note based on the string value provided by the player. The note is labeled in the background based on the portion ///
// of the story they are currently in as well to help provide filtering methods later on /// @arg[in] value is the new note to be added
///
/// @arg[in] context is the context of the ServerCommandSource object
/// the command was run with
///
/// @return 0 if success, -1 if not
/////////////////////////////////////////////////////////////////////////////
private Integer AddNote(String value, CommandContext<ServerCommandSource> context) { private Integer AddNote(String value, CommandContext<ServerCommandSource> context) {
Integer ret = -1; Integer ret = -1;
@ -111,39 +146,154 @@ public class NoteCommands {
return ret; return ret;
} }
/////////////////////////////////////////////////////////////////////////////
/// @fn DeleteNote
///
/// @brief Deletes a note by id
///
/// @arg[in] value is the integer ID of the note to be deleted
///
/// @arg[in] context is the context of the ServerCommandSource object
/// the command was run with
///
/// @return 0 if success, -1 if not
/////////////////////////////////////////////////////////////////////////////
private int DeleteNote(int value, CommandContext<ServerCommandSource> context) { private int DeleteNote(int value, CommandContext<ServerCommandSource> context) {
int ret = -1; int ret = -1;
return ret; if (context.getSource().isExecutedByPlayer()) {
} ServerPlayerEntity player = context.getSource().getPlayer();
private int ModifyNote(int value, CommandContext<ServerCommandSource> context) { PlayerNote note = new PlayerNote(player.getUuidAsString());
int ret = -1; ChatUtil.SendPlayerMsg(player, "Deleted note entry. View notes any time with /notegui");
ret = 0;
note.DeleteNote(value);
} else {
System.out.println("Only a player can execute this command!");
}
return ret; return ret;
} }
private int PurgeAllNotes(String value, CommandContext<ServerCommandSource> context) { /////////////////////////////////////////////////////////////////////////////
/// @fn ModifyNote
///
/// @brief Modifies a single note by id value
///
/// @arg[in] value is the integer ID of the note to be modified
///
/// @arg[in] newNote is the new version of the edited note
///
/// @arg[in] context is the context of the ServerCommandSource object
/// the command was run with
///
/// @return 0 if success, -1 if not
/////////////////////////////////////////////////////////////////////////////
private int ModifyNote(Integer value, String newNote, CommandContext<ServerCommandSource> context) {
int ret = -1; int ret = -1;
if (context.getSource().isExecutedByPlayer() && value > 0) {
ServerPlayerEntity player = context.getSource().getPlayer();
PlayerNote note = new PlayerNote(player.getUuidAsString());
long time = context.getSource().getWorld().getTime();
// long day = ; ///TODO: Docs lack this for some reason? Add in future
long epochTime = System.currentTimeMillis();
long storyChapter = -1; // Intentional garbage until story is fleshed out later (TODO)
long storyPart = -1; // Intentional garbage until story is fleshed out later (TODO)
note.ModifyNote(value, newNote, epochTime, storyChapter, storyPart);
ret = 0;
}
return ret; return ret;
} }
private int ListNotes(String value, CommandContext<ServerCommandSource> context) { /////////////////////////////////////////////////////////////////////////////
/// @fn PurgeAllNotes
///
/// @brief Removes all notes from a players note file
///
/// @arg[in] context is the context of the ServerCommandSource object
/// the command was run with
///
/// @return 0 if success, -1 if not
/////////////////////////////////////////////////////////////////////////////
private int PurgeAllNotes(CommandContext<ServerCommandSource> context) {
int ret = -1; int ret = -1;
if (context.getSource().isExecutedByPlayer()) {
ServerPlayerEntity player = context.getSource().getPlayer();
PlayerNote note = new PlayerNote(player.getUuidAsString());
note.PurgeAllNotes();
ChatUtil.SendPlayerMsg(player, "Purged all notes. View notes any time with /notegui");
ret = 0;
} else {
System.out.println("Only a player can execute this command!");
}
return ret; return ret;
} }
private int OpenNoteGui(String value, CommandContext<ServerCommandSource> context) { /////////////////////////////////////////////////////////////////////////////
/// @fn ListNotes
///
/// @brief Lists notes in pages in the players active chat
///
/// @arg[in] context is the context of the ServerCommandSource object
/// the command was run with
///
/// @return 0 if success, -1 if not
/////////////////////////////////////////////////////////////////////////////
private int ListNotes(CommandContext<ServerCommandSource> context) {
int ret = -1; int ret = -1;
if (context.getSource().isExecutedByPlayer()) {
ServerPlayerEntity player = context.getSource().getPlayer();
PlayerNote notes = new PlayerNote(player.getUuidAsString());
ChatUtil.SendPlayerMsg(player, "Listing all notes...");
for (int i = 0; i <= notes.GetNotebookSize(); i++) {
String individualNote = notes.GetNoteString(i);
if (individualNote != "") {
ChatUtil.SendPlayerMsg(player, "Note " + i + ": " + individualNote);
}
}
ret = 0;
} else {
System.out.println("Only a player can execute this command!");
}
return ret; return ret;
} }
private int FilterForNote(String value, CommandContext<ServerCommandSource> context) { ///TODO: Blocked until GUI manager is available
/////////////////////////////////////////////////////////////////////////////
/// @fn OpenNoteGui
///
/// @brief Opens up the graphical display of the note manager
///
/// @arg[in] context is the context of the ServerCommandSource object
/// the command was run with
///
/// @return 0 if success, -1 if not
/////////////////////////////////////////////////////////////////////////////
private int OpenNoteGui(CommandContext<ServerCommandSource> context) {
int ret = -1; int ret = -1;
if (context.getSource().isExecutedByPlayer()) {
ServerPlayerEntity player = context.getSource().getPlayer();
ret = 0;
} else {
System.out.println("Only a player can execute this command!");
}
return ret; return ret;
} }
} }

View File

@ -34,7 +34,7 @@ public class ShortcutCommands {
.executes(context -> GamemodeShortcut(IntegerArgumentType.getInteger(context, "value"), context)))); .executes(context -> GamemodeShortcut(IntegerArgumentType.getInteger(context, "value"), context))));
}); });
// Fly command ///TODO: Is this just being condensed into the FlightSpeedShortcut fn? // Fly command
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> { CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
dispatcher.register(CommandManager.literal("fly") dispatcher.register(CommandManager.literal("fly")
.executes(context -> { FlightShortcut(context); .executes(context -> { FlightShortcut(context);

View File

@ -7,7 +7,6 @@
package jesse.keeblarcraft.JsonClassObjects; package jesse.keeblarcraft.JsonClassObjects;
import java.math.BigInteger;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -17,13 +16,25 @@ import jesse.keeblarcraft.Utils.ChatUtil.CONSOLE_COLOR;
import jesse.keeblarcraft.Utils.CustomExceptions.FILE_WRITE_EXCEPTION; import jesse.keeblarcraft.Utils.CustomExceptions.FILE_WRITE_EXCEPTION;
public class PlayerNote { public class PlayerNote {
/// Class variables
NoteFile thisNote = new NoteFile();
ConfigManager config = new ConfigManager();
// Internal class structure that defines a blank note. It represents the overall loaded json object /////////////////////////////////////////////////////////////////////////////
/// @class NoteMetadata
///
/// @brief The metadata that is attached to each entry in the notebook.
/// This includes not just the note itself, but other important
/// factors that can be characteristic to each note and useful
///
/// @note You can picture this as each page in the notebook if it's
/// an easier mental image
/////////////////////////////////////////////////////////////////////////////
private class NoteMetadata { private class NoteMetadata {
public NoteMetadata(String note, long id, long mcday, long sysTime, long chapter, long part) { public NoteMetadata(String note, long id, /*long mcday,*/ long sysTime, long chapter, long part) {
this.note = note; this.note = note;
this.noteId = id; this.noteId = id;
this.minecraftDay = mcday; // this.minecraftDay = mcday;
this.systemTime = sysTime; this.systemTime = sysTime;
this.storyChapter = chapter; this.storyChapter = chapter;
this.storyPart = part; this.storyPart = part;
@ -32,50 +43,31 @@ public class PlayerNote {
String note; // The note itself String note; // The note itself
long noteId; // Copied in from the file name, noteId long noteId; // Copied in from the file name, noteId
long minecraftDay; // The minecraft day the note was taken on // long minecraftDay; // The minecraft day the note was taken on
long systemTime; // The current system time of the server long systemTime; // The current system time of the server
long storyChapter; // The chapter of the story the player is in long storyChapter; // The chapter of the story the player is in
long storyPart; // Every event in a story is one part long storyPart; // Every event in a story is one part
} }
/////////////////////////////////////////////////////////////////////////////
/// @class NoteFile
///
/// @brief This is the notebook
/////////////////////////////////////////////////////////////////////////////
public class NoteFile { public class NoteFile {
// Players uuid is the name of the file
String uuid; String uuid;
// Contents of file
/*
* Example:
* player_uuid_here:
* {
* "1":
* {
* "note": "this is the players first note";
* "noteId": "1";
* "minecraftDay": "443";
* "systemTime": "4849892839823";
* "storyChapter": "3";
* "storyPart": "2";
* }
* "2":
* {
* Etc.
* }
* }
*/
public HashMap<Integer, NoteMetadata> noteMap = new HashMap<Integer, NoteMetadata>(); public HashMap<Integer, NoteMetadata> noteMap = new HashMap<Integer, NoteMetadata>();
} }
/////////////////////////////////////////////////////////////////////////////
NoteFile thisNote = new NoteFile(); /// @fn PlayerNote
ConfigManager config = new ConfigManager(); ///
/// @brief This class's non-trivial constructor. Grabs a handle on the
class TestClass { /// server-side file that is the players notebook at object
String testString; /// creation. If one does not exist, one is created
} ///
/// @arg[in] uuid is the players uuid value
// PlayerNote /////////////////////////////////////////////////////////////////////////////
//
// String uuid - The uuid of the player (used in searching for existing notes file and writing to it)
public PlayerNote(String uuid) { public PlayerNote(String uuid) {
// DEVELOPER NOTE: // DEVELOPER NOTE:
@ -112,23 +104,114 @@ public class PlayerNote {
} }
} }
/////////////////////////////////////////////////////////////////////////////
/// @fn AddNote
///
/// @brief Adds a new note to the notebook
///
/// @arg[in] newNote is the new string value of the note
///
/// @arg[in] minecraftDay is currently unsupported but will be the day of
/// the minecraft world when it is implemented
///
/// @arg[in] systemTime is the epoch time in milliseconds
///
/// @arg[in] storyChapter is the chapter in the story this note was taken
///
/// @arg[in] storyPart is the part in the chapter the note was taken
/////////////////////////////////////////////////////////////////////////////
public void AddNote(String newNote, long minecraftDay, long systemTime, long storyChapter, long storyPart) { public void AddNote(String newNote, long minecraftDay, long systemTime, long storyChapter, long storyPart) {
Integer noteKey = thisNote.noteMap.size() + 1; Integer noteKey = thisNote.noteMap.size() + 1;
thisNote.noteMap.put(noteKey, new NoteMetadata(newNote, noteKey, minecraftDay, systemTime, storyChapter, storyPart)); thisNote.noteMap.put(noteKey, new NoteMetadata(newNote, noteKey, /*minecraftDay,*/ systemTime, storyChapter, storyPart));
FlashConfig(); ///TODO: This might be really unnecessary and may only be required on clean up as opposed to everytime the command is run FlashConfig(); ///TODO: This might be really unnecessary and may only be required on clean up as opposed to everytime the command is run
} }
/////////////////////////////////////////////////////////////////////////////
/// @fn DeleteNote
///
/// @brief Deletes a note in the notebook
///
/// @arg[in] noteId is the id to delete
/////////////////////////////////////////////////////////////////////////////
public void DeleteNote(Integer noteId) { public void DeleteNote(Integer noteId) {
thisNote.noteMap.remove(noteId); thisNote.noteMap.remove(noteId);
FlashConfig();
} }
public void ModifyNote(Integer noteId, String newNote, long minecraftDay, long systemTime, long storyChapter, long storyPart) { /////////////////////////////////////////////////////////////////////////////
thisNote.noteMap.put(noteId, new NoteMetadata(newNote, noteId, minecraftDay, systemTime, storyChapter, storyPart)); /// @fn ModifyNote
///
/// @brief Modifies a note at noteId entry OR creates new note at that
/// entry if the id didn't exist previously
///
/// @arg[in] noteId is the id we wish to modify the note of
///
/// @arg[in] newNote is the new string value of the note
///
/// @arg[in] minecraftDay is currently unsupported but will be the day of
/// the minecraft world when it is implemented
///
/// @arg[in] systemTime is the epoch time in milliseconds
///
/// @arg[in] storyChapter is the chapter in the story this note was taken
///
/// @arg[in] storyPart is the part in the chapter the note was taken
///
/// @return 0 if success, -1 if not
/////////////////////////////////////////////////////////////////////////////
public void ModifyNote(Integer noteId, String newNote, /*long minecraftDay,*/ long systemTime, long storyChapter, long storyPart) {
thisNote.noteMap.put(noteId, new NoteMetadata(newNote, noteId, /*minecraftDay,*/ systemTime, storyChapter, storyPart));
FlashConfig();
} }
// Find the key of a note if it exists (O(n) search time) /////////////////////////////////////////////////////////////////////////////
// Returns -1 on failure to find note key /// @fn PurgeAllNotes
///
/// @brief Wipes the players notebook clean
/////////////////////////////////////////////////////////////////////////////
public void PurgeAllNotes() {
thisNote.noteMap.clear();
FlashConfig();
}
/////////////////////////////////////////////////////////////////////////////
/// @fn GetNoteString
///
/// @brief Gets the note string in the map by identifier. NOT metadata
///
/// @arg[in] key is the map key we wish to return
///
/// @return Empty string if that ID contains no note, or string with note
/////////////////////////////////////////////////////////////////////////////
public String GetNoteString(Integer key) {
if (thisNote.noteMap.containsKey(key)) {
return thisNote.noteMap.get(key).note;
} else {
return "";
}
}
/////////////////////////////////////////////////////////////////////////////
/// @fn GetNotebookSize
///
/// @brief Returns the size of the notebook object
///
/// @return Size of notebook
/////////////////////////////////////////////////////////////////////////////
public Integer GetNotebookSize() {
return thisNote.noteMap.size();
}
/////////////////////////////////////////////////////////////////////////////
/// @fn GetNoteKey
///
/// @brief Returns the key identifier of a note by the value in the map
///
/// @arg[in] currentNote is the string note that we wish to see if exists
///
/// @return 0 or positive number if key found, negative number if not
/////////////////////////////////////////////////////////////////////////////
public Integer GetNoteKey(String currentNote) { public Integer GetNoteKey(String currentNote) {
Integer ret = -1; Integer ret = -1;
for (Entry<Integer, NoteMetadata> entry : thisNote.noteMap.entrySet()) { for (Entry<Integer, NoteMetadata> entry : thisNote.noteMap.entrySet()) {
@ -136,10 +219,15 @@ public class PlayerNote {
ret = entry.getKey(); ret = entry.getKey();
} }
} }
FlashConfig();
return ret; return ret;
} }
/////////////////////////////////////////////////////////////////////////////
/// @fn FlashConfig
///
/// @brief Writes to the configuration file
/////////////////////////////////////////////////////////////////////////////
public void FlashConfig() { public void FlashConfig() {
try { try {
config.WriteToJsonFile("notes/" + thisNote.uuid.toString() + ".json", thisNote); config.WriteToJsonFile("notes/" + thisNote.uuid.toString() + ".json", thisNote);

View File

@ -7,10 +7,11 @@
* *
*/ */
// color colour
package jesse.keeblarcraft; package jesse.keeblarcraft;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
// import net.minecraft.server.command.ServerCommandSource;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -11,7 +11,12 @@ package jesse.keeblarcraft.Utils;
import org.slf4j.Logger; import org.slf4j.Logger;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Map.Entry;
public class ChatUtil { public class ChatUtil {
//This is a private class only used internally to get ANSI colors //This is a private class only used internally to get ANSI colors
@ -51,11 +56,95 @@ public class ChatUtil {
CYAN; CYAN;
} }
static int CHATBOX_WIDTH_CHARS = 80; // Maximum length of the textbox in individual characters
// Helpful print wrapper function // Helpful print wrapper function
static public void SendPlayerMsg(ServerPlayerEntity player, String text) { static public void SendPlayerMsg(ServerPlayerEntity player, String text) {
player.sendMessage(Text.literal(text)); player.sendMessage(Text.literal(text));
} }
/// TODO: Add this back in later under a chat ticket
// Prints a table of data in chat
// static public void ChatBlock(ServerPlayerEntity player, HashMap<Text, List<Text>> table) {
// ///DEBUG
// for (Entry<Text, List<Text>> entry : table.entrySet()) {
// for (int debug = 0; debug < entry.getValue().size(); debug++) {
// System.out.println("KEY: " + entry.getKey().toString() + " VALUE: " + entry.getValue().get(debug).toString());
// }
// }
// // The user will likely pass in text strings longer than the character limit for num of columns; therefore
// // we are required to split these into this finalPrintList structure
// HashMap<Text, ArrayList<Text>> finalPrintList = new HashMap<Text, ArrayList<Text>>();
// int maxColumnWidth = CHATBOX_WIDTH_CHARS / table.size(); // Represents max char allowance per data column
// maxColumnWidth -= table.size(); // Represents a separating '|' between each column
// // This first behemoth of a loop is to take the given table hashmap and look at
// // the Text values & split them
// // should their size exceed the maxColumnWidth given for each entry key
// System.out.println("Entry data is size " + table.size());
// for (Entry<Text, List<Text>> entry : table.entrySet()) {
// // Each text line found cannot be longer than "maxColumnWidth" or else it must
// // wrap which splits it
// // into two texts; thus adding an additional row that is required for iteration.
// // Each split text must
// // maintain the same formatting as the root text it is split from
// finalPrintList.put(entry.getKey(), new ArrayList<Text>()); // Instantiate the key & array
// System.out.println("Map size is " + finalPrintList.size());
// System.out.println("Entry value size is " + entry.getValue().size());
// for (Text item : entry.getValue()) {
// int numItems = (int) Math.ceil((item.getString().length() / maxColumnWidth));
// int strOffset = numItems; // Represents number of items per string
// System.out.println("numItems: " + numItems);
// System.out.println("strOffset: " + strOffset);
// for (int offset = 0; offset <= numItems; offset++) { /// TODO: might need to be <=
// int start = strOffset * offset; // Multiple from start of string to needed point
// int end = start + strOffset; // The original start offset + the width spacer
// String substr = item.toString().substring(start, end); // Contains the string to be Textified
// MutableText newText = Text.literal(substr).setStyle(item.getStyle());
// finalPrintList.get(entry.getKey()).add(newText); // Add back into list
// System.out.println("SPLIT DEBUG: " + newText.toString());
// }
// }
// }
// // This loop does the printing of the table in chat
// int tempPreventInfiniteLoops = 10;
// while (finalPrintList.size() != 0) {
// // This is a one time print
// MutableText line = Text.literal("");
// for (Entry<Text, ArrayList<Text>> entry : finalPrintList.entrySet()) {
// if (entry.getValue().size() != 0) {
// line.append(entry.getValue().get(0));
// System.out.println("new line is now " + line.toString());
// line.append("|");
// } else {
// finalPrintList.remove(entry.getKey()); // Clear the key; as we are done with this column for
// // printing
// }
// player.sendMessage(line);
// String debugPrint = line.toString();
// System.out.println("Debug line to be printed: " + debugPrint);
// line = Text.literal("");
// break;
// }
// tempPreventInfiniteLoops--;
// if (tempPreventInfiniteLoops <= 0) {
// return;
// }
// }
// }
// Returns a string with the proper ANSI encoding for the specified CONSOLE_COLOR // Returns a string with the proper ANSI encoding for the specified CONSOLE_COLOR
static public String ColoredString(String msg, CONSOLE_COLOR color) { static public String ColoredString(String msg, CONSOLE_COLOR color) {
return "\033[" + ConsoleColor.getColor(color) + "m" + msg + "\033[0m"; return "\033[" + ConsoleColor.getColor(color) + "m" + msg + "\033[0m";