def setPlayerGameType(self, gametype, player="Player"):
        '''
        Sets the specified player's gametype/gamemode
        
        :param gametype: The desired Gametype/Gamemode number
        :type gametype: int
        :param player: The UUID of the player
        :type player: str
        '''
        playerTag = self.getPlayerTag(player)
        # This annoyingly works differently between single- and multi-player.
        if player == "Player":
            self.GameType = gametype
            self.setPlayerAbilities(gametype, player)
        else:
            playerTag['playerGameType'] = nbt.TAG_Int(gametype)
            self.setPlayerAbilities(gametype, player)

        Sets the specified player's gametype/gamemode
        
        :param gametype: The desired Gametype/Gamemode number
        :type gametype: int
        :param player: The UUID of the player
        :type player: str
        
pymclevel/infiniteworld.py