Debugger Commands Colored for easier Visibility

This commit is contained in:
Walrus 2024-08-08 14:22:59 -04:00
parent a355f13bb3
commit 26d288b39f
7 changed files with 45 additions and 45 deletions

View File

@ -19,7 +19,7 @@ public class CustomCommandManager {
NoteCommands noteCommands = new NoteCommands(); NoteCommands noteCommands = new NoteCommands();
// REGISTER COMMANDS BELOW // REGISTER COMMANDS BELOW
System.out.println("REGISTERING CUSTOM COMMAND EXTENSIONS BELOW"); System.out.println("\033[32m REGISTERING CUSTOM COMMAND EXTENSIONS BELOW \033[0m");
shortcuts.RegisterShortcutCommands(); shortcuts.RegisterShortcutCommands();
noteCommands.RegisterNoteCommands(); noteCommands.RegisterNoteCommands();
} }

View File

@ -31,15 +31,15 @@ public class NoteCommands {
// Attempt to create the directory // Attempt to create the directory
try { try {
if (notesConfig.CreateDirectory(NOTES_GLOBAL_DIRECTORY) == true) { if (notesConfig.CreateDirectory(NOTES_GLOBAL_DIRECTORY) == true) {
System.out.println("Created notes directory successfully!"); //TODO: Success! System.out.println("\033[32m Created notes directory successfully! \033[0m"); //TODO: Success!
} else { } else {
System.out.println("ERROR: Notes directory FAILED to create!! Either the directory already exists or we are missing permissions!"); //TODO: Critical failure System.out.println("\033[35m ERROR: Notes directory FAILED to create!! Either the directory already exists or we are missing permissions! \033[0m"); //TODO: Critical failure --not specfic enough to mark it as a red or blue
} }
} catch (DIRECTORY_CREATE_EXCEPTION e) { } catch (DIRECTORY_CREATE_EXCEPTION e) {
System.out.println("Directory creation failed"); System.out.println("\033[31m Directory creation failed \033[0m");
} }
} else { } else {
System.out.println("Notes directory already exists. Skipping creation..."); //TODO: Success! System.out.println("\033[34m Notes directory already exists. Skipping creation... \033[0m"); //TODO: Success!
} }
} }
@ -104,7 +104,7 @@ public class NoteCommands {
ret = 0; ret = 0;
} else { } else {
System.out.println("Only a player can execute this command!"); System.out.println("\033[31m Only a player can execute this command! \033[0m");
} }
return ret; return ret;

View File

@ -96,11 +96,11 @@ public class ShortcutCommands {
} }
else { else {
player.sendMessage(Text.literal("You do not have permissions to run this command!")); player.sendMessage(Text.literal("\033[31m You do not have permissions to run this command! \033[0m"));
} }
} }
else { else {
System.out.println("This command cannot be executed by a non-player entity!"); System.out.println("\033[31m This command cannot be executed by a non-player entity! \033[0m");
} }
return retValue; return retValue;

View File

@ -46,7 +46,7 @@ public class ConfigManager {
// Check 1: Does the file already exist? // Check 1: Does the file already exist?
ret = file.exists(); ret = file.exists();
System.out.println("Does file exist? " + (ret ? "YES" : "NO")); System.out.println("\033[34m Does file exist? \033[0m" + (ret ? "\033[33m YES \033[0m" : "\033[31m NO \033[0m"));
// Check 2: If the file does not exist, attempt to create it // Check 2: If the file does not exist, attempt to create it
if (ret == false) { if (ret == false) {
@ -57,8 +57,8 @@ public class ConfigManager {
throw new FILE_CREATE_EXCEPTION(); throw new FILE_CREATE_EXCEPTION();
} }
} else { } else {
ret = true; // This might be a hot fix, but technically the file already exists so would this be true or false? ret = true; // This might be a hot fix, but technically the file already exists so would this be true or false? --?this statement is wild?
System.out.println("File (name:" + fileName + ") was determined to already exist. Exiting out"); System.out.println("\033[34m File (name: \033[0m" + "\033[33m" + fileName + "\033[0m" + "\033[34m) was determined to already exist. Exiting out\033[0m");
} }
return ret; return ret;
} }
@ -81,7 +81,7 @@ public class ConfigManager {
throw new FILE_DELETE_EXCEPTION(); throw new FILE_DELETE_EXCEPTION();
} }
} else { } else {
System.out.println("Cannot delete file " + fileName + " because file does not exist"); System.out.println("\033[34m Cannot delete file \033[0m" + "\033[33m" + fileName + "\033[0m" + "\033[31m because file does not exist \033[0m");
} }
return ret; return ret;
} }
@ -105,13 +105,13 @@ public class ConfigManager {
ret = true; ret = true;
break; break;
default: default:
System.out.println("Invalid mode to WriteToFile!"); System.out.println("\033[31m Invalid mode to WriteToFile! \033[0m");
break; break;
} }
file.close(); file.close();
} catch (IOException e) { } catch (IOException e) {
System.out.println("Could not open file " + fileName + " to write to it! Possibly permission issue?"); System.out.println("\033[31m Could not open file \033[0m" + "\033[33m" + fileName + "\033[0m" + "\033[31m to write to it! Possibly permission issue? \033[0m");
} }
return ret; return ret;
@ -135,7 +135,7 @@ public class ConfigManager {
writer.flush(); writer.flush();
writer.close(); writer.close();
} catch (JsonIOException | IOException e) { } catch (JsonIOException | IOException e) {
System.out.println("Could not successfully write to json file"); System.out.println("\033[31m Could not successfully write to json file \033[0m");
throw new FILE_WRITE_EXCEPTION(); throw new FILE_WRITE_EXCEPTION();
} }
} }
@ -151,18 +151,18 @@ public class ConfigManager {
// return value in the future - but for now throw JsonSyntaxException no matter what exception is caught // return value in the future - but for now throw JsonSyntaxException no matter what exception is caught
try { try {
File file = new File(fileName); File file = new File(fileName);
ret = FileUtils.readFileToString(file, "UTF-8"); ret = FileUtils.readFileToString(file, "\033[32m UTF-8 \033[0m");
} catch (NullPointerException e) { } catch (NullPointerException e) {
System.out.println("nullptr exception"); System.out.println("\033[31m nullptr exception \033[0m");
throw new JsonSyntaxException(""); throw new JsonSyntaxException("");
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
System.out.println("file not found"); System.out.println("\033[31m file not found \033[0m");
throw new JsonSyntaxException(""); throw new JsonSyntaxException("");
} catch (java.nio.charset.UnsupportedCharsetException e) { } catch (java.nio.charset.UnsupportedCharsetException e) {
System.out.println("charset issue"); System.out.println("\033[31m charset issue \033[0m");
throw new JsonSyntaxException(""); throw new JsonSyntaxException("");
} catch (IOException e) { } catch (IOException e) {
System.out.println("io exception"); System.out.println("\033[31m io exception \033[0m");
throw new JsonSyntaxException(""); throw new JsonSyntaxException("");
} }
@ -191,7 +191,7 @@ public class ConfigManager {
ret = dir.mkdirs(); ret = dir.mkdirs();
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("Failed to make directory with name " + dirName); System.out.println("\033[31m Failed to make directory with name: \033[0m" + "\033[33m" + dirName + "\033[0m");
ret = true; /// TODO: Hack to make Setup fn be fine with prev-created files! Make Setup more robust! ret = true; /// TODO: Hack to make Setup fn be fine with prev-created files! Make Setup more robust!
throw new DIRECTORY_CREATE_EXCEPTION(); throw new DIRECTORY_CREATE_EXCEPTION();
} }
@ -205,9 +205,9 @@ public class ConfigManager {
try { try {
ret = dir.delete(); ret = dir.delete();
System.out.println("Deleted directory " + dirName); System.out.println("\033[32m Deleted directory \033[0m" + "\033[33m" + dirName + "\033[0m");
} catch (Exception e) { } catch (Exception e) {
System.out.println("Failed to delete directory " + dirName); System.out.println("\033[31m Failed to delete directory: \033[0m" + "\033[33m" + dirName + "\033[0m");
throw new DIRECTORY_DELETE_EXCEPTION(); throw new DIRECTORY_DELETE_EXCEPTION();
} }

View File

@ -91,21 +91,21 @@ public class PlayerNote {
// In the event the above code failed out, this means a new file has to be created for the player's uuid // In the event the above code failed out, this means a new file has to be created for the player's uuid
if (!existingFile) if (!existingFile)
{ {
System.out.println("Trying to create new file"); System.out.println("\033[34m Trying to create new file \033[0m");
try { try {
thisNote.uuid = uuid; thisNote.uuid = uuid;
FlashConfig(); FlashConfig();
} catch (Exception e) { } catch (Exception e) {
System.out.println("Could not write to file"); System.out.println("\033[31m Could not write to file \033[0m");
} }
} else { } else {
System.out.println("Moving on"); System.out.println("\033[34m Moving on \033[0m");
} }
// It's possible the above code will return a blank class if a file doesn't exist. This will make // It's possible the above code will return a blank class if a file doesn't exist. This will make
// a new file with this players uuid // a new file with this players uuid
if ("".equals(thisNote.uuid)) { if ("".equals(thisNote.uuid)) {
System.out.println("Assigning new config file for this uuid. No previous existing"); System.out.println("\033[32m Assigning new config file for this uuid. No previous existing \033[0m");
thisNote.uuid = uuid; thisNote.uuid = uuid;
} }
} }
@ -142,7 +142,7 @@ public class PlayerNote {
try { try {
config.WriteToJsonFile("notes/" + thisNote.uuid.toString() + ".json", thisNote); config.WriteToJsonFile("notes/" + thisNote.uuid.toString() + ".json", thisNote);
} catch (FILE_WRITE_EXCEPTION e) { } catch (FILE_WRITE_EXCEPTION e) {
System.out.println("Could not flash notes configuration file"); System.out.println("\033[31m Could not flash notes configuration file \033[0m");
} }
} }
} }

View File

@ -36,25 +36,25 @@ public class Keeblarcraft implements ModInitializer {
// This code runs as soon as Minecraft is in a mod-load-ready state. // This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized. // However, some things (like resources) may still be uninitialized.
// Proceed with mild caution. // Proceed with mild caution.
LOGGER.info("Hello Fabric world!"); LOGGER.info("\033[36m Hello Fabric world! \033[0m");
if (setup != null) { if (setup != null) {
try { try {
// Run setup. If setup fails; it throws SETUP_FAILED_EXCEPTION // Run setup. If setup fails; it throws SETUP_FAILED_EXCEPTION
LOGGER.info("Running setup stage"); LOGGER.info("\033[34m Running setup stage \033[0m");
setup.RunSetup(); setup.RunSetup();
// Run command registrations from the command manager // Run command registrations from the command manager
LOGGER.info("Running command registration"); LOGGER.info("\033[34m Running command registration \033[0m");
cmdMgr.RegisterCustomCommands(); cmdMgr.RegisterCustomCommands();
} catch (SETUP_FAILED_EXCEPTION e) { } catch (SETUP_FAILED_EXCEPTION e) {
System.out.println("ERROR. Setup failed to initialize environment. Mod likely does not have read/write permissions inside area. Mod will now close out."); System.out.println("\033[31m ERROR. Setup failed to initialize environment. Mod likely does not have read/write permissions inside area. Mod will now close out. \033[0m");
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {
// Program exit. Dual definition of setup somehow happened! // Program exit. Dual definition of setup somehow happened!
System.out.println("Dual definition of singleton attempted! Out of order initialization? How did this even happen?"); System.out.println("\033[35m Dual definition of singleton attempted! Out of order initialization? How did this even happen? \033[0m");
} }
} }
} }

View File

@ -35,7 +35,7 @@ public final class Setup {
private static Setup static_inst; private static Setup static_inst;
public Setup() { public Setup() {
System.out.println("Running system setup and checks..."); System.out.println("\033[34m Running system setup and checks... \033[0m");
} }
// Returns the singleton object // Returns the singleton object
@ -79,9 +79,9 @@ public final class Setup {
// Create directory check // Create directory check
try { try {
has_write = conf.CreateDirectory("test_dir"); has_write = conf.CreateDirectory("test_dir");
System.out.println("test_dir created? " + (has_write ? "YES" : "NO")); System.out.println("\033[32m test_dir created! has write: \033[0m" + (has_write ? "\033[33m YES \033[0m" : "\033[31m NO \033[0m"));
} catch (DIRECTORY_CREATE_EXCEPTION e) { } catch (DIRECTORY_CREATE_EXCEPTION e) {
System.out.println("Failed to create test directory or it already exists"); System.out.println("\033[31m Failed to create test directory or it already exists \033[0m");
has_write = false; has_write = false;
} }
@ -98,7 +98,7 @@ public final class Setup {
has_read = true; has_read = true;
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("Failed to create or write to test dir file"); System.out.println("\033[31m Failed to create or write to test dir file \033[0m");
has_read = false; has_read = false;
} }
} }
@ -109,12 +109,12 @@ public final class Setup {
has_write = conf.DeleteFile("test_dir/test_note.txt"); has_write = conf.DeleteFile("test_dir/test_note.txt");
has_write = conf.DeleteDirectory("test_dir"); has_write = conf.DeleteDirectory("test_dir");
} catch (Exception e) { } catch (Exception e) {
System.out.println("Lost access to writing mid-way"); System.out.println("\033[31m Lost access to writing mid-way \033[0m");
has_write = false; has_write = false;
} }
} }
System.out.println("CHECKS DEBUG: Value of has_write: " + has_write + ". Value of has_read: " + has_read); System.out.println("\033[34m CHECKS DEBUG: Value of has_write: \033[0m" + "\033[33m" + has_write + "\033[0m" + "\033[34m . Value of has_read: \033[0m" + "\033[33m" + has_read + "\033[0m");
return has_write && has_read; return has_write && has_read;
} }
@ -132,9 +132,9 @@ public final class Setup {
for (Integer i = 0; i < DIRECTORY_LIST.size(); i++) { for (Integer i = 0; i < DIRECTORY_LIST.size(); i++) {
if ( ! conf.DoesDirectoryExist(DIRECTORY_LIST.get(i))) { if ( ! conf.DoesDirectoryExist(DIRECTORY_LIST.get(i))) {
conf.CreateDirectory(DIRECTORY_LIST.get(i)); conf.CreateDirectory(DIRECTORY_LIST.get(i));
System.out.println("Creating directory " + DIRECTORY_LIST.get(i) + "..."); System.out.println("\033[32m Creating directory \033[0m" + "\033[33m" + DIRECTORY_LIST.get(i) + "\033[0m" + "\033[32m ... \033[0m");
} else { } else {
System.out.println("Directory " + conf.DoesDirectoryExist(DIRECTORY_LIST.get(i)) + " already exists. Skipping..."); System.out.println("\033[34m Directory \033[0m" + "\033[33m" + conf.DoesDirectoryExist(DIRECTORY_LIST.get(i)) + "\033[0m" + "\033[34m already exists. Skipping... \033[0m");
} }
} }
@ -142,20 +142,20 @@ public final class Setup {
for (Integer i = 0; i < FILE_LIST.size(); i++) { for (Integer i = 0; i < FILE_LIST.size(); i++) {
if ( ! conf.DoesFileExist(FILE_LIST.get(i))) { if ( ! conf.DoesFileExist(FILE_LIST.get(i))) {
conf.CreateFile(FILE_LIST.get(i)); conf.CreateFile(FILE_LIST.get(i));
System.out.println("Creating file " + FILE_LIST.get(i) + "..."); System.out.println("\033[32m Creating file \033[0m" + "\033[33m" + FILE_LIST.get(i) + "\033[0m" + "\033[32m ... \033[0m");
} else { } else {
System.out.println("File " + conf.DoesDirectoryExist(FILE_LIST.get(i)) + " already exists. Skipping..."); System.out.println("\033[34m File \033[0m" + "\033[33m" + conf.DoesDirectoryExist(FILE_LIST.get(i)) + "\033[0m" + "\033[34m already exists. Skipping...\033[0m");
} }
} }
} catch (Exception e) { } catch (Exception e) {
throw new SETUP_FAILED_EXCEPTION(); throw new SETUP_FAILED_EXCEPTION();
} }
} else { } else {
System.out.println("RunChecks() failed in its process. This mod has deemed it does not have read or write privileges in its hosted area and will now exit."); System.out.println("\033[31m RunChecks() failed in its process. This mod has deemed it does not have read or write privileges in its hosted area and will now exit. \033[0m");
throw new SETUP_FAILED_EXCEPTION(); throw new SETUP_FAILED_EXCEPTION();
} }
System.out.println("DID SETUP COMPLETE SUCCESSFULLY? " + (ret ? "YES" : "NO")); System.out.println("\033[34m DID SETUP COMPLETE SUCCESSFULLY? \033[0m" + (ret ? "\033[33m YES \033[0m" : "\033[31m NO \033[0m"));
return ret; return ret;
} }