-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f3330c1
Showing
10 changed files
with
376 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
release.properties | ||
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties | ||
|
||
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) | ||
!/.mvn/wrapper/maven-wrapper.jar | ||
/plugin | ||
|
||
# IntelliJ IDEA | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### PackMake | ||
Resource pack compiler | ||
|
||
##### Usage, commands and flags | ||
... to be added |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.github.ijustleyxo</groupId> | ||
<artifactId>packmake</artifactId> | ||
<version>0.0.0</version> | ||
|
||
<name>PackMake</name> | ||
<url>https://github.com/iJustLeyxo/PackMake</url> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<build> | ||
<finalName>${project.name}</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<source>21</source> | ||
<target>21</target> | ||
<showDeprecation>true</showDeprecation> | ||
<showWarnings>true</showWarnings> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.2.2</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<mainClass>com.github.ijustleyxo.packmake.PackMake</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jetbrains</groupId> | ||
<artifactId>annotations</artifactId> | ||
<version>24.0.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains</groupId> | ||
<artifactId>annotations</artifactId> | ||
<version>24.1.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/github/ijustleyxo/packmake/PackMake.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.github.ijustleyxo.packmake; | ||
|
||
import com.github.ijustleyxo.packmake.util.console.Console; | ||
import com.github.ijustleyxo.packmake.util.console.Type; | ||
|
||
/** | ||
* Minecraft resource pack compiler | ||
*/ | ||
public final class PackMake { | ||
public static void main(String[] args) { | ||
// TODO: Resource pack creation logic | ||
PackMake.exit(); | ||
} | ||
|
||
public static void exit() { | ||
Console.log(Type.DEBUG, "Exiting\n"); | ||
Console.sep(); | ||
System.exit(0); | ||
} | ||
} |
156 changes: 156 additions & 0 deletions
156
src/main/java/com/github/ijustleyxo/packmake/util/console/Console.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
package com.github.ijustleyxo.packmake.util.console; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* Console manager, used to format console outputs | ||
*/ | ||
public final class Console { | ||
public static @NotNull Detail detail = Detail.STD; | ||
private static @Nullable Type type = null; | ||
private static boolean empty = true; | ||
|
||
/** | ||
* Logs a message to console | ||
* @param type Type of message to log | ||
* @param style Style to override the default style of the specified type | ||
* @param msg Message to log | ||
* @return {@code true} if the message was logged and not held back due to verbosity | ||
*/ | ||
public static boolean log(@NotNull Type type, @NotNull Style style, @NotNull String msg) { | ||
if (!Console.logs(type.detail)) return false; | ||
Console.sep(type); | ||
System.out.print(XCode.RESET + style.toString() + msg); | ||
Console.empty = false; | ||
return true; | ||
} | ||
|
||
/** | ||
* Logs a formatted message to console | ||
* @param type Type of message to log | ||
* @param style Style to override the default style of the specified type | ||
* @param format Format to use for the message | ||
* @param params Params to format | ||
* @return {@code true} if the message was logged and not held back due to verbosity | ||
*/ | ||
public static boolean logF(@NotNull Type type, @NotNull Style style, @NotNull String format, @NotNull String... params) { | ||
if (!Console.logs(type.detail)) return false; | ||
Console.sep(type); | ||
System.out.printf(XCode.RESET + style.toString() + format, (Object[]) params); | ||
Console.empty = false; | ||
return true; | ||
} | ||
|
||
/** | ||
* Logs a list to console | ||
* @param type Type of message to log | ||
* @param style Style to override the default style of the specified type | ||
* @param header List header | ||
* @param cols Columns of the list | ||
* @param colSize Size of the columns of the list | ||
* @return {@code true} if the message was logged and not held back due to verbosity | ||
*/ | ||
public static boolean logL(@NotNull Type type, @NotNull Style style, @NotNull String header, | ||
int cols, int colSize, @NotNull Object... objects) { | ||
if (!Console.logs(type.detail)) return false; | ||
int dashes = (cols * colSize + cols - 1) - header.length() - 2; | ||
StringBuilder b = new StringBuilder(XCode.BOLD + "-".repeat(dashes / 2) + " " + header + " " | ||
+ "-".repeat(dashes / 2 + dashes % 2) + "\n" + XCode.WEIGHT_OFF); | ||
Arrays.sort(objects); | ||
int i = 1; | ||
for (Object o : objects) { | ||
b.append(o).append(" ".repeat(Math.max(0, colSize - o.toString().length()))); | ||
if (i >= cols) { | ||
b.append("\n"); | ||
i = 1; | ||
} else { | ||
b.append(" "); | ||
i++; | ||
} | ||
} | ||
String s = b.toString(); | ||
if (!s.endsWith("\n")) s += "\n"; | ||
Console.log(type, style, s); | ||
return true; | ||
} | ||
|
||
/** | ||
* Logs a style to console | ||
* @param type Type of style to log | ||
* @param style Style to override the default style of the specified type | ||
* @return {@code true} if the style was logged and not held back due to verbosity | ||
*/ | ||
public static boolean log(@NotNull Type type, @NotNull Style style) { | ||
return Console.log(type, style, ""); | ||
} | ||
|
||
/** | ||
* Logs a message to console | ||
* @param type Type of message to log using the default style of the type | ||
* @return {@code true} if the style was logged and not held back due to verbosity | ||
*/ | ||
public static boolean log(@NotNull Type type, @NotNull String msg) { | ||
return Console.log(type, type.style, msg); | ||
} | ||
|
||
/** | ||
* @param detail The detail to test for logging | ||
* @return {@code true} if the detail level gets logged and not held back due to verbosity | ||
*/ | ||
public static boolean logs(@NotNull Detail detail) { | ||
return Console.detail.val >= detail.val; | ||
} | ||
|
||
public static boolean logs(@NotNull Type type) { | ||
return Console.logs(type.detail); | ||
} | ||
|
||
/** | ||
* Test for separation between different types of logged output | ||
* @param type The type to test for separation, {@code type = null} will always separate | ||
*/ | ||
public static void sep(@Nullable Type type) { | ||
if (Console.type != type || null == type) { | ||
if (!Console.empty) System.out.println(); | ||
Console.type = type; | ||
Console.empty = true; | ||
} | ||
} | ||
|
||
/** | ||
* Force separation between logged outputs | ||
*/ | ||
public static void sep() { | ||
Console.sep(null); | ||
} | ||
|
||
/** | ||
* Get new input arguments from console | ||
* @return user input argument | ||
*/ | ||
public static @NotNull String @NotNull [] in() { | ||
Console.sep(); | ||
Console.log(Type.PROMPT, "> "); | ||
Console.log(Type.PROMPT, Style.INPUT); | ||
return System.console().readLine().split(" "); | ||
} | ||
|
||
/** | ||
* Get an input from console | ||
* @param prompt Prompt to output | ||
* @return user's response to the prompt | ||
*/ | ||
public static @NotNull String in(@NotNull String prompt) { | ||
Console.sep(); | ||
Console.log(Type.PROMPT, prompt + " "); | ||
Console.log(Type.PROMPT, Style.INPUT); | ||
return System.console().readLine(); | ||
} | ||
|
||
public static boolean confirm(@NotNull String string) { | ||
return Console.in(string + " (Y/n)?").equalsIgnoreCase("y"); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/github/ijustleyxo/packmake/util/console/Detail.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.github.ijustleyxo.packmake.util.console; | ||
|
||
/** | ||
* Console output detail level | ||
*/ | ||
public enum Detail { | ||
/** | ||
* Override detail management and force console output | ||
*/ | ||
OVERRIDE(Integer.MIN_VALUE), | ||
MIN(-2), | ||
LOW(-1), | ||
STD(0), | ||
HIGH(1); | ||
|
||
public final int val; | ||
|
||
Detail(int val) { | ||
this.val = val; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/github/ijustleyxo/packmake/util/console/Style.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.github.ijustleyxo.packmake.util.console; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Console output styles, used to manage color, weight, etc. of console outputs | ||
*/ | ||
public enum Style { | ||
PROMPT(XCode.BOLD, XCode.BLUE), | ||
INPUT(XCode.BOLD, XCode.WHITE), | ||
DEBUG(XCode.GRAY), | ||
SELECT(XCode.BLUE), | ||
INSTALL(XCode.GREEN), | ||
UPDATE(XCode.GREEN), | ||
UNINSTALL(XCode.RED), | ||
LINK(XCode.MAGENTA), | ||
SUPERFLUOUS(XCode.YELLOW), | ||
MISSING(XCode.RED), | ||
UNKNOWN(XCode.GRAY), | ||
PLUGIN(XCode.BLUE), | ||
CATEGORY(XCode.GREEN), | ||
SERVER(XCode.MAGENTA), | ||
SOFTWARE(XCode.YELLOW), | ||
INFO(XCode.WHITE), | ||
DONE(XCode.GREEN), | ||
HELP(XCode.GREEN), | ||
WARN(XCode.BOLD, XCode.YELLOW), | ||
ERR(XCode.BOLD, XCode.RED); | ||
|
||
public final @NotNull String xCodes; | ||
|
||
Style(@NotNull XCode @NotNull ... codes) { | ||
StringBuilder s = new StringBuilder(); | ||
for (XCode c : codes) { | ||
s.append(c); | ||
} | ||
this.xCodes = s.toString(); | ||
} | ||
|
||
@Override | ||
public @NotNull String toString() { return this.xCodes; } | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/github/ijustleyxo/packmake/util/console/Type.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.github.ijustleyxo.packmake.util.console; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Console output type, used to combine commonly used combinations of a style and detail level | ||
*/ | ||
public enum Type { | ||
PROMPT(Detail.OVERRIDE, Style.PROMPT), | ||
REQUESTED(Detail.OVERRIDE, Style.INFO), | ||
DEBUG(Detail.HIGH, Style.DEBUG), | ||
INFO(Detail.STD, Style.INFO), | ||
WARN(Detail.LOW, Style.WARN), | ||
ERR(Detail.MIN, Style.ERR); | ||
|
||
public final @NotNull Detail detail; | ||
public final @NotNull Style style; | ||
|
||
Type(@NotNull Detail detail, @NotNull Style style) { | ||
this.detail = detail; | ||
this.style = style; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/github/ijustleyxo/packmake/util/console/XCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.github.ijustleyxo.packmake.util.console; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* ANSI escape codes, used to format text outputted to most modern terminal emulators | ||
*/ | ||
public enum XCode { | ||
RESET("\u001B[0m"), | ||
BOLD("\u001B[1m"), | ||
WEIGHT_OFF("\u001B[22m"), | ||
GRAY("\u001B[90m"), | ||
RED("\u001B[91m"), | ||
GREEN("\u001B[92m"), | ||
YELLOW("\u001B[93m"), | ||
BLUE("\u001B[94m"), | ||
MAGENTA("\u001B[95m"), | ||
WHITE("\u001B[97m"); | ||
|
||
private final @NotNull String code; | ||
|
||
XCode(@NotNull String code) { | ||
this.code = code; | ||
} | ||
|
||
@Override | ||
public @NotNull String toString() { | ||
return this.code; | ||
} | ||
} |