Can you replace this with IsGameModeCreative()? I know it's the code that's been here, but why not fix it along the way?
The equality comparison will not work when player has their mode unset and inherits the world's gamemode.