Code extracted from useless for loop. Closes #2872

This commit is contained in:
Marc Baloup 2020-06-27 02:52:04 +02:00
parent 9c078b78c3
commit 6949470e3b
Signed by: marcbal
GPG Key ID: BBC0FE3ABC30B893

View File

@ -19,29 +19,31 @@ public class BungeeSecurityManager extends SecurityManager
private void checkRestricted(String text) private void checkRestricted(String text)
{ {
Class[] context = getClassContext(); Class[] context = getClassContext();
for ( int i = 2; i < context.length; i++ ) int i = 2;
if ( i >= context.length )
{ {
ClassLoader loader = context[i].getClassLoader(); return;
}
// Bungee / system can do everything ClassLoader loader = context[i].getClassLoader();
if ( loader == ClassLoader.getSystemClassLoader() || loader == null )
{
break;
}
AccessControlException ex = new AccessControlException( "Plugin violation: " + text ); // Bungee / system can do everything
if ( ENFORCE ) if ( loader == ClassLoader.getSystemClassLoader() || loader == null )
{ {
throw ex; return;
} }
StringWriter stack = new StringWriter(); AccessControlException ex = new AccessControlException( "Plugin violation: " + text );
ex.printStackTrace( new PrintWriter( stack ) ); if ( ENFORCE )
if ( seen.add( stack.toString() ) ) {
{ throw ex;
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Plugin performed restricted action, please inform them to use proper API methods: " + text, ex ); }
}
break; StringWriter stack = new StringWriter();
ex.printStackTrace( new PrintWriter( stack ) );
if ( seen.add( stack.toString() ) )
{
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Plugin performed restricted action, please inform them to use proper API methods: " + text, ex );
} }
} }