-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Silent work 1.20.1
- Loading branch information
Showing
7 changed files
with
185 additions
and
36 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
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
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
39 changes: 16 additions & 23 deletions
39
common/src/main/java/com/adamcalculator/dynamicpack/util/Out.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 |
---|---|---|
@@ -1,81 +1,74 @@ | ||
package com.adamcalculator.dynamicpack.util; | ||
|
||
import com.adamcalculator.dynamicpack.Mod; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.File; | ||
|
||
public class Out { | ||
public static final Logger LOGGER = LoggerFactory.getLogger("dynamicpack"); | ||
public static boolean ENABLE = true; | ||
public static boolean USE_SOUT = false; | ||
public static final String PREFIX = "[DynamicPack] "; | ||
|
||
public static void println(Object o) { | ||
if (!ENABLE) return; | ||
if (USE_SOUT) { | ||
System.out.println(o); | ||
System.out.println(PREFIX + o); | ||
return; | ||
} | ||
LOGGER.info(o + ""); | ||
LOGGER.info(PREFIX + o); | ||
} | ||
|
||
public static void error(String s, Exception e) { | ||
if (!ENABLE) return; | ||
if (USE_SOUT) { | ||
System.err.println(s); | ||
System.err.println(PREFIX + s); | ||
e.printStackTrace(); | ||
return; | ||
} | ||
LOGGER.error(s, e); | ||
} | ||
|
||
public static void downloading(String url, File file) { | ||
if (!ENABLE) return; | ||
if (USE_SOUT) { | ||
System.out.println(file.getName() + " downloading from " + url); | ||
return; | ||
} | ||
LOGGER.warn("Downloading " + file.getName() + " from " + url); | ||
LOGGER.error(PREFIX + s, e); | ||
} | ||
|
||
public static void warn(String s) { | ||
if (!ENABLE) return; | ||
if (USE_SOUT) { | ||
System.out.println("WARN: " + s); | ||
System.out.println(PREFIX + "WARN: " + s); | ||
return; | ||
} | ||
LOGGER.warn(s); | ||
LOGGER.warn(PREFIX + s); | ||
} | ||
|
||
/** | ||
* Always enable! Ignore enable/disable | ||
*/ | ||
public static void securityWarning(String s) { | ||
if (USE_SOUT) { | ||
System.out.println("[dynamicpack] " + s); | ||
System.out.println("[DynamicPack] " + s); | ||
return; | ||
} | ||
|
||
try { | ||
LOGGER.warn(s); | ||
LOGGER.warn("[DynamicPack] " + s); | ||
} catch (Exception ignored) { | ||
System.out.println("[dynamicpack] " + s); | ||
System.out.println("[DynamicPack] " + s); | ||
} | ||
} | ||
|
||
public static void debug(String s) { | ||
println("DEBUG: " + s); | ||
if (Mod.isDebugLogs()) { | ||
println("DEBUG: " + s); | ||
} | ||
} | ||
|
||
/** | ||
* Always enable! Ignore enable/disable | ||
*/ | ||
public static void securityStackTrace() { | ||
if (USE_SOUT) { | ||
System.out.println("[dynamicpack] Stacktrace"); | ||
System.out.println("[DynamicPack] Stacktrace"); | ||
new Throwable("StackTrace printer").printStackTrace(); | ||
return; | ||
} | ||
LOGGER.error("No error. This is stacktrace printer", new Throwable("StackTrace printer")); | ||
LOGGER.error("[DynamicPack] No error. This is stacktrace printer", new Throwable("StackTrace printer")); | ||
} | ||
} |
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
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.