1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-14 20:20:30 +00:00

Make UserLevel.OWNER a little more strict

Closes #904
This commit is contained in:
Jonathan Coates 2021-08-25 22:09:24 +01:00
parent 9fbcbae5b3
commit 3396fe2871
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06

View File

@ -56,18 +56,17 @@ public enum UserLevel implements Predicate<CommandSource>
public boolean test( CommandSource source )
{
if( this == ANYONE ) return true;
if( this == OWNER ) return isOwner( source );
if( this == OWNER_OP && isOwner( source ) ) return true;
return source.hasPermission( toLevel() );
}
if( this == OWNER || this == OWNER_OP )
private static boolean isOwner( CommandSource source )
{
MinecraftServer server = source.getServer();
Entity sender = source.getEntity();
if( server.isSingleplayer() && sender instanceof PlayerEntity &&
((PlayerEntity) sender).getGameProfile().getName().equalsIgnoreCase( server.getServerModName() ) )
{
return true;
}
}
return source.hasPermission( toLevel() );
return server.isDedicatedServer()
? source.getEntity() == null && source.hasPermission( 4 ) && source.getTextName().equals( "Server" )
: sender instanceof PlayerEntity && ((PlayerEntity) sender).getGameProfile().getName().equalsIgnoreCase( server.getServerModName() );
}
}