-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto common dependency downloader
- Loading branch information
1 parent
648f125
commit 498957e
Showing
10 changed files
with
357 additions
and
82 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 |
---|---|---|
|
@@ -28,4 +28,4 @@ jobs: | |
uses: actions/[email protected] | ||
with: | ||
name: Skidfuscator.jar | ||
path: staging/client-2.0.0-SNAPSHOT.jar | ||
path: staging/client-standalone-all.jar |
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
82 changes: 82 additions & 0 deletions
82
....client.standalone/src/main/java/dev/skidfuscator/obfuscator/command/MappingsCommand.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,82 @@ | ||
package dev.skidfuscator.obfuscator.command; | ||
|
||
import dev.skidfuscator.jghost.GhostHelper; | ||
import dev.skidfuscator.jghost.tree.GhostLibrary; | ||
import dev.skidfuscator.obfuscator.Skidfuscator; | ||
import dev.skidfuscator.obfuscator.util.misc.SkidTimedLogger; | ||
import org.apache.log4j.LogManager; | ||
import org.apache.log4j.Logger; | ||
import picocli.CommandLine; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
import java.util.concurrent.Callable; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
@CommandLine.Command( | ||
aliases = "mappings", | ||
mixinStandardHelpOptions = true, | ||
version = "1.0.0", | ||
description = "Creates a collated mappings file given a specific directory" | ||
) | ||
public class MappingsCommand implements Callable<Integer> { | ||
|
||
@CommandLine.Parameters( | ||
index = "0", | ||
description = "The directory which will be used to create the mappings file" | ||
) | ||
private File input; | ||
|
||
@CommandLine.Option( | ||
names = {"-o", "--output"}, | ||
description = "Path to the output mappings file location" | ||
) | ||
private File output = new File("compressed-mappings.json"); | ||
|
||
@Override | ||
public Integer call() throws Exception { | ||
if (input == null) { | ||
System.out.println("Invalid input file"); | ||
return 1; | ||
} | ||
|
||
if (!input.getPath().endsWith(".jar") && !input.isDirectory()) { | ||
System.err.println("Invalid input file. Must be a jar file or a directory"); | ||
return 1; | ||
} | ||
|
||
if (output == null) { | ||
System.err.println("Invalid output file"); | ||
return 1; | ||
} | ||
|
||
final Logger log = LogManager.getLogger(Skidfuscator.class); | ||
final SkidTimedLogger logger = new SkidTimedLogger(true, log); | ||
|
||
AtomicReference<GhostLibrary> ghostLibrary = new AtomicReference<>(null); | ||
iterateFolder(input, logger, ghostLibrary); | ||
|
||
GhostHelper.saveLibraryFile(logger, ghostLibrary.get(), output); | ||
logger.style("Successfully created mappings file"); | ||
|
||
return 0; | ||
} | ||
|
||
private void iterateFolder(File file, SkidTimedLogger logger, AtomicReference<GhostLibrary> ghostLibrary) { | ||
if (file.isDirectory()) { | ||
for (File files : file.listFiles()) { | ||
iterateFolder(files, logger, ghostLibrary); | ||
} | ||
} else { | ||
if (file.getAbsolutePath().endsWith(".jar") || file.getAbsolutePath().endsWith(".jmod")) { | ||
final GhostLibrary ghost = GhostHelper.createFromLibraryFile(logger, file); | ||
logger.style("Creating mappings for " + file.getAbsolutePath() + "...\n"); | ||
if (ghostLibrary.get() == null) { | ||
ghostLibrary.set(ghost); | ||
} else { | ||
ghostLibrary.get().merge(ghost); | ||
} | ||
} | ||
} | ||
} | ||
} |
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
73 changes: 73 additions & 0 deletions
73
...idfuscator.client.standalone/src/main/java/dev/skidfuscator/obfuscator/util/LogoUtil.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,73 @@ | ||
package dev.skidfuscator.obfuscator.util; | ||
|
||
import lombok.experimental.UtilityClass; | ||
|
||
import java.text.DateFormat; | ||
import java.time.Instant; | ||
import java.util.Date; | ||
|
||
@UtilityClass | ||
public class LogoUtil { | ||
public static void printLogo() { | ||
/* Total number of processors or cores available to the JVM */ | ||
final String processors = | ||
String.format("%19.19s", "Processors:") | ||
+ " " | ||
+ String.format( | ||
"%-19.19s", | ||
Runtime.getRuntime().availableProcessors() + " cores" | ||
); | ||
|
||
final long freeMemory = Math.round(Runtime.getRuntime().freeMemory() / 1E6); | ||
final String memory = | ||
String.format("%19.19s", "Current Memory:") | ||
+ " " | ||
+ String.format("%-19.19s", freeMemory + "mb"); | ||
|
||
final long maxMemory = Math.round(Runtime.getRuntime().maxMemory() / 1E6); | ||
final String memoryString = (maxMemory == Long.MAX_VALUE | ||
? ConsoleColors.GREEN + "no limit" | ||
: maxMemory + "mb" | ||
); | ||
String topMemory = | ||
String.format("%19.19s", "Max Memory:") | ||
+ " " | ||
+ String.format("%-19.19s", | ||
memoryString + (maxMemory > 1500 ? "" : " ⚠️") | ||
); | ||
|
||
topMemory = MiscUtil.replaceColor( | ||
topMemory, | ||
memoryString, | ||
maxMemory > 1500 ? ConsoleColors.GREEN_BRIGHT : ConsoleColors.RED_BRIGHT | ||
); | ||
// slight fix for thing | ||
topMemory = topMemory.replace("⚠️", "⚠️ "); | ||
|
||
final String[] logo = new String[] { | ||
"", | ||
" /$$$$$$ /$$ /$$ /$$ /$$$$$$ /$$", | ||
" /$$__ $$| $$ |__/ | $$ /$$__ $$ | $$", | ||
"| $$ \\__/| $$ /$$ /$$ /$$$$$$$| $$ \\__//$$ /$$ /$$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$", | ||
"| $$$$$$ | $$ /$$/| $$ /$$__ $$| $$$$ | $$ | $$ /$$_____/ /$$_____/ |____ $$|_ $$_/ /$$__ $$ /$$__ $$", | ||
" \\____ $$| $$$$$$/ | $$| $$ | $$| $$_/ | $$ | $$| $$$$$$ | $$ /$$$$$$$ | $$ | $$ \\ $$| $$ \\__/", | ||
" /$$ \\ $$| $$_ $$ | $$| $$ | $$| $$ | $$ | $$ \\____ $$| $$ /$$__ $$ | $$ /$$| $$ | $$| $$", | ||
"| $$$$$$/| $$ \\ $$| $$| $$$$$$$| $$ | $$$$$$/ /$$$$$$$/| $$$$$$$| $$$$$$$ | $$$$/| $$$$$$/| $$", | ||
" \\______/ |__/ \\__/|__/ \\_______/|__/ \\______/ |_______/ \\_______/ \\_______/ \\___/ \\______/ |__/", | ||
"", | ||
" ┌───────────────────────────────────────────┐", | ||
" │ " + processors + " │", | ||
" │ " + memory + " │", | ||
" │ " + topMemory + " │", | ||
" └───────────────────────────────────────────┘", | ||
"", | ||
" Author: Ghast Version: 2.0.8 Today: " | ||
+ DateFormat.getDateTimeInstance().format(new Date(Instant.now().toEpochMilli())), | ||
"" | ||
}; | ||
|
||
for (String s : logo) { | ||
System.out.println(s); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.