fixed files
This commit is contained in:
parent
d283c2f9b3
commit
1368d2f379
@ -8,6 +8,9 @@
|
|||||||
|
|
||||||
package jesse.keeblarcraft.Commands;
|
package jesse.keeblarcraft.Commands;
|
||||||
|
|
||||||
|
import jesse.keeblarcraft.Utils.ChatUtil;
|
||||||
|
import jesse.keeblarcraft.Utils.ChatUtil.CONSOLE_COLOR;
|
||||||
|
|
||||||
public class CustomCommandManager {
|
public class CustomCommandManager {
|
||||||
// Intentionally empty constructor since at object definition time it may not be possible to register commands
|
// Intentionally empty constructor since at object definition time it may not be possible to register commands
|
||||||
public CustomCommandManager() {}
|
public CustomCommandManager() {}
|
||||||
@ -19,7 +22,7 @@ public class CustomCommandManager {
|
|||||||
NoteCommands noteCommands = new NoteCommands();
|
NoteCommands noteCommands = new NoteCommands();
|
||||||
|
|
||||||
// REGISTER COMMANDS BELOW
|
// REGISTER COMMANDS BELOW
|
||||||
System.out.println("\033[32m REGISTERING CUSTOM COMMAND EXTENSIONS BELOW \033[0m");
|
System.out.println(ChatUtil.ColoredString("REGISTERING CUSTOM COMMAND EXTENSIONS BELOW", CONSOLE_COLOR.BLUE));
|
||||||
shortcuts.RegisterShortcutCommands();
|
shortcuts.RegisterShortcutCommands();
|
||||||
noteCommands.RegisterNoteCommands();
|
noteCommands.RegisterNoteCommands();
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ 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;
|
||||||
import jesse.keeblarcraft.Utils.ChatUtil;
|
import jesse.keeblarcraft.Utils.ChatUtil;
|
||||||
|
import jesse.keeblarcraft.Utils.ChatUtil.CONSOLE_COLOR;
|
||||||
import jesse.keeblarcraft.Utils.CustomExceptions.DIRECTORY_CREATE_EXCEPTION;
|
import jesse.keeblarcraft.Utils.CustomExceptions.DIRECTORY_CREATE_EXCEPTION;
|
||||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
@ -31,15 +32,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("\033[32m Created notes directory successfully! \033[0m"); //TODO: Success!
|
System.out.println(ChatUtil.ColoredString("Created notes directory successfully!", CONSOLE_COLOR.BLUE)); //TODO: Success!
|
||||||
} else {
|
} else {
|
||||||
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
|
System.out.println(ChatUtil.ColoredString("ERROR: Notes directory FAILED to create!! Either the directory already exists or we are missing permissions!", CONSOLE_COLOR.RED)); //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("\033[31m Directory creation failed \033[0m");
|
System.out.println(ChatUtil.ColoredString("Directory creation failed", CONSOLE_COLOR.RED));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("\033[34m Notes directory already exists. Skipping creation... \033[0m"); //TODO: Success!
|
System.out.println(ChatUtil.ColoredString("Notes directory already exists. Skipping creation...", CONSOLE_COLOR.BLUE)); //TODO: Success!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ public class NoteCommands {
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
System.out.println("\033[31m Only a player can execute this command! \033[0m");
|
System.out.println(ChatUtil.ColoredString("Only a player can execute this command!", CONSOLE_COLOR.RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -12,6 +12,7 @@ import com.mojang.brigadier.arguments.IntegerArgumentType;
|
|||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
|
||||||
import jesse.keeblarcraft.Utils.ChatUtil;
|
import jesse.keeblarcraft.Utils.ChatUtil;
|
||||||
|
import jesse.keeblarcraft.Utils.ChatUtil.CONSOLE_COLOR;
|
||||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||||
import net.minecraft.entity.player.PlayerAbilities;
|
import net.minecraft.entity.player.PlayerAbilities;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
@ -100,7 +101,7 @@ public class ShortcutCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
System.out.println("\033[31m This command cannot be executed by a non-player entity! \033[0m");
|
System.out.println(ChatUtil.ColoredString("This command cannot be executed by a non-player entity!", CONSOLE_COLOR.RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
return retValue;
|
return retValue;
|
||||||
|
@ -29,6 +29,8 @@ import org.apache.commons.io.FileUtils;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import jesse.keeblarcraft.Utils.ChatUtil;
|
||||||
|
import jesse.keeblarcraft.Utils.ChatUtil.CONSOLE_COLOR;
|
||||||
// Import all custom exceptions
|
// Import all custom exceptions
|
||||||
import jesse.keeblarcraft.Utils.CustomExceptions.*;
|
import jesse.keeblarcraft.Utils.CustomExceptions.*;
|
||||||
|
|
||||||
@ -46,7 +48,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("\033[34m Does file exist? \033[0m" + (ret ? "\033[33m YES \033[0m" : "\033[31m NO \033[0m"));
|
System.out.println(ChatUtil.ColoredString("Does file exist? ", CONSOLE_COLOR.BLUE) + (ret ? ChatUtil.ColoredString("YES", CONSOLE_COLOR.YELLOW) : ChatUtil.ColoredString("NO", CONSOLE_COLOR.YELLOW)));
|
||||||
|
|
||||||
// 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) {
|
||||||
@ -58,7 +60,7 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
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?
|
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("\033[34m File (name: \033[0m" + "\033[33m" + fileName + "\033[0m" + "\033[34m) was determined to already exist. Exiting out\033[0m");
|
System.out.println(ChatUtil.ColoredString("File (name: ", CONSOLE_COLOR.BLUE) + ChatUtil.ColoredString(fileName, CONSOLE_COLOR.YELLOW) + ChatUtil.ColoredString(" was determined to already exist. Exiting out", CONSOLE_COLOR.BLUE));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -81,7 +83,7 @@ public class ConfigManager {
|
|||||||
throw new FILE_DELETE_EXCEPTION();
|
throw new FILE_DELETE_EXCEPTION();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("\033[34m Cannot delete file \033[0m" + "\033[33m" + fileName + "\033[0m" + "\033[31m because file does not exist \033[0m");
|
System.out.println(ChatUtil.ColoredString("cannot delete file ", CONSOLE_COLOR.RED) + ChatUtil.ColoredString(fileName, CONSOLE_COLOR.YELLOW) + ChatUtil.ColoredString(" because file does not exist", CONSOLE_COLOR.BLUE));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -105,13 +107,13 @@ public class ConfigManager {
|
|||||||
ret = true;
|
ret = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
System.out.println("\033[31m Invalid mode to WriteToFile! \033[0m");
|
System.out.println(ChatUtil.ColoredString("Invalid mode to WriteToFile!", CONSOLE_COLOR.RED));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
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");
|
System.out.println(ChatUtil.ColoredString("Could not open file ", CONSOLE_COLOR.RED) + ChatUtil.ColoredString(fileName, CONSOLE_COLOR.YELLOW) + ChatUtil.ColoredString(" to write to it! Possibly permission issue?", CONSOLE_COLOR.RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -135,7 +137,7 @@ public class ConfigManager {
|
|||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
} catch (JsonIOException | IOException e) {
|
} catch (JsonIOException | IOException e) {
|
||||||
System.out.println("\033[31m Could not successfully write to json file \033[0m");
|
System.out.println(ChatUtil.ColoredString("Could not successfully write to json file", CONSOLE_COLOR.RED));
|
||||||
throw new FILE_WRITE_EXCEPTION();
|
throw new FILE_WRITE_EXCEPTION();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,18 +153,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, "\033[32m UTF-8 \033[0m");
|
ret = FileUtils.readFileToString(file, "UTF-8");
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
System.out.println("\033[31m nullptr exception \033[0m");
|
System.out.println(ChatUtil.ColoredString("nullptr exception", CONSOLE_COLOR.RED));
|
||||||
throw new JsonSyntaxException("");
|
throw new JsonSyntaxException("");
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
System.out.println("\033[31m file not found \033[0m");
|
System.out.println(ChatUtil.ColoredString("file not found", CONSOLE_COLOR.RED));
|
||||||
throw new JsonSyntaxException("");
|
throw new JsonSyntaxException("");
|
||||||
} catch (java.nio.charset.UnsupportedCharsetException e) {
|
} catch (java.nio.charset.UnsupportedCharsetException e) {
|
||||||
System.out.println("\033[31m charset issue \033[0m");
|
System.out.println(ChatUtil.ColoredString("charset issue", CONSOLE_COLOR.RED));
|
||||||
throw new JsonSyntaxException("");
|
throw new JsonSyntaxException("");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("\033[31m io exception \033[0m");
|
System.out.println(ChatUtil.ColoredString("io exception", CONSOLE_COLOR.RED));
|
||||||
throw new JsonSyntaxException("");
|
throw new JsonSyntaxException("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +193,7 @@ public class ConfigManager {
|
|||||||
ret = dir.mkdirs();
|
ret = dir.mkdirs();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("\033[31m Failed to make directory with name: \033[0m" + "\033[33m" + dirName + "\033[0m");
|
System.out.println(ChatUtil.ColoredString("Failed to make directory with name: ", CONSOLE_COLOR.RED) + ChatUtil.ColoredString(dirName, CONSOLE_COLOR.YELLOW));
|
||||||
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 +207,9 @@ public class ConfigManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
ret = dir.delete();
|
ret = dir.delete();
|
||||||
System.out.println("\033[32m Deleted directory \033[0m" + "\033[33m" + dirName + "\033[0m");
|
System.out.println(ChatUtil.ColoredString("Deleted directory ", CONSOLE_COLOR.GREEN) + ChatUtil.ColoredString(dirName, CONSOLE_COLOR.YELLOW));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("\033[31m Failed to delete directory: \033[0m" + "\033[33m" + dirName + "\033[0m");
|
System.out.println(ChatUtil.ColoredString("Failed to delete directory: ", CONSOLE_COLOR.RED) + ChatUtil.ColoredString(dirName, CONSOLE_COLOR.YELLOW));
|
||||||
throw new DIRECTORY_DELETE_EXCEPTION();
|
throw new DIRECTORY_DELETE_EXCEPTION();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@ import java.util.HashMap;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import jesse.keeblarcraft.ConfigMgr.ConfigManager;
|
import jesse.keeblarcraft.ConfigMgr.ConfigManager;
|
||||||
|
import jesse.keeblarcraft.Utils.ChatUtil;
|
||||||
|
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 {
|
||||||
@ -91,21 +93,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("\033[34m Trying to create new file \033[0m");
|
System.out.println(ChatUtil.ColoredString("Trying to create new file", CONSOLE_COLOR.BLUE));
|
||||||
try {
|
try {
|
||||||
thisNote.uuid = uuid;
|
thisNote.uuid = uuid;
|
||||||
FlashConfig();
|
FlashConfig();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("\033[31m Could not write to file \033[0m");
|
System.out.println(ChatUtil.ColoredString("Could not write to file", CONSOLE_COLOR.RED));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("\033[34m Moving on \033[0m");
|
System.out.println(ChatUtil.ColoredString("Moving on", CONSOLE_COLOR.BLUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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("\033[32m Assigning new config file for this uuid. No previous existing \033[0m");
|
System.out.println(ChatUtil.ColoredString("Assigning new config file for this uuid. No previous existing", CONSOLE_COLOR.BLUE));
|
||||||
thisNote.uuid = uuid;
|
thisNote.uuid = uuid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,7 +144,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("\033[31m Could not flash notes configuration file \033[0m");
|
System.out.println(ChatUtil.ColoredString("Could not flash notes configuration file", CONSOLE_COLOR.RED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,12 +51,12 @@ public class Keeblarcraft implements ModInitializer {
|
|||||||
cmdMgr.RegisterCustomCommands();
|
cmdMgr.RegisterCustomCommands();
|
||||||
|
|
||||||
} catch (SETUP_FAILED_EXCEPTION e) {
|
} catch (SETUP_FAILED_EXCEPTION e) {
|
||||||
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");
|
System.out.println(ChatUtil.ColoredString("ERROR. Setup failed to initialize environment. Mod likely does not have read/write permissions inside area. Mod will now close out.", CONSOLE_COLOR.RED));
|
||||||
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("\033[35m Dual definition of singleton attempted! Out of order initialization? How did this even happen? \033[0m");
|
System.out.println(ChatUtil.ColoredString("Dual definition of singleton attempted! Out of order initialization? How did this even happen?", CONSOLE_COLOR.RED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,7 +14,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
|||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
public class ChatUtil {
|
public class ChatUtil {
|
||||||
|
//This is a private class only used internally to get ANSI colors
|
||||||
private static class ConsoleColor {
|
private static class ConsoleColor {
|
||||||
public static String getColor(CONSOLE_COLOR color) {
|
public static String getColor(CONSOLE_COLOR color) {
|
||||||
String ret = "";
|
String ret = "";
|
||||||
@ -22,11 +22,17 @@ public class ChatUtil {
|
|||||||
case CONSOLE_COLOR.RED:
|
case CONSOLE_COLOR.RED:
|
||||||
ret = "31";
|
ret = "31";
|
||||||
break;
|
break;
|
||||||
|
case CONSOLE_COLOR.GREEN:
|
||||||
|
ret = "32";
|
||||||
|
break;
|
||||||
|
case CONSOLE_COLOR.YELLOW:
|
||||||
|
ret = "33";
|
||||||
|
break;
|
||||||
case CONSOLE_COLOR.BLUE:
|
case CONSOLE_COLOR.BLUE:
|
||||||
ret = "34";
|
ret = "34";
|
||||||
break;
|
break;
|
||||||
case CONSOLE_COLOR.GREEN:
|
case CONSOLE_COLOR.MAGENTA:
|
||||||
ret = "32";
|
ret = "35";
|
||||||
break;
|
break;
|
||||||
case CONSOLE_COLOR.CYAN:
|
case CONSOLE_COLOR.CYAN:
|
||||||
ret = "36";
|
ret = "36";
|
||||||
@ -38,8 +44,10 @@ public class ChatUtil {
|
|||||||
|
|
||||||
public static enum CONSOLE_COLOR {
|
public static enum CONSOLE_COLOR {
|
||||||
RED,
|
RED,
|
||||||
BLUE,
|
|
||||||
GREEN,
|
GREEN,
|
||||||
|
YELLOW,
|
||||||
|
BLUE,
|
||||||
|
MAGENTA,
|
||||||
CYAN;
|
CYAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import java.util.List;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import jesse.keeblarcraft.ConfigMgr.ConfigManager;
|
import jesse.keeblarcraft.ConfigMgr.ConfigManager;
|
||||||
|
import jesse.keeblarcraft.Utils.ChatUtil.CONSOLE_COLOR;
|
||||||
import jesse.keeblarcraft.Utils.CustomExceptions.DIRECTORY_CREATE_EXCEPTION;
|
import jesse.keeblarcraft.Utils.CustomExceptions.DIRECTORY_CREATE_EXCEPTION;
|
||||||
import jesse.keeblarcraft.Utils.CustomExceptions.DIRECTORY_DELETE_EXCEPTION;
|
import jesse.keeblarcraft.Utils.CustomExceptions.DIRECTORY_DELETE_EXCEPTION;
|
||||||
import jesse.keeblarcraft.Utils.CustomExceptions.SETUP_FAILED_EXCEPTION;
|
import jesse.keeblarcraft.Utils.CustomExceptions.SETUP_FAILED_EXCEPTION;
|
||||||
@ -35,7 +36,7 @@ public final class Setup {
|
|||||||
private static Setup static_inst;
|
private static Setup static_inst;
|
||||||
|
|
||||||
public Setup() {
|
public Setup() {
|
||||||
System.out.println("\033[34m Running system setup and checks... \033[0m");
|
System.out.println(ChatUtil.ColoredString("Running system setup and checks...", CONSOLE_COLOR.BLUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the singleton object
|
// Returns the singleton object
|
||||||
@ -79,9 +80,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("\033[32m test_dir created! has write: \033[0m" + (has_write ? "\033[33m YES \033[0m" : "\033[31m NO \033[0m"));
|
System.out.println(ChatUtil.ColoredString("test_dir created! has write: ", CONSOLE_COLOR.GREEN) + (has_write ? ChatUtil.ColoredString("YES", CONSOLE_COLOR.YELLOW) : ChatUtil.ColoredString("NO", CONSOLE_COLOR.YELLOW)));
|
||||||
} catch (DIRECTORY_CREATE_EXCEPTION e) {
|
} catch (DIRECTORY_CREATE_EXCEPTION e) {
|
||||||
System.out.println("\033[31m Failed to create test directory or it already exists \033[0m");
|
System.out.println(ChatUtil.ColoredString("Failed to create test directory or it already exists", CONSOLE_COLOR.MAGENTA));
|
||||||
has_write = false;
|
has_write = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ public final class Setup {
|
|||||||
has_read = true;
|
has_read = true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("\033[31m Failed to create or write to test dir file \033[0m");
|
System.out.println(ChatUtil.ColoredString("Failed to create or write to test dir file ", CONSOLE_COLOR.RED));
|
||||||
has_read = false;
|
has_read = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,12 +110,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("\033[31m Lost access to writing mid-way \033[0m");
|
System.out.println(ChatUtil.ColoredString("Lost access to writing mid-way", CONSOLE_COLOR.RED));
|
||||||
has_write = false;
|
has_write = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//need to be able to take in raw booleans for coloredstrings functions
|
||||||
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");
|
System.out.println(ChatUtil.ColoredString("CHECKS DEBUG: Value of has_write: ", CONSOLE_COLOR.BLUE) + has_write + ChatUtil.ColoredString(". Value of has_read: ", CONSOLE_COLOR.BLUE) + has_read);
|
||||||
return has_write && has_read;
|
return has_write && has_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,9 +133,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("\033[32m Creating directory \033[0m" + "\033[33m" + DIRECTORY_LIST.get(i) + "\033[0m" + "\033[32m ... \033[0m");
|
System.out.println(ChatUtil.ColoredString("Creating directory ", CONSOLE_COLOR.GREEN) + ChatUtil.ColoredString(DIRECTORY_LIST.get(i), CONSOLE_COLOR.YELLOW) + ChatUtil.ColoredString("...", CONSOLE_COLOR.GREEN));
|
||||||
} else {
|
} else {
|
||||||
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");
|
System.out.println(ChatUtil.ColoredString("Directory ", CONSOLE_COLOR.BLUE) + conf.DoesDirectoryExist(DIRECTORY_LIST.get(i)) + ChatUtil.ColoredString(" already exists. Skipping... ", CONSOLE_COLOR.BLUE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,20 +143,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("\033[32m Creating file \033[0m" + "\033[33m" + FILE_LIST.get(i) + "\033[0m" + "\033[32m ... \033[0m");
|
System.out.println(ChatUtil.ColoredString("Creating file ", CONSOLE_COLOR.GREEN) + ChatUtil.ColoredString(FILE_LIST.get(i), CONSOLE_COLOR.YELLOW) + ChatUtil.ColoredString("...", CONSOLE_COLOR.GREEN));
|
||||||
} else {
|
} else {
|
||||||
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");
|
System.out.println(ChatUtil.ColoredString("File ", CONSOLE_COLOR.BLUE) + conf.DoesDirectoryExist(FILE_LIST.get(i)) + ChatUtil.ColoredString(" already exists. Skipping...", CONSOLE_COLOR.BLUE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new SETUP_FAILED_EXCEPTION();
|
throw new SETUP_FAILED_EXCEPTION();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
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");
|
System.out.println(ChatUtil.ColoredString("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.", CONSOLE_COLOR.RED));
|
||||||
throw new SETUP_FAILED_EXCEPTION();
|
throw new SETUP_FAILED_EXCEPTION();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("\033[34m DID SETUP COMPLETE SUCCESSFULLY? \033[0m" + (ret ? "\033[33m YES \033[0m" : "\033[31m NO \033[0m"));
|
System.out.println(ChatUtil.ColoredString("DID SETUP COMPLETE SUCCESSFULLY? ", CONSOLE_COLOR.YELLOW) + (ret ? ChatUtil.ColoredString("YES", CONSOLE_COLOR.YELLOW) : ChatUtil.ColoredString("NO", CONSOLE_COLOR.YELLOW)));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user