Skip to content

Commit

Permalink
patch to handle restricted JVMs better
Browse files Browse the repository at this point in the history
Protip: own your server! Shared hosts suck!
  • Loading branch information
mcmonkey4eva committed Mar 9, 2019
1 parent 8d07489 commit 899c5d4
Showing 1 changed file with 16 additions and 6 deletions.
Expand Up @@ -367,17 +367,27 @@ protected Class[] getClassContext() {
}
}

private static boolean canGetClass = true;

public static void log(String message) {
if (!showDebug) {
return;
}
Class[] classes = new SecurityManagerTrick().getClassContext();
Class caller = classes.length > 2 ? classes[2] : dB.class;
String callerName = classNameCache.get(caller);
if (callerName == null) {
classNameCache.put(caller, callerName = caller.getSimpleName());
String callerName = "<JVM-Block>";
try {
if (canGetClass) {
Class[] classes = new SecurityManagerTrick().getClassContext();
Class caller = classes.length > 2 ? classes[2] : dB.class;
callerName = classNameCache.get(caller);
if (callerName == null) {
classNameCache.put(caller, callerName = caller.getSimpleName());
}
callerName = callerName.length() > 16 ? callerName.substring(0, 12) + "..." : callerName;
}
}
catch (Throwable ex) {
canGetClass = false;
}
callerName = callerName.length() > 16 ? callerName.substring(0, 12) + "..." : callerName;
ConsoleSender.sendMessage(ChatColor.YELLOW + "+> ["
+ callerName + "] "
+ ChatColor.WHITE + trimMessage(message));
Expand Down

0 comments on commit 899c5d4

Please sign in to comment.